]> git.decadent.org.uk Git - odhcp6c.git/commitdiff
React to carrier down events as well
authorSteven Barth <steven@midlink.org>
Wed, 30 Oct 2013 13:13:50 +0000 (14:13 +0100)
committerSteven Barth <steven@midlink.org>
Wed, 30 Oct 2013 13:13:50 +0000 (14:13 +0100)
src/ra.c

index 971a1723e84a4a05b9c966d1e406df1cae12492e..c8ccb888f8856172ff58f280625b5005b61ab356 100644 (file)
--- a/src/ra.c
+++ b/src/ra.c
@@ -150,6 +150,7 @@ static void update_proc(const char *sect, const char *opt, uint32_t value)
 
 bool ra_link_up(void)
 {
+       static bool firstcall = true;
        struct {
                struct nlmsghdr hdr;
                struct ifinfomsg msg;
@@ -167,14 +168,16 @@ bool ra_link_up(void)
                        continue;
 
                bool hascarrier = resp.msg.ifi_flags & IFF_LOWER_UP;
-               if (nocarrier && hascarrier)
+               if (!firstcall && nocarrier != !hascarrier)
                        ret = true;
 
                nocarrier = !hascarrier;
+               firstcall = false;
        } while (read > 0);
 
        if (ret) {
-               syslog(LOG_NOTICE, "carrier up event on %s", if_name);
+               syslog(LOG_NOTICE, "carrier => %i event on %s", (int)!nocarrier, if_name);
+
                rs_attempt = 0;
                ra_send_rs(SIGALRM);
        }