Fix a stray comma, and replace existing routes.
authorBenjamin Cama <benoar@dolka.fr>
Wed, 17 Aug 2011 15:16:30 +0000 (17:16 +0200)
committerBenjamin Cama <benoar@dolka.fr>
Wed, 17 Aug 2011 15:16:30 +0000 (17:16 +0200)
Signed-off-by: Benjamin Cama <benoar@dolka.fr>
l2tpns.c

index 4b7d93f..c34dc63 100644 (file)
--- a/l2tpns.c
+++ b/l2tpns.c
@@ -711,7 +711,7 @@ static void inittun(void)
                        char rtdata[32]; // 32 should be enough
                } req;
                uint32_t txqlen, mtu;
                        char rtdata[32]; // 32 should be enough
                } req;
                uint32_t txqlen, mtu;
-               struct in_addr ip;
+               in_addr_t ip;
 
                memset(&req, 0, sizeof(req));
 
 
                memset(&req, 0, sizeof(req));
 
@@ -736,17 +736,18 @@ static void inittun(void)
                memset(&req, 0, sizeof(req));
 
                req.nh.nlmsg_type = RTM_NEWADDR;
                memset(&req, 0, sizeof(req));
 
                req.nh.nlmsg_type = RTM_NEWADDR;
-               req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_MULTI;
+               req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_REPLACE | NLM_F_MULTI;
                req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.ifmsg.ifaddr));
 
                req.ifmsg.ifaddr.ifa_family = AF_INET;
                req.ifmsg.ifaddr.ifa_prefixlen = 32;
                req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.ifmsg.ifaddr));
 
                req.ifmsg.ifaddr.ifa_family = AF_INET;
                req.ifmsg.ifaddr.ifa_prefixlen = 32;
+               req.ifmsg.ifaddr.ifa_scope = RT_SCOPE_UNIVERSE;
                req.ifmsg.ifaddr.ifa_index = ifinfo.ifi_index;
 
                if (config->bind_address)
                req.ifmsg.ifaddr.ifa_index = ifinfo.ifi_index;
 
                if (config->bind_address)
-                       ip.s_addr = config->bind_address;
+                       ip = config->bind_address;
                else
                else
-                       ip.s_addr = 0x01010101, // 1.1.1.1
+                       ip = 0x01010101; // 1.1.1.1
                netlink_addattr(&req.nh, IFA_LOCAL, &ip, sizeof(ip));
 
                if (netlink_send(&req.nh) < 0)
                netlink_addattr(&req.nh, IFA_LOCAL, &ip, sizeof(ip));
 
                if (netlink_send(&req.nh) < 0)
@@ -759,7 +760,7 @@ static void inittun(void)
                        memset(&req, 0, sizeof(req));
 
                        req.nh.nlmsg_type = RTM_NEWADDR;
                        memset(&req, 0, sizeof(req));
 
                        req.nh.nlmsg_type = RTM_NEWADDR;
-                       req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_MULTI;
+                       req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_REPLACE | NLM_F_MULTI;
                        req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.ifmsg.ifaddr));
 
                        req.ifmsg.ifaddr.ifa_family = AF_INET6;
                        req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.ifmsg.ifaddr));
 
                        req.ifmsg.ifaddr.ifa_family = AF_INET6;
@@ -780,7 +781,7 @@ static void inittun(void)
                        memset(&req, 0, sizeof(req));
 
                        req.nh.nlmsg_type = RTM_NEWADDR;
                        memset(&req, 0, sizeof(req));
 
                        req.nh.nlmsg_type = RTM_NEWADDR;
-                       req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_MULTI;
+                       req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_REPLACE | NLM_F_MULTI;
                        req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.ifmsg.ifaddr));
 
                        req.ifmsg.ifaddr.ifa_family = AF_INET6;
                        req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.ifmsg.ifaddr));
 
                        req.ifmsg.ifaddr.ifa_family = AF_INET6;