Skip to content

Commit 272c233

Browse files
jarodwilsondavem330
authored andcommitted
xfrm: bail early on slave pass over skb
This is prep work for initial support of bonding hardware encryption pass-through support. The bonding driver will fill in the slave_dev pointer, and we use that to know not to skb_push() again on a given skb that was already processed on the bond device. CC: Jay Vosburgh <j.vosburgh@gmail.com> CC: Veaceslav Falico <vfalico@gmail.com> CC: Andy Gospodarek <andy@greyhouse.net> CC: "David S. Miller" <davem@davemloft.net> CC: Jeff Kirsher <jeffrey.t.kirsher@intel.com> CC: Jakub Kicinski <kuba@kernel.org> CC: Steffen Klassert <steffen.klassert@secunet.com> CC: Herbert Xu <herbert@gondor.apana.org.au> CC: netdev@vger.kernel.org CC: intel-wired-lan@lists.osuosl.org Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 389cc2f commit 272c233

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

include/net/xfrm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ struct xfrm_state_walk {
127127

128128
struct xfrm_state_offload {
129129
struct net_device *dev;
130+
struct net_device *slave_dev;
130131
unsigned long offload_handle;
131132
unsigned int num_exthdrs;
132133
u8 flags;

net/xfrm/xfrm_device.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
106106
struct sk_buff *skb2, *nskb, *pskb = NULL;
107107
netdev_features_t esp_features = features;
108108
struct xfrm_offload *xo = xfrm_offload(skb);
109+
struct net_device *dev = skb->dev;
109110
struct sec_path *sp;
110111

111112
if (!xo)
@@ -119,6 +120,10 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
119120
if (xo->flags & XFRM_GRO || x->xso.flags & XFRM_OFFLOAD_INBOUND)
120121
return skb;
121122

123+
/* This skb was already validated on the master dev */
124+
if ((x->xso.dev != dev) && (x->xso.slave_dev == dev))
125+
return skb;
126+
122127
local_irq_save(flags);
123128
sd = this_cpu_ptr(&softnet_data);
124129
err = !skb_queue_empty(&sd->xfrm_backlog);
@@ -129,25 +134,20 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
129134
return skb;
130135
}
131136

132-
if (skb_is_gso(skb)) {
133-
struct net_device *dev = skb->dev;
134-
135-
if (unlikely(x->xso.dev != dev)) {
136-
struct sk_buff *segs;
137+
if (skb_is_gso(skb) && unlikely(x->xso.dev != dev)) {
138+
struct sk_buff *segs;
137139

138-
/* Packet got rerouted, fixup features and segment it. */
139-
esp_features = esp_features & ~(NETIF_F_HW_ESP
140-
| NETIF_F_GSO_ESP);
140+
/* Packet got rerouted, fixup features and segment it. */
141+
esp_features = esp_features & ~(NETIF_F_HW_ESP | NETIF_F_GSO_ESP);
141142

142-
segs = skb_gso_segment(skb, esp_features);
143-
if (IS_ERR(segs)) {
144-
kfree_skb(skb);
145-
atomic_long_inc(&dev->tx_dropped);
146-
return NULL;
147-
} else {
148-
consume_skb(skb);
149-
skb = segs;
150-
}
143+
segs = skb_gso_segment(skb, esp_features);
144+
if (IS_ERR(segs)) {
145+
kfree_skb(skb);
146+
atomic_long_inc(&dev->tx_dropped);
147+
return NULL;
148+
} else {
149+
consume_skb(skb);
150+
skb = segs;
151151
}
152152
}
153153

0 commit comments

Comments
 (0)