Commit 967b05f6 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller

[SK_BUFF]: Introduce skb_set_transport_header

For the cases where the transport header is being set to a offset from
skb->data.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ea2ae17d
...@@ -962,6 +962,12 @@ static inline void skb_reset_transport_header(struct sk_buff *skb) ...@@ -962,6 +962,12 @@ static inline void skb_reset_transport_header(struct sk_buff *skb)
skb->h.raw = skb->data; skb->h.raw = skb->data;
} }
static inline void skb_set_transport_header(struct sk_buff *skb,
const int offset)
{
skb->h.raw = skb->data + offset;
}
static inline int skb_transport_offset(const struct sk_buff *skb) static inline int skb_transport_offset(const struct sk_buff *skb)
{ {
return skb->h.raw - skb->data; return skb->h.raw - skb->data;
......
...@@ -1425,7 +1425,6 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1425,7 +1425,6 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
struct sockaddr_ax25 sax; struct sockaddr_ax25 sax;
struct sk_buff *skb; struct sk_buff *skb;
ax25_digi dtmp, *dp; ax25_digi dtmp, *dp;
unsigned char *asmptr;
ax25_cb *ax25; ax25_cb *ax25;
size_t size; size_t size;
int lv, err, addr_len = msg->msg_namelen; int lv, err, addr_len = msg->msg_namelen;
...@@ -1551,10 +1550,8 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1551,10 +1550,8 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
skb_reset_network_header(skb); skb_reset_network_header(skb);
/* Add the PID if one is not supplied by the user in the skb */ /* Add the PID if one is not supplied by the user in the skb */
if (!ax25->pidincl) { if (!ax25->pidincl)
asmptr = skb_push(skb, 1); *skb_push(skb, 1) = sk->sk_protocol;
*asmptr = sk->sk_protocol;
}
SOCK_DEBUG(sk, "AX.25: Transmitting buffer\n"); SOCK_DEBUG(sk, "AX.25: Transmitting buffer\n");
...@@ -1573,7 +1570,7 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1573,7 +1570,7 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
goto out; goto out;
} }
asmptr = skb_push(skb, 1 + ax25_addr_size(dp)); skb_push(skb, 1 + ax25_addr_size(dp));
SOCK_DEBUG(sk, "Building AX.25 Header (dp=%p).\n", dp); SOCK_DEBUG(sk, "Building AX.25 Header (dp=%p).\n", dp);
...@@ -1581,17 +1578,16 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1581,17 +1578,16 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
SOCK_DEBUG(sk, "Num digipeaters=%d\n", dp->ndigi); SOCK_DEBUG(sk, "Num digipeaters=%d\n", dp->ndigi);
/* Build an AX.25 header */ /* Build an AX.25 header */
asmptr += (lv = ax25_addr_build(asmptr, &ax25->source_addr, lv = ax25_addr_build(skb->data, &ax25->source_addr, &sax.sax25_call,
&sax.sax25_call, dp, dp, AX25_COMMAND, AX25_MODULUS);
AX25_COMMAND, AX25_MODULUS));
SOCK_DEBUG(sk, "Built header (%d bytes)\n",lv); SOCK_DEBUG(sk, "Built header (%d bytes)\n",lv);
skb->h.raw = asmptr; skb_set_transport_header(skb, lv);
SOCK_DEBUG(sk, "base=%p pos=%p\n", skb->data, asmptr); SOCK_DEBUG(sk, "base=%p pos=%p\n", skb->data, skb->h.raw);
*asmptr = AX25_UI; *skb->h.raw = AX25_UI;
/* Datagram frames go straight out of the door as UI */ /* Datagram frames go straight out of the door as UI */
ax25_queue_xmit(skb, ax25->ax25_dev->dev); ax25_queue_xmit(skb, ax25->ax25_dev->dev);
......
...@@ -233,7 +233,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -233,7 +233,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
/* UI frame - bypass LAPB processing */ /* UI frame - bypass LAPB processing */
if ((*skb->data & ~0x10) == AX25_UI && dp.lastrepeat + 1 == dp.ndigi) { if ((*skb->data & ~0x10) == AX25_UI && dp.lastrepeat + 1 == dp.ndigi) {
skb->h.raw = skb->data + 2; /* skip control and pid */ skb_set_transport_header(skb, 2); /* skip control and pid */
ax25_send_to_raw(&dest, skb, skb->data[1]); ax25_send_to_raw(&dest, skb, skb->data[1]);
......
...@@ -261,7 +261,8 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb) ...@@ -261,7 +261,8 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
iph->protocol = nexthdr[1]; iph->protocol = nexthdr[1];
pskb_trim(skb, skb->len - alen - padlen - 2); pskb_trim(skb, skb->len - alen - padlen - 2);
skb->h.raw = __skb_pull(skb, sizeof(*esph) + esp->conf.ivlen) - ihl; __skb_pull(skb, sizeof(*esph) + esp->conf.ivlen);
skb_set_transport_header(skb, -ihl);
return 0; return 0;
......
...@@ -593,7 +593,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*)) ...@@ -593,7 +593,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
skb_reserve(skb2, ll_rs); skb_reserve(skb2, ll_rs);
skb_put(skb2, len + hlen); skb_put(skb2, len + hlen);
skb_reset_network_header(skb2); skb_reset_network_header(skb2);
skb2->h.raw = skb2->data + hlen; skb2->h.raw = skb2->nh.raw + hlen;
/* /*
* Charge the memory for the fragment to any owner * Charge the memory for the fragment to any owner
...@@ -724,7 +724,7 @@ static inline int ip_ufo_append_data(struct sock *sk, ...@@ -724,7 +724,7 @@ static inline int ip_ufo_append_data(struct sock *sk,
skb_reset_network_header(skb); skb_reset_network_header(skb);
/* initialize protocol header pointer */ /* initialize protocol header pointer */
skb->h.raw = skb->data + fragheaderlen; skb->h.raw = skb->nh.raw + fragheaderlen;
skb->ip_summed = CHECKSUM_PARTIAL; skb->ip_summed = CHECKSUM_PARTIAL;
skb->csum = 0; skb->csum = 0;
...@@ -1099,8 +1099,6 @@ ssize_t ip_append_page(struct sock *sk, struct page *page, ...@@ -1099,8 +1099,6 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
} }
if (len <= 0) { if (len <= 0) {
struct sk_buff *skb_prev; struct sk_buff *skb_prev;
char *data;
struct iphdr *iph;
int alloclen; int alloclen;
skb_prev = skb; skb_prev = skb;
...@@ -1123,16 +1121,15 @@ ssize_t ip_append_page(struct sock *sk, struct page *page, ...@@ -1123,16 +1121,15 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
/* /*
* Find where to start putting bytes. * Find where to start putting bytes.
*/ */
data = skb_put(skb, fragheaderlen + fraggap); skb_put(skb, fragheaderlen + fraggap);
skb_reset_network_header(skb); skb_reset_network_header(skb);
iph = ip_hdr(skb); skb->h.raw = skb->nh.raw + fragheaderlen;
data += fragheaderlen;
skb->h.raw = data;
if (fraggap) { if (fraggap) {
skb->csum = skb_copy_and_csum_bits( skb->csum = skb_copy_and_csum_bits(skb_prev,
skb_prev, maxfraglen, maxfraglen,
data, fraggap, 0); skb->h.raw,
fraggap, 0);
skb_prev->csum = csum_sub(skb_prev->csum, skb_prev->csum = csum_sub(skb_prev->csum,
skb->csum); skb->csum);
pskb_trim_unique(skb_prev, maxfraglen); pskb_trim_unique(skb_prev, maxfraglen);
......
...@@ -3636,7 +3636,7 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, ...@@ -3636,7 +3636,7 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list,
skb_set_mac_header(nskb, skb_mac_header(skb) - skb->head); skb_set_mac_header(nskb, skb_mac_header(skb) - skb->head);
skb_set_network_header(nskb, skb_set_network_header(nskb,
skb_network_header(skb) - skb->head); skb_network_header(skb) - skb->head);
nskb->h.raw = nskb->data + (skb->h.raw - skb->head); skb_set_transport_header(nskb, skb->h.raw - skb->head);
skb_reserve(nskb, header); skb_reserve(nskb, header);
memcpy(nskb->head, skb->head, header); memcpy(nskb->head, skb->head, header);
......
...@@ -247,7 +247,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb) ...@@ -247,7 +247,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
memcpy(tmp_base, top_iph, sizeof(tmp_base)); memcpy(tmp_base, top_iph, sizeof(tmp_base));
tmp_ext = NULL; tmp_ext = NULL;
extlen = skb->h.raw - (unsigned char *)(top_iph + 1); extlen = skb_transport_offset(skb) + sizeof(struct ipv6hdr);
if (extlen) { if (extlen) {
extlen += sizeof(*tmp_ext); extlen += sizeof(*tmp_ext);
tmp_ext = kmalloc(extlen, GFP_ATOMIC); tmp_ext = kmalloc(extlen, GFP_ATOMIC);
......
...@@ -228,8 +228,8 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb) ...@@ -228,8 +228,8 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
ret = nexthdr[1]; ret = nexthdr[1];
} }
skb->h.raw = __skb_pull(skb, sizeof(*esph) + esp->conf.ivlen) - hdr_len; __skb_pull(skb, sizeof(*esph) + esp->conf.ivlen);
skb_set_transport_header(skb, -hdr_len);
out: out:
return ret; return ret;
} }
......
...@@ -785,7 +785,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb) ...@@ -785,7 +785,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
goto ret_orig; goto ret_orig;
} }
clone->h.raw = clone->data + fhoff; skb_set_transport_header(clone, fhoff);
hdr = ipv6_hdr(clone); hdr = ipv6_hdr(clone);
fhdr = (struct frag_hdr *)clone->h.raw; fhdr = (struct frag_hdr *)clone->h.raw;
......
...@@ -42,7 +42,7 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb) ...@@ -42,7 +42,7 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
hdr_len = ip6_find_1stfragopt(skb, &prevhdr); hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
skb->nh.raw = prevhdr - x->props.header_len; skb->nh.raw = prevhdr - x->props.header_len;
skb->h.raw = skb->data + hdr_len; skb_set_transport_header(skb, hdr_len);
memmove(skb->data, iph, hdr_len); memmove(skb->data, iph, hdr_len);
skb_reset_network_header(skb); skb_reset_network_header(skb);
......
...@@ -54,7 +54,7 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb) ...@@ -54,7 +54,7 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
hdr_len = x->type->hdr_offset(x, skb, &prevhdr); hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
skb->nh.raw = prevhdr - x->props.header_len; skb->nh.raw = prevhdr - x->props.header_len;
skb->h.raw = skb->data + hdr_len; skb_set_transport_header(skb, hdr_len);
memmove(skb->data, iph, hdr_len); memmove(skb->data, iph, hdr_len);
return 0; return 0;
} }
......
...@@ -36,7 +36,7 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb) ...@@ -36,7 +36,7 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)
hdr_len = x->type->hdr_offset(x, skb, &prevhdr); hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
skb->nh.raw = prevhdr - x->props.header_len; skb->nh.raw = prevhdr - x->props.header_len;
skb->h.raw = skb->data + hdr_len; skb_set_transport_header(skb, hdr_len);
memmove(skb->data, iph, hdr_len); memmove(skb->data, iph, hdr_len);
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