aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-03-10 20:16:10 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:24:58 -0400
commitbbe735e4247dba32568a305553b010081c8dea99 (patch)
tree95d96619c85785a47ccee48965b68d99cf946854 /net
parente7dd65dafda5737a983c04d652a69ab8da78ee3f (diff)
[SK_BUFF]: Introduce skb_network_offset()
For the quite common 'skb->nh.raw - skb->data' sequence. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ax25/ax25_out.c4
-rw-r--r--net/core/neighbour.c6
-rw-r--r--net/ipv4/ip_output.c4
-rw-r--r--net/ipv6/icmp.c4
-rw-r--r--net/ipv6/ip6_output.c4
-rw-r--r--net/netfilter/nf_conntrack_core.c4
-rw-r--r--net/packet/af_packet.c8
-rw-r--r--net/sched/sch_teql.c2
8 files changed, 18 insertions, 18 deletions
diff --git a/net/ax25/ax25_out.c b/net/ax25/ax25_out.c
index 6e08dc8dee40..02dea851a11a 100644
--- a/net/ax25/ax25_out.c
+++ b/net/ax25/ax25_out.c
@@ -148,7 +148,7 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
148 148
149 if (ka9qfrag == 1) { 149 if (ka9qfrag == 1) {
150 skb_reserve(skbn, frontlen + 2); 150 skb_reserve(skbn, frontlen + 2);
151 skbn->nh.raw = skbn->data + (skb->nh.raw - skb->data); 151 skbn->nh.raw = skbn->data + skb_network_offset(skb);
152 memcpy(skb_put(skbn, len), skb->data, len); 152 memcpy(skb_put(skbn, len), skb->data, len);
153 p = skb_push(skbn, 2); 153 p = skb_push(skbn, 2);
154 154
@@ -161,7 +161,7 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
161 } 161 }
162 } else { 162 } else {
163 skb_reserve(skbn, frontlen + 1); 163 skb_reserve(skbn, frontlen + 1);
164 skbn->nh.raw = skbn->data + (skb->nh.raw - skb->data); 164 skbn->nh.raw = skbn->data + skb_network_offset(skb);
165 memcpy(skb_put(skbn, len), skb->data, len); 165 memcpy(skb_put(skbn, len), skb->data, len);
166 p = skb_push(skbn, 1); 166 p = skb_push(skbn, 1);
167 *p = AX25_P_TEXT; 167 *p = AX25_P_TEXT;
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 841e3f32cab1..c5653c512b43 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1125,7 +1125,7 @@ int neigh_compat_output(struct sk_buff *skb)
1125{ 1125{
1126 struct net_device *dev = skb->dev; 1126 struct net_device *dev = skb->dev;
1127 1127
1128 __skb_pull(skb, skb->nh.raw - skb->data); 1128 __skb_pull(skb, skb_network_offset(skb));
1129 1129
1130 if (dev->hard_header && 1130 if (dev->hard_header &&
1131 dev->hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL, 1131 dev->hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL,
@@ -1147,7 +1147,7 @@ int neigh_resolve_output(struct sk_buff *skb)
1147 if (!dst || !(neigh = dst->neighbour)) 1147 if (!dst || !(neigh = dst->neighbour))
1148 goto discard; 1148 goto discard;
1149 1149
1150 __skb_pull(skb, skb->nh.raw - skb->data); 1150 __skb_pull(skb, skb_network_offset(skb));
1151 1151
1152 if (!neigh_event_send(neigh, skb)) { 1152 if (!neigh_event_send(neigh, skb)) {
1153 int err; 1153 int err;
@@ -1190,7 +1190,7 @@ int neigh_connected_output(struct sk_buff *skb)
1190 struct neighbour *neigh = dst->neighbour; 1190 struct neighbour *neigh = dst->neighbour;
1191 struct net_device *dev = neigh->dev; 1191 struct net_device *dev = neigh->dev;
1192 1192
1193 __skb_pull(skb, skb->nh.raw - skb->data); 1193 __skb_pull(skb, skb_network_offset(skb));
1194 1194
1195 read_lock_bh(&neigh->lock); 1195 read_lock_bh(&neigh->lock);
1196 err = dev->hard_header(skb, dev, ntohs(skb->protocol), 1196 err = dev->hard_header(skb, dev, ntohs(skb->protocol),
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 99cd90c22310..669f5d97c6eb 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -96,7 +96,7 @@ __inline__ void ip_send_check(struct iphdr *iph)
96static int ip_dev_loopback_xmit(struct sk_buff *newskb) 96static int ip_dev_loopback_xmit(struct sk_buff *newskb)
97{ 97{
98 skb_reset_mac_header(newskb); 98 skb_reset_mac_header(newskb);
99 __skb_pull(newskb, newskb->nh.raw - newskb->data); 99 __skb_pull(newskb, skb_network_offset(newskb));
100 newskb->pkt_type = PACKET_LOOPBACK; 100 newskb->pkt_type = PACKET_LOOPBACK;
101 newskb->ip_summed = CHECKSUM_UNNECESSARY; 101 newskb->ip_summed = CHECKSUM_UNNECESSARY;
102 BUG_TRAP(newskb->dst); 102 BUG_TRAP(newskb->dst);
@@ -1199,7 +1199,7 @@ int ip_push_pending_frames(struct sock *sk)
1199 1199
1200 /* move skb->data to ip header from ext header */ 1200 /* move skb->data to ip header from ext header */
1201 if (skb->data < skb->nh.raw) 1201 if (skb->data < skb->nh.raw)
1202 __skb_pull(skb, skb->nh.raw - skb->data); 1202 __skb_pull(skb, skb_network_offset(skb));
1203 while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) { 1203 while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) {
1204 __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw); 1204 __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw);
1205 *tail_skb = tmp_skb; 1205 *tail_skb = tmp_skb;
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index a91dfbce8433..aa4a0a59ffac 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -206,7 +206,7 @@ static __inline__ int opt_unrec(struct sk_buff *skb, __u32 offset)
206{ 206{
207 u8 _optval, *op; 207 u8 _optval, *op;
208 208
209 offset += skb->nh.raw - skb->data; 209 offset += skb_network_offset(skb);
210 op = skb_header_pointer(skb, offset, sizeof(_optval), &_optval); 210 op = skb_header_pointer(skb, offset, sizeof(_optval), &_optval);
211 if (op == NULL) 211 if (op == NULL)
212 return 1; 212 return 1;
@@ -431,7 +431,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
431 tclass = 0; 431 tclass = 0;
432 432
433 msg.skb = skb; 433 msg.skb = skb;
434 msg.offset = skb->nh.raw - skb->data; 434 msg.offset = skb_network_offset(skb);
435 msg.type = type; 435 msg.type = type;
436 436
437 len = skb->len - msg.offset; 437 len = skb->len - msg.offset;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 8a7b5c760147..47d00210cba1 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -89,7 +89,7 @@ static inline int ip6_output_finish(struct sk_buff *skb)
89static int ip6_dev_loopback_xmit(struct sk_buff *newskb) 89static int ip6_dev_loopback_xmit(struct sk_buff *newskb)
90{ 90{
91 skb_reset_mac_header(newskb); 91 skb_reset_mac_header(newskb);
92 __skb_pull(newskb, newskb->nh.raw - newskb->data); 92 __skb_pull(newskb, skb_network_offset(newskb));
93 newskb->pkt_type = PACKET_LOOPBACK; 93 newskb->pkt_type = PACKET_LOOPBACK;
94 newskb->ip_summed = CHECKSUM_UNNECESSARY; 94 newskb->ip_summed = CHECKSUM_UNNECESSARY;
95 BUG_TRAP(newskb->dst); 95 BUG_TRAP(newskb->dst);
@@ -1330,7 +1330,7 @@ int ip6_push_pending_frames(struct sock *sk)
1330 1330
1331 /* move skb->data to ip header from ext header */ 1331 /* move skb->data to ip header from ext header */
1332 if (skb->data < skb->nh.raw) 1332 if (skb->data < skb->nh.raw)
1333 __skb_pull(skb, skb->nh.raw - skb->data); 1333 __skb_pull(skb, skb_network_offset(skb));
1334 while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) { 1334 while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) {
1335 __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw); 1335 __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw);
1336 *tail_skb = tmp_skb; 1336 *tail_skb = tmp_skb;
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index b3a70eb6d42a..7694c51f1251 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -768,7 +768,7 @@ resolve_normal_ct(struct sk_buff *skb,
768 struct nf_conntrack_tuple_hash *h; 768 struct nf_conntrack_tuple_hash *h;
769 struct nf_conn *ct; 769 struct nf_conn *ct;
770 770
771 if (!nf_ct_get_tuple(skb, (unsigned int)(skb->nh.raw - skb->data), 771 if (!nf_ct_get_tuple(skb, skb_network_offset(skb),
772 dataoff, l3num, protonum, &tuple, l3proto, 772 dataoff, l3num, protonum, &tuple, l3proto,
773 l4proto)) { 773 l4proto)) {
774 DEBUGP("resolve_normal_ct: Can't get tuple\n"); 774 DEBUGP("resolve_normal_ct: Can't get tuple\n");
@@ -960,7 +960,7 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
960 if (do_acct) { 960 if (do_acct) {
961 ct->counters[CTINFO2DIR(ctinfo)].packets++; 961 ct->counters[CTINFO2DIR(ctinfo)].packets++;
962 ct->counters[CTINFO2DIR(ctinfo)].bytes += 962 ct->counters[CTINFO2DIR(ctinfo)].bytes +=
963 skb->len - (unsigned int)(skb->nh.raw - skb->data); 963 skb->len - skb_network_offset(skb);
964 964
965 if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000) 965 if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000)
966 || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000)) 966 || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000))
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 1225e751b3f1..a059cc7be672 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -491,7 +491,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet
491 skb_push(skb, skb->data - skb_mac_header(skb)); 491 skb_push(skb, skb->data - skb_mac_header(skb));
492 else if (skb->pkt_type == PACKET_OUTGOING) { 492 else if (skb->pkt_type == PACKET_OUTGOING) {
493 /* Special case: outgoing packets have ll header at head */ 493 /* Special case: outgoing packets have ll header at head */
494 skb_pull(skb, skb->nh.raw - skb->data); 494 skb_pull(skb, skb_network_offset(skb));
495 } 495 }
496 } 496 }
497 497
@@ -595,7 +595,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
595 skb_push(skb, skb->data - skb_mac_header(skb)); 595 skb_push(skb, skb->data - skb_mac_header(skb));
596 else if (skb->pkt_type == PACKET_OUTGOING) { 596 else if (skb->pkt_type == PACKET_OUTGOING) {
597 /* Special case: outgoing packets have ll header at head */ 597 /* Special case: outgoing packets have ll header at head */
598 skb_pull(skb, skb->nh.raw - skb->data); 598 skb_pull(skb, skb_network_offset(skb));
599 } 599 }
600 } 600 }
601 601
@@ -613,7 +613,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
613 if (sk->sk_type == SOCK_DGRAM) { 613 if (sk->sk_type == SOCK_DGRAM) {
614 macoff = netoff = TPACKET_ALIGN(TPACKET_HDRLEN) + 16; 614 macoff = netoff = TPACKET_ALIGN(TPACKET_HDRLEN) + 16;
615 } else { 615 } else {
616 unsigned maclen = skb->nh.raw - skb->data; 616 unsigned maclen = skb_network_offset(skb);
617 netoff = TPACKET_ALIGN(TPACKET_HDRLEN + (maclen < 16 ? 16 : maclen)); 617 netoff = TPACKET_ALIGN(TPACKET_HDRLEN + (maclen < 16 ? 16 : maclen));
618 macoff = netoff - maclen; 618 macoff = netoff - maclen;
619 } 619 }
@@ -1145,7 +1145,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
1145 aux.tp_len = PACKET_SKB_CB(skb)->origlen; 1145 aux.tp_len = PACKET_SKB_CB(skb)->origlen;
1146 aux.tp_snaplen = skb->len; 1146 aux.tp_snaplen = skb->len;
1147 aux.tp_mac = 0; 1147 aux.tp_mac = 0;
1148 aux.tp_net = skb->nh.raw - skb->data; 1148 aux.tp_net = skb_network_offset(skb);
1149 1149
1150 put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux); 1150 put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
1151 } 1151 }
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index 587123c61af9..d24914db7861 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -323,7 +323,7 @@ restart:
323 nores = 1; 323 nores = 1;
324 break; 324 break;
325 } 325 }
326 __skb_pull(skb, skb->nh.raw - skb->data); 326 __skb_pull(skb, skb_network_offset(skb));
327 } while ((q = NEXT_SLAVE(q)) != start); 327 } while ((q = NEXT_SLAVE(q)) != start);
328 328
329 if (nores && skb_res == NULL) { 329 if (nores && skb_res == NULL) {