Skip to contentSkip to conversation

bluetoothd-service-network fails to execute ifup scripts from network.conf after repeated connection attempts (Patched)

Bluez-devel Valmantas 3 participants 11 messages Apr 29, 2008 – May 8, 2008 Bluetooth drivers

lore
Share & tools
lore

Valmantas

author
#0 lore raw

After connecting to a server once, the relevent scripts in network.conf are executed, and pan* and bnep* interfaces come up, but when you disconnect and
reconnect the second time, neither the script gets executed, nor the interface comes up and this makes the connection unusable. (You would have to manually bring it up with "ifconfig bnep0 up" )

Also PANU role script does not get executed, ever, on incoming connections, fixed in patch.

Example:
i have /etc/bluetooth/network.conf

[General]

[PANU Role]
Script=/usr/bin/my-ifup

[GN Role]
Script=/usr/bin/my-ifup

[NAP Role]
Script=/usr/bin/my-ifup

Connection 1 ( server pan0 (GN) )
my-ifup gets executed with pan0 argument

Disconnect / Connect 2 ( server pan0 (GN) )
No execution

Correct behaviour:
Connection 1 ( server pan0 (GN) )
my-ifup gets executed with pan0 argument
my-ifup gets executed with bnep0 argument

Disconnect / Connect 2 ( server pan0 (GN) )
my-ifup gets executed with bnep0 argument

Disconnect / Connect 3 ( server pan0 (GN) )
my-ifup gets executed with bnep0 argument

server.c renamed from server.c.orig +1 -1
@@ -344,7 +344,7 @@
 			goto failed;
 		}
 
-		bnep_if_up(devname, 0);
+		bnep_if_up(devname, ns->id);
 	} else
 		bnep_if_up(devname, ns->id);
 
common.c renamed from common.c.orig +42 -18

86 lines not on this page · raw message

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#1 lore raw

SGVsbG8sCgpPbiBUdWUsIEFwciAyOSwgMjAwOCBhdCA1OjQyIFBNLCBWYWxtYW50YXMgPHdhbG1p c0BnbWFpbC5jb20+IHdyb3RlOgo+IEFmdGVyIGNv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LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQpUaGlzIFNGLm5ldCBl bWFpbCBpcyBzcG9uc29yZWQgYnkgdGhlIDIwMDggSmF2YU9uZShTTSkgQ29uZmVyZW5jZSAKRG9u J3QgbWlzcyB0aGlzIHllYXIncyBleGNpdGluZyBldmVudC4gVGhlcmUncyBzdGlsbCB0aW1lIHRv IHNhdmUgJDEwMC4gClVzZSBwcmlvcml0eSBjb2RlIEo4VEwyRDIuIApodHRwOi8vYWQuZG91Ymxl Y2xpY2submV0L2NsazsxOTg3NTc2NzM7MTM1MDMwMzg7cD9odHRwOi8vamF2YS5zdW4uY29tL2ph dmFvbmUKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KQmx1 ZXotZGV2ZWwgbWFpbGluZyBsaXN0CkJsdWV6LWRldmVsQGxpc3RzLnNvdXJjZWZvcmdlLm5ldApo dHRwczovL2xpc3RzLnNvdXJjZWZvcmdlLm5ldC9saXN0cy9saXN0aW5mby9ibHVlei1kZXZlbAo=

author
#2 lore raw
Quoted 10 lines · Luiz Augusto von Dentz

Hello,

Quoted 6 lines · Valmantas

After connecting to a server once, the relevent scripts in network.conf
are executed, and pan* and bnep* interfaces come up, but when you disconnect and
reconnect the second time, neither the script gets executed, nor the interface comes up and this makes the connection unusable. (You would have to manually bring it up with "ifconfig bnep0 up" )

Quoted 4 lines

The bridge on server side was already up I supposed, so it is pointless to execute the script again and again, but you may have found a bug on client side if what you are saying is that the bnep interface does not come up a second time.

Yes, bridges should come up only once and nope, not on the client side, the server side, the bnepX in the bridge does not come up after the first reconnect. Spent hours figuring out why there was no network with my PDA, and ifconfig bnep0 up done the trick.

Quoted 14 lines
Quoted 7 lines

Correct behaviour:
Connection 1 ( server pan0 (GN) )
my-ifup gets executed with pan0 argument
my-ifup gets executed with bnep0 argument

Quoted 6 lines

Disconnect / Connect 2 ( server pan0 (GN) )
my-ifup gets executed with bnep0 argument

Disconnect / Connect 3 ( server pan0 (GN) )
my-ifup gets executed with bnep0 argument

