X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=blobdiff_plain;f=src%2Fra.c;h=c8ccb888f8856172ff58f280625b5005b61ab356;hp=aa03ff4d3ab8f6235b38aa8f069c785d3486a10e;hb=c570ee307de12e47e8a370fb66d8f99f14d4b064;hpb=4a9de784477a0f0dbc04ff890e35adae02ee6e8b diff --git a/src/ra.c b/src/ra.c index aa03ff4..c8ccb88 100644 --- 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; @@ -161,19 +162,22 @@ bool ra_link_up(void) do { read = recv(rtnl, &resp, sizeof(resp), MSG_DONTWAIT); - if (!NLMSG_OK(&resp.hdr, read) || resp.hdr.nlmsg_type != RTM_NEWLINK || + if (read < 0 || !NLMSG_OK(&resp.hdr, (size_t)read) || + resp.hdr.nlmsg_type != RTM_NEWLINK || resp.msg.ifi_index != if_index) 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); }