: raw packet filtering via tc-flower
Subsystems (2)
Hello,
Following on the discussion in [1] regarding raw packet filtering via ethtool and ntuple. To recap, we wanted to enable the user to offload filtering and flow direction using binary patterns of extended lengths and masks (e.g. 512 bytes). The conclusion was that ethtool and ntuple are deemed legacy and are not the best approach.
After some internal discussions, tc-flower seems to be another possibility. In [2], the skbedit and queue-mapping is now supported on the rx and the user can offload flow direction to a specific rx queue.
Can we extend tc-flower to support raw packet filtering, for example:
# tc filter add dev $IFACE ingress protocol 802_3 flower \ offset $OFF pattern $BYTES mask $MASK \ action skbedit queue_mapping $RXQ_ID skip_sw
where offset, pattern and mask are new the flower args, $BYTES and $MASK could be up to 512 bytes.
Any feedback is welcome.
Thank you,
Ahmed
Jakub Kicinski
maintainerQuoted 10 lines · On Wed, 21 Feb 2024 12:43:47 -0700 Ahmed Zaki wrote:
Following on the discussion in [1] regarding raw packet filtering via ethtool and ntuple. To recap, we wanted to enable the user to offload filtering and flow direction using binary patterns of extended lengths and masks (e.g. 512 bytes). The conclusion was that ethtool and ntuple are deemed legacy and are not the best approach.
After some internal discussions, tc-flower seems to be another possibility. In [2], the skbedit and queue-mapping is now supported on the rx and the user can offload flow direction to a specific rx queue.
Quoted 8 lines
Can we extend tc-flower to support raw packet filtering, for example:
# tc filter add dev $IFACE ingress protocol 802_3 flower \ offset $OFF pattern $BYTES mask $MASK \ action skbedit queue_mapping $RXQ_ID skip_swwhere offset, pattern and mask are new the flower args, $BYTES and $MASK could be up to 512 bytes.
Have you looked at cls_u32 offload?
Quoted 13 lines · Fri, Feb 23, 2024 at 03:40:45AM CET, [email protected] wrote:
Quoted 12 lines · On Wed, 21 Feb 2024 12:43:47 -0700 Ahmed Zaki wrote:
Following on the discussion in [1] regarding raw packet filtering via ethtool and ntuple. To recap, we wanted to enable the user to offload filtering and flow direction using binary patterns of extended lengths and masks (e.g. 512 bytes). The conclusion was that ethtool and ntuple are deemed legacy and are not the best approach.
After some internal discussions, tc-flower seems to be another possibility. In [2], the skbedit and queue-mapping is now supported on the rx and the user can offload flow direction to a specific rx queue.
Can we extend tc-flower to support raw packet filtering, for example:
Quoted 8 lines
Quoted 6 lines
# tc filter add dev $IFACE ingress protocol 802_3 flower \ offset $OFF pattern $BYTES mask $MASK \ action skbedit queue_mapping $RXQ_ID skip_swwhere offset, pattern and mask are new the flower args, $BYTES and $MASK could be up to 512 bytes.
Have you looked at
cls_u32offload?
Hmm, but why flower can't be extended this direction. I mean, it is very convenient to match on well-defined fields. I can imagine that the combination of match on well-defined fields and random chunks together is completely valid use-case. Also, offloading of flower is straightforward.
U32 is, well, not that convenient.
Quoted 2 lines · Jiri Pirko
Hmm, but why flower can't be extended this direction. I mean, it is very convenient to match on well-defined fields.
Flower is intrinsically tied to the flow dissector, both conceptually
and in implementation. I'm not sure it's appropriate for it to become a dumping ground for random vendor filtering extensions/capabilities.
Quoted 1 line
U32 is, well, not that convenient.
How about a new classifier that just does this raw matching?
Quoted 3 lines
I can imagine that the
combination of match on well-defined fields and random chunks together is completely valid use-case.
But is it likely to be something that hardware supports? (Since the
motivation for this feature is clearly the hardware offload — otherwise there are other mechanisms like BPF for arbitrary packet filtering.)
As the vendor behind this, one hopes Intel can comment on both the
hardware and the use-case side of this question.
Quoted 7 lines · Fri, Feb 23, 2024 at 01:07:06PM CET, [email protected] wrote:
Quoted 2 lines · Jiri Pirko
Hmm, but why flower can't be extended this direction. I mean, it is very convenient to match on well-defined fields.
Flower is intrinsically tied to the flow dissector, both conceptually and in implementation. I'm not sure it's appropriate for it to become a dumping ground for random vendor filtering extensions/capabilities.
Nope, the extension of dissector would be clean, one timer. Just add support for offset+len based dissection. Also, the fact that flower uses flow_dissector is only because DaveM requested that back in the days I pushed flower. The original implementation was not using flow_dissector. The dissection backing should not block flower extension. We can always replace it if needed and convenient (maybe the criteria is met already).
Quoted 4 lines
Quoted 2 lines
U32 is, well, not that convenient.
How about a new classifier that just does this raw matching?
That's u32 basically, isn't it?
Quoted 6 lines
Quoted 4 lines
I can imagine that the
combination of match on well-defined fields and random chunks together is completely valid use-case.But is it likely to be something that hardware supports? (Since the
Yeah, I know couple of ASICs that support this, driver names are mlx5 and mlxsw :)
Quoted 5 lines
motivation for this feature is clearly the hardware offload — otherwise there are other mechanisms like BPF for arbitrary packet filtering.)
As the vendor behind this, one hopes Intel can comment on both the hardware and the use-case side of this question.
Quoted 2 lines · Jiri Pirko
Nope, the extension of dissector would be clean, one timer. Just add support for offset+len based dissection.
... until someone else comes along with another kind of filtering and
wants _that_ in flower for the same reasons.
Quoted 3 lines
Quoted 1 line
How about a new classifier that just does this raw matching?
That's u32 basically, isn't it?
Well, u32 has all the extra complications around hashtables, links,
permoff... I guess you could have helpers in the kernel to stitch 'const' u32 filters into raw matches for drivers that only offload that and reject anything else; and tc userspace could have syntactic sugar to transform Ahmed's offset/pattern/mask into the appropriate u32 matches under the hood.
Quoted 10 lines · Edward Cree
Quoted 2 lines · Jiri Pirko
Nope, the extension of dissector would be clean, one timer. Just add support for offset+len based dissection.
... until someone else comes along with another kind of filtering and
wants _that_ in flower for the same reasons.Quoted 2 lines
Quoted 1 line
How about a new classifier that just does this raw matching?
Quoted 8 lines
Quoted 1 line
That's u32 basically, isn't it?
Well, u32 has all the extra complications around hashtables, links,
permoff... I guess you could have helpers in the kernel to stitch 'const' u32 filters into raw matches for drivers that only offload that and reject anything else; and tc userspace could have syntactic sugar to transform Ahmed's offset/pattern/mask into the appropriate u32 matches under the hood.
u32 has a DSL that deals with parsing as well, which includes dealing with variable packet offsets etc. That is a necessary ingredient if you want to do pragmatic parsing (example how do you point to TCP ports if the IP header has options etc).
This flower extension, if it wants to do something equivalent, would have to adopt some of that language.
For the record, I am not against this being part of flower i just dont think it's a simple offset/value/mask. u32 for example decided that it will work with fixed 4 byte lengths to simplify, etc..
I wouldnt trust user space to do the right thing either otherwise syzkaller will be feasting on this ... I empathise that using flower will impose an operational challenge of having to use two classifiers (but I want to point out that it already does offloads).
cheers,
jamal
Quoted 4 lines · Jamal Hadi Salim
u32 has a DSL that deals with parsing as well, which includes dealing with variable packet offsets etc. That is a necessary ingredient if you want to do pragmatic parsing (example how do you point to TCP ports if the IP header has options etc).
My understanding (Ahmed can correct me) is that the proposed raw
filtering here would not support variable packet offsets at all.
That is precisely why I consider it a narrow hack for specialised
use-cases and thus oppose its addition to cls_flower.
Quoted 10 lines · Edward Cree
Quoted 4 lines · Jamal Hadi Salim
u32 has a DSL that deals with parsing as well, which includes dealing with variable packet offsets etc. That is a necessary ingredient if you want to do pragmatic parsing (example how do you point to TCP ports if the IP header has options etc).
My understanding (Ahmed can correct me) is that the proposed raw
filtering here would not support variable packet offsets at all.
That is precisely why I consider it a narrow hack for specialised
use-cases and thus oppose its addition tocls_flower.
Intel's DDP (NVM) comes with default parser tables that contain all the supported protocol definitions. In order to use RSS or flow director on any of these protocol/field that is not defined in ethtool/tc, we usually need to submit patches for kernel, PF and even virtchannel and vf drivers if we want support on the VF.
While Intel's hardware supports programming the parser IP stage (and that would allow mixed protocol field + binary matching/arbitrary offset), for now we want to support something like DPDK's raw filtering:
What we had in mind is offloading based on exclusive binary matching, not mixed protocol field + binary matching. Also, as in my original example, may be restrict the protocol to 802_3, so all parsing starts at MAC hdr which would make the offset calculations much easier.
Please advice what is the best way forward, flower vs u32, new filter, ..etc.
Thanks
Ahmed, Sridhar, Amritha
Jakub Kicinski
maintainerQuoted 13 lines · On Mon, 26 Feb 2024 07:40:55 -0700 Ahmed Zaki wrote:
Intel's DDP (NVM) comes with default parser tables that contain all the supported protocol definitions. In order to use RSS or flow director on any of these protocol/field that is not defined in ethtool/tc, we usually need to submit patches for kernel, PF and even virtchannel and vf drivers if we want support on the VF.
While Intel's hardware supports programming the parser IP stage (and that would allow mixed protocol field + binary matching/arbitrary offset), for now we want to support something like DPDK's raw filtering:
Quoted 7 lines
What we had in mind is offloading based on exclusive binary matching, not mixed protocol field + binary matching. Also, as in my original example, may be restrict the protocol to 802_3, so all parsing starts at MAC hdr which would make the offset calculations much easier.
Please advice what is the best way forward, flower vs u32, new filter, ..etc.
I vote for u32. We can always add a new filter. But if one already exists which fully covers the functionality we shouldn't add a new one until we know the exact pain points, IOW have tried the existing.
If we do add a new filter, I think this should be part of the P4 classifier. With the parsing tree instantiated from the device side and filters added by the user..
Quoted 20 lines · Jakub Kicinski
Quoted 18 lines · On Mon, 26 Feb 2024 07:40:55 -0700 Ahmed Zaki wrote:
Intel's DDP (NVM) comes with default parser tables that contain all the supported protocol definitions. In order to use RSS or flow director on any of these protocol/field that is not defined in ethtool/tc, we usually need to submit patches for kernel, PF and even virtchannel and vf drivers if we want support on the VF.
While Intel's hardware supports programming the parser IP stage (and that would allow mixed protocol field + binary matching/arbitrary offset), for now we want to support something like DPDK's raw filtering:
What we had in mind is offloading based on exclusive binary matching, not mixed protocol field + binary matching. Also, as in my original example, may be restrict the protocol to 802_3, so all parsing starts at MAC hdr which would make the offset calculations much easier.
Quoted 7 lines
Quoted 2 lines
Please advice what is the best way forward, flower vs u32, new filter, ..etc.
I vote for u32. We can always add a new filter. But if one already exists which fully covers the functionality we shouldn't add a new one until we know the exact pain points, IOW have tried the existing.
Yes, u32 is the most "ready". No need to patch the classifier code (unlike flower) and the dev ops exists already (and has been used by drivers in the past).
Quoted 3 lines
If we do add a new filter, I think this should be part of the P4 classifier. With the parsing tree instantiated from the device side and filters added by the user..
P4 will open much bigger opportunities for DDP imo (but some people would claim i am a little tiny biased ;->).
cheers,
jamal