Skip to contentSkip to conversation

: ir256_packet_type.diff

PATCH New Jean Tourrilhes 1 participant 1 message Nov 5, 2002 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : ir256_packet_type.diff

ir256_packet_type.diff :
----------------------
<Thanks to Martin Diehl>
o [CORRECT] Handle non-linear and shared skbs
o [CORRECT] Tell kernel we can handle multithreaded receive <Of course, this has been tested extensively on SMP>

net/irda/irsyms.c renamed from net/irda/irsyms.d5.c +8 -6
diff -u -p linux/net/irda/irsyms.d5.c linux/net/irda/irsyms.c
@@ -180,13 +180,16 @@ EXPORT_SYMBOL(irtty_set_packet_mode);
 __u32 irda_debug = IRDA_DEBUG_LEVEL;
 #endif
 
+/* Packet type handler.
+ * Tell the kernel how IrDA packets should be handled.
+ */
 static struct packet_type irda_packet_type = 
 {
-	0,	/* MUTTER ntohs(ETH_P_IRDA),*/
-	NULL,
-	irlap_driver_rcv,
-	NULL,
-	NULL,
+	.type	= __constant_htons(ETH_P_IRDA),
+	.dev	= NULL,			/* Wildcard : All devices */
+	.func	= irlap_driver_rcv,	/* Packet type handler irlap_frame.c */
+	.data	= (void*) 1,		/* Understand shared skbs */
+	//.next	= NULL,
 };
 
 /*
@@ -267,7 +270,6 @@ int __init irda_init(void)
 	irsock_init();
 	
 	/* Add IrDA packet type (Start receiving packets) */
-	irda_packet_type.type = htons(ETH_P_IRDA);
         dev_add_pack(&irda_packet_type);
 
 	/* Notifier for Interface changes */
net/irda/irlap_frame.c renamed from net/irda/irlap_frame.d5.c +14 -0
diff -u -p linux/net/irda/irlap_frame.d5.c linux/net/irda/irlap_frame.c
@@ -1280,6 +1280,20 @@ int irlap_driver_rcv(struct sk_buff *skb
 		return -1;
 	}
 
+	/* We are no longer an "old" protocol, so we need to handle
+	 * share and non linear skbs. This should never happen, so
+	 * we don't need to be clever about it. Jean II */
+	if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
+		ERROR("%s: can't clone shared skb!\n", __FUNCTION__);
+		return -1;
+	}
+	if (skb_is_nonlinear(skb))
+		if (skb_linearize(skb, GFP_ATOMIC) != 0) {
+			ERROR("%s: can't linearize skb!\n", __FUNCTION__);
+			dev_kfree_skb(skb);
+			return -1;
+		}
+
 	/* Check if frame is large enough for parsing */
 	if (skb->len < 2) {
 		ERROR("%s: frame to short!\n", __FUNCTION__);