From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, tom@herbertland.com,
simon.horman@netronome.com, eric.dumazet@gmail.com,
dinan.gunawardena@netronome.com, mlxsw@mellanox.com
Subject: [patch net-next RFC 2/2] flow_dissecror: Move MPLS dissection into a separate function
Date: Tue, 21 Feb 2017 15:33:19 +0100 [thread overview]
Message-ID: <1487687599-5464-2-git-send-email-jiri@resnulli.us> (raw)
In-Reply-To: <1487687599-5464-1-git-send-email-jiri@resnulli.us>
From: Jiri Pirko <jiri@mellanox.com>
Make the main flow_dissect function a bit smaller and move the MPLS
dissection into a separate function. Along with that, do the MPLS header
processing only in case the flow dissection user requires it.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
net/core/flow_dissector.c | 52 ++++++++++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 21 deletions(-)
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 10dc5bb..3ab935e 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -113,6 +113,33 @@ __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
}
EXPORT_SYMBOL(__skb_flow_get_ports);
+static bool __skb_flow_dissect_mpls(const struct sk_buff *skb,
+ struct flow_dissector *flow_dissector,
+ void *target_container, void *data,
+ int nhoff, int hlen)
+{
+ struct flow_dissector_key_keyid *key_keyid;
+ struct mpls_label *hdr, _hdr[2];
+
+ if (!dissector_uses_key(flow_dissector,
+ FLOW_DISSECTOR_KEY_MPLS_ENTROPY))
+ return true;
+
+ hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data,
+ hlen, &_hdr);
+ if (!hdr)
+ return false;
+
+ if ((ntohl(hdr[0].entry) & MPLS_LS_LABEL_MASK) >>
+ MPLS_LS_LABEL_SHIFT == MPLS_LABEL_ENTROPY) {
+ key_keyid = skb_flow_dissector_target(flow_dissector,
+ FLOW_DISSECTOR_KEY_MPLS_ENTROPY,
+ target_container);
+ key_keyid->keyid = hdr[1].entry & htonl(MPLS_LS_LABEL_MASK);
+ }
+ return true;
+}
+
static bool __skb_flow_dissect_arp(const struct sk_buff *skb,
struct flow_dissector *flow_dissector,
void *target_container, void *data,
@@ -403,30 +430,13 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
}
case htons(ETH_P_MPLS_UC):
- case htons(ETH_P_MPLS_MC): {
- struct mpls_label *hdr, _hdr[2];
+ case htons(ETH_P_MPLS_MC):
mpls:
- hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data,
- hlen, &_hdr);
- if (!hdr)
+ if (!__skb_flow_dissect_mpls(skb, flow_dissector,
+ target_container, data,
+ nhoff, hlen))
goto out_bad;
-
- if ((ntohl(hdr[0].entry) & MPLS_LS_LABEL_MASK) >>
- MPLS_LS_LABEL_SHIFT == MPLS_LABEL_ENTROPY) {
- if (dissector_uses_key(flow_dissector,
- FLOW_DISSECTOR_KEY_MPLS_ENTROPY)) {
- key_keyid = skb_flow_dissector_target(flow_dissector,
- FLOW_DISSECTOR_KEY_MPLS_ENTROPY,
- target_container);
- key_keyid->keyid = hdr[1].entry &
- htonl(MPLS_LS_LABEL_MASK);
- }
-
- goto out_good;
- }
-
goto out_good;
- }
case htons(ETH_P_FCOE):
if ((hlen - nhoff) < FCOE_HEADER_LEN)
--
2.7.4
next prev parent reply other threads:[~2017-02-21 14:33 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-02 10:37 [PATCH/RFC net-next 0/2] net/sched: cls_flower: Support matching on ND Simon Horman
2017-02-02 10:37 ` [PATCH/RFC net-next 1/2] flow dissector: ND support Simon Horman
2017-02-02 12:31 ` Eric Dumazet
2017-02-02 15:58 ` Simon Horman
2017-02-02 17:24 ` Tom Herbert
2017-02-02 17:48 ` Jiri Pirko
2017-02-02 18:36 ` Tom Herbert
2017-02-02 18:56 ` Eric Dumazet
2017-02-02 19:19 ` Tom Herbert
2017-02-06 9:12 ` [oss-drivers] " Simon Horman
2017-02-07 17:36 ` Tom Herbert
2017-02-07 17:38 ` David Miller
2017-02-08 9:28 ` Simon Horman
2017-02-08 16:43 ` Simon Horman
2017-02-08 18:33 ` [oss-drivers] " Tom Herbert
2017-02-08 18:54 ` David Miller
2017-02-08 19:10 ` Tom Herbert
2017-02-08 20:12 ` Jiri Pirko
2017-02-08 20:33 ` Tom Herbert
2017-02-08 20:09 ` Jiri Pirko
2017-02-09 8:25 ` Simon Horman
2017-02-21 14:31 ` Jiri Pirko
2017-02-21 14:33 ` [patch net-next RFC 1/2] flow_dissecror: Move ARP dissection into a separate function Jiri Pirko
2017-02-21 14:33 ` Jiri Pirko [this message]
2017-02-22 8:34 ` [patch net-next RFC 2/2] flow_dissecror: Move MPLS " Simon Horman
2017-02-21 18:32 ` [patch net-next RFC 1/2] flow_dissecror: Move ARP " David Miller
2017-02-22 8:36 ` Simon Horman
2017-02-21 18:50 ` Tom Herbert
2017-02-21 21:21 ` Jiri Pirko
2017-03-06 15:49 ` Jiri Pirko
2017-02-22 8:12 ` Simon Horman
2017-02-21 15:28 ` [PATCH/RFC net-next 1/2] flow dissector: ND support Jiri Pirko
2017-03-10 14:19 ` Simon Horman
2017-03-10 14:27 ` Jiri Pirko
2017-03-10 15:20 ` Simon Horman
2017-03-10 15:26 ` Jiri Pirko
2017-03-13 13:50 ` Simon Horman
2017-03-13 13:53 ` Jiri Pirko
2017-02-02 10:37 ` [PATCH/RFC net-next 2/2] net/sched: cls_flower: Support matching on ND Simon Horman
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=1487687599-5464-2-git-send-email-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=dinan.gunawardena@netronome.com \
--cc=eric.dumazet@gmail.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=simon.horman@netronome.com \
--cc=tom@herbertland.com \
/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).