Skip to contentSkip to conversation

introduce tr_hdr(skb)

PATCH In review Arnaldo Carvalho de Melo 3 participants 5 messages Oct 6, 2004

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

PATCH 2/2 introduce tr_hdr(skb)

Hi David,

Please consider pulling from:

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

Regards,

- Arnaldo

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

[email protected], 2004-10-06 15:33:22-03:00, [email protected]
[SKBUFF] introduce tr_hdr(skb)

The token ring code in the kernel is bitrotting (no surprise :) ), it uses skb->data all around... I have an assortment of token ring cards but no MAU, can anybody send me one, please? I promise to make ssh work over LLC over Token Ring networks! Duh... :o)

 include/linux/if_tr.h |    9 +++++++++
 include/net/llc_pdu.h |    4 ++--
 net/llc/llc_output.c  |    4 ++--
 3 files changed, 13 insertions(+), 4 deletions(-)
include/linux/if_tr.h +9 -0
diff -Nru a/include/linux/if_tr.h b/include/linux/if_tr.h
@@ -48,6 +48,15 @@
 	__u16 rseg[8];			/* routing registers */
 };
 
+#ifdef __KERNEL__
+#include <linux/skbuff.h>
+
+static inline struct trh_hdr *tr_hdr(const struct sk_buff *skb)
+{
+	return (struct trh_hdr *)skb->mac.raw;
+}
+#endif
+
 /* This is an Token-Ring LLC structure */
 struct trllc {
 	__u8  dsap;			/* destination SAP */
include/net/llc_pdu.h +2 -2
diff -Nru a/include/net/llc_pdu.h b/include/net/llc_pdu.h
@@ -255,7 +255,7 @@
 	if (skb->protocol == ntohs(ETH_P_802_2))
 		memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN);
 	else if (skb->protocol == ntohs(ETH_P_TR_802_2))
-		memcpy(sa, ((struct trh_hdr *)skb->mac.raw)->saddr, ETH_ALEN);
+		memcpy(sa, tr_hdr(skb)->saddr, ETH_ALEN);
 }
 
 /**
@@ -270,7 +270,7 @@
 	if (skb->protocol == ntohs(ETH_P_802_2))
 		memcpy(da, eth_hdr(skb)->h_dest, ETH_ALEN);
 	else if (skb->protocol == ntohs(ETH_P_TR_802_2))
-		memcpy(da, ((struct trh_hdr *)skb->mac.raw)->daddr, ETH_ALEN);
+		memcpy(da, tr_hdr(skb)->daddr, ETH_ALEN);
 }
 
 /**
net/llc/llc_output.c +2 -2
diff -Nru a/net/llc/llc_output.c b/net/llc/llc_output.c
@@ -40,7 +40,8 @@
 		struct net_device *dev = skb->dev;
 		struct trh_hdr *trh;
 		
-		trh = (struct trh_hdr *)skb_push(skb, sizeof(*trh));
+		skb->mac.raw = skb_push(skb, sizeof(*trh));
+		trh = tr_hdr(skb);
 		trh->ac = AC;
 		trh->fc = LLC_FRAME;
 		if (sa)
@@ -51,7 +52,6 @@
 			memcpy(trh->daddr, da, dev->addr_len);
 			tr_source_route(skb, trh, dev);
 		}
-		skb->mac.raw = skb->data;
 		break;
 	}
 #endif
#1 lore raw

* Arnaldo Carvalho de Melo <[email protected]> 2004-10-06 15:41

net/llc/llc_output.c line 54

Quoted 11 lines
net/llc/llc_output.c +2 -2
-		trh = (struct trh_hdr *)skb_push(skb, sizeof(*trh));
+		skb->mac.raw = skb_push(skb, sizeof(*trh));
+		trh = tr_hdr(skb);
 		trh->ac = AC;
 		trh->fc = LLC_FRAME;
 		if (sa)
@@ -51,7 +52,6 @@
 			memcpy(trh->daddr, da, dev->addr_len);
 			tr_source_route(skb, trh, dev);
 		}
-		skb->mac.raw = skb->data;

Are you sure the bevhaviour is the same? There is an skb_pull in tr_source_route so skb->data gets modified.

#2 lore raw
Quoted 19 lines · Thomas Graf

* Arnaldo Carvalho de Melo <[email protected]> 2004-10-06 15:41

net/llc/llc_output.c line 54

Quoted 11 lines
net/llc/llc_output.c +2 -1
-		trh = (struct trh_hdr *)skb_push(skb, sizeof(*trh));
+		skb->mac.raw = skb_push(skb, sizeof(*trh));
+		trh = tr_hdr(skb);
		trh->ac = AC;
		trh->fc = LLC_FRAME;
		if (sa)
net/llc/llc_output.c +0 -1
@@ -51,7 +52,6 @@
 			memcpy(trh->daddr, da, dev->addr_len);
 			tr_source_route(skb, trh, dev);
 		}
-		skb->mac.raw = skb->data;

Are you sure the bevhaviour is the same? There is an skb_pull in tr_source_route so skb->data gets modified.

Thanks for reviewing, checking...

#3 lore raw
Quoted 25 lines · Arnaldo Carvalho de Melo
Quoted 19 lines · Thomas Graf

* Arnaldo Carvalho de Melo <[email protected]> 2004-10-06 15:41

net/llc/llc_output.c line 54

Quoted 11 lines
net/llc/llc_output.c +2 -2
-        trh = (struct trh_hdr *)skb_push(skb, sizeof(*trh));
+        skb->mac.raw = skb_push(skb, sizeof(*trh));
+        trh = tr_hdr(skb);
        trh->ac = AC;
        trh->fc = LLC_FRAME;
        if (sa)
@@ -51,7 +52,6 @@
            memcpy(trh->daddr, da, dev->addr_len);
            tr_source_route(skb, trh, dev);
        }
-        skb->mac.raw = skb->data;

Are you sure the bevhaviour is the same? There is an skb_pull in tr_source_route so skb->data gets modified.

Quoted 3 lines

Thanks for reviewing, checking...

You're right, if tr_source_route is called, skb->mac.raw has to be set to skb->data, to maintain the old behaviour, if it is right? Oh well, as I said there aren't many people using Token Ring, let alone LLC over token ring, I'll be posting a patch in some minutes.

- Arnaldo

maintainer
#4 lore raw
Quoted 2 lines · On Wed, 06 Oct 2004 16:18:49 -0300 Arnaldo Carvalho de Melo…

You're right, if tr_source_route is called, skb->mac.raw has to be set to skb->data, to maintain the old behaviour, if it is right?

Yep.