From: Martijn van Oosterhout <kleptog@svana.org>
To: netdev@vger.kernel.org
Subject: AF_PACKET fanout not working on MPLS traffic
Date: Mon, 14 Jan 2019 19:40:46 +0100 [thread overview]
Message-ID: <20190114184046.GA22481@svana.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 2579 bytes --]
Hi netdev,
We're running into an issue where incoming traffic for Suricata is not
being distributed across the workers despite AF_PACKET with fanout
being used, and it appears to be a kernel issue. Below is a description
of the problem and possible solution.
Seen on version kernel 4.19, but the code on 4.20 seem largely
unchanged.
When a packet needs to be distributed by fanout it calls
net/packet/af_packet.c:fanout_demux_hash which in turns calls
net/core/flow_dissector.c:__skb_get_hash_symmetric which in turn calls
net/core/flow_dissector.c:__skb_flow_dissect. However, if you look at
the code that parses MPLS traffic it looks like so:
--- snip ---
net/core/flow_dissector.c:1023
case htons(ETH_P_MPLS_UC):
case htons(ETH_P_MPLS_MC):
fdret = __skb_flow_dissect_mpls(skb, flow_dissector,
target_container, data,
nhoff, hlen);
break;
--- snip ---
What's going on here is that the dissector goes to extract the MPLS
flow information and then stops (it returns either GOOD or BAD here).
However because flow_keys_dissector_symmetric does not include
FLOW_DISSECTOR_KEY_MPLS no information is extracted at all, with the
result that the hash is always the same for every packet.
I see a two ways this could be fixed.
Option 1: include FLOW_DISSECTOR_KEY_MPLS in
flow_keys_dissector_symmetric but that seems a big assumption, we don't
do that for VLANs for example.
Option 2: Teach the dissector to, in the case where there is an MPLS
header that is not for entropy, to skip the MPLS header(s) and continue
the dissection on the IP headers that come after the MPLS header.
I think option 2 seems to me the right approach, however the dissector
(AFAICT) is used extensively from many places in the kernel so I'd like
some confirmation before spending too much time on it. It seems like it
could lead to an unexpected performance impact on systems using MPLS.
Or perhaps there is something else going on I missed.
And there is actually another problem: MPLS provides no information
about the next header because it assumes the endpoints in the network
recognise the MPLS headers. Which means you'd have to make a guess
about what the next layer should be.
Any ideas? Is this the right approach?
Thanks in advance,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> The combine: one man, one day, wheat for half a million loaves of bread.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
next reply other threads:[~2019-01-14 19:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-14 18:40 Martijn van Oosterhout [this message]
2019-01-14 20:03 ` AF_PACKET fanout not working on MPLS traffic Willem de Bruijn
2019-01-15 8:22 ` Martijn van Oosterhout
2019-01-15 16:06 ` Willem de Bruijn
2019-01-15 17:35 ` Ido Schimmel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190114184046.GA22481@svana.org \
--to=kleptog@svana.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).