[SK_BUFF]: Introduce skb_network_header_len
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 16 Mar 2007 20:26:39 +0000 (17:26 -0300)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 26 Apr 2007 05:26:19 +0000 (22:26 -0700)
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>
14 files changed:
drivers/net/gianfar.c
drivers/net/pasemi_mac.c
include/linux/skbuff.h
net/core/skbuff.c
net/ipv4/ip_output.c
net/ipv6/esp6.c
net/ipv6/exthdrs.c
net/ipv6/ip6_input.c
net/ipv6/ip6_output.c
net/ipv6/mcast.c
net/ipv6/netfilter/nf_conntrack_reasm.c
net/ipv6/raw.c
net/ipv6/reassembly.c
net/ipv6/xfrm6_policy.c

index b9f44602c5e14e640211425a1b2232a550504d58..b666a0cc064252691fa80877083e370428cf155d 100644 (file)
@@ -953,7 +953,7 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)
         * l4os is the distance between the start of the
         * l3 hdr and the l4 hdr */
        fcb->l3os = (u16)(skb_network_offset(skb) - GMAC_FCB_LEN);
-       fcb->l4os = (u16)(skb->h.raw - skb->nh.raw);
+       fcb->l4os = skb_network_header_len(skb);
 
        fcb->flags = flags;
 }
index 1d8129986cc5722936539c805ccbc3d79740f355..76fe9dd8e841581cd70dcbd09746bd7a84705ea0 100644 (file)
@@ -734,12 +734,12 @@ static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
                switch (ip_hdr(skb)->protocol) {
                case IPPROTO_TCP:
                        dflags |= XCT_MACTX_CSUM_TCP;
-                       dflags |= XCT_MACTX_IPH((skb->h.raw - skb->nh.raw) >> 2);
+                       dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
                        dflags |= XCT_MACTX_IPO(nh - skb->data);
                        break;
                case IPPROTO_UDP:
                        dflags |= XCT_MACTX_CSUM_UDP;
-                       dflags |= XCT_MACTX_IPH((skb->h.raw - skb->nh.raw) >> 2);
+                       dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
                        dflags |= XCT_MACTX_IPO(nh - skb->data);
                        break;
                }
index 47c57be97d435493a16825c490d71ecc64c4951a..230dd43fc9b32ef8614d9e441c8af72cc2cc3b40 100644 (file)
@@ -992,6 +992,11 @@ static inline int skb_network_offset(const struct sk_buff *skb)
        return skb->nh.raw - skb->data;
 }
 
+static inline u32 skb_network_header_len(const struct sk_buff *skb)
+{
+       return skb->h.raw - skb->nh.raw;
+}
+
 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
 {
        return skb->mac.raw;
index 87e000633f413e47703fbf4513d87b851d403d6d..f38af6c01b123028527d2b3368807b0e3e1729c4 100644 (file)
@@ -1906,7 +1906,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
                skb_reserve(nskb, headroom);
                skb_reset_mac_header(nskb);
                skb_set_network_header(nskb, skb->mac_len);
-               nskb->h.raw = nskb->nh.raw + (skb->h.raw - skb->nh.raw);
+               nskb->h.raw = nskb->nh.raw + skb_network_header_len(skb);
                memcpy(skb_put(nskb, doffset), skb->data, doffset);
 
                if (!sg) {
index 11a6ac756f8cb227dd4ac449ddfd45c2dc9a124f..02988fb262d624c15b6e18ea6d225a7ec7083d54 100644 (file)
@@ -1187,7 +1187,7 @@ int ip_push_pending_frames(struct sock *sk)
        if (skb->data < skb_network_header(skb))
                __skb_pull(skb, skb_network_offset(skb));
        while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) {
-               __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw);
+               __skb_pull(tmp_skb, skb_network_header_len(skb));
                *tail_skb = tmp_skb;
                tail_skb = &(tmp_skb->next);
                skb->len += tmp_skb->len;
index 436eb9e6a6cf66fcd86284a615c9417facdd7d7f..7fdf84dee73f3ab080e66333c7a3b48d8c852ec0 100644 (file)
@@ -147,8 +147,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
        int blksize = ALIGN(crypto_blkcipher_blocksize(tfm), 4);
        int alen = esp->auth.icv_trunc_len;
        int elen = skb->len - sizeof(struct ipv6_esp_hdr) - esp->conf.ivlen - alen;
-
-       int hdr_len = skb->h.raw - skb->nh.raw;
+       int hdr_len = skb_network_header_len(skb);
        int nfrags;
        int ret = 0;
 
index f763409ea740860ec4d4847273423d3e695ed311..f34cc2bd489abbaf19190dc2e666d374b1a8bd96 100644 (file)
@@ -143,7 +143,7 @@ static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff **skbp)
        struct sk_buff *skb = *skbp;
        struct tlvtype_proc *curr;
        const unsigned char *nh = skb_network_header(skb);
-       int off = skb->h.raw - skb->nh.raw;
+       int off = skb_network_header_len(skb);
        int len = (skb_transport_header(skb)[1] + 1) << 3;
 
        if (skb_transport_offset(skb) + len > skb_headlen(skb))
@@ -297,7 +297,7 @@ static int ipv6_destopt_rcv(struct sk_buff **skbp)
                return -1;
        }
 
-       opt->lastopt = opt->dst1 = skb->h.raw - skb->nh.raw;
+       opt->lastopt = opt->dst1 = skb_network_header_len(skb);
 #ifdef CONFIG_IPV6_MIP6
        dstbuf = opt->dst1;
 #endif
@@ -443,7 +443,7 @@ looped_back:
                        break;
                }
 
