[SK_BUFF]: Introduce skb_reset_transport_header(skb)
For the common, open coded 'skb->h.raw = skb->data' operation, so that we can
later turn skb->h.raw into a offset, reducing the size of struct sk_buff in
64bit land while possibly keeping it as a pointer on 32bit.
This one touches just the most simple cases:
skb->h.raw = skb->data;
skb->h.raw = {skb_push|[__]skb_pull}()
The next ones will handle the slightly more "complex" cases.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index e7720c7..f011390 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1120,7 +1120,8 @@
if (unlikely(!pskb_may_pull(skb, ihl)))
goto out;
- skb->h.raw = __skb_pull(skb, ihl);
+ __skb_pull(skb, ihl);
+ skb_reset_transport_header(skb);
iph = ip_hdr(skb);
proto = iph->protocol & (MAX_INET_PROTOS - 1);
err = -EPROTONOSUPPORT;
@@ -1163,7 +1164,8 @@
if (unlikely(!pskb_may_pull(skb, ihl)))
goto out;
- skb->h.raw = __skb_pull(skb, ihl);
+ __skb_pull(skb, ihl);
+ skb_reset_transport_header(skb);
iph = ip_hdr(skb);
id = ntohs(iph->id);
proto = iph->protocol & (MAX_INET_PROTOS - 1);
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 00fd31d..ebcc797 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -182,7 +182,8 @@
}
((struct iphdr*)work_buf)->protocol = ah->nexthdr;
skb->nh.raw += ah_hlen;
- skb->h.raw = memcpy(skb_network_header(skb), work_buf, ihl);
+ memcpy(skb_network_header(skb), work_buf, ihl);
+ skb->h.raw = skb->nh.raw;
__skb_pull(skb, ah_hlen + ihl);
return 0;
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 237880a..324e7e0 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -201,7 +201,7 @@
__skb_pull(skb, ip_hdrlen(skb));
/* Point into the IP datagram, just past the header. */
- skb->h.raw = skb->data;
+ skb_reset_transport_header(skb);
rcu_read_lock();
{
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 1abc488..63c05be 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -500,7 +500,7 @@
* before previous one went down. */
if (frag) {
frag->ip_summed = CHECKSUM_NONE;
- frag->h.raw = frag->data;
+ skb_reset_transport_header(frag);
__skb_push(frag, hlen);
skb_reset_network_header(frag);
memcpy(skb_network_header(frag), iph, hlen);
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index e002149..03869d9 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -563,7 +563,7 @@
*/
skb_push(skb, sizeof(struct iphdr));
skb_reset_network_header(skb);
- skb->h.raw = skb->data;
+ skb_reset_transport_header(skb);
msg = (struct igmpmsg *)skb_network_header(skb);
memcpy(msg, skb_network_header(pkt), sizeof(struct iphdr));
msg->im_msgtype = IGMPMSG_WHOLEPKT;
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index b4cad50..13739cd 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1002,7 +1002,8 @@
* transport header to point to ESP. Keep UDP on the stack
* for later.
*/
- skb->h.raw = __skb_pull(skb, len);
+ __skb_pull(skb, len);
+ skb_reset_transport_header(skb);
/* modify the protocol (it's ESP!) */
iph->protocol = IPPROTO_ESP;
diff --git a/net/ipv4/xfrm4_mode_transport.c b/net/ipv4/xfrm4_mode_transport.c
index 124f24b..2c46cbb 100644
--- a/net/ipv4/xfrm4_mode_transport.c
+++ b/net/ipv4/xfrm4_mode_transport.c
@@ -52,7 +52,7 @@
skb->nh.raw = skb->h.raw;
}
ip_hdr(skb)->tot_len = htons(skb->len + ihl);
- skb->h.raw = skb->data;
+ skb_reset_transport_header(skb);
return 0;
}