Quoted 8 lines

No need to execute any script on bnepX at all, you seems to actually misunderstood the way it should goes, each bnepX interface always execute the PANU script on client side, on server it is the same if the role is PANU, GN and NAP uses bridges so the bnepX doesn't need any configuration besides bring them up, thats why there is a bnep_if_up(dev,
0)
where 0 means do not execute any script as this interface will be added to a bridge.

There's a bonus, this way you can know when a client has connected and do some stuff. To my knowledge this is the only way. Unless someone develops dbus signals for this. Well, it's not THAT necessary, but fixing the bug i mentioned above in this email is.

Quoted 5 lines

ps: it really helps if you include what version are you testing and what network
service is printing.

Sorry i forgot, it's bluez-utils 3.26 and i'll provide output later

Quoted 11 lines

--
Luiz Augusto von Dentz
Engenheiro de Computação
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.

Quoted 6 lines

http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

author
#3 lore raw

Ok, so i made a proper patch. It does not execute the scripts as the previous did, but it does properly bring up the server side bnep interfaces after numerous connections.

Waiting for review.

oh, and here's some output:

network[19366]: Authorization succedded. New connection: bnep0 network[19366]: Bringing up interface pan0 network[19366]: Bringing up interface bnep0 network[19366]: filter_function: sender=:1.60 destination=:1.58 obj_path=/org/bluez/network interface=org.bluez.network.Manager method=FindConnection
network[19366]: /org/bluez/network:
org.bluez.network.Manager.FindConnection() network[19366]: filter_function: sender=:1.5 destination=(null) obj_path=/org/freedesktop/Hal/Manager interface=org.freedesktop.Hal.Manager method=DeviceAdded Found user 'avahi-autoipd' (UID 103) and group 'avahi-autoipd' (GID 110).
Successfully called chroot().
Successfully dropped root privileges.
Starting with address 169.254.5.87
Callout BIND, address 169.254.5.87 on interface pan0 network[19366]: filter_function: sender=:1.5 destination=(null) obj_path=/org/freedesktop/Hal/Manager interface=org.freedesktop.Hal.Manager method=DeviceRemoved network[19366]: filter_function: sender=:1.5 destination=(null) obj_path=/org/freedesktop/Hal/Manager interface=org.freedesktop.Hal.Manager method=DeviceRemoved Successfully claimed IP address 169.254.5.87 network[19366]: filter_function: sender=:1.5 destination=(null) obj_path=/org/freedesktop/Hal/Manager interface=org.freedesktop.Hal.Manager method=DeviceAdded hcid[19363]: link_key_request (sba=00:09:DD:50:6E:2F, dba=00:1A:92:FF:16:0D)
network[19366]: Connection from: 00:1A:92:FF:16:0D on PSM 15 hcid[19363]: link_key_notify (sba=00:09:DD:50:6E:2F, dba=00:1A:92:FF:16:0D)
network[19366]: Requesting authorization for 00:1A:92:FF:16:0D UUID:00001117-0000-1000-8000-00805f9b34fb network[19366]: Authorization succedded. New connection: bnep0 network[19366]: Bringing up interface bnep0 network[19366]: filter_function: sender=:1.61 destination=:1.58 obj_path=/org/bluez/network interface=org.bluez.network.Manager method=FindConnection
network[19366]: /org/bluez/network:
org.bluez.network.Manager.FindConnection() network[19366]: filter_function: sender=:1.5 destination=(null) obj_path=/org/freedesktop/Hal/Manager interface=org.freedesktop.Hal.Manager method=DeviceAdded

Regards,
Valmantas Palikša

common.c renamed from common.c.old +19 -14
@@ -71,6 +71,7 @@
 	char *devname;
 	char *script;
 	int pid;
+	int is_initialized;
 };
 
 static gint find_devname(gconstpointer a, gconstpointer b)
