diff options
author | Juliusz Chroboczek <jch@pps.jussieu.fr> | 2012-02-14 09:09:32 +0100 |
---|---|---|
committer | Paul Jakma <paul@quagga.net> | 2012-03-25 17:06:54 +0100 |
commit | 260948cdd6030b332137dfa0580d5a9ba651b145 (patch) | |
tree | 873a640ce0a3befae45dbc4d4625ab97acbdb271 | |
parent | 46b92c043f1a83d8343a4a0345a7b69bac3cdf20 (diff) |
babeld: set interface flags eagerly, not at interface up.
-rw-r--r-- | babeld/babel_interface.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 2b5f9569..00d53bc6 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -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; } |