From: Tom Herbert <tom@quantonium.net>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Tom Herbert <tom@quantonium.net>
Subject: [PATCH v2 net-next 6/6] vxlan: support flow dissect
Date: Tue, 29 Aug 2017 16:27:11 -0700 [thread overview]
Message-ID: <20170829232711.1465-7-tom@quantonium.net> (raw)
In-Reply-To: <20170829232711.1465-1-tom@quantonium.net>
Populate offload flow_dissect callback appropriately for VXLAN and
VXLAN-GPE.
Signed-off-by: Tom Herbert <tom@quantonium.net>
---
drivers/net/vxlan.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index ae3a1da703c2..41e50de40af4 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1336,6 +1336,55 @@ static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph,
return err <= 1;
}
+static enum flow_dissect_ret vxlan_flow_dissect(struct sock *sk,
+ const struct sk_buff *skb,
+ struct flow_dissector_key_control *key_control,
+ struct flow_dissector *flow_dissector,
+ void *target_container, void *data,
+ __be16 *p_proto, u8 *p_ip_proto, int *p_nhoff,
+ int *p_hlen, unsigned int flags)
+{
+ __be16 protocol = htons(ETH_P_TEB);
+ struct vxlanhdr *vhdr, _vhdr;
+ struct vxlan_sock *vs;
+
+ vhdr = __skb_header_pointer(skb, *p_nhoff + sizeof(struct udphdr),
+ sizeof(_vhdr), data, *p_hlen, &_vhdr);
+ if (!vhdr)
+ return FLOW_DISSECT_RET_OUT_BAD;
+
+ vs = rcu_dereference_sk_user_data(sk);
+ if (!vs)
+ return FLOW_DISSECT_RET_OUT_BAD;
+
+ if (vs->flags & VXLAN_F_GPE) {
+ struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)vhdr;
+
+ /* Need to have Next Protocol set for interfaces in GPE mode. */
+ if (gpe->version != 0 || !gpe->np_applied || gpe->oam_flag)
+ return FLOW_DISSECT_RET_CONTINUE;
+
+ switch (gpe->next_protocol) {
+ case VXLAN_GPE_NP_IPV4:
+ protocol = htons(ETH_P_IP);
+ break;
+ case VXLAN_GPE_NP_IPV6:
+ protocol = htons(ETH_P_IPV6);
+ break;
+ case VXLAN_GPE_NP_ETHERNET:
+ protocol = htons(ETH_P_TEB);
+ break;
+ default:
+ return FLOW_DISSECT_RET_CONTINUE;
+ }
+ }
+
+ *p_nhoff += sizeof(struct udphdr) + sizeof(_vhdr);
+ *p_proto = protocol;
+
+ return FLOW_DISSECT_RET_PROTO_AGAIN;
+}
+
/* Callback from net/ipv4/udp.c to receive packets */
static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
{
@@ -2864,6 +2913,7 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6,
tunnel_cfg.encap_destroy = NULL;
tunnel_cfg.gro_receive = vxlan_gro_receive;
tunnel_cfg.gro_complete = vxlan_gro_complete;
+ tunnel_cfg.flow_dissect = vxlan_flow_dissect;
setup_udp_tunnel_sock(net, sock, &tunnel_cfg);
--
2.11.0
next prev parent reply other threads:[~2017-08-29 23:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 23:27 [PATCH v2 net-next 0/6] flow_dissector: Protocol specific flow dissector offload Tom Herbert
2017-08-29 23:27 ` [PATCH v2 net-next 1/6] flow_dissector: Move ETH_P_TEB processing to main switch Tom Herbert
2017-08-29 23:27 ` [PATCH v2 net-next 2/6] udp: Constify skb argument in lookup functions Tom Herbert
2017-08-30 0:58 ` David Miller
2017-08-30 3:09 ` Tom Herbert
2017-08-29 23:27 ` [PATCH v2 net-next 3/6] flow_dissector: Add protocol specific flow dissection offload Tom Herbert
2017-08-30 1:00 ` David Miller
2017-08-29 23:27 ` [PATCH v2 net-next 4/6] udp: flow dissector offload Tom Herbert
2017-08-30 10:36 ` Paolo Abeni
2017-08-30 14:56 ` Tom Herbert
2017-08-31 15:53 ` Willem de Bruijn
2017-08-29 23:27 ` [PATCH v2 net-next 5/6] fou: Support flow dissection Tom Herbert
2017-08-29 23:27 ` Tom Herbert [this message]
2017-08-30 8:41 ` [PATCH v2 net-next 0/6] flow_dissector: Protocol specific flow dissector offload Hannes Frederic Sowa
2017-08-30 14:50 ` Tom Herbert
2017-08-31 10:11 ` Hannes Frederic Sowa
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=20170829232711.1465-7-tom@quantonium.net \
--to=tom@quantonium.net \
--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;
as well as URLs for NNTP newsgroup(s).