Commit c3b18e0d authored by Jason A. Donenfeld's avatar Jason A. Donenfeld Committed by David S. Miller

net: xfrm: use skb_list_walk_safe helper for gso segments

This is converts xfrm segment iteration to use the new function, keeping
the flow of the existing code as intact as possible. One case is very
straight-forward, whereas the other case has some more subtle code that
likes to peak at ->next and relink skbs. By keeping the variables the
same as before, we can upgrade this code with minimal surgery required.
Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1a186c14
...@@ -78,7 +78,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur ...@@ -78,7 +78,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
int err; int err;
unsigned long flags; unsigned long flags;
struct xfrm_state *x; struct xfrm_state *x;
struct sk_buff *skb2; struct sk_buff *skb2, *nskb;
struct softnet_data *sd; struct softnet_data *sd;
netdev_features_t esp_features = features; netdev_features_t esp_features = features;
struct xfrm_offload *xo = xfrm_offload(skb); struct xfrm_offload *xo = xfrm_offload(skb);
...@@ -148,11 +148,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur ...@@ -148,11 +148,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
return skb; return skb;
} }
skb2 = skb; skb_list_walk_safe(skb, skb2, nskb) {
do {
struct sk_buff *nskb = skb2->next;
esp_features |= skb->dev->gso_partial_features; esp_features |= skb->dev->gso_partial_features;
skb_mark_not_on_list(skb2); skb_mark_not_on_list(skb2);
...@@ -176,14 +172,11 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur ...@@ -176,14 +172,11 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
if (!skb) if (!skb)
return NULL; return NULL;
goto skip_push; continue;
} }
skb_push(skb2, skb2->data - skb_mac_header(skb2)); skb_push(skb2, skb2->data - skb_mac_header(skb2));
}
skip_push:
skb2 = nskb;
} while (skb2);
return skb; return skb;
} }
......
...@@ -533,7 +533,7 @@ static int xfrm_output2(struct net *net, struct sock *sk, struct sk_buff *skb) ...@@ -533,7 +533,7 @@ static int xfrm_output2(struct net *net, struct sock *sk, struct sk_buff *skb)
static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb) static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb)
{ {
struct sk_buff *segs; struct sk_buff *segs, *nskb;
BUILD_BUG_ON(sizeof(*IPCB(skb)) > SKB_SGO_CB_OFFSET); BUILD_BUG_ON(sizeof(*IPCB(skb)) > SKB_SGO_CB_OFFSET);
BUILD_BUG_ON(sizeof(*IP6CB(skb)) > SKB_SGO_CB_OFFSET); BUILD_BUG_ON(sizeof(*IP6CB(skb)) > SKB_SGO_CB_OFFSET);
...@@ -544,8 +544,7 @@ static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb ...@@ -544,8 +544,7 @@ static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb
if (segs == NULL) if (segs == NULL)
return -EINVAL; return -EINVAL;
do { skb_list_walk_safe(segs, segs, nskb) {
struct sk_buff *nskb = segs->next;
int err; int err;
skb_mark_not_on_list(segs); skb_mark_not_on_list(segs);
...@@ -555,9 +554,7 @@ static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb ...@@ -555,9 +554,7 @@ static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb
kfree_skb_list(nskb); kfree_skb_list(nskb);
return err; return err;
} }
}
segs = nskb;
} while (segs);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment