Skip to content

Commit

Permalink
Support tc flower ip tos
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-noland committed Apr 6, 2024
1 parent e7896ff commit 4ef077d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/tc/filters/cls_flower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ pub type MplsBos = u8;
pub type MplsTc = u8;
pub type MplsLabel = u32;
pub type TcpFlagsMask = u8;
pub type IpTos = u8;

bitflags! {
// TcpFlags _ARE_ exactly 8 bits.
Expand Down Expand Up @@ -1370,6 +1371,7 @@ pub enum TcFilterFlowerOption {
KeyMplsLabel(MplsLabel),
KeyTcpFlags(TcpFlags),
KeyTcpFlagsMask(TcpFlagsMask),
KeyIpTos(IpTos),
}

impl Nla for TcFilterFlowerOption {
Expand Down Expand Up @@ -1445,6 +1447,7 @@ impl Nla for TcFilterFlowerOption {
Self::KeyMplsLabel(_) => 4,
Self::KeyTcpFlags(_) => 2,
Self::KeyTcpFlagsMask(_) => 2,
Self::KeyIpTos(_) => 1,
Self::Other(attr) => attr.value_len(),
}
}
Expand Down Expand Up @@ -1525,6 +1528,7 @@ impl Nla for TcFilterFlowerOption {
Self::KeyMplsLabel(_) => TCA_FLOWER_KEY_MPLS_LABEL,
Self::KeyTcpFlags(_) => TCA_FLOWER_KEY_TCP_FLAGS,
Self::KeyTcpFlagsMask(_) => TCA_FLOWER_KEY_TCP_FLAGS_MASK,
Self::KeyIpTos(_) => TCA_FLOWER_KEY_IP_TOS,
Self::Other(attr) => attr.kind(),
}
}
Expand Down Expand Up @@ -1676,6 +1680,7 @@ impl Nla for TcFilterFlowerOption {
Self::KeyTcpFlagsMask(flags) => {
buffer.copy_from_slice((*flags as u16).to_be_bytes().as_slice())
}
Self::KeyIpTos(tos) => buffer.copy_from_slice(&[*tos].as_slice()),
Self::Other(attr) => attr.emit_value(buffer),
}
}
Expand Down

0 comments on commit 4ef077d

Please sign in to comment.