Skip to contentSkip to conversation

PATCH 1/1: [SKBUFF] move common code to hdlc_type_trans

PATCH Arnaldo Carvalho de Melo 2 participants 3 messages Oct 8, 2004

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

Hi David,

Please consider pulling from:

bk://kernel.bkbits.net/acme/sk_buff-2.6

It should be equivalent to the code it was before, the only
thing that seems fishy is the drivers/net/wan/dssc4.c, where the skb->mac.raw is being set after the call to hdlc_type_trans, where, in some codepaths there are calls to skb_pull and all the other hdlc layer drivers set the mac.raw _before_ the skb_pull, like eth_type_trans (that may well be called thru the hdlc layer type_trans pointer).

Francois, is this really what is intended? I left it as
is for now...

- Arnaldo

===================================================================

[email protected], 2004-10-07 22:35:15-03:00, [email protected]
[SKBUFF] move common code to hdlc_type_trans

 drivers/char/pcmcia/synclink_cs.c |    4 ---
 drivers/char/synclink.c           |    4 ---
 drivers/char/synclinkmp.c         |    4 ---
 drivers/net/wan/dscc4.c           |    1 
 drivers/net/wan/farsync.c         |   42 ++++++++++++++++++--------------------
 drivers/net/wan/hd6457x.c         |    2 -
 drivers/net/wan/pc300_drv.c       |    1 
 drivers/net/wan/wanxl.c           |    2 -
 include/linux/hdlc.h              |    8 +++++--
 9 files changed, 29 insertions(+), 39 deletions(-)
drivers/char/pcmcia/synclink_cs.c +1 -3
diff -Nru a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
@@ -4570,9 +4570,7 @@
 
 	memcpy(skb_put(skb, size),buf,size);
 
-	skb->dev      = info->netdev;
-	skb->mac.raw  = skb->data;
-	skb->protocol = hdlc_type_trans(skb, skb->dev);
+	skb->protocol = hdlc_type_trans(skb, info->netdev);
 
 	stats->rx_packets++;
 	stats->rx_bytes += size;
drivers/char/synclink.c +1 -3
diff -Nru a/drivers/char/synclink.c b/drivers/char/synclink.c
@@ -8150,9 +8150,7 @@
 
 	memcpy(skb_put(skb, size),buf,size);
 
-	skb->dev      = info->netdev;
-	skb->mac.raw  = skb->data;
-	skb->protocol = hdlc_type_trans(skb, skb->dev);
+	skb->protocol = hdlc_type_trans(skb, info->netdev);
 
 	stats->rx_packets++;
 	stats->rx_bytes += size;
drivers/char/synclinkmp.c +1 -3
diff -Nru a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
@@ -1968,9 +1968,7 @@
 
 	memcpy(skb_put(skb, size),buf,size);
 
-	skb->dev      = info->netdev;
-	skb->mac.raw  = skb->data;
-	skb->protocol = hdlc_type_trans(skb, skb->dev);
+	skb->protocol = hdlc_type_trans(skb, info->netdev);
 
 	stats->rx_packets++;
 	stats->rx_bytes += size;
drivers/net/wan/dscc4.c +0 -1
diff -Nru a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
@@ -517,7 +517,6 @@
 	skb = dev_alloc_skb(len);
 	dpriv->rx_skbuff[dirty] = skb;
 	if (skb) {
-		skb->dev = dev;
 		skb->protocol = hdlc_type_trans(skb, dev);
 		skb->mac.raw = skb->data;
 		rx_fd->data = pci_map_single(dpriv->pci_priv->pdev, skb->data,
drivers/net/wan/farsync.c +20 -22

60 lines not on this page · raw message

drivers/net/wan/hd6457x.c +0 -2
diff -Nru a/drivers/net/wan/hd6457x.c b/drivers/net/wan/hd6457x.c
@@ -315,8 +315,6 @@
 #endif
 	stats->rx_packets++;
 	stats->rx_bytes += skb->len;
-	skb->mac.raw = skb->data;
-	skb->dev = dev;
 	skb->dev->last_rx = jiffies;
 	skb->protocol = hdlc_type_trans(skb, dev);
 	netif_rx(skb);
drivers/net/wan/pc300_drv.c +0 -1
diff -Nru a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
@@ -1959,7 +1959,6 @@
 			cpc_trace(dev, skb, 'R');
 		}
 		stats->rx_packets++;
-		skb->mac.raw = skb->data;
 		skb->protocol = hdlc_type_trans(skb, dev);
 		netif_rx(skb);
 	}
drivers/net/wan/wanxl.c +0 -2
diff -Nru a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
@@ -224,8 +224,6 @@
 #endif
 				stats->rx_packets++;
 				stats->rx_bytes += skb->len;
-				skb->mac.raw = skb->data;
-				skb->dev = dev;
 				dev->last_rx = jiffies;
 				skb->protocol = hdlc_type_trans(skb, dev);
 				netif_rx(skb);
include/linux/hdlc.h +6 -2
diff -Nru a/include/linux/hdlc.h b/include/linux/hdlc.h
@@ -243,11 +243,15 @@
 static __inline__ unsigned short hdlc_type_trans(struct sk_buff *skb,
 						 struct net_device *dev)
 {
-	hdlc_device *hdlc = dev_to_hdlc(skb->dev);
+	hdlc_device *hdlc = dev_to_hdlc(dev);
+
+	skb->mac.raw  = skb->data;
+	skb->dev      = dev;
+
 	if (hdlc->proto.type_trans)
 		return hdlc->proto.type_trans(skb, dev);
 	else
-		return __constant_htons(ETH_P_HDLC);
+		return htons(ETH_P_HDLC);
 }
 
 #endif /* __KERNEL */
#1 lore raw

Arnaldo Carvalho de Melo <[email protected]> :
[dscc4.c sets skb->mac.raw after hdlc_type_trans]

Quoted 1 line

Francois, is this really what is intended? I left it as

In the pre-eth_type_trans area, yes :o/ I did not test dscc4 in a bridged setup. Please fix the driver in your patch.

--
Ueimor

#2 lore raw
Quoted 8 lines · Francois Romieu

Arnaldo Carvalho de Melo <[email protected]> :
[dscc4.c sets skb->mac.raw after hdlc_type_trans]

Quoted 1 line

Francois, is this really what is intended? I left it as

In the pre-eth_type_trans area, yes :o/ I did not test dscc4 in a bridged setup. Please fix the driver in your patch.

OK, I'll do that later today, i.e. just remove
the skb->mac.raw = skb->data after the call to hdlc_type_trans as it already, like eth_type_trans, sets skb->mac.raw to skb->data prior to calling any hdlc layer type_trans pointer.

For those paying attention to this lowly stuff, what do you think of renaming all those foo_type_trans to foo_setup_rx_skb (suggestions for a better name than foo_type_trans are welcome) and make it set skb->protocol, making it return just void? I think it makes the whole thing clearer...

- Arnaldo