mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 00:34:10 +08:00
[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: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ea2ae17d64
commit
967b05f64e
@ -962,6 +962,12 @@ static inline void skb_reset_transport_header(struct sk_buff *skb)
|
||||
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)
|
||||
{
|
||||
return skb->h.raw - skb->data;
|
||||
|
@ -1425,7 +1425,6 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
|
||||
struct sockaddr_ax25 sax;
|
||||
struct sk_buff *skb;
|
||||
ax25_digi dtmp, *dp;
|
||||
unsigned char *asmptr;
|
||||
ax25_cb *ax25;
|
||||
size_t size;
|
||||
int lv, err, addr_len = msg->msg_namelen;
|
||||
@ -1551,10 +1550,8 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
|
||||
skb_reset_network_header(skb);
|
||||
|
||||
/* Add the PID if one is not supplied by the user in the skb */
|
||||
if (!ax25->pidincl) {
|
||||
asmptr = skb_push(skb, 1);
|
||||
*asmptr = sk->sk_protocol;
|
||||
}
|
||||
if (!ax25->pidincl)
|
||||
*skb_push(skb, 1) = sk->sk_protocol;
|
||||
|
||||
SOCK_DEBUG(sk, "AX.25: Transmitting buffer\n");
|
||||
|
||||
@ -1573,7 +1570,7 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
|
||||
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);
|
||||
|
||||
@ -1581,17 +1578,16 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
|
||||
SOCK_DEBUG(sk, "Num digipeaters=%d\n", dp->ndigi);
|
||||
|
||||
/* Build an AX.25 header */
|
||||
asmptr += (lv = ax25_addr_build(asmptr, &ax25->source_addr,
|
||||
&sax.sax25_call, dp,
|
||||
AX25_COMMAND, AX25_MODULUS));
|
||||
lv = ax25_addr_build(skb->data, &ax25->source_addr, &sax.sax25_call,
|
||||
dp, AX25_COMMAND, AX25_MODULUS);
|
||||
|
||||
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 */
|
||||
ax25_queue_xmit(skb, ax25->ax25_dev->dev);
|
||||
|
@ -233,7 +233,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||
|
||||
/* UI frame - bypass LAPB processing */
|
||||
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]);
|
||||
|
||||
|
@ -261,7 +261,8 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
|
||||
|
||||
iph->protocol = nexthdr[1];
|
||||
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;
|
||||
|
||||
|
@ -593,7 +593,7 @@ slow_path:
|
||||
skb_reserve(skb2, ll_rs);
|
||||
skb_put(skb2, len + hlen);
|
||||
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
|
||||
@ -724,7 +724,7 @@ static inline int ip_ufo_append_data(struct sock *sk,
|
||||
skb_reset_network_header(skb);
|
||||
|
||||
/* initialize protocol header pointer */
|
||||
skb->h.raw = skb->data + fragheaderlen;
|
||||
skb->h.raw = skb->nh.raw + fragheaderlen;
|
||||
|
||||
skb->ip_summed = CHECKSUM_PARTIAL;
|
||||
skb->csum = 0;
|
||||
@ -1099,8 +1099,6 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
|
||||
}
|
||||
if (len <= 0) {
|
||||
struct sk_buff *skb_prev;
|
||||
char *data;
|
||||
struct iphdr *iph;
|
||||
int alloclen;
|
||||
|
||||
skb_prev = skb;
|
||||
@ -1123,16 +1121,15 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
|
||||
/*
|
||||
* Find where to start putting bytes.
|
||||
*/
|
||||
data = skb_put(skb, fragheaderlen + fraggap);
|
||||
skb_put(skb, fragheaderlen + fraggap);
|
||||
skb_reset_network_header(skb);
|
||||
iph = ip_hdr(skb);
|
||||
data += fragheaderlen;
|
||||
skb->h.raw = data;
|
||||
skb->h.raw = skb->nh.raw + fragheaderlen;
|
||||
|
||||
if (fraggap) {
|
||||
skb->csum = skb_copy_and_csum_bits(
|
||||
skb_prev, maxfraglen,
|
||||
data, fraggap, 0);
|
||||
skb->csum = skb_copy_and_csum_bits(skb_prev,
|
||||
maxfraglen,
|
||||
skb->h.raw,
|
||||
fraggap, 0);
|
||||
skb_prev->csum = csum_sub(skb_prev->csum,
|
||||
skb->csum);
|
||||
pskb_trim_unique(skb_prev, maxfraglen);
|
||||
|
@ -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_network_header(nskb,
|
||||
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);
|
||||
memcpy(nskb->head, skb->head, header);
|
||||
|
@ -247,7 +247,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||
memcpy(tmp_base, top_iph, sizeof(tmp_base));
|
||||
|
||||
tmp_ext = NULL;
|
||||
extlen = skb->h.raw - (unsigned char *)(top_iph + 1);
|
||||
extlen = skb_transport_offset(skb) + sizeof(struct ipv6hdr);
|
||||
if (extlen) {
|
||||
extlen += sizeof(*tmp_ext);
|
||||
tmp_ext = kmalloc(extlen, GFP_ATOMIC);
|
||||
|
@ -228,8 +228,8 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
|
||||
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:
|
||||
return ret;
|
||||
}
|
||||
|
@ -785,7 +785,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
|
||||
goto ret_orig;
|
||||
}
|
||||
|
||||
clone->h.raw = clone->data + fhoff;
|
||||
skb_set_transport_header(clone, fhoff);
|
||||
hdr = ipv6_hdr(clone);
|
||||
fhdr = (struct frag_hdr *)clone->h.raw;
|
||||
|
||||
|
@ -42,7 +42,7 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||
|
||||
hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
|
||||
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);
|
||||
|
||||
skb_reset_network_header(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);
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
@ -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);
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user