bool ra_link_up(void)
{
+ static bool firstcall = true;
struct {
struct nlmsghdr hdr;
struct ifinfomsg msg;
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);
}