From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Subject: [PATCH net-next 6/6] mpls: Add MPLS entropy label in flow_keys
Date: Mon, 4 May 2015 16:02:40 -0700 [thread overview]
Message-ID: <1430780560-2758924-7-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1430780560-2758924-1-git-send-email-tom@herbertland.com>
In flow dissector if an MPLS header contains an entropy label this is
saved in the new extra entropy field of flow_keys. The entropy label is
then represented in the flow hash function input.
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
include/uapi/linux/in.h | 2 ++
include/uapi/linux/mpls.h | 3 +++
net/core/flow_dissector.c | 27 +++++++++++++++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h
index 589ced0..c86f6ab 100644
--- a/include/uapi/linux/in.h
+++ b/include/uapi/linux/in.h
@@ -69,6 +69,8 @@ enum {
#define IPPROTO_SCTP IPPROTO_SCTP
IPPROTO_UDPLITE = 136, /* UDP-Lite (RFC 3828) */
#define IPPROTO_UDPLITE IPPROTO_UDPLITE
+ IPPROTO_MPLS = 137, /* MPLS in IP (RFC 4023) */
+#define IPPROTO_MPLS IPPROTO_SCTP
IPPROTO_RAW = 255, /* Raw IP packets */
#define IPPROTO_RAW IPPROTO_RAW
IPPROTO_MAX
diff --git a/include/uapi/linux/mpls.h b/include/uapi/linux/mpls.h
index bc9abfe..3be9eb7 100644
--- a/include/uapi/linux/mpls.h
+++ b/include/uapi/linux/mpls.h
@@ -31,4 +31,7 @@ struct mpls_label {
#define MPLS_LS_TTL_MASK 0x000000FF
#define MPLS_LS_TTL_SHIFT 0
+/* Reserved labels */
+#define MPLS_LS_ENTROPY_IS_NEXT 7
+
#endif /* _UAPI_MPLS_H */
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 025b91f..95c9a07 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -7,6 +7,7 @@
#include <net/ipv6.h>
#include <linux/igmp.h>
#include <linux/icmp.h>
+#include <linux/mpls.h>
#include <linux/sctp.h>
#include <linux/dccp.h>
#include <linux/if_tunnel.h>
@@ -169,6 +170,29 @@ ipv6:
flow->thoff = (u16)nhoff;
return true;
}
+ case htons(ETH_P_MPLS_UC):
+ case htons(ETH_P_MPLS_MC): {
+ struct mpls_label *hdr, _hdr[2];
+mpls:
+ 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_ENTROPY_IS_NEXT) {
+ flow->n_proto = proto;
+ flow->ip_proto = ip_proto;
+ flow->extra_entropy = ntohl(hdr[1].entry) &
+ MPLS_LS_LABEL_MASK;
+ flow->thoff = (u16)nhoff;
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
case htons(ETH_P_FCOE):
flow->thoff = (u16)(nhoff + FCOE_HEADER_LEN);
/* fall through */
@@ -234,6 +258,9 @@ ipv6:
case IPPROTO_IPV6:
proto = htons(ETH_P_IPV6);
goto ipv6;
+ case IPPROTO_MPLS:
+ proto = htons(ETH_P_MPLS_UC);
+ goto mpls;
default:
break;
}
--
1.8.1
next prev parent reply other threads:[~2015-05-04 23:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-04 23:02 [PATCH net-next 0/6] net: Increase inputs to flow_keys hashing Tom Herbert
2015-05-04 23:02 ` [PATCH net-next 1/6] net: Get skb hash over flow_keys structure Tom Herbert
2015-05-04 23:02 ` [PATCH net-next 2/6] net: Add full IPv6 addresses to flow_keys Tom Herbert
2015-05-04 23:02 ` [PATCH net-next 3/6] net: Add VLAN ID " Tom Herbert
2015-05-04 23:02 ` [PATCH net-next 4/6] net: Add IPv6 flow label " Tom Herbert
2015-05-04 23:02 ` [PATCH net-next 5/6] net: Add GRE keyid in flow_keys Tom Herbert
2015-05-04 23:02 ` Tom Herbert [this message]
2015-05-05 0:56 ` [PATCH net-next 6/6] mpls: Add MPLS entropy label " Alexei Starovoitov
2015-05-05 2:13 ` Tom Herbert
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=1430780560-2758924-7-git-send-email-tom@herbertland.com \
--to=tom@herbertland.com \
--cc=davem@davemloft.net \
--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