summaryrefslogtreecommitdiffstats
path: root/drivers/net/vxlan.c
diff options
context:
space:
mode:
authorJiri Benc <jbenc@redhat.com>2016-02-23 18:02:58 +0100
committerDavid S. Miller <davem@davemloft.net>2016-02-25 15:17:12 -0500
commitf2d1968ec85e85def98fdea0cf325851433bb60a (patch)
tree5b03a4ff9f475658376f2c89bfe628e7dfe46338 /drivers/net/vxlan.c
parent760c68054e9ed1c6e43b06f916f6efc2c8a1adcc (diff)
downloadlinux-f2d1968ec85e85def98fdea0cf325851433bb60a.tar.gz
linux-f2d1968ec85e85def98fdea0cf325851433bb60a.tar.bz2
linux-f2d1968ec85e85def98fdea0cf325851433bb60a.zip
vxlan: consolidate rx handling to a single function
Now when both vxlan_udp_encap_recv and vxlan_rcv are much shorter, combine them into a single function. Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/vxlan.c')
-rw-r--r--drivers/net/vxlan.c72
1 files changed, 28 insertions, 44 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 382535bc9e59..cfd6deb9f090 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1247,56 +1247,17 @@ static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph,
return err <= 1;
}
-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 pcpu_sw_netstats *stats;
- void *oiph;
-
- if (!vxlan_set_mac(vxlan, vs, skb))
- goto drop;
-
- if (tun_dst) {
- skb_dst_set(skb, (struct dst_entry *)tun_dst);
- tun_dst = NULL;
- }
-
- oiph = skb_network_header(skb);
- skb_reset_network_header(skb);
-
- if (!vxlan_ecn_decapsulate(vs, oiph, skb)) {
- ++vxlan->dev->stats.rx_frame_errors;
- ++vxlan->dev->stats.rx_errors;
- goto drop;
- }
-
- stats = this_cpu_ptr(vxlan->dev->tstats);
- u64_stats_update_begin(&stats->syncp);
- stats->rx_packets++;
- stats->rx_bytes += skb->len;
- u64_stats_update_end(&stats->syncp);
-
- gro_cells_receive(&vxlan->gro_cells, skb);
-
- return;
-drop:
- if (tun_dst)
- dst_release((struct dst_entry *)tun_dst);
-
- /* Consume bad packet */
- kfree_skb(skb);
-}
-
/* Callback from net/ipv4/udp.c to receive packets */
-static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
+static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
{
struct metadata_dst *tun_dst = NULL;
+ struct pcpu_sw_netstats *stats;
struct vxlan_dev *vxlan;
struct vxlan_sock *vs;
struct vxlanhdr unparsed;
struct vxlan_metadata _md;
struct vxlan_metadata *md = &_md;
+ void *oiph;
/* Need Vxlan and inner Ethernet header to be present */
if (!pskb_may_pull(skb, VXLAN_HLEN))
@@ -1361,7 +1322,30 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
goto drop;
}
- vxlan_rcv(vxlan, vs, skb, md, tun_dst);
+ if (!vxlan_set_mac(vxlan, vs, skb))
+ goto drop;
+
+ if (tun_dst) {
+ skb_dst_set(skb, (struct dst_entry *)tun_dst);
+ tun_dst = NULL;
+ }
+
+ oiph = skb_network_header(skb);
+ skb_reset_network_header(skb);
+
+ if (!vxlan_ecn_decapsulate(vs, oiph, skb)) {
+ ++vxlan->dev->stats.rx_frame_errors;
+ ++vxlan->dev->stats.rx_errors;
+ goto drop;
+ }
+
+ stats = this_cpu_ptr(vxlan->dev->tstats);
+ u64_stats_update_begin(&stats->syncp);
+ stats->rx_packets++;
+ stats->rx_bytes += skb->len;
+ u64_stats_update_end(&stats->syncp);
+
+ gro_cells_receive(&vxlan->gro_cells, skb);
return 0;
drop:
@@ -2666,7 +2650,7 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6,
/* Mark socket as an encapsulation socket. */
tunnel_cfg.sk_user_data = vs;
tunnel_cfg.encap_type = 1;
- tunnel_cfg.encap_rcv = vxlan_udp_encap_recv;
+ tunnel_cfg.encap_rcv = vxlan_rcv;
tunnel_cfg.encap_destroy = NULL;
setup_udp_tunnel_sock(net, sock, &tunnel_cfg);