-               opt->lastopt = opt->srcrt = skb->h.raw - skb->nh.raw;
+               opt->lastopt = opt->srcrt = skb_network_header_len(skb);
                skb->h.raw += (hdr->hdrlen + 1) << 3;
                opt->dst0 = opt->dst1;
                opt->dst1 = 0;
@@ -738,7 +738,7 @@ int ipv6_parse_hopopts(struct sk_buff **skbp)
 
        /*
         * skb_network_header(skb) is equal to skb->data, and
-        * skb->h.raw - skb->nh.raw is always equal to
+        * skb_network_header_len(skb) is always equal to
         * sizeof(struct ipv6hdr) by definition of
         * hop-by-hop options.
         */
index 44275411d1a829fccbc93c625b05df5bec58f211..cf0c4406b59ea3163ae0d116f0fed3571ba1d112 100644 (file)
@@ -182,7 +182,7 @@ resubmit:
                        nf_reset(skb);
 
                        skb_postpull_rcsum(skb, skb_network_header(skb),
-                                          skb->h.raw - skb->nh.raw);
+                                          skb_network_header_len(skb));
                        hdr = ipv6_hdr(skb);
                        if (ipv6_addr_is_multicast(&hdr->daddr) &&
                            !ipv6_chk_mcast_addr(skb->dev, &hdr->daddr,
index 32e8c3f73c797b96a651924ae9025295cc346d12..57a326080757dd4af4bcba3bdf1d8c5551d58353 100644 (file)
@@ -1325,7 +1325,7 @@ int ip6_push_pending_frames(struct sock *sk)
        if (skb->data < skb_network_header(skb))
                __skb_pull(skb, skb_network_offset(skb));
        while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) {
-               __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw);
+               __skb_pull(tmp_skb, skb_network_header_len(skb));
                *tail_skb = tmp_skb;
                tail_skb = &(tmp_skb->next);
                skb->len += tmp_skb->len;
@@ -1337,7 +1337,7 @@ int ip6_push_pending_frames(struct sock *sk)
        }
 
        ipv6_addr_copy(final_dst, &fl->fl6_dst);
-       __skb_pull(skb, skb->h.raw - skb->nh.raw);
+       __skb_pull(skb, skb_network_header_len(skb));
        if (opt && opt->opt_flen)
                ipv6_push_frag_opts(skb, opt, &proto);
        if (opt && opt->opt_nflen)
index 07e86ebb46b85a42622a89f9d58d383249535618..4c45bcce75e895bfc764b5148abea46b207dc818 100644 (file)
@@ -1168,7 +1168,7 @@ int igmp6_event_query(struct sk_buff *skb)
 
        /* compute payload length excluding extension headers */
        len = ntohs(ipv6_hdr(skb)->payload_len) + sizeof(struct ipv6hdr);
-       len -= skb->h.raw - skb->nh.raw;
+       len -= skb_network_header_len(skb);
 
        /* Drop queries with not link local source */
        if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL))
index 84ce5b3c4b21f2931d038698d16870abc8520186..490e7e151f2d450eef8b993955946e4ec9a12e0a 100644 (file)
@@ -657,7 +657,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev)
        /* Yes, and fold redundant checksum back. 8) */
        if (head->ip_summed == CHECKSUM_COMPLETE)
                head->csum = csum_partial(skb_network_header(head),
-                                         head->h.raw - head->nh.raw,
+                                         skb_network_header_len(head),
                                          head->csum);
 
        fq->fragments = NULL;
index 116257d59a36ef379426c87d153c143faa7ca4c1..f925ca7c1a507809f1907602d06718bc544c6557 100644 (file)
@@ -362,7 +362,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
 
        if (skb->ip_summed == CHECKSUM_COMPLETE) {
                skb_postpull_rcsum(skb, skb_network_header(skb),
-                                  skb->h.raw - skb->nh.raw);
+                                  skb_network_header_len(skb));
                if (!csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
                                     &ipv6_hdr(skb)->daddr,
                                     skb->len, inet->num, skb->csum))
index 31d4271ea54051ff99da27517fa00e2ed78099a6..6dfacfa7a599925b61df3392206ea172116ae0d6 100644 (file)
@@ -679,7 +679,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in,
        /* Yes, and fold redundant checksum back. 8) */
        if (head->ip_summed == CHECKSUM_COMPLETE)
                head->csum = csum_partial(skb_network_header(head),
-                                         head->h.raw - head->nh.raw,
+                                         skb_network_header_len(head),
                                          head->csum);
 
        rcu_read_lock();
@@ -715,13 +715,15 @@ static int ipv6_frag_rcv(struct sk_buff **skbp)
        /* Jumbo payload inhibits frag. header */
        if (hdr->payload_len==0) {
                IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS);
-               icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, skb->h.raw-skb->nh.raw);
+               icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
+                                 skb_network_header_len(skb));
                return -1;
        }
        if (!pskb_may_pull(skb, (skb_transport_offset(skb) +
                                 sizeof(struct frag_hdr)))) {
                IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS);
-               icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, skb->h.raw-skb->nh.raw);
+               icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
+                                 skb_network_header_len(skb));
                return -1;
        }
 
index b93bfb87f494956b5744bbd43eaeb233101087c0..ef746d4f313149ab042d998ab7f328fe38d139ba 100644 (file)
@@ -270,7 +270,7 @@ error:
 static inline void
 _decode_session6(struct sk_buff *skb, struct flowi *fl)
 {
-       u16 offset = skb->h.raw - skb->nh.raw;
+       u16 offset = skb_network_header_len(skb);
        struct ipv6hdr *hdr = ipv6_hdr(skb);
        struct ipv6_opt_hdr *exthdr;
        const unsigned char *nh = skb_network_header(skb);