fix adding routes
authorFelix Fietkau <nbd@openwrt.org>
Fri, 14 Oct 2011 01:35:52 +0000 (03:35 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 14 Oct 2011 01:35:52 +0000 (03:35 +0200)
system-linux.c

index e04fa23..cf4e9c7 100644 (file)
@@ -393,6 +393,7 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd)
 {
        int alen = ((route->flags & DEVADDR_FAMILY) == DEVADDR_INET4) ? 4 : 16;
        bool have_gw;
+       unsigned int flags = 0;
 
        if (alen == 4)
                have_gw = !!route->nexthop.in.s_addr;
@@ -414,7 +415,10 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd)
                .rtm_type = (cmd == RTM_DELROUTE) ? 0: RTN_UNICAST,
        };
 
-       struct nl_msg *msg = nlmsg_alloc_simple(cmd, 0);
+       if (cmd == RTM_NEWROUTE)
+               flags |= NLM_F_CREATE | NLM_F_REPLACE;
+
+       struct nl_msg *msg = nlmsg_alloc_simple(cmd, flags);
        if (!msg)
                return -1;