Skip to content

Commit ea23192

Browse files
NicolasDichteldavem330
authored andcommitted
tunnels: harmonize cleanup done on skb on rx path
The goal of this patch is to harmonize cleanup done on a skbuff on rx path. Before this patch, behaviors were different depending of the tunnel type. Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 963a88b commit ea23192

File tree

7 files changed

+13
-26
lines changed

7 files changed

+13
-26
lines changed

include/net/dst.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,13 @@ static inline void skb_dst_force(struct sk_buff *skb)
311311
* __skb_tunnel_rx - prepare skb for rx reinsert
312312
* @skb: buffer
313313
* @dev: tunnel device
314+
* @net: netns for packet i/o
314315
*
315316
* After decapsulation, packet is going to re-enter (netif_rx()) our stack,
316317
* so make some cleanups. (no accounting done)
317318
*/
318-
static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
319+
static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev,
320+
struct net *net)
319321
{
320322
skb->dev = dev;
321323

@@ -327,8 +329,7 @@ static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
327329
if (!skb->l4_rxhash)
328330
skb->rxhash = 0;
329331
skb_set_queue_mapping(skb, 0);
330-
skb_dst_drop(skb);
331-
nf_reset(skb);
332+
skb_scrub_packet(skb, !net_eq(net, dev_net(dev)));
332333
}
333334

334335
/**
@@ -340,12 +341,13 @@ static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
340341
* so make some cleanups, and perform accounting.
341342
* Note: this accounting is not SMP safe.
342343
*/
343-
static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
344+
static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev,
345+
struct net *net)
344346
{
345347
/* TODO : stats should be SMP safe */
346348
dev->stats.rx_packets++;
347349
dev->stats.rx_bytes += skb->len;
348-
__skb_tunnel_rx(skb, dev);
350+
__skb_tunnel_rx(skb, dev, net);
349351
}
350352

351353
/* Children define the path of the packet through the

net/ipv4/ip_tunnel.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
461461
skb->dev = tunnel->dev;
462462
}
463463

464-
if (!net_eq(tunnel->net, dev_net(tunnel->dev)))
465-
skb_scrub_packet(skb, true);
464+
skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(tunnel->dev)));
466465

467466
gro_cells_receive(&tunnel->gro_cells, skb);
468467
return 0;

net/ipv4/ipmr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,9 +2067,8 @@ static int __pim_rcv(struct mr_table *mrt, struct sk_buff *skb,
20672067
skb_reset_network_header(skb);
20682068
skb->protocol = htons(ETH_P_IP);
20692069
skb->ip_summed = CHECKSUM_NONE;
2070-
skb->pkt_type = PACKET_HOST;
20712070

2072-
skb_tunnel_rx(skb, reg_dev);
2071+
skb_tunnel_rx(skb, reg_dev, dev_net(reg_dev));
20732072

20742073
netif_rx(skb);
20752074

net/ipv6/ip6_gre.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,6 @@ static int ip6gre_rcv(struct sk_buff *skb)
509509
goto drop;
510510
}
511511

512-
secpath_reset(skb);
513-
514512
skb->protocol = gre_proto;
515513
/* WCCP version 1 and 2 protocol decoding.
516514
* - Change protocol to IP
@@ -525,7 +523,6 @@ static int ip6gre_rcv(struct sk_buff *skb)
525523
skb->mac_header = skb->network_header;
526524
__pskb_pull(skb, offset);
527525
skb_postpull_rcsum(skb, skb_transport_header(skb), offset);
528-
skb->pkt_type = PACKET_HOST;
529526

530527
if (((flags&GRE_CSUM) && csum) ||
531528
(!(flags&GRE_CSUM) && tunnel->parms.i_flags&GRE_CSUM)) {
@@ -557,7 +554,7 @@ static int ip6gre_rcv(struct sk_buff *skb)
557554
skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
558555
}
559556

560-
__skb_tunnel_rx(skb, tunnel->dev);
557+
__skb_tunnel_rx(skb, tunnel->dev, tunnel->net);
561558

562559
skb_reset_network_header(skb);
563560

net/ipv6/ip6_tunnel.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -802,14 +802,12 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
802802
rcu_read_unlock();
803803
goto discard;
804804
}
805-
secpath_reset(skb);
806805
skb->mac_header = skb->network_header;
807806
skb_reset_network_header(skb);
808807
skb->protocol = htons(protocol);
809-
skb->pkt_type = PACKET_HOST;
810808
memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
811809

812-
__skb_tunnel_rx(skb, t->dev);
810+
__skb_tunnel_rx(skb, t->dev, t->net);
813811

814812
err = dscp_ecn_decapsulate(t, ipv6h, skb);
815813
if (unlikely(err)) {
@@ -829,9 +827,6 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
829827
tstats->rx_packets++;
830828
tstats->rx_bytes += skb->len;
831829

832-
if (!net_eq(t->net, dev_net(t->dev)))
833-
skb_scrub_packet(skb, true);
834-
835830
netif_rx(skb);
836831

837832
rcu_read_unlock();

net/ipv6/ip6mr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,8 @@ static int pim6_rcv(struct sk_buff *skb)
672672
skb_reset_network_header(skb);
673673
skb->protocol = htons(ETH_P_IPV6);
674674
skb->ip_summed = CHECKSUM_NONE;
675-
skb->pkt_type = PACKET_HOST;
676675

677-
skb_tunnel_rx(skb, reg_dev);
676+
skb_tunnel_rx(skb, reg_dev, dev_net(reg_dev));
678677

679678
netif_rx(skb);
680679

net/ipv6/sit.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,10 @@ static int ipip6_rcv(struct sk_buff *skb)
581581
tunnel->parms.iph.protocol != 0)
582582
goto out;
583583

584-
secpath_reset(skb);
585584
skb->mac_header = skb->network_header;
586585
skb_reset_network_header(skb);
587586
IPCB(skb)->flags = 0;
588587
skb->protocol = htons(ETH_P_IPV6);
589-
skb->pkt_type = PACKET_HOST;
590588

591589
if (tunnel->dev->priv_flags & IFF_ISATAP) {
592590
if (!isatap_chksrc(skb, iph, tunnel)) {
@@ -603,7 +601,7 @@ static int ipip6_rcv(struct sk_buff *skb)
603601
}
604602
}
605603

606-
__skb_tunnel_rx(skb, tunnel->dev);
604+
__skb_tunnel_rx(skb, tunnel->dev, tunnel->net);
607605

608606
err = IP_ECN_decapsulate(iph, skb);
609607
if (unlikely(err)) {
@@ -621,8 +619,6 @@ static int ipip6_rcv(struct sk_buff *skb)
621619
tstats->rx_packets++;
622620
tstats->rx_bytes += skb->len;
623621

624-
if (!net_eq(tunnel->net, dev_net(tunnel->dev)))
625-
skb_scrub_packet(skb, true);
626622
netif_rx(skb);
627623

628624
return 0;

0 commit comments

Comments
 (0)