Skip to content

Commit 80651ea

Browse files
committed
Support tc flower ip tos
1 parent e7896ff commit 80651ea

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/tc/filters/cls_flower.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ pub type MplsBos = u8;
211211
pub type MplsTc = u8;
212212
pub type MplsLabel = u32;
213213
pub type TcpFlagsMask = u8;
214+
pub type IpTos = u8;
214215

215216
bitflags! {
216217
// TcpFlags _ARE_ exactly 8 bits.
@@ -1370,6 +1371,7 @@ pub enum TcFilterFlowerOption {
13701371
KeyMplsLabel(MplsLabel),
13711372
KeyTcpFlags(TcpFlags),
13721373
KeyTcpFlagsMask(TcpFlagsMask),
1374+
KeyIpTos(IpTos),
13731375
}
13741376

13751377
impl Nla for TcFilterFlowerOption {
@@ -1445,6 +1447,7 @@ impl Nla for TcFilterFlowerOption {
14451447
Self::KeyMplsLabel(_) => 4,
14461448
Self::KeyTcpFlags(_) => 2,
14471449
Self::KeyTcpFlagsMask(_) => 2,
1450+
Self::KeyIpTos(_) => 1,
14481451
Self::Other(attr) => attr.value_len(),
14491452
}
14501453
}
@@ -1525,6 +1528,7 @@ impl Nla for TcFilterFlowerOption {
15251528
Self::KeyMplsLabel(_) => TCA_FLOWER_KEY_MPLS_LABEL,
15261529
Self::KeyTcpFlags(_) => TCA_FLOWER_KEY_TCP_FLAGS,
15271530
Self::KeyTcpFlagsMask(_) => TCA_FLOWER_KEY_TCP_FLAGS_MASK,
1531+
Self::KeyIpTos(_) => TCA_FLOWER_KEY_IP_TOS,
15281532
Self::Other(attr) => attr.kind(),
15291533
}
15301534
}
@@ -1676,6 +1680,7 @@ impl Nla for TcFilterFlowerOption {
16761680
Self::KeyTcpFlagsMask(flags) => {
16771681
buffer.copy_from_slice((*flags as u16).to_be_bytes().as_slice())
16781682
}
1683+
Self::KeyIpTos(tos) => buffer.copy_from_slice(&[*tos].as_slice()),
16791684
Self::Other(attr) => attr.emit_value(buffer),
16801685
}
16811686
}
@@ -2277,6 +2282,12 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
22772282
let flags = BigEndian::read_u16(payload);
22782283
Self::KeyTcpFlagsMask(flags as u8)
22792284
}
2285+
TCA_FLOWER_KEY_IP_TOS => {
2286+
if payload.len() != 1 {
2287+
return Err(DecodeError::from("invalid ip tos length"));
2288+
}
2289+
Self::KeyIpTos(payload[0])
2290+
}
22802291
_ => Self::Other(
22812292
DefaultNla::parse(buf).context("failed to parse flower nla")?,
22822293
),

0 commit comments

Comments
 (0)