X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=system-linux.c;h=c7b8b8f66c8c45bdcdf3dbdd7f57de9376d8402b;hp=0e6ce5ac686570dc15de99b6f6b46c43225d6d4c;hb=120cd39654a33401423f1b65bb19e12681a6e46f;hpb=87648299f8944a3268210e0315f6b5244d42fa4f diff --git a/system-linux.c b/system-linux.c index 0e6ce5a..c7b8b8f 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1,3 +1,16 @@ +/* + * netifd - network interface daemon + * Copyright (C) 2012 Felix Fietkau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ #define _GNU_SOURCE #include @@ -243,10 +256,15 @@ handle_hotplug_event(struct uloop_fd *u, unsigned int events) static int system_rtnl_call(struct nl_msg *msg) { - int s = -(nl_send_auto_complete(sock_rtnl, msg) - || nl_wait_for_ack(sock_rtnl)); + int ret; + + ret = nl_send_auto_complete(sock_rtnl, msg); nlmsg_free(msg); - return s; + + if (ret < 0) + return ret; + + return nl_wait_for_ack(sock_rtnl); } int system_bridge_delbr(struct device *bridge) @@ -839,8 +857,12 @@ static int system_addr(struct device *dev, struct device_addr *addr, int cmd) nlmsg_append(msg, &ifa, sizeof(ifa), 0); nla_put(msg, IFA_LOCAL, alen, &addr->addr); - if (v4) - nla_put_u32(msg, IFA_BROADCAST, addr->broadcast); + if (v4) { + if (addr->broadcast) + nla_put_u32(msg, IFA_BROADCAST, addr->broadcast); + if (addr->point_to_point) + nla_put_u32(msg, IFA_ADDRESS, addr->point_to_point); + } return system_rtnl_call(msg); } @@ -877,7 +899,7 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd) .rtm_family = (alen == 4) ? AF_INET : AF_INET6, .rtm_dst_len = route->mask, .rtm_table = RT_TABLE_MAIN, - .rtm_protocol = RTPROT_BOOT, + .rtm_protocol = (route->flags & DEVADDR_KERNEL) ? RTPROT_KERNEL : RTPROT_BOOT, .rtm_scope = scope, .rtm_type = (cmd == RTM_DELROUTE) ? 0: RTN_UNICAST, }; @@ -901,8 +923,7 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd) if (have_gw) nla_put(msg, RTA_GATEWAY, alen, &route->nexthop); - if (route->flags & DEVADDR_DEVICE) - nla_put_u32(msg, RTA_OIF, ifindex); + nla_put_u32(msg, RTA_OIF, ifindex); return system_rtnl_call(msg); }