Skip to content

Commit 064ddc8

Browse files
daniel-nolandcathay4t
authored andcommitted
Docs for existing tc-actions
1 parent baed9af commit 064ddc8

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/tc/actions/mirror.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,27 @@ use netlink_packet_utils::{
1414

1515
use super::{TcActionGeneric, TcActionGenericBuffer};
1616

17+
/// Traffic control action used to mirror or redirect packets.
1718
#[derive(Debug, PartialEq, Eq, Clone)]
1819
#[non_exhaustive]
1920
pub struct TcActionMirror {}
2021
impl TcActionMirror {
22+
/// The `TcActionAttribute::Kind` of this action.
2123
pub const KIND: &'static str = "mirred";
2224
}
2325

2426
const TCA_MIRRED_TM: u16 = 1;
2527
const TCA_MIRRED_PARMS: u16 = 2;
2628

29+
/// Options for the `TcActionMirror` action.
2730
#[derive(Debug, PartialEq, Eq, Clone)]
2831
#[non_exhaustive]
2932
pub enum TcActionMirrorOption {
33+
/// TODO: document this after we make it something better than `Vec<u8>`
3034
Tm(Vec<u8>),
35+
/// Parameters for the mirred action.
3136
Parms(TcMirror),
37+
/// Other attributes unknown at the time of writing.
3238
Other(DefaultNla),
3339
}
3440

@@ -74,11 +80,15 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
7480

7581
const TC_MIRRED_BUF_LEN: usize = TcActionGeneric::BUF_LEN + 8;
7682

83+
/// Parameters for the mirred action.
7784
#[derive(Debug, PartialEq, Eq, Clone, Default)]
7885
#[non_exhaustive]
7986
pub struct TcMirror {
87+
/// Generic action parameters.
8088
pub generic: TcActionGeneric,
89+
/// Describes how the packet be mirrored or redirected.
8190
pub eaction: TcMirrorActionType,
91+
/// Interface index to mirror or redirect to.
8292
pub ifindex: u32,
8393
}
8494

@@ -121,14 +131,20 @@ const TCA_EGRESS_MIRROR: i32 = 2;
121131
const TCA_INGRESS_REDIR: i32 = 3;
122132
const TCA_INGRESS_MIRROR: i32 = 4;
123133

134+
/// Type of mirroring or redirecting action.
124135
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
125136
#[non_exhaustive]
126137
pub enum TcMirrorActionType {
127138
#[default]
139+
/// Redirect to the egress pipeline.
128140
EgressRedir,
141+
/// Mirror to the egress pipeline.
129142
EgressMirror,
143+
/// Redirect to the ingress pipeline.
130144
IngressRedir,
145+
/// Mirror to the ingress pipeline.
131146
IngressMirror,
147+
/// Other action type unknown at the time of writing.
132148
Other(i32),
133149
}
134150

src/tc/actions/nat.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use super::{nat_flag::TcNatFlags, TcActionGeneric, TcActionGenericBuffer};
1616
const TCA_NAT_PARMS: u16 = 1;
1717
const TCA_NAT_TM: u16 = 2;
1818

19+
/// Network address translation action.
1920
#[derive(Debug, PartialEq, Eq, Clone)]
2021
#[non_exhaustive]
2122
pub struct TcActionNat {}
@@ -24,11 +25,15 @@ impl TcActionNat {
2425
pub(crate) const KIND: &'static str = "nat";
2526
}
2627

28+
/// Options for the [`TcActionNat`] action.
2729
#[derive(Debug, PartialEq, Eq, Clone)]
2830
#[non_exhaustive]
2931
pub enum TcActionNatOption {
32+
/// > TODO: document this after we make it something better than `Vec<u8>`
3033
Tm(Vec<u8>),
34+
/// Parameters for the nat action.
3135
Parms(TcNat),
36+
/// Other attributes unknown at the time of writing.
3237
Other(DefaultNla),
3338
}
3439

@@ -74,13 +79,19 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
7479

7580
const TC_NAT_BUF_LEN: usize = TcActionGeneric::BUF_LEN + 16;
7681

82+
/// Network address translation action.
7783
#[derive(Debug, PartialEq, Eq, Clone)]
7884
#[non_exhaustive]
7985
pub struct TcNat {
86+
/// Common attributes for all actions.
8087
pub generic: TcActionGeneric,
88+
/// Original address.
8189
pub old_addr: Ipv4Addr,
90+
/// New address.
8291
pub new_addr: Ipv4Addr,
92+
/// Mask of the old address
8393
pub mask: Ipv4Addr,
94+
/// Flags for the NAT action.
8495
pub flags: TcNatFlags,
8596
}
8697

src/tc/actions/nat_flag.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const TCA_ACT_FLAGS_NO_RTNL: u32 = 1u32 << (TCA_ACT_FLAGS_USER_BITS + 3);
99
const TCA_ACT_FLAGS_AT_INGRESS: u32 = 1u32 << (TCA_ACT_FLAGS_USER_BITS + 4);
1010

1111
bitflags! {
12+
/// Network Address Translation flags.
1213
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
1314
#[non_exhaustive]
1415
pub struct TcNatFlags: u32 {

0 commit comments

Comments
 (0)