From: Jiri Benc Date: Thu, 18 Feb 2016 10:22:51 +0000 (+0100) Subject: vxlan: move vxlan device lookup before iptunnel_pull_header X-Git-Tag: MMI-PSA29.97-13-9~8298^2~229^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c9e78efb6f668c42e0e0f47398e814b758b95336;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git vxlan: move vxlan device lookup before iptunnel_pull_header This is in preparation for iptunnel_pull_header calling skb_scrub_packet. Signed-off-by: Jiri Benc Signed-off-by: David S. Miller --- diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 75bccb360599..16a176cd0dad 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -1187,22 +1187,16 @@ out: unparsed->vx_flags &= ~VXLAN_GBP_USED_BITS; } -static void vxlan_rcv(struct vxlan_sock *vs, struct sk_buff *skb, - struct vxlan_metadata *md, __be32 vni, +static void vxlan_rcv(struct vxlan_dev *vxlan, struct vxlan_sock *vs, + struct sk_buff *skb, struct vxlan_metadata *md, struct metadata_dst *tun_dst) { struct iphdr *oip = NULL; struct ipv6hdr *oip6 = NULL; - struct vxlan_dev *vxlan; struct pcpu_sw_netstats *stats; union vxlan_addr saddr; int err = 0; - /* Is this VNI defined? */ - vxlan = vxlan_vs_find_vni(vs, vni); - if (!vxlan) - goto drop; - skb_reset_mac_header(skb); skb_scrub_packet(skb, !net_eq(vxlan->net, dev_net(vxlan->dev))); skb->protocol = eth_type_trans(skb, vxlan->dev); @@ -1281,6 +1275,7 @@ drop: static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb) { struct metadata_dst *tun_dst = NULL; + struct vxlan_dev *vxlan; struct vxlan_sock *vs; struct vxlanhdr unparsed; struct vxlan_metadata _md; @@ -1302,13 +1297,17 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb) unparsed.vx_flags &= ~VXLAN_HF_VNI; unparsed.vx_vni &= ~VXLAN_VNI_MASK; - if (iptunnel_pull_header(skb, VXLAN_HLEN, htons(ETH_P_TEB))) - goto drop; - vs = rcu_dereference_sk_user_data(sk); if (!vs) goto drop; + vxlan = vxlan_vs_find_vni(vs, vxlan_vni(vxlan_hdr(skb)->vx_vni)); + if (!vxlan) + goto drop; + + if (iptunnel_pull_header(skb, VXLAN_HLEN, htons(ETH_P_TEB))) + goto drop; + if (vxlan_collect_metadata(vs)) { __be32 vni = vxlan_vni(vxlan_hdr(skb)->vx_vni); @@ -1344,7 +1343,7 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb) goto drop; } - vxlan_rcv(vs, skb, md, vxlan_vni(vxlan_hdr(skb)->vx_vni), tun_dst); + vxlan_rcv(vxlan, vs, skb, md, tun_dst); return 0; drop: