]> git.puffer.fish Git - matthieu/frr.git/commitdiff
babeld: set interface flags eagerly, not at interface up.
authorJuliusz Chroboczek <jch@pps.jussieu.fr>
Tue, 14 Feb 2012 08:09:32 +0000 (09:09 +0100)
committerPaul Jakma <paul@quagga.net>
Sun, 25 Mar 2012 16:06:54 +0000 (17:06 +0100)
babeld/babel_interface.c

index 2b5f9569bc0b9a7fbb4778545f5c83576425c10b..00d53bc67b1644a02f33e26c234ea434f9d6d1e0 100644 (file)
@@ -288,7 +288,6 @@ babel_enable_if_delete (const char *ifname)
     return 1;
 }
 
-
 /* [Babel Command] Babel enable on specified interface or matched network. */
 DEFUN (babel_network,
        babel_network_cmd,
@@ -344,6 +343,25 @@ DEFUN (no_babel_network,
     return CMD_SUCCESS;
 }
 
+/* There are a number of interface parameters that must be changed when
+   an interface becomes wired/wireless.  In Quagga, they cannot be
+   configured separately. */
+
+static void
+babel_set_wired_internal(babel_interface_nfo *babel_ifp, int wired)
+{
+    if(wired) {
+        babel_ifp->flags |= BABEL_IF_WIRED;
+        babel_ifp->cost = 96;
+        babel_ifp->flags &= ~BABEL_IF_LQ;
+    } else {
+        babel_ifp->flags &= ~BABEL_IF_WIRED;
+        babel_ifp->cost = 256;
+        babel_ifp->flags |= BABEL_IF_LQ;
+    }
+
+}
+
 /* [Interface Command] Tell the interface is wire. */
 DEFUN (babel_set_wired,
        babel_set_wired_cmd,
@@ -358,7 +376,7 @@ DEFUN (babel_set_wired,
     babel_ifp = babel_get_if_nfo(ifp);
 
     assert (babel_ifp != NULL);
-    babel_ifp->flags |= BABEL_IF_WIRED;
+    babel_set_wired_internal(babel_ifp, 1);
     return CMD_SUCCESS;
 }
 
@@ -376,7 +394,7 @@ DEFUN (babel_set_wireless,
     babel_ifp = babel_get_if_nfo(ifp);
 
     assert (babel_ifp != NULL);
-    babel_ifp->flags &= ~BABEL_IF_WIRED;
+    babel_set_wired_internal(babel_ifp, 0);
     return CMD_SUCCESS;
 }
 
@@ -557,14 +575,6 @@ interface_recalculate(struct interface *ifp)
 
     resize_receive_buffer(mtu);
 
-    if(!(babel_ifp->flags & BABEL_IF_WIRED)) { /* if (wired) */
-        babel_ifp->cost = 96;
-        babel_ifp->flags &= ~BABEL_IF_LQ;
-    } else {
-        babel_ifp->cost = 256;
-        babel_ifp->flags |= BABEL_IF_LQ;
-    }
-
     memset(&mreq, 0, sizeof(mreq));
     memcpy(&mreq.ipv6mr_multiaddr, protocol_group, 16);
     mreq.ipv6mr_interface = ifp->ifindex;
@@ -1018,6 +1028,7 @@ babel_interface_allocate (void)
     babel_ifp->hello_interval = BABEL_DEFAULT_HELLO_INTERVAL;
     babel_ifp->update_interval = BABEL_DEFAULT_UPDATE_INTERVAL;
     babel_ifp->channel = BABEL_IF_CHANNEL_INTERFERING;
+    babel_set_wired_internal(babel_ifp, 0);
 
     return babel_ifp;
 }