tunnels: harmonize skb scrubbing during encapsulation/decapsulation
Subsystems (4)
cover tunnels: harmonize skb scrubbing during encapsulation/decapsulation
We talk recently about harmonizing tunnels so they behave consistently wrt. SKB orphaning, cleaning netfilter state, etc.
The goal of this serie is to achieve this.
Note that I only made some basic tests with ipip, sit and ip6_tunnels modules.
drivers/net/vxlan.c | 4 ++-- include/linux/skbuff.h | 2 +- include/net/dst.h | 12 +++++++----- include/net/ip6_tunnel.h | 1 - include/net/ip_tunnels.h | 5 ++--- net/core/dev.c | 2 +- net/core/skbuff.c | 19 ++++++++++++------- net/ipv4/ip_tunnel.c | 12 ++++-------- net/ipv4/ip_tunnel_core.c | 10 ++++------ net/ipv4/ipmr.c | 3 +-- net/ipv6/ip6_gre.c | 9 +++------ net/ipv6/ip6_tunnel.c | 11 ++--------- net/ipv6/ip6mr.c | 3 +-- net/ipv6/sit.c | 13 +++---------- net/openvswitch/vport-gre.c | 4 ++-- 15 files changed, 45 insertions(+), 65 deletions(-)
Comments are welcome.
Regards,
Nicolas
A message that is not in the archive (sent off-list or not yet received): 1377703210-7021-1-git-send-email-nicolas.dichtel-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
RFC PATCH 2/4 skb: allow skb_scrub_packet() to be used by tunnels
This function was only used when a packet was sent to another netns. Now, it can also be used after tunnel encapsulation or decapsulation.
Only skb_orphan() should not be done when a packet is not crossing netns.
--- include/linux/skbuff.h | 2 +- net/core/dev.c | 2 +- net/core/skbuff.c | 19 ++++++++++++------- net/ipv4/ip_tunnel.c | 4 ++-- net/ipv6/ip6_tunnel.c | 4 ++-- net/ipv6/sit.c | 4 ++-- 6 files changed, 20 insertions(+), 15 deletions(-)
include/linux/skbuff.h +1 -1
@@ -2392,7 +2392,7 @@ extern void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len);extern int skb_shift (struct sk_buff *tgt,struct sk_buff *skb,int shiftlen); -extern void skb_scrub_packet (struct sk_buff *skb); +extern void skb_scrub_packet (struct sk_buff *skb,bool xnet);extern struct sk_buff *skb_segment (struct sk_buff *skb,netdev_features_t features);
net/core/dev.c +1 -1
@@ -1697,7 +1697,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)* call skb_scrub_packet() after it to clear pkt_type _after_ calling * eth_type_trans(). */ -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);return netif_rx (skb); }
net/core/skbuff.c +12 -7
@@ -3500,17 +3500,22 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,EXPORT_SYMBOL (skb_try_coalesce);/** -* skb_scrub_packet - scrub an skb before sending it to another netns +* skb_scrub_packet - scrub an skb * * @skb: buffer to clean -* -* skb_scrub_packet can be used to clean an skb before injecting it in -* another namespace. We have to clear all information in the skb that -* could impact namespace isolation. +* @xnet: packet is crossing netns +* +* skb_scrub_packet can be used after encapsulating or decapsulting a packet +* into/from a tunnel. Some information have to be cleared during these +* operations. +* skb_scrub_packet can also be used to clean a skb before injecting it in +* another namespace (@xnet == true). We have to clear all information in the +* skb that could impact namespace isolation. */ -void skb_scrub_packet (struct sk_buff *skb) +void skb_scrub_packet (struct sk_buff *skb,bool xnet) { -skb_orphan (skb); +if (xnet) +skb_orphan (skb); skb->tstamp.tv64 =0 ; skb->pkt_type =PACKET_HOST ; skb->skb_iif =0 ;
net/ipv4/ip_tunnel.c +2 -2
@@ -462,7 +462,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, }if (!net_eq (tunnel->net,dev_net (tunnel->dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);gro_cells_receive (&tunnel->gro_cells, skb);return 0 ;
@@ -615,7 +615,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, }if (!net_eq (tunnel->net,dev_net (dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);if (tunnel->err_count >0 ) { if (time_before(jiffies,
net/ipv6/ip6_tunnel.c +2 -2
@@ -830,7 +830,7 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol, tstats->rx_bytes += skb->len;if (!net_eq (t->net,dev_net (t->dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);netif_rx (skb);
@@ -1002,7 +1002,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, }if (!net_eq (t->net,dev_net (dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);/* * Okay, now see if we can stuff it in the buffer as-is.
net/ipv6/sit.c +2 -2
@@ -622,7 +622,7 @@ static int ipip6_rcv(struct sk_buff *skb) tstats->rx_bytes += skb->len;if (!net_eq (tunnel->net,dev_net (tunnel->dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);netif_rx (skb);return 0 ;
@@ -861,7 +861,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, }if (!net_eq (tunnel->net,dev_net (dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);/* * Okay, now see if we can stuff it in the buffer as-is.
Signature · 1 line
1.8.2.1
RFC PATCH 4/4 tunnels: harmonize cleanup done on skb on rx path
In reply to a message not in the archiveThe 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.
--- include/net/dst.h | 12 +++++++----- net/ipv4/ip_tunnel.c | 3 +-- net/ipv4/ipmr.c | 3 +-- net/ipv6/ip6_gre.c | 5 +---- net/ipv6/ip6_tunnel.c | 7 +------ net/ipv6/ip6mr.c | 3 +-- net/ipv6/sit.c | 6 +----- 7 files changed, 13 insertions(+), 26 deletions(-)
include/net/dst.h +7 -5
@@ -311,11 +311,13 @@ static inline void skb_dst_force(struct sk_buff *skb)* __skb_tunnel_rx - prepare skb for rx reinsert * @skb: buffer * @dev: tunnel device +* @net: netns for packet i/o * * After decapsulation, packet is going to re-enter (netif_rx()) our stack, * so make some cleanups. (no accounting done) */ -static inline void __skb_tunnel_rx (struct sk_buff *skb,struct net_device *dev) +static inline void __skb_tunnel_rx (struct sk_buff *skb,struct net_device *dev, +struct net *net) { skb->dev = dev;
@@ -327,8 +329,7 @@ static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)if (!skb->l4_rxhash) skb->rxhash =0 ;skb_set_queue_mapping (skb,0 ); -skb_dst_drop (skb); -nf_reset (skb); +skb_scrub_packet (skb, !net_eq (net,dev_net (dev))); }/**
@@ -340,12 +341,13 @@ static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)* so make some cleanups, and perform accounting. * Note: this accounting is not SMP safe. */ -static inline void skb_tunnel_rx (struct sk_buff *skb,struct net_device *dev) +static inline void skb_tunnel_rx (struct sk_buff *skb,struct net_device *dev, +struct net *net) {/* TODO : stats should be SMP safe */ dev->stats.rx_packets++; dev->stats.rx_bytes += skb->len; -__skb_tunnel_rx (skb, dev); +__skb_tunnel_rx (skb, dev, net); }/* Children define the path of the packet through the
net/ipv4/ip_tunnel.c +1 -2
@@ -461,8 +461,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, skb->dev = tunnel->dev; } -if (!net_eq (tunnel->net,dev_net (tunnel->dev))) -skb_scrub_packet (skb, true); +skb_scrub_packet (skb, !net_eq (tunnel->net,dev_net (tunnel->dev)));gro_cells_receive (&tunnel->gro_cells, skb);return 0 ;
net/ipv4/ipmr.c +1 -2
@@ -2067,9 +2067,8 @@ static int __pim_rcv(struct mr_table *mrt, struct sk_buff *skb,skb_reset_network_header (skb); skb->protocol =htons (ETH_P_IP ); skb->ip_summed =CHECKSUM_NONE ; - skb->pkt_type =PACKET_HOST ; -skb_tunnel_rx (skb, reg_dev); +skb_tunnel_rx (skb, reg_dev,dev_net (reg_dev));netif_rx (skb);
net/ipv6/ip6_gre.c +1 -4
@@ -509,8 +509,6 @@ static int ip6gre_rcv(struct sk_buff *skb) goto drop; } -secpath_reset (skb); - skb->protocol = gre_proto;/* WCCP version 1 and 2 protocol decoding. * - Change protocol to IP
@@ -525,7 +523,6 @@ static int ip6gre_rcv(struct sk_buff *skb) skb->mac_header = skb->network_header;__pskb_pull (skb, offset);skb_postpull_rcsum (skb,skb_transport_header (skb), offset); - skb->pkt_type =PACKET_HOST ;if (((flags&GRE_CSUM ) && csum) || (!(flags&GRE_CSUM ) && tunnel->parms.i_flags&GRE_CSUM )) {
@@ -557,7 +554,7 @@ static int ip6gre_rcv(struct sk_buff *skb)skb_postpull_rcsum (skb,eth_hdr (skb),ETH_HLEN ); } -__skb_tunnel_rx (skb, tunnel->dev); +__skb_tunnel_rx (skb, tunnel->dev, tunnel->net);skb_reset_network_header (skb);
net/ipv6/ip6_tunnel.c +1 -6
@@ -802,14 +802,12 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,rcu_read_unlock (); goto discard; } -secpath_reset (skb); skb->mac_header = skb->network_header;skb_reset_network_header (skb); skb->protocol =htons (protocol); - skb->pkt_type =PACKET_HOST ;memset (skb->cb,0 ,sizeof (struct inet6_skb_parm )); -__skb_tunnel_rx (skb, t->dev); +__skb_tunnel_rx (skb, t->dev, t->net); err =dscp_ecn_decapsulate (t, ipv6h, skb);if (unlikely (err)) {
@@ -829,9 +827,6 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol, tstats->rx_packets++; tstats->rx_bytes += skb->len; -if (!net_eq (t->net,dev_net (t->dev))) -skb_scrub_packet (skb, true); -netif_rx (skb);rcu_read_unlock ();
net/ipv6/ip6mr.c +1 -2
@@ -672,9 +672,8 @@ static int pim6_rcv(struct sk_buff *skb)skb_reset_network_header (skb); skb->protocol =htons (ETH_P_IPV6 ); skb->ip_summed =CHECKSUM_NONE ; - skb->pkt_type =PACKET_HOST ; -skb_tunnel_rx (skb, reg_dev); +skb_tunnel_rx (skb, reg_dev,dev_net (reg_dev));netif_rx (skb);
net/ipv6/sit.c +1 -5
@@ -581,12 +581,10 @@ static int ipip6_rcv(struct sk_buff *skb) tunnel->parms.iph.protocol != 0) goto out; -secpath_reset (skb); skb->mac_header = skb->network_header;skb_reset_network_header (skb);IPCB (skb)->flags =0 ; skb->protocol =htons (ETH_P_IPV6 ); - skb->pkt_type =PACKET_HOST ;if (tunnel->dev->priv_flags &IFF_ISATAP ) {if (!isatap_chksrc (skb, iph, tunnel)) {
@@ -603,7 +601,7 @@ static int ipip6_rcv(struct sk_buff *skb) } } -__skb_tunnel_rx (skb, tunnel->dev); +__skb_tunnel_rx (skb, tunnel->dev, tunnel->net); err =IP_ECN_decapsulate (iph, skb);if (unlikely (err)) {
@@ -621,8 +619,6 @@ static int ipip6_rcv(struct sk_buff *skb) tstats->rx_packets++; tstats->rx_bytes += skb->len; -if (!net_eq (tunnel->net,dev_net (tunnel->dev))) -skb_scrub_packet (skb, true);netif_rx (skb);return 0 ;
Signature · 1 line
1.8.2.1
RFC PATCH 1/4 iptunnels: remove net arg from iptunnel_xmit()
In reply to Nicolas DichtelThis argument is not used, let's remove it.
--- drivers/net/vxlan.c | 3 +-- include/net/ip_tunnels.h | 3 +-- net/ipv4/ip_tunnel.c | 3 +-- net/ipv4/ip_tunnel_core.c | 3 +-- net/ipv6/sit.c | 4 ++-- net/openvswitch/vport-gre.c | 2 +- 6 files changed, 7 insertions(+), 11 deletions(-)
drivers/net/vxlan.c +1 -2
@@ -1171,8 +1171,7 @@ int vxlan_xmit_skb(struct net *net, struct vxlan_sock *vs,if (err)return err; -return iptunnel_xmit (net, rt, skb, src, dst, -IPPROTO_UDP , tos, ttl, df); +return iptunnel_xmit (rt, skb, src, dst,IPPROTO_UDP , tos, ttl, df); }EXPORT_SYMBOL_GPL (vxlan_xmit_skb);
include/net/ip_tunnels.h +1 -2
@@ -146,8 +146,7 @@ static inline u8 ip_tunnel_ecn_encap(u8 tos, const struct iphdr *iph, }int iptunnel_pull_header (struct sk_buff *skb,int hdr_len,__be16 inner_proto); -int iptunnel_xmit (struct net *net,struct rtable *rt, -struct sk_buff *skb, +int iptunnel_xmit (struct rtable *rt,struct sk_buff *skb,__be32 src,__be32 dst,__u8 proto,__u8 tos,__u8 ttl,__be16 df);
net/ipv4/ip_tunnel.c +1 -2
@@ -654,8 +654,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, } } - err =iptunnel_xmit (tunnel->net, rt, skb, - fl4.saddr, fl4.daddr, protocol, + err =iptunnel_xmit (rt, skb, fl4.saddr, fl4.daddr, protocol,ip_tunnel_ecn_encap (tos, inner_iph, skb), ttl, df);iptunnel_xmit_stats (err, &dev->stats, dev->tstats);
net/ipv4/ip_tunnel_core.c +1 -2
@@ -46,8 +46,7 @@#include <net/netns/generic.h> #include <net/rtnetlink.h> -int iptunnel_xmit (struct net *net,struct rtable *rt, -struct sk_buff *skb, +int iptunnel_xmit (struct rtable *rt,struct sk_buff *skb,__be32 src,__be32 dst,__u8 proto,__u8 tos,__u8 ttl,__be16 df) {
net/ipv6/sit.c +2 -2
@@ -888,8 +888,8 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, ttl = iph6->hop_limit; tos =INET_ECN_encapsulate (tos,ipv6_get_dsfield (iph6)); - err =iptunnel_xmit (dev_net (dev), rt, skb, fl4.saddr, fl4.daddr, -IPPROTO_IPV6 , tos, ttl, df); + err =iptunnel_xmit (rt, skb, fl4.saddr, fl4.daddr,IPPROTO_IPV6 , tos, + ttl, df);iptunnel_xmit_stats (err, &dev->stats, dev->tstats);return NETDEV_TX_OK ;
net/openvswitch/vport-gre.c +1 -1
@@ -176,7 +176,7 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb) skb->local_df =1 ; -return iptunnel_xmit (net, rt, skb, fl.saddr, +return iptunnel_xmit (rt, skb, fl.saddr,OVS_CB (skb)->tun_key->ipv4_dst,IPPROTO_GRE ,OVS_CB (skb)->tun_key->ipv4_tos,OVS_CB (skb)->tun_key->ipv4_ttl, df);
Signature · 1 line
1.8.2.1
Re: [ovs-dev] [RFC PATCH net-next 1/4] iptunnels: remove net arg from iptunnel_xmit()
Quoted 17 lines · Nicolas Dichtel
This argument is not used, let's remove it.
Signed-off-by Nicolas Dichtel <[email protected]>--- drivers/net/vxlan.c | 3 +-- include/net/ip_tunnels.h | 3 +-- net/ipv4/ip_tunnel.c | 3 +-- net/ipv4/ip_tunnel_core.c | 3 +-- net/ipv6/sit.c | 4 ++-- net/openvswitch/vport-gre.c | 2 +- 6 files changed, 7 insertions(+), 11 deletions(-)drivers/net/vxlan.c +0
-0
drivers/net/vxlan.c int vxlan_xmit_skb(struct net *net, struct vxlan_sock *vs, · line 1174
Quoted 6 lines
drivers/net/vxlan.c +1
-2@@ -1171,8 +1171,7 @@ int vxlan_xmit_skb(struct net *net, struct vxlan_sock *vs,if (err)return err; -return iptunnel_xmit (net, rt, skb, src, dst, -IPPROTO_UDP , tos, ttl, df); +return iptunnel_xmit (rt, skb, src, dst,IPPROTO_UDP , tos, ttl, df);
Can you remove argument net from vxlan_xmit_skb() also?
Thanks.
A message that is not in the archive (sent off-list or not yet received): CALnjE+pKi=p0y2ot2qWG1w=pxEUcPUKY+_UUi0RXbnGqVk9poA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
cover tunnels: harmonize skb scrubbing during encapsulation/decapsulation
We talk recently about harmonizing tunnels so they behave consistently wrt. SKB orphaning, cleaning netfilter state, etc.
The goal of this serie is to achieve this.
Note that I test only ipip, sit and ip6_tunnels modules.
v2: add patch 2/5
rebase on head
remove 'RFC' prefix
drivers/net/vxlan.c | 15 ++++++++------- include/linux/skbuff.h | 2 +- include/net/dst.h | 12 +++++++----- include/net/ip6_tunnel.h | 1 - include/net/ip_tunnels.h | 5 ++--- include/net/vxlan.h | 2 +- net/core/dev.c | 2 +- net/core/skbuff.c | 19 ++++++++++++------- net/ipv4/ip_tunnel.c | 12 ++++-------- net/ipv4/ip_tunnel_core.c | 10 ++++------ net/ipv4/ipmr.c | 3 +-- net/ipv6/ip6_gre.c | 9 +++------ net/ipv6/ip6_tunnel.c | 11 ++--------- net/ipv6/ip6mr.c | 3 +-- net/ipv6/sit.c | 13 +++---------- net/openvswitch/vport-gre.c | 4 ++-- net/openvswitch/vport-vxlan.c | 2 +- 17 files changed, 53 insertions(+), 72 deletions(-)
Comments are welcome.
Regards,
Nicolas
A message that is not in the archive (sent off-list or not yet received): 1378128898-15136-1-git-send-email-nicolas.dichtel-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
PATCH v2 1/5 iptunnels: remove net arg from iptunnel_xmit()
This argument is not used, let's remove it.
--- drivers/net/vxlan.c | 3 +-- include/net/ip_tunnels.h | 3 +-- net/ipv4/ip_tunnel.c | 3 +-- net/ipv4/ip_tunnel_core.c | 3 +-- net/ipv6/sit.c | 4 ++-- net/openvswitch/vport-gre.c | 2 +- 6 files changed, 7 insertions(+), 11 deletions(-)
drivers/net/vxlan.c +1 -2
@@ -1528,8 +1528,7 @@ int vxlan_xmit_skb(struct net *net, struct vxlan_sock *vs,if (err)return err; -return iptunnel_xmit (net, rt, skb, src, dst, -IPPROTO_UDP , tos, ttl, df); +return iptunnel_xmit (rt, skb, src, dst,IPPROTO_UDP , tos, ttl, df); }EXPORT_SYMBOL_GPL (vxlan_xmit_skb);
include/net/ip_tunnels.h +1 -2
@@ -146,8 +146,7 @@ static inline u8 ip_tunnel_ecn_encap(u8 tos, const struct iphdr *iph, }int iptunnel_pull_header (struct sk_buff *skb,int hdr_len,__be16 inner_proto); -int iptunnel_xmit (struct net *net,struct rtable *rt, -struct sk_buff *skb, +int iptunnel_xmit (struct rtable *rt,struct sk_buff *skb,__be32 src,__be32 dst,__u8 proto,__u8 tos,__u8 ttl,__be16 df);
net/ipv4/ip_tunnel.c +1 -2
@@ -654,8 +654,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, } } - err =iptunnel_xmit (tunnel->net, rt, skb, - fl4.saddr, fl4.daddr, protocol, + err =iptunnel_xmit (rt, skb, fl4.saddr, fl4.daddr, protocol,ip_tunnel_ecn_encap (tos, inner_iph, skb), ttl, df);iptunnel_xmit_stats (err, &dev->stats, dev->tstats);
net/ipv4/ip_tunnel_core.c +1 -2
@@ -46,8 +46,7 @@#include <net/netns/generic.h> #include <net/rtnetlink.h> -int iptunnel_xmit (struct net *net,struct rtable *rt, -struct sk_buff *skb, +int iptunnel_xmit (struct rtable *rt,struct sk_buff *skb,__be32 src,__be32 dst,__u8 proto,__u8 tos,__u8 ttl,__be16 df) {
net/ipv6/sit.c +2 -2
@@ -888,8 +888,8 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, ttl = iph6->hop_limit; tos =INET_ECN_encapsulate (tos,ipv6_get_dsfield (iph6)); - err =iptunnel_xmit (dev_net (dev), rt, skb, fl4.saddr, fl4.daddr, -IPPROTO_IPV6 , tos, ttl, df); + err =iptunnel_xmit (rt, skb, fl4.saddr, fl4.daddr,IPPROTO_IPV6 , tos, + ttl, df);iptunnel_xmit_stats (err, &dev->stats, dev->tstats);return NETDEV_TX_OK ;
net/openvswitch/vport-gre.c +1 -1
@@ -176,7 +176,7 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb) skb->local_df =1 ; -return iptunnel_xmit (net, rt, skb, fl.saddr, +return iptunnel_xmit (rt, skb, fl.saddr,OVS_CB (skb)->tun_key->ipv4_dst,IPPROTO_GRE ,OVS_CB (skb)->tun_key->ipv4_tos,OVS_CB (skb)->tun_key->ipv4_ttl, df);
Signature · 1 line
1.8.2.1
PATCH v2 2/5 vxlan: remove net arg from vxlan[6]_xmit_skb()
In reply to a message not in the archiveThis argument is not used, let's remove it.
--- drivers/net/vxlan.c | 8 ++++---- include/net/vxlan.h | 2 +- net/openvswitch/vport-vxlan.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/vxlan.c +4 -4
@@ -1380,7 +1380,7 @@ static int handle_offloads(struct sk_buff *skb) }#if IS_ENABLED (CONFIG_IPV6 ) -static int vxlan6_xmit_skb(struct net *net, struct vxlan_sock *vs, +static int vxlan6_xmit_skb(struct vxlan_sock *vs, struct dst_entry *dst, struct sk_buff *skb, struct net_device *dev, struct in6_addr *saddr, struct in6_addr *daddr, __u8 prio, __u8 ttl,
@@ -1475,7 +1475,7 @@ static int vxlan6_xmit_skb(struct net *net, struct vxlan_sock *vs, }#endif -int vxlan_xmit_skb (struct net *net,struct vxlan_sock *vs, +int vxlan_xmit_skb (struct vxlan_sock *vs,struct rtable *rt,struct sk_buff *skb,__be32 src,__be32 dst,__u8 tos,__u8 ttl,__be16 df,__be16 src_port,__be16 dst_port,__be32 vni)
@@ -1651,7 +1651,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, tos =ip_tunnel_ecn_encap (tos, old_iph, skb); ttl = ttl ? :ip4_dst_hoplimit (&rt->dst); - err =vxlan_xmit_skb (dev_net (dev), vxlan->vn_sock, rt, skb, + err =vxlan_xmit_skb (vxlan->vn_sock, rt, skb, fl4.saddr, dst->sin.sin_addr.s_addr, tos, ttl, df, src_port, dst_port,htonl (vni <<8 ));
@@ -1703,7 +1703,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ttl = ttl ? :ip6_dst_hoplimit (ndst); - err =vxlan6_xmit_skb (dev_net (dev), vxlan->vn_sock, ndst, skb, + err =vxlan6_xmit_skb (vxlan->vn_sock, ndst, skb, dev, &fl6.saddr, &fl6.daddr,0 , ttl, src_port, dst_port,htonl (vni <<8 ));#endif
include/net/vxlan.h +1 -1
@@ -29,7 +29,7 @@ struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port,void vxlan_sock_release (struct vxlan_sock *vs); -int vxlan_xmit_skb (struct net *net,struct vxlan_sock *vs, +int vxlan_xmit_skb (struct vxlan_sock *vs,struct rtable *rt,struct sk_buff *skb,__be32 src,__be32 dst,__u8 tos,__u8 ttl,__be16 df,__be16 src_port,__be16 dst_port,__be32 vni);
net/openvswitch/vport-vxlan.c +1 -1
@@ -176,7 +176,7 @@ static int vxlan_tnl_send(struct vport *vport, struct sk_buff *skb)inet_get_local_port_range (&port_min, &port_max); src_port =vxlan_src_port (port_min, port_max, skb); - err = vxlan_xmit_skb(net, vxlan_port->vs, rt, skb, + err = vxlan_xmit_skb(vxlan_port->vs, rt, skb, fl.saddr, OVS_CB(skb)->tun_key->ipv4_dst, OVS_CB(skb)->tun_key->ipv4_tos, OVS_CB(skb)->tun_key->ipv4_ttl, df,
Signature · 1 line
1.8.2.1
PATCH v2 5/5 tunnels: harmonize cleanup done on skb on rx path
In reply to a message not in the archiveThe 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.
--- include/net/dst.h | 12 +++++++----- net/ipv4/ip_tunnel.c | 3 +-- net/ipv4/ipmr.c | 3 +-- net/ipv6/ip6_gre.c | 5 +---- net/ipv6/ip6_tunnel.c | 7 +------ net/ipv6/ip6mr.c | 3 +-- net/ipv6/sit.c | 6 +----- 7 files changed, 13 insertions(+), 26 deletions(-)
include/net/dst.h +7 -5
@@ -311,11 +311,13 @@ static inline void skb_dst_force(struct sk_buff *skb)* __skb_tunnel_rx - prepare skb for rx reinsert * @skb: buffer * @dev: tunnel device +* @net: netns for packet i/o * * After decapsulation, packet is going to re-enter (netif_rx()) our stack, * so make some cleanups. (no accounting done) */ -static inline void __skb_tunnel_rx (struct sk_buff *skb,struct net_device *dev) +static inline void __skb_tunnel_rx (struct sk_buff *skb,struct net_device *dev, +struct net *net) { skb->dev = dev;
@@ -327,8 +329,7 @@ static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)if (!skb->l4_rxhash) skb->rxhash =0 ;skb_set_queue_mapping (skb,0 ); -skb_dst_drop (skb); -nf_reset (skb); +skb_scrub_packet (skb, !net_eq (net,dev_net (dev))); }/**
@@ -340,12 +341,13 @@ static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)* so make some cleanups, and perform accounting. * Note: this accounting is not SMP safe. */ -static inline void skb_tunnel_rx (struct sk_buff *skb,struct net_device *dev) +static inline void skb_tunnel_rx (struct sk_buff *skb,struct net_device *dev, +struct net *net) {/* TODO : stats should be SMP safe */ dev->stats.rx_packets++; dev->stats.rx_bytes += skb->len; -__skb_tunnel_rx (skb, dev); +__skb_tunnel_rx (skb, dev, net); }/* Children define the path of the packet through the
net/ipv4/ip_tunnel.c +1 -2
@@ -461,8 +461,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, skb->dev = tunnel->dev; } -if (!net_eq (tunnel->net,dev_net (tunnel->dev))) -skb_scrub_packet (skb, true); +skb_scrub_packet (skb, !net_eq (tunnel->net,dev_net (tunnel->dev)));gro_cells_receive (&tunnel->gro_cells, skb);return 0 ;
net/ipv4/ipmr.c +1 -2
@@ -2067,9 +2067,8 @@ static int __pim_rcv(struct mr_table *mrt, struct sk_buff *skb,skb_reset_network_header (skb); skb->protocol =htons (ETH_P_IP ); skb->ip_summed =CHECKSUM_NONE ; - skb->pkt_type =PACKET_HOST ; -skb_tunnel_rx (skb, reg_dev); +skb_tunnel_rx (skb, reg_dev,dev_net (reg_dev));netif_rx (skb);
net/ipv6/ip6_gre.c +1 -4
@@ -509,8 +509,6 @@ static int ip6gre_rcv(struct sk_buff *skb) goto drop; } -secpath_reset (skb); - skb->protocol = gre_proto;/* WCCP version 1 and 2 protocol decoding. * - Change protocol to IP
@@ -525,7 +523,6 @@ static int ip6gre_rcv(struct sk_buff *skb) skb->mac_header = skb->network_header;__pskb_pull (skb, offset);skb_postpull_rcsum (skb,skb_transport_header (skb), offset); - skb->pkt_type =PACKET_HOST ;if (((flags&GRE_CSUM ) && csum) || (!(flags&GRE_CSUM ) && tunnel->parms.i_flags&GRE_CSUM )) {
@@ -557,7 +554,7 @@ static int ip6gre_rcv(struct sk_buff *skb)skb_postpull_rcsum (skb,eth_hdr (skb),ETH_HLEN ); } -__skb_tunnel_rx (skb, tunnel->dev); +__skb_tunnel_rx (skb, tunnel->dev, tunnel->net);skb_reset_network_header (skb);
net/ipv6/ip6_tunnel.c +1 -6
@@ -802,14 +802,12 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,rcu_read_unlock (); goto discard; } -secpath_reset (skb); skb->mac_header = skb->network_header;skb_reset_network_header (skb); skb->protocol =htons (protocol); - skb->pkt_type =PACKET_HOST ;memset (skb->cb,0 ,sizeof (struct inet6_skb_parm )); -__skb_tunnel_rx (skb, t->dev); +__skb_tunnel_rx (skb, t->dev, t->net); err =dscp_ecn_decapsulate (t, ipv6h, skb);if (unlikely (err)) {
@@ -829,9 +827,6 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol, tstats->rx_packets++; tstats->rx_bytes += skb->len; -if (!net_eq (t->net,dev_net (t->dev))) -skb_scrub_packet (skb, true); -netif_rx (skb);rcu_read_unlock ();
net/ipv6/ip6mr.c +1 -2
@@ -672,9 +672,8 @@ static int pim6_rcv(struct sk_buff *skb)skb_reset_network_header (skb); skb->protocol =htons (ETH_P_IPV6 ); skb->ip_summed =CHECKSUM_NONE ; - skb->pkt_type =PACKET_HOST ; -skb_tunnel_rx (skb, reg_dev); +skb_tunnel_rx (skb, reg_dev,dev_net (reg_dev));netif_rx (skb);
net/ipv6/sit.c +1 -5
@@ -581,12 +581,10 @@ static int ipip6_rcv(struct sk_buff *skb) tunnel->parms.iph.protocol != 0) goto out; -secpath_reset (skb); skb->mac_header = skb->network_header;skb_reset_network_header (skb);IPCB (skb)->flags =0 ; skb->protocol =htons (ETH_P_IPV6 ); - skb->pkt_type =PACKET_HOST ;if (tunnel->dev->priv_flags &IFF_ISATAP ) {if (!isatap_chksrc (skb, iph, tunnel)) {
@@ -603,7 +601,7 @@ static int ipip6_rcv(struct sk_buff *skb) } } -__skb_tunnel_rx (skb, tunnel->dev); +__skb_tunnel_rx (skb, tunnel->dev, tunnel->net); err =IP_ECN_decapsulate (iph, skb);if (unlikely (err)) {
@@ -621,8 +619,6 @@ static int ipip6_rcv(struct sk_buff *skb) tstats->rx_packets++; tstats->rx_bytes += skb->len; -if (!net_eq (tunnel->net,dev_net (tunnel->dev))) -skb_scrub_packet (skb, true);netif_rx (skb);return 0 ;
Signature · 1 line
1.8.2.1
PATCH v2 3/5 skb: allow skb_scrub_packet() to be used by tunnels
In reply to Nicolas DichtelThis function was only used when a packet was sent to another netns. Now, it can also be used after tunnel encapsulation or decapsulation.
Only skb_orphan() should not be done when a packet is not crossing netns.
--- include/linux/skbuff.h | 2 +- net/core/dev.c | 2 +- net/core/skbuff.c | 19 ++++++++++++------- net/ipv4/ip_tunnel.c | 4 ++-- net/ipv6/ip6_tunnel.c | 4 ++-- net/ipv6/sit.c | 4 ++-- 6 files changed, 20 insertions(+), 15 deletions(-)
include/linux/skbuff.h +1 -1
@@ -2392,7 +2392,7 @@ extern void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len);extern int skb_shift (struct sk_buff *tgt,struct sk_buff *skb,int shiftlen); -extern void skb_scrub_packet (struct sk_buff *skb); +extern void skb_scrub_packet (struct sk_buff *skb,bool xnet);extern struct sk_buff *skb_segment (struct sk_buff *skb,netdev_features_t features);
net/core/dev.c +1 -1
@@ -1697,7 +1697,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)* call skb_scrub_packet() after it to clear pkt_type _after_ calling * eth_type_trans(). */ -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);return netif_rx (skb); }
net/core/skbuff.c +12 -7
@@ -3500,17 +3500,22 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,EXPORT_SYMBOL (skb_try_coalesce);/** -* skb_scrub_packet - scrub an skb before sending it to another netns +* skb_scrub_packet - scrub an skb * * @skb: buffer to clean -* -* skb_scrub_packet can be used to clean an skb before injecting it in -* another namespace. We have to clear all information in the skb that -* could impact namespace isolation. +* @xnet: packet is crossing netns +* +* skb_scrub_packet can be used after encapsulating or decapsulting a packet +* into/from a tunnel. Some information have to be cleared during these +* operations. +* skb_scrub_packet can also be used to clean a skb before injecting it in +* another namespace (@xnet == true). We have to clear all information in the +* skb that could impact namespace isolation. */ -void skb_scrub_packet (struct sk_buff *skb) +void skb_scrub_packet (struct sk_buff *skb,bool xnet) { -skb_orphan (skb); +if (xnet) +skb_orphan (skb); skb->tstamp.tv64 =0 ; skb->pkt_type =PACKET_HOST ; skb->skb_iif =0 ;
net/ipv4/ip_tunnel.c +2 -2
@@ -462,7 +462,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, }if (!net_eq (tunnel->net,dev_net (tunnel->dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);gro_cells_receive (&tunnel->gro_cells, skb);return 0 ;
@@ -615,7 +615,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, }if (!net_eq (tunnel->net,dev_net (dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);if (tunnel->err_count >0 ) { if (time_before(jiffies,
net/ipv6/ip6_tunnel.c +2 -2
@@ -830,7 +830,7 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol, tstats->rx_bytes += skb->len;if (!net_eq (t->net,dev_net (t->dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);netif_rx (skb);
@@ -1002,7 +1002,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, }if (!net_eq (t->net,dev_net (dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);/* * Okay, now see if we can stuff it in the buffer as-is.
net/ipv6/sit.c +2 -2
@@ -622,7 +622,7 @@ static int ipip6_rcv(struct sk_buff *skb) tstats->rx_bytes += skb->len;if (!net_eq (tunnel->net,dev_net (tunnel->dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);netif_rx (skb);return 0 ;
@@ -861,7 +861,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, }if (!net_eq (tunnel->net,dev_net (dev))) -skb_scrub_packet (skb); +skb_scrub_packet (skb, true);/* * Okay, now see if we can stuff it in the buffer as-is.
Signature · 1 line
1.8.2.1
PATCH v2 4/5 tunnels: harmonize cleanup done on skb on xmit path
In reply to Nicolas DichtelThe goal of this patch is to harmonize cleanup done on a skbuff on xmit path. Before this patch, behaviors were different depending of the tunnel type.
--- drivers/net/vxlan.c | 6 ++++-- include/net/ip6_tunnel.h | 1 - include/net/ip_tunnels.h | 2 +- net/ipv4/ip_tunnel.c | 6 ++---- net/ipv4/ip_tunnel_core.c | 7 +++---- net/ipv6/ip6_gre.c | 4 ++-- net/ipv6/ip6_tunnel.c | 4 +--- net/ipv6/sit.c | 5 +---- net/openvswitch/vport-gre.c | 2 +- 9 files changed, 15 insertions(+), 22 deletions(-)
drivers/net/vxlan.c +4 -2
@@ -1397,6 +1397,8 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs, skb->encapsulation =1 ; } +skb_scrub_packet (skb, false); + min_headroom =LL_RESERVED_SPACE (dst->dev) + dst->header_len +VXLAN_HLEN +sizeof (struct ipv6hdr ) + (vlan_tx_tag_present (skb) ?VLAN_HLEN :0 );
@@ -1432,7 +1434,6 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,memset (&(IPCB (skb)->opt),0 ,sizeof (IPCB (skb)->opt));IPCB (skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE |IPSKB_XFRM_TRANSFORMED |IPSKB_REROUTED ); -skb_dst_drop (skb);skb_dst_set (skb, dst);if (!skb_is_gso (skb) && !(dst->dev->features &NETIF_F_IPV6_CSUM )) {
@@ -1528,7 +1529,8 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,if (err)return err; -return iptunnel_xmit (rt, skb, src, dst,IPPROTO_UDP , tos, ttl, df); +return iptunnel_xmit (rt, skb, src, dst,IPPROTO_UDP , tos, ttl, df, + false); }EXPORT_SYMBOL_GPL (vxlan_xmit_skb);
include/net/ip6_tunnel.h +0 -1
@@ -75,7 +75,6 @@ static inline void ip6tunnel_xmit(struct sk_buff *skb, struct net_device *dev)struct net_device_stats *stats = &dev->stats;int pkt_len, err; -nf_reset (skb); pkt_len = skb->len; err =ip6_local_out (skb);
include/net/ip_tunnels.h +1 -1
@@ -148,7 +148,7 @@ static inline u8 ip_tunnel_ecn_encap(u8 tos, const struct iphdr *iph,int iptunnel_pull_header (struct sk_buff *skb,int hdr_len,__be16 inner_proto);int iptunnel_xmit (struct rtable *rt,struct sk_buff *skb,__be32 src,__be32 dst,__u8 proto, -__u8 tos,__u8 ttl,__be16 df); +__u8 tos,__u8 ttl,__be16 df,bool xnet); static inline void iptunnel_xmit_stats(int err, struct net_device_stats *err_stats,
net/ipv4/ip_tunnel.c +2 -4
@@ -614,9 +614,6 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, goto tx_error; } -if (!net_eq (tunnel->net,dev_net (dev))) -skb_scrub_packet (skb, true); -if (tunnel->err_count >0 ) {if (time_before (jiffies, tunnel->err_time +IPTUNNEL_ERR_TIMEO )) {
@@ -655,7 +652,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, } err =iptunnel_xmit (rt, skb, fl4.saddr, fl4.daddr, protocol, -ip_tunnel_ecn_encap (tos, inner_iph, skb), ttl, df); +ip_tunnel_ecn_encap (tos, inner_iph, skb), ttl, df, + !net_eq (tunnel->net,dev_net (dev)));iptunnel_xmit_stats (err, &dev->stats, dev->tstats);return ;
net/ipv4/ip_tunnel_core.c +3 -4
@@ -48,16 +48,15 @@int iptunnel_xmit (struct rtable *rt,struct sk_buff *skb,__be32 src,__be32 dst,__u8 proto, -__u8 tos,__u8 ttl,__be16 df) +__u8 tos,__u8 ttl,__be16 df,bool xnet) {int pkt_len = skb->len;struct iphdr *iph;int err; -nf_reset (skb); -secpath_reset (skb); +skb_scrub_packet (skb, xnet); + skb->rxhash =0 ; -skb_dst_drop (skb);skb_dst_set (skb, &rt->dst);memset (IPCB (skb),0 ,sizeof (*IPCB (skb)));
net/ipv6/ip6_gre.c +2 -2
@@ -694,6 +694,8 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb, tunnel->err_count =0 ; } +skb_scrub_packet (skb, !net_eq (tunnel->net,dev_net (dev))); + max_headroom =LL_RESERVED_SPACE (tdev) + gre_hlen + dst->header_len; if (skb_headroom(skb) < max_headroom || skb_shared(skb) ||
@@ -710,8 +712,6 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb, skb = new_skb; } -skb_dst_drop (skb); -if (fl6->flowi6_mark) {skb_dst_set (skb, dst); ndst =NULL ;
net/ipv6/ip6_tunnel.c +1 -3
@@ -1001,8 +1001,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, goto tx_err_dst_release; } -if (!net_eq (t->net,dev_net (dev))) -skb_scrub_packet (skb, true); +skb_scrub_packet (skb, !net_eq (t->net,dev_net (dev)));/* * Okay, now see if we can stuff it in the buffer as-is.
@@ -1021,7 +1020,6 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,consume_skb (skb); skb = new_skb; } -skb_dst_drop (skb);if (fl6->flowi6_mark) {skb_dst_set (skb, dst); ndst =NULL ;
net/ipv6/sit.c +1 -4
@@ -860,9 +860,6 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, tunnel->err_count =0 ; } -if (!net_eq (tunnel->net,dev_net (dev))) -skb_scrub_packet (skb, true); -/* * Okay, now see if we can stuff it in the buffer as-is. */
@@ -889,7 +886,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, tos =INET_ECN_encapsulate (tos,ipv6_get_dsfield (iph6)); err =iptunnel_xmit (rt, skb, fl4.saddr, fl4.daddr,IPPROTO_IPV6 , tos, - ttl, df); + ttl, df, !net_eq (tunnel->net,dev_net (dev)));iptunnel_xmit_stats (err, &dev->stats, dev->tstats);return NETDEV_TX_OK ;
net/openvswitch/vport-gre.c +1 -1
@@ -179,7 +179,7 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)return iptunnel_xmit (rt, skb, fl.saddr,OVS_CB (skb)->tun_key->ipv4_dst,IPPROTO_GRE ,OVS_CB (skb)->tun_key->ipv4_tos, -OVS_CB (skb)->tun_key->ipv4_ttl, df); +OVS_CB (skb)->tun_key->ipv4_ttl, df, false); err_free_rt:ip_rt_put (rt); error:
Signature · 1 line
1.8.2.1
David Miller
maintainerFrom: Nicolas Dichtel <[email protected]>
Date: Mon, 2 Sep 2013 15:34:53 +0200
Quoted 9 lines
We talk recently about harmonizing tunnels so they behave consistently wrt. SKB orphaning, cleaning netfilter state, etc.
The goal of this serie is to achieve this.Note that I test only ipip, sit and
ip6_tunnelsmodules.v2: add patch 2/5
rebase on head
remove 'RFC' prefix
Series applied.
RFC PATCH 3/4 tunnels: harmonize cleanup done on skb on xmit path
In reply to Nicolas DichtelThe goal of this patch is to harmonize cleanup done on a skbuff on xmit path. Before this patch, behaviors were different depending of the tunnel type.
--- drivers/net/vxlan.c | 3 ++- include/net/ip6_tunnel.h | 1 - include/net/ip_tunnels.h | 2 +- net/ipv4/ip_tunnel.c | 6 ++---- net/ipv4/ip_tunnel_core.c | 7 +++---- net/ipv6/ip6_gre.c | 4 ++-- net/ipv6/ip6_tunnel.c | 4 +--- net/ipv6/sit.c | 5 +---- net/openvswitch/vport-gre.c | 2 +- 9 files changed, 13 insertions(+), 21 deletions(-)
drivers/net/vxlan.c +2 -1
@@ -1171,7 +1171,8 @@ int vxlan_xmit_skb(struct net *net, struct vxlan_sock *vs,if (err)return err; -return iptunnel_xmit (rt, skb, src, dst,IPPROTO_UDP , tos, ttl, df); +return iptunnel_xmit (rt, skb, src, dst,IPPROTO_UDP , tos, ttl, df, + false); }EXPORT_SYMBOL_GPL (vxlan_xmit_skb);
include/net/ip6_tunnel.h +0 -1
@@ -75,7 +75,6 @@ static inline void ip6tunnel_xmit(struct sk_buff *skb, struct net_device *dev)struct net_device_stats *stats = &dev->stats;int pkt_len, err; -nf_reset (skb); pkt_len = skb->len; err =ip6_local_out (skb);
include/net/ip_tunnels.h +1 -1
@@ -148,7 +148,7 @@ static inline u8 ip_tunnel_ecn_encap(u8 tos, const struct iphdr *iph,int iptunnel_pull_header (struct sk_buff *skb,int hdr_len,__be16 inner_proto);int iptunnel_xmit (struct rtable *rt,struct sk_buff *skb,__be32 src,__be32 dst,__u8 proto, -__u8 tos,__u8 ttl,__be16 df); +__u8 tos,__u8 ttl,__be16 df,bool xnet); static inline void iptunnel_xmit_stats(int err, struct net_device_stats *err_stats,
net/ipv4/ip_tunnel.c +2 -4
@@ -614,9 +614,6 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, goto tx_error; } -if (!net_eq (tunnel->net,dev_net (dev))) -skb_scrub_packet (skb, true); -if (tunnel->err_count >0 ) {if (time_before (jiffies, tunnel->err_time +IPTUNNEL_ERR_TIMEO )) {
@@ -655,7 +652,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, } err =iptunnel_xmit (rt, skb, fl4.saddr, fl4.daddr, protocol, -ip_tunnel_ecn_encap (tos, inner_iph, skb), ttl, df); +ip_tunnel_ecn_encap (tos, inner_iph, skb), ttl, df, + !net_eq (tunnel->net,dev_net (dev)));iptunnel_xmit_stats (err, &dev->stats, dev->tstats);return ;
net/ipv4/ip_tunnel_core.c +3 -4
@@ -48,16 +48,15 @@int iptunnel_xmit (struct rtable *rt,struct sk_buff *skb,__be32 src,__be32 dst,__u8 proto, -__u8 tos,__u8 ttl,__be16 df) +__u8 tos,__u8 ttl,__be16 df,bool xnet) {int pkt_len = skb->len;struct iphdr *iph;int err; -nf_reset (skb); -secpath_reset (skb); +skb_scrub_packet (skb, xnet); + skb->rxhash =0 ; -skb_dst_drop (skb);skb_dst_set (skb, &rt->dst);memset (IPCB (skb),0 ,sizeof (*IPCB (skb)));
net/ipv6/ip6_gre.c +2 -2
@@ -694,6 +694,8 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb, tunnel->err_count =0 ; } +skb_scrub_packet (skb, !net_eq (tunnel->net,dev_net (dev))); + max_headroom =LL_RESERVED_SPACE (tdev) + gre_hlen + dst->header_len; if (skb_headroom(skb) < max_headroom || skb_shared(skb) ||
@@ -710,8 +712,6 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb, skb = new_skb; } -skb_dst_drop (skb); -if (fl6->flowi6_mark) {skb_dst_set (skb, dst); ndst =NULL ;
net/ipv6/ip6_tunnel.c +1 -3
@@ -1001,8 +1001,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, goto tx_err_dst_release; } -if (!net_eq (t->net,dev_net (dev))) -skb_scrub_packet (skb, true); +skb_scrub_packet (skb, !net_eq (t->net,dev_net (dev)));/* * Okay, now see if we can stuff it in the buffer as-is.
@@ -1021,7 +1020,6 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,consume_skb (skb); skb = new_skb; } -skb_dst_drop (skb);if (fl6->flowi6_mark) {skb_dst_set (skb, dst); ndst =NULL ;
net/ipv6/sit.c +1 -4
@@ -860,9 +860,6 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, tunnel->err_count =0 ; } -if (!net_eq (tunnel->net,dev_net (dev))) -skb_scrub_packet (skb, true); -/* * Okay, now see if we can stuff it in the buffer as-is. */
@@ -889,7 +886,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, tos =INET_ECN_encapsulate (tos,ipv6_get_dsfield (iph6)); err =iptunnel_xmit (rt, skb, fl4.saddr, fl4.daddr,IPPROTO_IPV6 , tos, - ttl, df); + ttl, df, !net_eq (tunnel->net,dev_net (dev)));iptunnel_xmit_stats (err, &dev->stats, dev->tstats);return NETDEV_TX_OK ;
net/openvswitch/vport-gre.c +1 -1
@@ -179,7 +179,7 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)return iptunnel_xmit (rt, skb, fl.saddr,OVS_CB (skb)->tun_key->ipv4_dst,IPPROTO_GRE ,OVS_CB (skb)->tun_key->ipv4_tos, -OVS_CB (skb)->tun_key->ipv4_ttl, df); +OVS_CB (skb)->tun_key->ipv4_ttl, df, false); err_free_rt:ip_rt_put (rt); error:
Signature · 1 line
1.8.2.1