Commit 53744a4a authored by Vasily Averin's avatar Vasily Averin Committed by David S. Miller

ax25: use skb_expand_head

Use skb_expand_head() in ax25_transmit_buffer and ax25_rt_build_path.
Unlike skb_realloc_headroom, new helper does not allocate a new skb if possible.
Signed-off-by: default avatarVasily Averin <vvs@virtuozzo.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 14ee70ca
...@@ -193,10 +193,8 @@ netdev_tx_t ax25_ip_xmit(struct sk_buff *skb) ...@@ -193,10 +193,8 @@ netdev_tx_t ax25_ip_xmit(struct sk_buff *skb)
skb_pull(skb, AX25_KISS_HEADER_LEN); skb_pull(skb, AX25_KISS_HEADER_LEN);
if (digipeat != NULL) { if (digipeat != NULL) {
if ((ourskb = ax25_rt_build_path(skb, src, dst, route->digipeat)) == NULL) { if ((ourskb = ax25_rt_build_path(skb, src, dst, route->digipeat)) == NULL)
kfree_skb(skb);
goto put; goto put;
}
skb = ourskb; skb = ourskb;
} }
......
...@@ -325,7 +325,6 @@ void ax25_kick(ax25_cb *ax25) ...@@ -325,7 +325,6 @@ void ax25_kick(ax25_cb *ax25)
void ax25_transmit_buffer(ax25_cb *ax25, struct sk_buff *skb, int type) void ax25_transmit_buffer(ax25_cb *ax25, struct sk_buff *skb, int type)
{ {
struct sk_buff *skbn;
unsigned char *ptr; unsigned char *ptr;
int headroom; int headroom;
...@@ -336,18 +335,12 @@ void ax25_transmit_buffer(ax25_cb *ax25, struct sk_buff *skb, int type) ...@@ -336,18 +335,12 @@ void ax25_transmit_buffer(ax25_cb *ax25, struct sk_buff *skb, int type)
headroom = ax25_addr_size(ax25->digipeat); headroom = ax25_addr_size(ax25->digipeat);
if (skb_headroom(skb) < headroom) { if (unlikely(skb_headroom(skb) < headroom)) {
if ((skbn = skb_realloc_headroom(skb, headroom)) == NULL) { skb = skb_expand_head(skb, headroom);
if (!skb) {
printk(KERN_CRIT "AX.25: ax25_transmit_buffer - out of memory\n"); printk(KERN_CRIT "AX.25: ax25_transmit_buffer - out of memory\n");
kfree_skb(skb);
return; return;
} }
if (skb->sk != NULL)
skb_set_owner_w(skbn, skb->sk);
consume_skb(skb);
skb = skbn;
} }
ptr = skb_push(skb, headroom); ptr = skb_push(skb, headroom);
......
...@@ -441,24 +441,17 @@ int ax25_rt_autobind(ax25_cb *ax25, ax25_address *addr) ...@@ -441,24 +441,17 @@ int ax25_rt_autobind(ax25_cb *ax25, ax25_address *addr)
struct sk_buff *ax25_rt_build_path(struct sk_buff *skb, ax25_address *src, struct sk_buff *ax25_rt_build_path(struct sk_buff *skb, ax25_address *src,
ax25_address *dest, ax25_digi *digi) ax25_address *dest, ax25_digi *digi)
{ {
struct sk_buff *skbn;
unsigned char *bp; unsigned char *bp;
int len; int len;
len = digi->ndigi * AX25_ADDR_LEN; len = digi->ndigi * AX25_ADDR_LEN;
if (skb_headroom(skb) < len) { if (unlikely(skb_headroom(skb) < len)) {
if ((skbn = skb_realloc_headroom(skb, len)) == NULL) { skb = skb_expand_head(skb, len);
if (!skb) {
printk(KERN_CRIT "AX.25: ax25_dg_build_path - out of memory\n"); printk(KERN_CRIT "AX.25: ax25_dg_build_path - out of memory\n");
return NULL; return NULL;
} }
if (skb->sk != NULL)
skb_set_owner_w(skbn, skb->sk);
consume_skb(skb);
skb = skbn;
} }
bp = skb_push(skb, len); bp = skb_push(skb, len);
......
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