@@ -1165,16 +1165,17 @@ static bool vxlan_remcsum(struct vxlanhdr *unparsed,
11651165
11661166static void vxlan_parse_gbp_hdr (struct vxlanhdr * unparsed ,
11671167 struct sk_buff * skb , u32 vxflags ,
1168- struct vxlan_metadata * md ,
1169- struct metadata_dst * tun_dst )
1168+ struct vxlan_metadata * md )
11701169{
11711170 struct vxlanhdr_gbp * gbp = (struct vxlanhdr_gbp * )unparsed ;
1171+ struct metadata_dst * tun_dst ;
11721172
11731173 if (!(unparsed -> vx_flags & VXLAN_HF_GBP ))
11741174 goto out ;
11751175
11761176 md -> gbp = ntohs (gbp -> policy_id );
11771177
1178+ tun_dst = (struct metadata_dst * )skb_dst (skb );
11781179 if (tun_dst )
11791180 tun_dst -> u .tun_info .key .tun_flags |= TUNNEL_VXLAN_OPT ;
11801181
@@ -1250,7 +1251,6 @@ static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph,
12501251/* Callback from net/ipv4/udp.c to receive packets */
12511252static int vxlan_rcv (struct sock * sk , struct sk_buff * skb )
12521253{
1253- struct metadata_dst * tun_dst = NULL ;
12541254 struct pcpu_sw_netstats * stats ;
12551255 struct vxlan_dev * vxlan ;
12561256 struct vxlan_sock * vs ;
@@ -1289,6 +1289,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
12891289
12901290 if (vxlan_collect_metadata (vs )) {
12911291 __be32 vni = vxlan_vni (vxlan_hdr (skb )-> vx_vni );
1292+ struct metadata_dst * tun_dst ;
12921293
12931294 tun_dst = udp_tun_rx_dst (skb , vxlan_get_sk_family (vs ), TUNNEL_KEY ,
12941295 vxlan_vni_to_tun_id (vni ), sizeof (* md ));
@@ -1297,6 +1298,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
12971298 goto drop ;
12981299
12991300 md = ip_tunnel_info_opts (& tun_dst -> u .tun_info );
1301+
1302+ skb_dst_set (skb , (struct dst_entry * )tun_dst );
13001303 } else {
13011304 memset (md , 0 , sizeof (* md ));
13021305 }
@@ -1308,7 +1311,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
13081311 if (!vxlan_remcsum (& unparsed , skb , vs -> flags ))
13091312 goto drop ;
13101313 if (vs -> flags & VXLAN_F_GBP )
1311- vxlan_parse_gbp_hdr (& unparsed , skb , vs -> flags , md , tun_dst );
1314+ vxlan_parse_gbp_hdr (& unparsed , skb , vs -> flags , md );
13121315
13131316 if (unparsed .vx_flags || unparsed .vx_vni ) {
13141317 /* If there are any unprocessed flags remaining treat
@@ -1325,11 +1328,6 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
13251328 if (!vxlan_set_mac (vxlan , vs , skb ))
13261329 goto drop ;
13271330
1328- if (tun_dst ) {
1329- skb_dst_set (skb , (struct dst_entry * )tun_dst );
1330- tun_dst = NULL ;
1331- }
1332-
13331331 oiph = skb_network_header (skb );
13341332 skb_reset_network_header (skb );
13351333
@@ -1349,9 +1347,6 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
13491347 return 0 ;
13501348
13511349drop :
1352- if (tun_dst )
1353- dst_release ((struct dst_entry * )tun_dst );
1354-
13551350 /* Consume bad packet */
13561351 kfree_skb (skb );
13571352 return 0 ;
0 commit comments