aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-04-19 23:29:13 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:26:28 -0400
commit27a884dc3cb63b93c2b3b643f5b31eed5f8a4d26 (patch)
tree5a267e40f9b94014be38dad5de0a52b6628834e0 /net/ipv6
parentbe8bd86321fa7f06359d866ef61fb4d2f3e9dce9 (diff)
[SK_BUFF]: Convert skb->tail to sk_buff_data_t
So that it is also an offset from skb->head, reduces its size from 8 to 4 bytes on 64bit architectures, allowing us to combine the 4 bytes hole left by the layer headers conversion, reducing struct sk_buff size to 256 bytes, i.e. 4 64byte cachelines, and since the sk_buff slab cache is SLAB_HWCACHE_ALIGN... :-) Many calculations that previously required that skb->{transport,network, mac}_header be first converted to a pointer now can be done directly, being meaningful as offsets or pointers. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/datagram.c2
-rw-r--r--net/ipv6/esp6.c8
-rw-r--r--net/ipv6/exthdrs.c2
-rw-r--r--net/ipv6/icmp.c3
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/mcast.c6
-rw-r--r--net/ipv6/mip6.c4
-rw-r--r--net/ipv6/ndisc.c19
-rw-r--r--net/ipv6/netfilter/ip6_queue.c4
-rw-r--r--net/ipv6/raw.c2
10 files changed, 28 insertions, 24 deletions
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index f16f4f0c5814..4a355fea4098 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -268,7 +268,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
268 serr->addr_offset = (u8 *)&iph->daddr - skb_network_header(skb); 268 serr->addr_offset = (u8 *)&iph->daddr - skb_network_header(skb);
269 serr->port = fl->fl_ip_dport; 269 serr->port = fl->fl_ip_dport;
270 270
271 __skb_pull(skb, skb->tail - skb->data); 271 __skb_pull(skb, skb_tail_pointer(skb) - skb->data);
272 skb_reset_transport_header(skb); 272 skb_reset_transport_header(skb);
273 273
274 if (sock_queue_err_skb(sk, skb)) 274 if (sock_queue_err_skb(sk, skb))
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 7fdf84dee73f..b8e8914cc002 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -51,6 +51,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
51 int clen; 51 int clen;
52 int alen; 52 int alen;
53 int nfrags; 53 int nfrags;
54 u8 *tail;
54 struct esp_data *esp = x->data; 55 struct esp_data *esp = x->data;
55 int hdr_len = (skb_transport_offset(skb) + 56 int hdr_len = (skb_transport_offset(skb) +
56 sizeof(*esph) + esp->conf.ivlen); 57 sizeof(*esph) + esp->conf.ivlen);
@@ -78,18 +79,19 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
78 } 79 }
79 80
80 /* Fill padding... */ 81 /* Fill padding... */
82 tail = skb_tail_pointer(trailer);
81 do { 83 do {
82 int i; 84 int i;
83 for (i=0; i<clen-skb->len - 2; i++) 85 for (i=0; i<clen-skb->len - 2; i++)
84 *(u8*)(trailer->tail + i) = i+1; 86 tail[i] = i + 1;
85 } while (0); 87 } while (0);
86 *(u8*)(trailer->tail + clen-skb->len - 2) = (clen - skb->len)-2; 88 tail[clen-skb->len - 2] = (clen - skb->len) - 2;
87 pskb_put(skb, trailer, clen - skb->len); 89 pskb_put(skb, trailer, clen - skb->len);
88 90
89 top_iph = (struct ipv6hdr *)__skb_push(skb, hdr_len); 91 top_iph = (struct ipv6hdr *)__skb_push(skb, hdr_len);
90 esph = (struct ipv6_esp_hdr *)skb_transport_header(skb); 92 esph = (struct ipv6_esp_hdr *)skb_transport_header(skb);
91 top_iph->payload_len = htons(skb->len + alen - sizeof(*top_iph)); 93 top_iph->payload_len = htons(skb->len + alen - sizeof(*top_iph));
92 *(u8 *)(trailer->tail - 1) = *skb_network_header(skb); 94 *(skb_tail_pointer(skb) - 1) = *skb_network_header(skb);
93 *skb_network_header(skb) = IPPROTO_ESP; 95 *skb_network_header(skb) = IPPROTO_ESP;
94 96
95 esph->spi = x->id.spi; 97 esph->spi = x->id.spi;
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index a6a275db88cd..275d2e812a44 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -51,7 +51,7 @@
51int ipv6_find_tlv(struct sk_buff *skb, int offset, int type) 51int ipv6_find_tlv(struct sk_buff *skb, int offset, int type)
52{ 52{
53 const unsigned char *nh = skb_network_header(skb); 53 const unsigned char *nh = skb_network_header(skb);
54 int packet_len = skb->tail - nh; 54 int packet_len = skb->tail - skb->network_header;
55 struct ipv6_opt_hdr *hdr; 55 struct ipv6_opt_hdr *hdr;
56 int len; 56 int len;
57 57
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index d3edc3cf1ce9..e94992ab92e6 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -317,7 +317,8 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
317 int hlimit, tclass; 317 int hlimit, tclass;
318 int err = 0; 318 int err = 0;
319 319
320 if ((u8*)hdr < skb->head || (u8*)(hdr+1) > skb->tail) 320 if ((u8 *)hdr < skb->head ||
321 (skb->network_header + sizeof(*hdr)) > skb->tail)
321 return; 322 return;
322 323
323 /* 324 /*
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index b2c092c6b9dc..e2b8db6b9aef 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -514,7 +514,7 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
514 u16 offset = sizeof(struct ipv6hdr); 514 u16 offset = sizeof(struct ipv6hdr);
515 struct ipv6_opt_hdr *exthdr = 515 struct ipv6_opt_hdr *exthdr =
516 (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1); 516 (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1);
517 unsigned int packet_len = skb->tail - skb_network_header(skb); 517 unsigned int packet_len = skb->tail - skb->network_header;
518 int found_rhdr = 0; 518 int found_rhdr = 0;
519 *nexthdr = &ipv6_hdr(skb)->nexthdr; 519 *nexthdr = &ipv6_hdr(skb)->nexthdr;
520 520
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 4c45bcce75e8..6c2758951d60 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1423,7 +1423,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size)
1423 1423
1424 memcpy(skb_put(skb, sizeof(ra)), ra, sizeof(ra)); 1424 memcpy(skb_put(skb, sizeof(ra)), ra, sizeof(ra));
1425 1425
1426 skb_set_transport_header(skb, skb->tail - skb->data); 1426 skb_set_transport_header(skb, skb_tail_pointer(skb) - skb->data);
1427 skb_put(skb, sizeof(*pmr)); 1427 skb_put(skb, sizeof(*pmr));
1428 pmr = (struct mld2_report *)skb_transport_header(skb); 1428 pmr = (struct mld2_report *)skb_transport_header(skb);
1429 pmr->type = ICMPV6_MLD2_REPORT; 1429 pmr->type = ICMPV6_MLD2_REPORT;
@@ -1468,8 +1468,8 @@ static void mld_sendpack(struct sk_buff *skb)
1468 int err; 1468 int err;
1469 1469
1470 IP6_INC_STATS(idev, IPSTATS_MIB_OUTREQUESTS); 1470 IP6_INC_STATS(idev, IPSTATS_MIB_OUTREQUESTS);
1471 payload_len = skb->tail - skb_network_header(skb) - sizeof(*pip6); 1471 payload_len = (skb->tail - skb->network_header) - sizeof(*pip6);
1472 mldlen = skb->tail - skb_transport_header(skb); 1472 mldlen = skb->tail - skb->transport_header;
1473 pip6->payload_len = htons(payload_len); 1473 pip6->payload_len = htons(payload_len);
1474 1474
1475 pmr->csum = csum_ipv6_magic(&pip6->saddr, &pip6->daddr, mldlen, 1475 pmr->csum = csum_ipv6_magic(&pip6->saddr, &pip6->daddr, mldlen,
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c
index f0288e92fb52..6ed763ee6785 100644
--- a/net/ipv6/mip6.c
+++ b/net/ipv6/mip6.c
@@ -260,7 +260,7 @@ static int mip6_destopt_offset(struct xfrm_state *x, struct sk_buff *skb,
260 struct ipv6_opt_hdr *exthdr = 260 struct ipv6_opt_hdr *exthdr =
261 (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1); 261 (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1);
262 const unsigned char *nh = skb_network_header(skb); 262 const unsigned char *nh = skb_network_header(skb);
263 unsigned int packet_len = skb->tail - nh; 263 unsigned int packet_len = skb->tail - skb->network_header;
264 int found_rhdr = 0; 264 int found_rhdr = 0;
265 265
266 *nexthdr = &ipv6_hdr(skb)->nexthdr; 266 *nexthdr = &ipv6_hdr(skb)->nexthdr;
@@ -392,7 +392,7 @@ static int mip6_rthdr_offset(struct xfrm_state *x, struct sk_buff *skb,
392 struct ipv6_opt_hdr *exthdr = 392 struct ipv6_opt_hdr *exthdr =
393 (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1); 393 (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1);
394 const unsigned char *nh = skb_network_header(skb); 394 const unsigned char *nh = skb_network_header(skb);
395 unsigned int packet_len = skb->tail - nh; 395 unsigned int packet_len = skb->tail - skb->network_header;
396 int found_rhdr = 0; 396 int found_rhdr = 0;
397 397
398 *nexthdr = &ipv6_hdr(skb)->nexthdr; 398 *nexthdr = &ipv6_hdr(skb)->nexthdr;
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index f8e619772fb4..b1cf70816477 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -492,7 +492,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
492 skb_reserve(skb, LL_RESERVED_SPACE(dev)); 492 skb_reserve(skb, LL_RESERVED_SPACE(dev));
493 ip6_nd_hdr(sk, skb, dev, src_addr, daddr, IPPROTO_ICMPV6, len); 493 ip6_nd_hdr(sk, skb, dev, src_addr, daddr, IPPROTO_ICMPV6, len);
494 494
495 skb_set_transport_header(skb, skb->tail - skb->data); 495 skb->transport_header = skb->tail;
496 skb_put(skb, len); 496 skb_put(skb, len);
497 msg = (struct nd_msg *)skb_transport_header(skb); 497 msg = (struct nd_msg *)skb_transport_header(skb);
498 498
@@ -584,7 +584,7 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
584 skb_reserve(skb, LL_RESERVED_SPACE(dev)); 584 skb_reserve(skb, LL_RESERVED_SPACE(dev));
585 ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len); 585 ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len);
586 586
587 skb_set_transport_header(skb, skb->tail - skb->data); 587 skb->transport_header = skb->tail;
588 skb_put(skb, len); 588 skb_put(skb, len);
589 msg = (struct nd_msg *)skb_transport_header(skb); 589 msg = (struct nd_msg *)skb_transport_header(skb);
590 msg->icmph.icmp6_type = NDISC_NEIGHBOUR_SOLICITATION; 590 msg->icmph.icmp6_type = NDISC_NEIGHBOUR_SOLICITATION;
@@ -685,7 +685,7 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
685 skb_reserve(skb, LL_RESERVED_SPACE(dev)); 685 skb_reserve(skb, LL_RESERVED_SPACE(dev));
686 ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len); 686 ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len);
687 687
688 skb_set_transport_header(skb, skb->tail - skb->data); 688 skb->transport_header = skb->tail;
689 skb_put(skb, len); 689 skb_put(skb, len);
690 hdr = icmp6_hdr(skb); 690 hdr = icmp6_hdr(skb);
691 hdr->icmp6_type = NDISC_ROUTER_SOLICITATION; 691 hdr->icmp6_type = NDISC_ROUTER_SOLICITATION;
@@ -767,7 +767,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
767 struct in6_addr *saddr = &ipv6_hdr(skb)->saddr; 767 struct in6_addr *saddr = &ipv6_hdr(skb)->saddr;
768 struct in6_addr *daddr = &ipv6_hdr(skb)->daddr; 768 struct in6_addr *daddr = &ipv6_hdr(skb)->daddr;
769 u8 *lladdr = NULL; 769 u8 *lladdr = NULL;
770 u32 ndoptlen = skb->tail - msg->opt; 770 u32 ndoptlen = skb->tail - (skb->transport_header +
771 offsetof(struct nd_msg, opt));
771 struct ndisc_options ndopts; 772 struct ndisc_options ndopts;
772 struct net_device *dev = skb->dev; 773 struct net_device *dev = skb->dev;
773 struct inet6_ifaddr *ifp; 774 struct inet6_ifaddr *ifp;
@@ -945,7 +946,8 @@ static void ndisc_recv_na(struct sk_buff *skb)
945 struct in6_addr *saddr = &ipv6_hdr(skb)->saddr; 946 struct in6_addr *saddr = &ipv6_hdr(skb)->saddr;
946 struct in6_addr *daddr = &ipv6_hdr(skb)->daddr; 947 struct in6_addr *daddr = &ipv6_hdr(skb)->daddr;
947 u8 *lladdr = NULL; 948 u8 *lladdr = NULL;
948 u32 ndoptlen = skb->tail - msg->opt; 949 u32 ndoptlen = skb->tail - (skb->transport_header +
950 offsetof(struct nd_msg, opt));
949 struct ndisc_options ndopts; 951 struct ndisc_options ndopts;
950 struct net_device *dev = skb->dev; 952 struct net_device *dev = skb->dev;
951 struct inet6_ifaddr *ifp; 953 struct inet6_ifaddr *ifp;
@@ -1111,8 +1113,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1111 1113
1112 __u8 * opt = (__u8 *)(ra_msg + 1); 1114 __u8 * opt = (__u8 *)(ra_msg + 1);
1113 1115
1114 optlen = (skb->tail - skb_transport_header(skb)) - 1116 optlen = (skb->tail - skb->transport_header) - sizeof(struct ra_msg);
1115 sizeof(struct ra_msg);
1116 1117
1117 if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) { 1118 if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) {
1118 ND_PRINTK2(KERN_WARNING 1119 ND_PRINTK2(KERN_WARNING
@@ -1361,7 +1362,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
1361 return; 1362 return;
1362 } 1363 }
1363 1364
1364 optlen = skb->tail - skb_transport_header(skb); 1365 optlen = skb->tail - skb->transport_header;
1365 optlen -= sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr); 1366 optlen -= sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr);
1366 1367
1367 if (optlen < 0) { 1368 if (optlen < 0) {
@@ -1522,7 +1523,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1522 ip6_nd_hdr(sk, buff, dev, &saddr_buf, &ipv6_hdr(skb)->saddr, 1523 ip6_nd_hdr(sk, buff, dev, &saddr_buf, &ipv6_hdr(skb)->saddr,
1523 IPPROTO_ICMPV6, len); 1524 IPPROTO_ICMPV6, len);
1524 1525
1525 skb_set_transport_header(buff, buff->tail - buff->data); 1526 skb_set_transport_header(buff, skb_tail_pointer(buff) - buff->data);
1526 skb_put(buff, len); 1527 skb_put(buff, len);
1527 icmph = icmp6_hdr(buff); 1528 icmph = icmp6_hdr(buff);
1528 1529
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index 66a2c4135251..5cfce218c5e1 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -189,7 +189,7 @@ ipq_flush(int verdict)
189static struct sk_buff * 189static struct sk_buff *
190ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp) 190ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
191{ 191{
192 unsigned char *old_tail; 192 sk_buff_data_t old_tail;
193 size_t size = 0; 193 size_t size = 0;
194 size_t data_len = 0; 194 size_t data_len = 0;
195 struct sk_buff *skb; 195 struct sk_buff *skb;
@@ -233,7 +233,7 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
233 if (!skb) 233 if (!skb)
234 goto nlmsg_failure; 234 goto nlmsg_failure;
235 235
236 old_tail= skb->tail; 236 old_tail = skb->tail;
237 nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh)); 237 nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh));
238 pmsg = NLMSG_DATA(nlh); 238 pmsg = NLMSG_DATA(nlh);
239 memset(pmsg, 0, sizeof(*pmsg)); 239 memset(pmsg, 0, sizeof(*pmsg));
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 8705f6a502d9..2b3be68b70a7 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -1077,7 +1077,7 @@ static int rawv6_ioctl(struct sock *sk, int cmd, unsigned long arg)
1077 spin_lock_bh(&sk->sk_receive_queue.lock); 1077 spin_lock_bh(&sk->sk_receive_queue.lock);
1078 skb = skb_peek(&sk->sk_receive_queue); 1078 skb = skb_peek(&sk->sk_receive_queue);
1079 if (skb != NULL) 1079 if (skb != NULL)
1080 amount = skb->tail - skb_transport_header(skb); 1080 amount = skb->tail - skb->transport_header;
1081 spin_unlock_bh(&sk->sk_receive_queue.lock); 1081 spin_unlock_bh(&sk->sk_receive_queue.lock);
1082 return put_user(amount, (int __user *)arg); 1082 return put_user(amount, (int __user *)arg);
1083 } 1083 }