PATCH: [SKBUFF] introduce skb_link_header_size(skb)
Subsystems (4)
Hi David,
Please consider pulling from:
bk://kernel.bkbits.net/acme/sk_buff-2.6
Now there ate 13 outstanding changesets in this tree.
Regards,
- Arnaldo
===================================================================
[email protected], 2004-10-05 16:11:14-03:00, [email protected]
[SKBUFF] introduce skb_link_header_size(skb)
drivers/net/arcnet/arcnet.c | 8 ++++---- include/linux/skbuff.h | 5 +++++ net/core/dev.c | 2 +- net/ipv4/ip_gre.c | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-)
drivers/net/arcnet/arcnet.c +4 -4
@@ -478,9 +478,9 @@*/ if (!daddr) { *(uint16_t *)skb_push (skb,2 ) = type; -if (skb->nh.raw - skb->mac.raw !=2 ) +if (skb_link_header_size (skb) !=2 )BUGMSG (D_NORMAL ,"arcnet_header: Yikes! diff (%d) is not 2!\n" , - (int )(skb->nh.raw - skb->mac.raw)); +skb_link_header_size (skb));return -2 ;/* return error -- can't transmit yet! */ }/* otherwise, we can just add the header as usual. */
@@ -512,10 +512,10 @@uint8_t daddr=0 ;struct ArcProto *proto; -if (skb->nh.raw - skb->mac.raw !=2 ) { +if (skb_link_header_size (skb) !=2 ) {BUGMSG (D_NORMAL ,"rebuild_header: shouldn't be here! (hdrsize=%d)\n" , - (int )(skb->nh.raw - skb->mac.raw)); +skb_link_header_size (skb));return 0 ; } type = *(uint16_t *)skb_pull (skb,2 );
include/linux/skbuff.h +5 -0
@@ -302,6 +302,11 @@ (skb->mac.raw + hdrlen) <= skb->data; } +static inline int skb_link_header_size (const struct sk_buff *skb) +{ +return skb->nh.raw - skb->mac.raw; +} +extern void __kfree_skb (struct sk_buff *skb);extern struct sk_buff *alloc_skb (unsigned int size,int priority);extern void kfree_skbmem (struct sk_buff *skb);
net/core/dev.c +1 -1
@@ -1735,7 +1735,7 @@__get_cpu_var (netdev_rx_stat).total++; skb->h.raw = skb->nh.raw = skb->data; - skb->mac_len = skb->nh.raw - skb->mac.raw; + skb->mac_len =skb_link_header_size (skb); pt_prev =NULL ;
net/ipv4/ip_gre.c +2 -1
@@ -621,7 +621,8 @@memset (&(IPCB (skb)->opt),0 ,sizeof (struct ip_options ));if (skb->ip_summed ==CHECKSUM_HW ) skb->csum =csum_sub (skb->csum, -csum_partial (skb->mac.raw, skb->nh.raw-skb->mac.raw,0 )); +csum_partial (skb->mac.raw, +skb_link_header_size (skb),0 )); skb->pkt_type =PACKET_HOST ;#ifdef CONFIG_NET_IPGRE_BROADCAST if (MULTICAST (iph->daddr)) {
* Arnaldo Carvalho de Melo <[email protected]> 2004-10-05 16:14
include/linux/skbuff.h line 308
Quoted 4 lines
include/linux/skbuff.h +4
-0+static inline int skb_link_header_size (const struct sk_buff *skb) +{ +return skb->nh.raw - skb->mac.raw; +}
The patch is valid and I think it is right to do so but this may lead to wrong results when skb->mac.raw is set to 0x0 F.e in classifiers. Maybe add a comment to warn about it?
Quoted 11 lines · Thomas Graf
* Arnaldo Carvalho de Melo <[email protected]> 2004-10-05 16:14
include/linux/skbuff.h line 308
Quoted 4 lines
include/linux/skbuff.h +4
-0+static inline int skb_link_header_size (const struct sk_buff *skb) +{ +return skb->nh.raw - skb->mac.raw; +}The patch is valid and I think it is right to do so but this may lead to wrong results when
skb->mac.rawis set to0x0F.e in classifiers. Maybe add a comment to warn about it?
I never looked at classifiers code, suggest a comment and I'll stick it there.
Thanks for commenting on the patch.
Regards,
- Arnaldo