[SK_BUFF]: Introduce skb_set_network_header

For the cases where the network header is being set to a offset from skb->data.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Arnaldo Carvalho de Melo 2007-03-11 22:39:41 -03:00 committed by David S. Miller
parent 878c814500
commit c14d2450cb
5 changed files with 15 additions and 7 deletions

View file

@ -970,6 +970,11 @@ static inline void skb_reset_network_header(struct sk_buff *skb)
skb->nh.raw = skb->data; skb->nh.raw = skb->data;
} }
static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
{
skb->nh.raw = skb->data + offset;
}
static inline int skb_network_offset(const struct sk_buff *skb) static inline int skb_network_offset(const struct sk_buff *skb)
{ {
return skb->nh.raw - skb->data; return skb->nh.raw - skb->data;

View file

@ -148,7 +148,8 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
if (ka9qfrag == 1) { if (ka9qfrag == 1) {
skb_reserve(skbn, frontlen + 2); skb_reserve(skbn, frontlen + 2);
skbn->nh.raw = skbn->data + skb_network_offset(skb); skb_set_network_header(skbn,
skb_network_offset(skb));
memcpy(skb_put(skbn, len), skb->data, len); memcpy(skb_put(skbn, len), skb->data, len);
p = skb_push(skbn, 2); p = skb_push(skbn, 2);
@ -161,7 +162,8 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
} }
} else { } else {
skb_reserve(skbn, frontlen + 1); skb_reserve(skbn, frontlen + 1);
skbn->nh.raw = skbn->data + skb_network_offset(skb); skb_set_network_header(skbn,
skb_network_offset(skb));
memcpy(skb_put(skbn, len), skb->data, len); memcpy(skb_put(skbn, len), skb->data, len);
p = skb_push(skbn, 1); p = skb_push(skbn, 1);
*p = AX25_P_TEXT; *p = AX25_P_TEXT;

View file

@ -928,9 +928,9 @@ alloc_new_skb:
* Find where to start putting bytes. * Find where to start putting bytes.
*/ */
data = skb_put(skb, fraglen); data = skb_put(skb, fraglen);
skb->nh.raw = data + exthdrlen; skb_set_network_header(skb, exthdrlen);
skb->h.raw = skb->nh.raw + fragheaderlen;
data += fragheaderlen; data += fragheaderlen;
skb->h.raw = data + exthdrlen;
if (fraggap) { if (fraggap) {
skb->csum = skb_copy_and_csum_bits( skb->csum = skb_copy_and_csum_bits(

View file

@ -3634,7 +3634,8 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list,
return; return;
skb_set_mac_header(nskb, skb_mac_header(skb) - skb->head); skb_set_mac_header(nskb, skb_mac_header(skb) - skb->head);
nskb->nh.raw = nskb->data + (skb_network_header(skb) - skb->head); skb_set_network_header(nskb,
skb_network_header(skb) - skb->head);
nskb->h.raw = nskb->data + (skb->h.raw - skb->head); nskb->h.raw = nskb->data + (skb->h.raw - skb->head);
skb_reserve(nskb, header); skb_reserve(nskb, header);

View file

@ -1206,9 +1206,9 @@ alloc_new_skb:
* Find where to start putting bytes * Find where to start putting bytes
*/ */
data = skb_put(skb, fraglen); data = skb_put(skb, fraglen);
skb->nh.raw = data + exthdrlen; skb_set_network_header(skb, exthdrlen);
data += fragheaderlen; data += fragheaderlen;
skb->h.raw = data + exthdrlen; skb->h.raw = skb->nh.raw + fragheaderlen;
if (fraggap) { if (fraggap) {
skb->csum = skb_copy_and_csum_bits( skb->csum = skb_copy_and_csum_bits(