@@ -1247,56 +1247,17 @@ static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph,
12471247 return err <= 1 ;
12481248}
12491249
1250- static void vxlan_rcv (struct vxlan_dev * vxlan , struct vxlan_sock * vs ,
1251- struct sk_buff * skb , struct vxlan_metadata * md ,
1252- struct metadata_dst * tun_dst )
1253- {
1254- struct pcpu_sw_netstats * stats ;
1255- void * oiph ;
1256-
1257- if (!vxlan_set_mac (vxlan , vs , skb ))
1258- goto drop ;
1259-
1260- if (tun_dst ) {
1261- skb_dst_set (skb , (struct dst_entry * )tun_dst );
1262- tun_dst = NULL ;
1263- }
1264-
1265- oiph = skb_network_header (skb );
1266- skb_reset_network_header (skb );
1267-
1268- if (!vxlan_ecn_decapsulate (vs , oiph , skb )) {
1269- ++ vxlan -> dev -> stats .rx_frame_errors ;
1270- ++ vxlan -> dev -> stats .rx_errors ;
1271- goto drop ;
1272- }
1273-
1274- stats = this_cpu_ptr (vxlan -> dev -> tstats );
1275- u64_stats_update_begin (& stats -> syncp );
1276- stats -> rx_packets ++ ;
1277- stats -> rx_bytes += skb -> len ;
1278- u64_stats_update_end (& stats -> syncp );
1279-
1280- gro_cells_receive (& vxlan -> gro_cells , skb );
1281-
1282- return ;
1283- drop :
1284- if (tun_dst )
1285- dst_release ((struct dst_entry * )tun_dst );
1286-
1287- /* Consume bad packet */
1288- kfree_skb (skb );
1289- }
1290-
12911250/* Callback from net/ipv4/udp.c to receive packets */
1292- static int vxlan_udp_encap_recv (struct sock * sk , struct sk_buff * skb )
1251+ static int vxlan_rcv (struct sock * sk , struct sk_buff * skb )
12931252{
12941253 struct metadata_dst * tun_dst = NULL ;
1254+ struct pcpu_sw_netstats * stats ;
12951255 struct vxlan_dev * vxlan ;
12961256 struct vxlan_sock * vs ;
12971257 struct vxlanhdr unparsed ;
12981258 struct vxlan_metadata _md ;
12991259 struct vxlan_metadata * md = & _md ;
1260+ void * oiph ;
13001261
13011262 /* Need Vxlan and inner Ethernet header to be present */
13021263 if (!pskb_may_pull (skb , VXLAN_HLEN ))
@@ -1361,7 +1322,30 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
13611322 goto drop ;
13621323 }
13631324
1364- vxlan_rcv (vxlan , vs , skb , md , tun_dst );
1325+ if (!vxlan_set_mac (vxlan , vs , skb ))
1326+ goto drop ;
1327+
1328+ if (tun_dst ) {
1329+ skb_dst_set (skb , (struct dst_entry * )tun_dst );
1330+ tun_dst = NULL ;
1331+ }
1332+
1333+ oiph = skb_network_header (skb );
1334+ skb_reset_network_header (skb );
1335+
1336+ if (!vxlan_ecn_decapsulate (vs , oiph , skb )) {
1337+ ++ vxlan -> dev -> stats .rx_frame_errors ;
1338+ ++ vxlan -> dev -> stats .rx_errors ;
1339+ goto drop ;
1340+ }
1341+
1342+ stats = this_cpu_ptr (vxlan -> dev -> tstats );
1343+ u64_stats_update_begin (& stats -> syncp );
1344+ stats -> rx_packets ++ ;
1345+ stats -> rx_bytes += skb -> len ;
1346+ u64_stats_update_end (& stats -> syncp );
1347+
1348+ gro_cells_receive (& vxlan -> gro_cells , skb );
13651349 return 0 ;
13661350
13671351drop :
@@ -2666,7 +2650,7 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6,
26662650 /* Mark socket as an encapsulation socket. */
26672651 tunnel_cfg .sk_user_data = vs ;
26682652 tunnel_cfg .encap_type = 1 ;
2669- tunnel_cfg .encap_rcv = vxlan_udp_encap_recv ;
2653+ tunnel_cfg .encap_rcv = vxlan_rcv ;
26702654 tunnel_cfg .encap_destroy = NULL ;
26712655
26722656 setup_udp_tunnel_sock (net , sock , & tunnel_cfg );
0 commit comments