@@ -235,22 +236,23 @@
 	/* Check if a script is running */
 	if ((l = g_slist_find_custom(pids, devname, find_devname))) {
 		bnep = l->data;
+		if(bnep->pid != 0) {
+			if (bnep->script && !strcmp(bnep->script, "avahi-autoipd")) {
+				argv[0] = bnep->script;
+				argv[1] = devname;
+				argv[2] = "--refresh";
+				argv[3] = NULL;
+
+				flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH;
+				g_spawn_async(NULL, (char **) argv, NULL, flags,
+						bnep_setup, (gpointer) devname, &pid,
+						NULL);
+			}
 
-		if (bnep->script && !strcmp(bnep->script, "avahi-autoipd")) {
-			argv[0] = bnep->script;
-			argv[1] = devname;
-			argv[2] = "--refresh";
-			argv[3] = NULL;
-
-			flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH;
-			g_spawn_async(NULL, (char **) argv, NULL, flags,
-					bnep_setup, (gpointer) devname, &pid,
-					NULL);
+			return bnep->pid;
 		}
-
-		return bnep->pid;
 	}
-
+	info("Bringing up interface %s", devname);
 	sd = socket(AF_INET6, SOCK_DGRAM, 0);
 	memset(&ifr, 0, sizeof(ifr));
 	strcpy(ifr.ifr_name, devname);
@@ -264,10 +266,13 @@
 			err);
 		return -err;
 	}
+	
+	if(!id && bnep->is_initialized)
+		return bnep->pid;
 
 	bnep = g_new0(struct bnep_data, 1);
 	bnep->devname = g_strdup(devname);
-
+	bnep->is_initialized = 1;
 	if (!id)
 		goto done;
 

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#4 lore raw

What seems to be triggering the problem is that bnep_if_down is not been called on disconnect than
the g_slist_find is causing the problem on bnep_if_up as it turn to return without bringing up the
interface.

Also please make sure you test this against cvs, so we avoid redoing work already done.

-- =

Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference =

Don't miss this year's exciting event. There's still time to save $100. =

Use priority code J8TL2D2. =

http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/java=
one
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

author
#5 lore raw
Quoted 9 lines · Luiz Augusto von Dentz

What seems to be triggering the problem is that bnep_if_down is not been called on disconnect than
the g_slist_find is causing the problem on bnep_if_up as it turn to return without bringing up the
interface.

Also please make sure you test this against cvs, so we avoid redoing work already done.

How can i know when the connection has been broken?

bnep_io() does not seem to get called on disconnect.

Also i found another bug, NAP bridge does not get initialized.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

author
#6 lore raw
Quoted 11 lines · Valmantas
Quoted 9 lines · Luiz Augusto von Dentz

What seems to be triggering the problem is that bnep_if_down is not been called on disconnect than
the g_slist_find is causing the problem on bnep_if_up as it turn to return without bringing up the
interface.

Also please make sure you test this against cvs, so we avoid redoing work already done.

Quoted 7 lines

How can i know when the connection has been broken?

bnep_io() does not seem to get called on disconnect.

Also i found another bug, NAP bridge does not get initialized.

I mean connect_setup_event() not bnep_io

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#7 lore raw
In reply to Valmantas

It should be fixed now in cvs, could you please test it.

ps: I left NAP bridge out for instance.

-- =

Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference =

Don't miss this year's exciting event. There's still time to save $100. =

Use priority code J8TL2D2. =

http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/java=
one
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

author
#8 lore raw

Hi,

I've backported your patch to bluez-utils 3.26, works excellent as far as i can tell. Thank you.

And, so, what's the verdict on the nap bridge?

Quoted 14 lines · Luiz Augusto von Dentz

It should be fixed now in cvs, could you please test it.

ps: I left NAP bridge out for instance.

--
Luiz Augusto von Dentz
Engenheiro de Computação

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.

Quoted 6 lines

http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#9 lore raw

[Bluez-devel] BlueZ API Documentation

I am new to this mailing list and trying to evaluate BlueZ for one of my application requirement. I didnt find any updated BlueZ API Documentation, If any one can help me

Thanks
Saurabh Mukadam,
-------------------------------------------------------------------------------------------

" The price of success is hard work, dedication to the job
at hand, and the determination that whether we win or lose, we have applied the best of ourselves to the task at hand."

Larsen & Toubro Infotech Ltd.
www.Lntinfotech.com

This Document is classified as:

L&T Infotech Proprietary L&T Infotech Confidential L&T Infotech
Internal Use Only L&T Infotech General Business

This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.

______________________________________________________________________

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#10 lore raw
In reply to walmis

Hi,

Great, so at least GN is now working as expected, as I said before NAP is more complicated even though we could return its bridge and leave to user script to deal with dhcp server/NAT this code was in cvs before but Marcel requested to remove it since we have no interface to change any script configuration (ip range, routing interface...). But you have a point saying it is not a big deal to leave NAP bridge for user to create and configure and network service still announce it without any verification, it might be better to return the bridge creation to network service and when possible hook the bridge to connman(http://www.moblin.org/projects/projects_connman.php) when it comes to support access points.

-- =

Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference =

Don't miss this year's exciting event. There's still time to save $100. =

Use priority code J8TL2D2. =

http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/java=
one
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel