vrf: use skb_expand_head in vrf_finish_output
Unlike skb_realloc_headroom, new helper skb_expand_head does not allocate a new skb if possible. Signed-off-by: Vasily Averin <vvs@virtuozzo.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
5678a59579
commit
14ee70ca89
1 changed files with 7 additions and 14 deletions
|
@ -857,30 +857,24 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
|
||||||
unsigned int hh_len = LL_RESERVED_SPACE(dev);
|
unsigned int hh_len = LL_RESERVED_SPACE(dev);
|
||||||
struct neighbour *neigh;
|
struct neighbour *neigh;
|
||||||
bool is_v6gw = false;
|
bool is_v6gw = false;
|
||||||
int ret = -EINVAL;
|
|
||||||
|
|
||||||
nf_reset_ct(skb);
|
nf_reset_ct(skb);
|
||||||
|
|
||||||
/* Be paranoid, rather than too clever. */
|
/* Be paranoid, rather than too clever. */
|
||||||
if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) {
|
if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) {
|
||||||
struct sk_buff *skb2;
|
skb = skb_expand_head(skb, hh_len);
|
||||||
|
if (!skb) {
|
||||||
skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev));
|
skb->dev->stats.tx_errors++;
|
||||||
if (!skb2) {
|
return -ENOMEM;
|
||||||
ret = -ENOMEM;
|
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
if (skb->sk)
|
|
||||||
skb_set_owner_w(skb2, skb->sk);
|
|
||||||
|
|
||||||
consume_skb(skb);
|
|
||||||
skb = skb2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rcu_read_lock_bh();
|
rcu_read_lock_bh();
|
||||||
|
|
||||||
neigh = ip_neigh_for_gw(rt, skb, &is_v6gw);
|
neigh = ip_neigh_for_gw(rt, skb, &is_v6gw);
|
||||||
if (!IS_ERR(neigh)) {
|
if (!IS_ERR(neigh)) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
sock_confirm_neigh(skb, neigh);
|
sock_confirm_neigh(skb, neigh);
|
||||||
/* if crossing protocols, can not use the cached header */
|
/* if crossing protocols, can not use the cached header */
|
||||||
ret = neigh_output(neigh, skb, is_v6gw);
|
ret = neigh_output(neigh, skb, is_v6gw);
|
||||||
|
@ -889,9 +883,8 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
|
||||||
}
|
}
|
||||||
|
|
||||||
rcu_read_unlock_bh();
|
rcu_read_unlock_bh();
|
||||||
err:
|
|
||||||
vrf_tx_error(skb->dev, skb);
|
vrf_tx_error(skb->dev, skb);
|
||||||
return ret;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vrf_output(struct net *net, struct sock *sk, struct sk_buff *skb)
|
static int vrf_output(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||||
|
|
Loading…
Add table
Reference in a new issue