From 2f47fa5db2ce0fbe118ed9b6727c3956a48c85fb Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 14 Oct 2011 03:35:52 +0200 Subject: [PATCH] fix adding routes --- system-linux.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system-linux.c b/system-linux.c index e04fa23..cf4e9c7 100644 --- a/system-linux.c +++ b/system-linux.c @@ -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; -- 2.11.0