Package:  mrd6
Version:  0.9.6-9
Severity: normal
Tags:     patch

Whenever mrd6 is running and a new interface detected, it is improperly
marked as down even if it is up and running. Consider the following
example.

mrd6 is running and ip6tnl1 is not yet there:

# ifconfig ip6tnl1
ip6tnl1: error fetching interface information: Device not found

# mrd6sh show | grep ip6tnl1
#

Now ip6tnl1 is created, up and running, but mrd6 keeps seeing it as
down:

# ifconfig ip6tnl1
ip6tnl1   Link encap:UNSPEC  HWaddr
20-01-01-00-00-00-00-00-00-00-00-00-00-00-00-00 
inet6 addr: fe80::488:a0ff:fe00:1/64 Scope:Link 
UP POINTOPOINT RUNNING NOARP MTU:1460  Metric:1 
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
collisions:0 txqueuelen:0 
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

# mrd6sh show | grep ip6tnl1
Interface ip6tnl1 (9) is Down (Uptime: 16s)
Interface: ip6tnl1, Disabled

This has already been reported upstream and a patch has been coded,
built and tested by me:
https://github.com/hugosantos/mrd6/issues/23
You can find the git commit attached here.

I would be really glad if you could please upload it soon, so that I
can have it available in time for Wheezy. I can volunteer for an NMU,
if you want.

Cheers, Luca

-- 
  .''`.  |               ~<[ Luca BRUNO ~ (kaeso) ]>~
 : :'  : | Email: lucab (AT) debian.org ~ Debian Developer
 `. `'`  | GPG Key ID: 0x3BFB9FB3       ~ Free Software supporter
   `-    | HAM-radio callsign: IZ1WGT   ~ Networking sorcerer
commit 2ecdfe06976f7a8db61e7aafe7817fab78637e80
Author: Luca Bruno <lu...@debian.org>
Date:   Sat May 26 10:30:59 2012 +0200

    Correctly detect and enable new interfaces (Issue #23)
    
    When new interfaces are created while mrd6 is running, they are detected
    but incorrectly added as down. This patch correctly manages the case of
    enabling interfaces which were not previously available.
    
    Signed-off-by: Luca Bruno <lu...@debian.org>

diff --git a/include/mrd/interface.h b/include/mrd/interface.h
index eb8735d..d979d26 100644
--- a/include/mrd/interface.h
+++ b/include/mrd/interface.h
@@ -204,7 +204,7 @@ private:
 
 	void add_remove_address(bool isnew, const inet6_addr &);
 	void broadcast_change_state(bool wasdown);
-	void set_enabled(bool);
+	void set_enabled(bool newstate, bool newiface=false);
 };
 
 uint16_t ipv6_checksum(uint8_t protocol, const in6_addr &src, const in6_addr &dst, const void *data, uint16_t len);
diff --git a/src/interface.cpp b/src/interface.cpp
index 6bbc56e..d0e6796 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -292,12 +292,16 @@ void interface::broadcast_change_state(bool wasdown) {
 	}
 }
 
-void interface::set_enabled(bool newstate) {
-	bool wasdown = !up();
-
-	mif_enabled = newstate;
-
-	broadcast_change_state(wasdown);
+void interface::set_enabled(bool newstate, bool newiface) {
+	if (!newiface) {
+		bool wasdown = !up();
+		mif_enabled = newstate;
+		broadcast_change_state(wasdown);
+	} else {
+		mif_state = (newstate) ? Up : Down;
+		mif_enabled = newstate;
+		g_mrd->broadcast_interface_state_changed(this);
+	}
 }
 
 bool interface::attach_node(interface_node *node) {
diff --git a/src/linux/linux_unicast_route.cpp b/src/linux/linux_unicast_route.cpp
index 7ce1ab4..331a7a0 100644
--- a/src/linux/linux_unicast_route.cpp
+++ b/src/linux/linux_unicast_route.cpp
@@ -199,7 +199,7 @@ static void _install_interface(const interface_desc &d) {
 			((linux_unicast_router &)g_mrd->rib()).do_dump(RTM_GETADDR);
 		}
 
-		intf->change_state(d.up ? interface::Up : interface::Down);
+		intf->change_state((d.up | intf->up()) ? interface::Up : interface::Down);
 	}
 }
 
diff --git a/src/mrd.cpp b/src/mrd.cpp
index 8f95030..e85bf21 100644
--- a/src/mrd.cpp
+++ b/src/mrd.cpp
@@ -1484,7 +1484,7 @@ interface *mrd::found_interface(int index, const char *name, int type,
 			      (uint32_t)intf->mtu());
 	}
 
-	intf->set_enabled(enabled);
+	intf->set_enabled(enabled, true);
 
 	return intf;
 }

Attachment: signature.asc
Description: PGP signature

Reply via email to