aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet/af_packet.c
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/packet/af_packet.c
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/packet/af_packet.c')
-rw-r--r--net/packet/af_packet.c8
1 files changed, 4 insertions, 4 deletions
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 }