Work around warn_unused_result in recent gcc/libc
[project/netifd.git] / system-linux.c
index dae98b0..cbcc5bd 100644 (file)
@@ -156,7 +156,7 @@ static void system_set_sysctl(const char *path, const char *val)
        if (fd < 0)
                return;
 
-       write(fd, val, strlen(val));
+       if (write(fd, val, strlen(val))) {}
        close(fd);
 }
 
@@ -456,8 +456,9 @@ static int cb_clear_event(struct nl_msg *msg, void *arg)
        hdr->nlmsg_type = type;
        hdr->nlmsg_flags = NLM_F_REQUEST;
 
-       if (!nl_send_auto_complete(sock_rtnl, clr->msg))
-               nl_wait_for_ack(sock_rtnl);
+       nl_socket_disable_auto_ack(sock_rtnl);
+       nl_send_auto_complete(sock_rtnl, clr->msg);
+       nl_socket_enable_auto_ack(sock_rtnl);
 
        return NL_SKIP;
 }
@@ -1067,6 +1068,7 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd)
        struct rtmsg rtm = {
                .rtm_family = (alen == 4) ? AF_INET : AF_INET6,
                .rtm_dst_len = route->mask,
+               .rtm_src_len = route->sourcemask,
                .rtm_table = (table < 256) ? table : RT_TABLE_UNSPEC,
                .rtm_protocol = (route->flags & DEVADDR_KERNEL) ? RTPROT_KERNEL : RTPROT_STATIC,
                .rtm_scope = scope,
@@ -1092,6 +1094,9 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd)
        if (route->mask)
                nla_put(msg, RTA_DST, alen, &route->addr);
 
+       if (route->sourcemask)
+               nla_put(msg, RTA_SRC, alen, &route->source);
+
        if (route->metric > 0)
                nla_put_u32(msg, RTA_PRIORITY, route->metric);
 
@@ -1130,7 +1135,7 @@ int system_flush_routes(void)
                if (fd < 0)
                        continue;
 
-               write(fd, "-1", 2);
+               if (write(fd, "-1", 2)) {}
                close(fd);
        }
        return 0;