@@ -18,7 +18,7 @@ use netlink_packet_utils::{
1818} ;
1919
2020use crate :: tc:: filters:: ethernet;
21- use crate :: tc:: filters:: flower:: encap:: EncOpts ;
21+ use crate :: tc:: filters:: flower:: encap;
2222use crate :: tc:: filters:: flower:: mpls;
2323use crate :: tc:: { arp, icmpv4, icmpv6, TcAction , TcFlowerOptionFlags , TcHandle } ;
2424use crate :: { EncKeyId , IpProtocol } ;
@@ -141,21 +141,6 @@ impl TcFilterFlower {
141141 pub const KIND : & ' static str = "flower" ;
142142}
143143
144- pub type AbstractPort = u16 ;
145- pub type IpTos = u8 ;
146- pub type IpTosMask = u8 ;
147- pub type IpTtl = u8 ;
148- pub type IpTtlMask = u8 ;
149- pub type L2tpV3Sid = u32 ;
150- pub type PppProtocol = u16 ;
151- pub type PppoeSid = u16 ;
152- pub type SctpPort = u16 ;
153- pub type Spi = u32 ;
154- pub type SpiMask = u32 ;
155- pub type TcpFlagsMask = u8 ;
156- pub type TcpPort = u16 ;
157- pub type UdpPort = u16 ;
158-
159144/// I can't figure out a better type than just `u8` for `CfmOpCode`.
160145/// The only reserved values and meanings I was able to find were in
161146/// [rfc7319][1], and that only specifies that values 64-95 are expressly
@@ -221,10 +206,10 @@ pub enum TcFilterFlowerOption {
221206 KeyIpv6SrcMask ( Ipv6Addr ) ,
222207 KeyIpv6Dst ( Ipv6Addr ) ,
223208 KeyIpv6DstMask ( Ipv6Addr ) ,
224- KeyTcpSrc ( TcpPort ) ,
225- KeyTcpDst ( TcpPort ) ,
226- KeyUdpSrc ( UdpPort ) ,
227- KeyUdpDst ( UdpPort ) ,
209+ KeyTcpSrc ( u16 ) ,
210+ KeyTcpDst ( u16 ) ,
211+ KeyUdpSrc ( u16 ) ,
212+ KeyUdpDst ( u16 ) ,
228213 Flags ( TcFlowerOptionFlags ) ,
229214 Other ( DefaultNla ) ,
230215 KeyVlanId ( ethernet:: VlanId ) ,
@@ -239,80 +224,80 @@ pub enum TcFilterFlowerOption {
239224 KeyEncIpv6SrcMask ( Ipv6Addr ) ,
240225 KeyEncIpv6Dst ( Ipv6Addr ) ,
241226 KeyEncIpv6DstMask ( Ipv6Addr ) ,
242- KeyTcpSrcMask ( TcpPort ) ,
243- KeyTcpDstMask ( TcpPort ) ,
244- KeyUdpSrcMask ( UdpPort ) ,
245- KeyUdpDstMask ( UdpPort ) ,
246- KeySctpSrcMask ( SctpPort ) ,
247- KeySctpDstMask ( SctpPort ) ,
248- KeySctpSrc ( SctpPort ) ,
249- KeySctpDst ( SctpPort ) ,
250- KeyEncUdpSrcPort ( UdpPort ) ,
251- KeyEncUdpSrcPortMask ( UdpPort ) ,
252- KeyEncUdpDstPort ( UdpPort ) ,
253- KeyEncUdpDstPortMask ( UdpPort ) ,
227+ KeyTcpSrcMask ( u16 ) ,
228+ KeyTcpDstMask ( u16 ) ,
229+ KeyUdpSrcMask ( u16 ) ,
230+ KeyUdpDstMask ( u16 ) ,
231+ KeySctpSrcMask ( u16 ) ,
232+ KeySctpDstMask ( u16 ) ,
233+ KeySctpSrc ( u16 ) ,
234+ KeySctpDst ( u16 ) ,
235+ KeyEncUdpSrcPort ( u16 ) ,
236+ KeyEncUdpSrcPortMask ( u16 ) ,
237+ KeyEncUdpDstPort ( u16 ) ,
238+ KeyEncUdpDstPortMask ( u16 ) ,
254239 KeyFlags ( FlowerKeyFlags ) ,
255240 KeyFlagsMask ( FlowerKeyFlags ) ,
256241 KeyIcmpv4Code ( icmpv4:: Code ) ,
257- KeyIcmpv4CodeMask ( icmpv4 :: CodeMask ) ,
242+ KeyIcmpv4CodeMask ( u8 ) ,
258243 KeyIcmpv4Type ( icmpv4:: Type ) ,
259- KeyIcmpv4TypeMask ( icmpv4 :: TypeMask ) ,
244+ KeyIcmpv4TypeMask ( u8 ) ,
260245 KeyIcmpv6Code ( icmpv6:: Code ) ,
261- KeyIcmpv6CodeMask ( icmpv6 :: CodeMask ) ,
246+ KeyIcmpv6CodeMask ( u8 ) ,
262247 KeyIcmpv6Type ( icmpv6:: Type ) ,
263- KeyIcmpv6TypeMask ( icmpv6 :: TypeMask ) ,
264- KeyArpSip ( arp :: Sip ) ,
265- KeyArpSipMask ( arp :: SipMask ) ,
266- KeyArpTip ( arp :: Tip ) ,
267- KeyArpTipMask ( arp :: TipMask ) ,
248+ KeyIcmpv6TypeMask ( u8 ) ,
249+ KeyArpSip ( Ipv4Addr ) ,
250+ KeyArpSipMask ( Ipv4Addr ) ,
251+ KeyArpTip ( Ipv4Addr ) ,
252+ KeyArpTipMask ( Ipv4Addr ) ,
268253 KeyArpOp ( arp:: Operation ) ,
269- KeyArpOpMask ( arp :: OperationMask ) ,
270- KeyArpSha ( arp :: Sha ) ,
271- KeyArpShaMask ( arp :: ShaMask ) ,
272- KeyArpTha ( arp :: Tha ) ,
273- KeyArpThaMask ( arp :: ThaMask ) ,
274- KeyMplsTtl ( mpls :: MplsTtl ) ,
254+ KeyArpOpMask ( u8 ) ,
255+ KeyArpSha ( ethernet :: Mac ) ,
256+ KeyArpShaMask ( ethernet :: Mac ) ,
257+ KeyArpTha ( ethernet :: Mac ) ,
258+ KeyArpThaMask ( ethernet :: Mac ) ,
259+ KeyMplsTtl ( u8 ) ,
275260 KeyMplsBos ( mpls:: BottomOfStack ) ,
276- KeyMplsTc ( mpls :: TrafficClass ) ,
261+ KeyMplsTc ( u8 ) ,
277262 KeyMplsLabel ( mpls:: Label ) ,
278263 KeyTcpFlags ( TcpFlags ) ,
279- KeyTcpFlagsMask ( TcpFlagsMask ) ,
280- KeyIpTos ( IpTos ) ,
281- KeyIpTosMask ( IpTos ) ,
282- KeyIpTtl ( IpTtl ) ,
283- KeyIpTtlMask ( IpTtlMask ) ,
264+ KeyTcpFlagsMask ( u8 ) ,
265+ KeyIpTos ( u8 ) ,
266+ KeyIpTosMask ( u8 ) ,
267+ KeyIpTtl ( u8 ) ,
268+ KeyIpTtlMask ( u8 ) ,
284269 KeyCvlanId ( ethernet:: VlanId ) ,
285270 KeyCvlanPrio ( ethernet:: VlanPrio ) ,
286271 KeyCvlanEthType ( ethernet:: Ethertype ) ,
287- KeyEncIpTos ( IpTos ) ,
288- KeyEncIpTosMask ( IpTosMask ) ,
289- KeyEncIpTtl ( IpTtl ) ,
290- KeyEncIpTtlMask ( IpTtlMask ) ,
291- KeyEncOpts ( EncOpts ) ,
292- KeyEncOptsMask ( EncOpts ) ,
293- KeyPortSrcMin ( AbstractPort ) ,
294- KeyPortSrcMax ( AbstractPort ) ,
295- KeyPortDstMin ( AbstractPort ) ,
296- KeyPortDstMax ( AbstractPort ) ,
272+ KeyEncIpTos ( u8 ) ,
273+ KeyEncIpTosMask ( u8 ) ,
274+ KeyEncIpTtl ( u8 ) ,
275+ KeyEncIpTtlMask ( u8 ) ,
276+ KeyEncOpts ( encap :: Options ) ,
277+ KeyEncOptsMask ( encap :: Options ) ,
278+ KeyPortSrcMin ( u16 ) ,
279+ KeyPortSrcMax ( u16 ) ,
280+ KeyPortDstMin ( u16 ) ,
281+ KeyPortDstMax ( u16 ) ,
297282 KeyCtState ( ConnectionTrackingFlags ) ,
298283 KeyCtStateMask ( ConnectionTrackingFlags ) ,
299- KeyCtZone ( ConnectionTrackingZone ) ,
300- KeyCtZoneMask ( ConnectionTrackingZone ) ,
301- KeyCtMark ( ConnectionTrackingMark ) ,
302- KeyCtMarkMask ( ConnectionTrackingMark ) ,
303- KeyCtLabels ( ConnectionTrackingLabel ) ,
304- KeyCtLabelsMask ( ConnectionTrackingLabel ) ,
284+ KeyCtZone ( u16 ) ,
285+ KeyCtZoneMask ( u16 ) ,
286+ KeyCtMark ( u32 ) ,
287+ KeyCtMarkMask ( u32 ) ,
288+ KeyCtLabels ( u128 ) ,
289+ KeyCtLabelsMask ( u128 ) ,
305290 KeyMplsOpts ( mpls:: Options ) ,
306291 KeyHash ( u32 ) ,
307292 KeyHashMask ( u32 ) ,
308293 KeyNumOfVlans ( u8 ) ,
309- KeyPppoeSid ( PppoeSid ) ,
310- KeyPppProto ( PppProtocol ) ,
311- KeyL2tpv3Sid ( L2tpV3Sid ) ,
294+ KeyPppoeSid ( u16 ) ,
295+ KeyPppProto ( u16 ) ,
296+ KeyL2tpv3Sid ( u32 ) ,
312297 L2Miss ( L2Miss ) ,
313298 KeyCfm ( Vec < CfmAttribute > ) ,
314- KeySpi ( Spi ) ,
315- KeySpiMask ( SpiMask ) ,
299+ KeySpi ( u32 ) ,
300+ KeySpiMask ( u32 ) ,
316301 InHwCount ( u32 ) ,
317302}
318303
@@ -1007,7 +992,8 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
1007992 }
1008993 let id = NativeEndian :: read_u16 ( payload) ;
1009994 Self :: KeyVlanId (
1010- ethernet:: VlanId :: try_new ( id) . context ( "failed to parse vlan id" ) ?,
995+ ethernet:: VlanId :: try_new ( id)
996+ . context ( "failed to parse vlan id" ) ?,
1011997 )
1012998 }
1013999 TCA_FLOWER_KEY_VLAN_PRIO => {
@@ -1460,7 +1446,8 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
14601446 }
14611447 let id = NativeEndian :: read_u16 ( payload) ;
14621448 Self :: KeyCvlanId (
1463- ethernet:: VlanId :: try_new ( id) . context ( "failed to parse cvlan id" ) ?,
1449+ ethernet:: VlanId :: try_new ( id)
1450+ . context ( "failed to parse cvlan id" ) ?,
14641451 )
14651452 }
14661453 TCA_FLOWER_KEY_CVLAN_PRIO => {
@@ -1514,9 +1501,11 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
15141501 }
15151502 Self :: KeyEncIpTtlMask ( payload[ 0 ] )
15161503 }
1517- TCA_FLOWER_KEY_ENC_OPTS => Self :: KeyEncOpts ( EncOpts :: parse ( buf) ?) ,
1504+ TCA_FLOWER_KEY_ENC_OPTS => {
1505+ Self :: KeyEncOpts ( encap:: Options :: parse ( buf) ?)
1506+ }
15181507 TCA_FLOWER_KEY_ENC_OPTS_MASK => {
1519- Self :: KeyEncOptsMask ( EncOpts :: parse ( buf) ?)
1508+ Self :: KeyEncOptsMask ( encap :: Options :: parse ( buf) ?)
15201509 }
15211510 TCA_FLOWER_IN_HW_COUNT => Self :: InHwCount (
15221511 parse_u32 ( payload)
@@ -1635,10 +1624,6 @@ bitflags! {
16351624 }
16361625}
16371626
1638- type ConnectionTrackingZone = u16 ;
1639- type ConnectionTrackingMark = u32 ;
1640- type ConnectionTrackingLabel = u128 ;
1641-
16421627fn parse_u128_be ( slice : & [ u8 ] ) -> Result < u128 , DecodeError > {
16431628 if slice. len ( ) != 16 {
16441629 return Err ( DecodeError :: from ( "invalid u128 length" ) ) ;
0 commit comments