[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [bluetooth-dev] Trouble when compiling OpenBT with PAN profil e



Here is the patch. It modifies the following (1 and 2 are for allowing 
compilation as a module):
1) bnep_init_module is now called from bluetooth.c. If called from 
module_init, a link error occurred:

bnep.o(.text+0x0): multiple definition of `init_module'
bluetooth.o(.text+0x25a0): first defined here

2) when the module is removed, bluetooth.c calls a new function named 
bnep_exit_module
3) swapped the >= and <= signs in the multicast filter check (they caused 
multicast packets to be dropped)
4) if bnep_send_packet cannot subscribe a memory buffer, the packet is not 
dropped with dev_kfree_skb, instead -1 is returned so the queue discipline 
re-enqueues the packet. Packet dropping is utterly destructive for 
non-acknowledged traffic like UDP. For TCP, a packet drop does not cause 
data loss because TCP has retransmissions, however TCP retransmissions are 
better avoided because they cause traffic slowdown

Fabrizio Gennari
Philips Research Monza
via G.Casati 23, 20052 Monza (MI), Italy
tel. +39 039 2037816, fax +39 039 2037800





Peter Kjellerstedt <peter.kjellerstedt@xxxxxxx.com>
04/02/2002 12.54

 
        To:     Fabrizio Gennari/MOZ/RESEARCH/PHILIPS@EMEA1
        cc:     Bluetooth-dev <bluetooth-dev@xxxxxxx.com>
        Subject:        RE: [bluetooth-dev] Trouble when compiling OpenBT with PAN profil e
        Classification: 




> However, the BNEP profile still does not compile as a module 
> (but it is fine as a part of the kernel), neither in or outside
> the kernel tree. I modified it so it does, and if you are
> interested I can send it to you.

Please do (you can send it to the list).

diff -ruN /mnt/wip/code/linux/bluetooth/axis-bt/linux/drivers/char/bluetooth/bluetooth.c linux/drivers/char/bluetooth/bluetooth.c
--- /mnt/wip/code/linux/bluetooth/axis-bt/linux/drivers/char/bluetooth/bluetooth.c	Thu Jan 31 10:11:57 2002
+++ linux/drivers/char/bluetooth/bluetooth.c	Fri Feb  1 14:49:01 2002
@@ -255,6 +255,8 @@
 #endif
 
 #ifdef CONFIG_BLUETOOTH_PAN
+int bnep_init_module(void);
+void bnep_exit_module(void);
 void bnep_init(void);
 void bnep_shutdown(void);
 u32 bnep_connect_req(u8 *bd_addr);
@@ -2527,6 +2529,9 @@
 
 	hci_module_init();
 	rfcomm_module_init();
+#ifdef CONFIG_BLUETOOTH_PAN
+	bnep_init_module();
+#endif
         
 	return 0; /* success */
 }
@@ -3238,6 +3243,10 @@
 	bnep_status_remove_proc_file();
 #endif
 #endif /* CONFIG_BLUETOOTH_PROC */
+
+#ifdef CONFIG_BLUETOOTH_PAN
+	bnep_exit_module();
+#endif
 
 	DSYS("Bluetooth Driver unregistered\n");
 }
diff -ruN /mnt/wip/code/linux/bluetooth/axis-bt/linux/drivers/char/bluetooth/bnep.c linux/drivers/char/bluetooth/bnep.c
--- /mnt/wip/code/linux/bluetooth/axis-bt/linux/drivers/char/bluetooth/bnep.c	Tue Jan 29 16:57:26 2002
+++ linux/drivers/char/bluetooth/bnep.c	Fri Feb  1 14:49:15 2002
@@ -128,8 +128,6 @@
 
 /****************** LOCAL FUNCTION DECLARATION SECTION **********************/
 
-static int bnep_init_module(void);
-
 /* Ethernet interface */
 static int __init bnep_init_interface(struct net_device *dev);
 static int bnep_close(struct net_device *dev);
@@ -153,13 +151,10 @@
 
 /****************** FUNCTION DEFINITION SECTION *****************************/
 
-/* Tell the kernel to call my init routine. */
-module_init(bnep_init_module);
-
 /* 
  * Init routine for the BNEP driver. 
  */
-static int
+int
 bnep_init_module(void)
 {
 	int i, err;
@@ -247,6 +242,20 @@
 	}
 }
 
+void
+bnep_exit_module(void)
+{
+	int i;
+	struct net_device *d;
+	
+	for (i = 0; i < BNEP_INTERFACES; i++) {
+		d = &dev_bnep[i];
+
+		D_MISC("Unregister netdev %s\n", d->name);
+		unregister_netdev(d);
+	}
+}
+
 /* 
  * Init routine for BNEP interfaces.
  */
@@ -450,8 +459,8 @@
 		/* Step through filter range by filter range */
 		for (i = 0; (i < BNEP_MAX_MCAST_FILTER_RANGES) && (!send_packet); i++) {
 			D_MISC(__FUNCTION__": Trying multicast filter range %d\n", i);
-			if (memcmp(local->filter_multi_addr_list[i*2].addr, eth->h_dest, 6) >= 0 &&
-			    memcmp(local->filter_multi_addr_list[i*2+1].addr, eth->h_dest, 6) <= 0) {
+			if (memcmp(local->filter_multi_addr_list[i*2].addr, eth->h_dest, 6) <= 0 &&
+			    memcmp(local->filter_multi_addr_list[i*2+1].addr, eth->h_dest, 6) >= 0) {
 				D_MISC(__FUNCTION__": Multicast filter range %d OK\n",i);
 				send_packet = 1;
 			}
@@ -612,14 +621,14 @@
 		D_ERR(__FUNCTION__": not enough room for a %d byte bt_tx_buf\n", skb->len);
 		/* don't necessarily need to discard the buffer; could set dev->tbusy = 1
 		   and then start a timer to check for free buffer space */
-		local->stats.tx_dropped++;
+		return -1;
 	} else {
 		/* subscribe to a bt_tx_buf */
 		D_XMIT("New bt buf length %i \n", buflen );
 		if ((tx_buf = subscribe_bt_buf(buflen)) == NULL) {
 			D_ERR(__FUNCTION__": failed to subscribe to a %d byte bt_tx_buf buflen %d\n", 
 			      skb->len, buflen);
-			local->stats.tx_dropped++;
+			return -1;
 		} else {
 			/* copy the frame into the bt_tx_buf */
 			memcpy(tx_buf->data + sizeof(bnep_tx_buf),bhdr,bhdrlen);