aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-03-16 16:26:39 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:26:19 -0400
commitcfe1fc7759fdacb0c650b575daed1692bf3eaece (patch)
treeb8ed6fbc6c028595f5e82be1bccdeb2727e0a0b2
parentbff9b61ce330df04c6830d823c30c04203543f01 (diff)
[SK_BUFF]: Introduce skb_network_header_len
For the common sequence "skb->h.raw - skb->nh.raw", similar to skb->mac_len, that is precalculated tho, don't think we need to bloat skb with one more member, so just use this new helper, reducing the number of non-skbuff.h references to the layer headers even more. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/gianfar.c2
-rw-r--r--drivers/net/pasemi_mac.c4
-rw-r--r--include/linux/skbuff.h5
-rw-r--r--net/core/skbuff.c2
-rw-r--r--net/ipv4/ip_output.c2
-rw-r--r--net/ipv6/esp6.c3
-rw-r--r--net/ipv6/exthdrs.c8
-rw-r--r--net/ipv6/ip6_input.c2
-rw-r--r--net/ipv6/ip6_output.c4
-rw-r--r--net/ipv6/mcast.c2
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c2
-rw-r--r--net/ipv6/raw.c2
-rw-r--r--net/ipv6/reassembly.c8
-rw-r--r--net/ipv6/xfrm6_policy.c2
14 files changed, 27 insertions, 21 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index b9f44602c5e1..b666a0cc0642 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -953,7 +953,7 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)
953 * l4os is the distance between the start of the 953 * l4os is the distance between the start of the
954 * l3 hdr and the l4 hdr */ 954 * l3 hdr and the l4 hdr */
955 fcb->l3os = (u16)(skb_network_offset(skb) - GMAC_FCB_LEN); 955 fcb->l3os = (u16)(skb_network_offset(skb) - GMAC_FCB_LEN);
956 fcb->l4os = (u16)(skb->h.raw - skb->nh.raw); 956 fcb->l4os = skb_network_header_len(skb);
957 957
958 fcb->flags = flags; 958 fcb->flags = flags;
959} 959}
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 1d8129986cc5..76fe9dd8e841 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -734,12 +734,12 @@ static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
734 switch (ip_hdr(skb)->protocol) { 734 switch (ip_hdr(skb)->protocol) {
735 case IPPROTO_TCP: 735 case IPPROTO_TCP:
736 dflags |= XCT_MACTX_CSUM_TCP; 736 dflags |= XCT_MACTX_CSUM_TCP;
737 dflags |= XCT_MACTX_IPH((skb->h.raw - skb->nh.raw) >> 2); 737 dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
738 dflags |= XCT_MACTX_IPO(nh - skb->data); 738 dflags |= XCT_MACTX_IPO(nh - skb->data);
739 break; 739 break;
740 case IPPROTO_UDP: 740 case IPPROTO_UDP:
741 dflags |= XCT_MACTX_CSUM_UDP; 741 dflags |= XCT_MACTX_CSUM_UDP;
742 dflags |= XCT_MACTX_IPH((skb->h.raw - skb->nh.raw) >> 2); 742 dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
743 dflags |= XCT_MACTX_IPO(nh - skb->data); 743 dflags |= XCT_MACTX_IPO(nh - skb->data);
744 break; 744 break;
745 } 745 }
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 47c57be97d43..230dd43fc9b3 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -992,6 +992,11 @@ static inline int skb_network_offset(const struct sk_buff *skb)
992 return skb->nh.raw - skb->data; 992 return skb->nh.raw - skb->data;
993} 993}
994 994
995static inline u32 skb_network_header_len(const struct sk_buff *skb)
996{
997 return skb->h.raw - skb->nh.raw;
998}
999
995static inline unsigned char *skb_mac_header(const struct sk_buff *skb) 1000static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
996{ 1001{
997 return skb->mac.raw; 1002 return skb->mac.raw;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 87e000633f41..f38af6c01b12 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1906,7 +1906,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
1906 skb_reserve(nskb, headroom); 1906 skb_reserve(nskb, headroom);
1907 skb_reset_mac_header(nskb); 1907 skb_reset_mac_header(nskb);
1908 skb_set_network_header(nskb, skb->mac_len); 1908 skb_set_network_header(nskb, skb->mac_len);
1909 nskb->h.raw = nskb->nh.raw + (skb->h.raw - skb->nh.raw); 1909 nskb->h.raw = nskb->nh.raw + skb_network_header_len(skb);
1910 memcpy(skb_put(nskb, doffset), skb->data, doffset); 1910 memcpy(skb_put(nskb, doffset), skb->data, doffset);
1911 1911
1912 if (!sg) { 1912 if (!sg) {
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 11a6ac756f8c..02988fb262d6 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1187,7 +1187,7 @@ int ip_push_pending_frames(struct sock *sk)
1187 if (skb->data < skb_network_header(skb)) 1187 if (skb->data < skb_network_header(skb))
1188 __skb_pull(skb, skb_network_offset(skb)); 1188 __skb_pull(skb, skb_network_offset(skb));
1189 while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) { 1189 while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) {
1190 __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw); 1190 __skb_pull(tmp_skb, skb_network_header_len(skb));
1191 *tail_skb = tmp_skb; 1191 *tail_skb = tmp_skb;
1192 tail_skb = &(tmp_skb->next); 1192 tail_skb = &(tmp_skb->next);
1193 skb->len += tmp_skb->len; 1193 skb->len += tmp_skb->len;
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 436eb9e6a6cf..7fdf84dee73f 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -147,8 +147,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
147 int blksize = ALIGN(crypto_blkcipher_blocksize(tfm), 4); 147 int blksize = ALIGN(crypto_blkcipher_blocksize(tfm), 4);
148 int alen = esp->auth.icv_trunc_len; 148 int alen = esp->auth.icv_trunc_len;
149 int elen = skb->len - sizeof(struct ipv6_esp_hdr) - esp->conf.ivlen - alen; 149 int elen = skb->len - sizeof(struct ipv6_esp_hdr) - esp->conf.ivlen - alen;
150 150 int hdr_len = skb_network_header_len(skb);
151 int hdr_len = skb->h.raw - skb->nh.raw;
152 int nfrags; 151 int nfrags;
153 int ret = 0; 152 int ret = 0;
154 153
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index f763409ea740..f34cc2bd489a 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -143,7 +143,7 @@ static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff **skbp)
143 struct sk_buff *skb = *skbp; 143 struct sk_buff *skb = *skbp;
144 struct tlvtype_proc *curr; 144 struct tlvtype_proc *curr;
145 const unsigned char *nh = skb_network_header(skb); 145 const unsigned char *nh = skb_network_header(skb);
146 int off = skb->h.raw - skb->nh.raw; 146 int off = skb_network_header_len(skb);
147 int len = (skb_transport_header(skb)[1] + 1) << 3; 147 int len = (skb_transport_header(skb)[1] + 1) << 3;
148 148
149 if (skb_transport_offset(skb) + len > skb_headlen(skb)) 149 if (skb_transport_offset(skb) + len > skb_headlen(skb))
@@ -297,7 +297,7 @@ static int ipv6_destopt_rcv(struct sk_buff **skbp)
297 return -1; 297 return -1;
298 } 298 }
299 299
300 opt->lastopt = opt->dst1 = skb->h.raw - skb->nh.raw; 300 opt->lastopt = opt->dst1 = skb_network_header_len(skb);
301#ifdef CONFIG_IPV6_MIP6 301#ifdef CONFIG_IPV6_MIP6
302 dstbuf = opt->dst1; 302 dstbuf = opt->dst1;
303#endif 303#endif
@@ -443,7 +443,7 @@ looped_back:
443 break; 443 break;
444 } 444 }
445 445
446 opt->lastopt = opt->srcrt = skb->h.raw - skb->nh.raw; 446 opt->lastopt = opt->srcrt = skb_network_header_len(skb);
447 skb->h.raw += (hdr->hdrlen + 1) << 3; 447 skb->h.raw += (hdr->hdrlen + 1) << 3;
448 opt->dst0 = opt->dst1; 448 opt->dst0 = opt->dst1;
449 opt->dst1 = 0; 449 opt->dst1 = 0;
@@ -738,7 +738,7 @@ int ipv6_parse_hopopts(struct sk_buff **skbp)
738 738
739 /* 739 /*
740 * skb_network_header(skb) is equal to skb->data, and 740 * skb_network_header(skb) is equal to skb->data, and
741 * skb->h.raw - skb->nh.raw is always equal to 741 * skb_network_header_len(skb) is always equal to
742 * sizeof(struct ipv6hdr) by definition of 742 * sizeof(struct ipv6hdr) by definition of
743 * hop-by-hop options. 743 * hop-by-hop options.
744 */ 744 */
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 44275411d1a8..cf0c4406b59e 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -182,7 +182,7 @@ resubmit:
182 nf_reset(skb); 182 nf_reset(skb);
183 183
184 skb_postpull_rcsum(skb, skb_network_header(skb), 184 skb_postpull_rcsum(skb, skb_network_header(skb),
185 skb->h.raw - skb->nh.raw); 185 skb_network_header_len(skb));
186 hdr = ipv6_hdr(skb); 186 hdr = ipv6_hdr(skb);
187 if (ipv6_addr_is_multicast(&hdr->daddr) && 187 if (ipv6_addr_is_multicast(&hdr->daddr) &&
188 !ipv6_chk_mcast_addr(skb->dev, &hdr->daddr, 188 !ipv6_chk_mcast_addr(skb->dev, &hdr->daddr,
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 32e8c3f73c79..57a326080757 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1325,7 +1325,7 @@ int ip6_push_pending_frames(struct sock *sk)
1325 if (skb->data < skb_network_header(skb)) 1325 if (skb->data < skb_network_header(skb))
1326 __skb_pull(skb, skb_network_offset(skb)); 1326 __skb_pull(skb, skb_network_offset(skb));
1327 while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) { 1327 while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) {
1328 __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw); 1328 __skb_pull(tmp_skb, skb_network_header_len(skb));
1329 *tail_skb = tmp_skb; 1329 *tail_skb = tmp_skb;
1330 tail_skb = &(tmp_skb->next); 1330 tail_skb = &(tmp_skb->next);
1331 skb->len += tmp_skb->len; 1331 skb->len += tmp_skb->len;
@@ -1337,7 +1337,7 @@ int ip6_push_pending_frames(struct sock *sk)
1337 } 1337 }
1338 1338
1339 ipv6_addr_copy(final_dst, &fl->fl6_dst); 1339 ipv6_addr_copy(final_dst, &fl->fl6_dst);
1340 __skb_pull(skb, skb->h.raw - skb->nh.raw); 1340 __skb_pull(skb, skb_network_header_len(skb));
1341 if (opt && opt->opt_flen) 1341 if (opt && opt->opt_flen)
1342 ipv6_push_frag_opts(skb, opt, &proto); 1342 ipv6_push_frag_opts(skb, opt, &proto);
1343 if (opt && opt->opt_nflen) 1343 if (opt && opt->opt_nflen)
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 07e86ebb46b8..4c45bcce75e8 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1168,7 +1168,7 @@ int igmp6_event_query(struct sk_buff *skb)
1168 1168
1169 /* compute payload length excluding extension headers */ 1169 /* compute payload length excluding extension headers */
1170 len = ntohs(ipv6_hdr(skb)->payload_len) + sizeof(struct ipv6hdr); 1170 len = ntohs(ipv6_hdr(skb)->payload_len) + sizeof(struct ipv6hdr);
1171 len -= skb->h.raw - skb->nh.raw; 1171 len -= skb_network_header_len(skb);
1172 1172
1173 /* Drop queries with not link local source */ 1173 /* Drop queries with not link local source */
1174 if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) 1174 if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL))
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 84ce5b3c4b21..490e7e151f2d 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -657,7 +657,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev)
657 /* Yes, and fold redundant checksum back. 8) */ 657 /* Yes, and fold redundant checksum back. 8) */
658 if (head->ip_summed == CHECKSUM_COMPLETE) 658 if (head->ip_summed == CHECKSUM_COMPLETE)
659 head->csum = csum_partial(skb_network_header(head), 659 head->csum = csum_partial(skb_network_header(head),
660 head->h.raw - head->nh.raw, 660 skb_network_header_len(head),
661 head->csum); 661 head->csum);
662 662
663 fq->fragments = NULL; 663 fq->fragments = NULL;
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 116257d59a36..f925ca7c1a50 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -362,7 +362,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
362 362
363 if (skb->ip_summed == CHECKSUM_COMPLETE) { 363 if (skb->ip_summed == CHECKSUM_COMPLETE) {
364 skb_postpull_rcsum(skb, skb_network_header(skb), 364 skb_postpull_rcsum(skb, skb_network_header(skb),
365 skb->h.raw - skb->nh.raw); 365 skb_network_header_len(skb));
366 if (!csum_ipv6_magic(&ipv6_hdr(skb)->saddr, 366 if (!csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
367 &ipv6_hdr(skb)->daddr, 367 &ipv6_hdr(skb)->daddr,
368 skb->len, inet->num, skb->csum)) 368 skb->len, inet->num, skb->csum))
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 31d4271ea540..6dfacfa7a599 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -679,7 +679,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in,
679 /* Yes, and fold redundant checksum back. 8) */ 679 /* Yes, and fold redundant checksum back. 8) */
680 if (head->ip_summed == CHECKSUM_COMPLETE) 680 if (head->ip_summed == CHECKSUM_COMPLETE)
681 head->csum = csum_partial(skb_network_header(head), 681 head->csum = csum_partial(skb_network_header(head),
682 head->h.raw - head->nh.raw, 682 skb_network_header_len(head),
683 head->csum); 683 head->csum);
684 684
685 rcu_read_lock(); 685 rcu_read_lock();
@@ -715,13 +715,15 @@ static int ipv6_frag_rcv(struct sk_buff **skbp)
715 /* Jumbo payload inhibits frag. header */ 715 /* Jumbo payload inhibits frag. header */
716 if (hdr->payload_len==0) { 716 if (hdr->payload_len==0) {
717 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS); 717 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS);
718 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, skb->h.raw-skb->nh.raw); 718 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
719 skb_network_header_len(skb));
719 return -1; 720 return -1;
720 } 721 }
721 if (!pskb_may_pull(skb, (skb_transport_offset(skb) + 722 if (!pskb_may_pull(skb, (skb_transport_offset(skb) +
722 sizeof(struct frag_hdr)))) { 723 sizeof(struct frag_hdr)))) {
723 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS); 724 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS);
724 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, skb->h.raw-skb->nh.raw); 725 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
726 skb_network_header_len(skb));
725 return -1; 727 return -1;
726 } 728 }
727 729
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index b93bfb87f494..ef746d4f3131 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -270,7 +270,7 @@ error:
270static inline void 270static inline void
271_decode_session6(struct sk_buff *skb, struct flowi *fl) 271_decode_session6(struct sk_buff *skb, struct flowi *fl)
272{ 272{
273 u16 offset = skb->h.raw - skb->nh.raw; 273 u16 offset = skb_network_header_len(skb);
274 struct ipv6hdr *hdr = ipv6_hdr(skb); 274 struct ipv6hdr *hdr = ipv6_hdr(skb);
275 struct ipv6_opt_hdr *exthdr; 275 struct ipv6_opt_hdr *exthdr;
276 const unsigned char *nh = skb_network_header(skb); 276 const unsigned char *nh = skb_network_header(skb);