system-linux.c: install user routes with RTPROT_STATIC instead of RTPROT_BOOT so...
[project/netifd.git] / system-linux.c
index 3372a66..e1343a5 100644 (file)
@@ -154,7 +154,7 @@ static void system_set_sysctl(const char *path, const char *val)
 
 static void system_set_dev_sysctl(const char *path, const char *device, const char *val)
 {
-       snprintf(dev_buf, sizeof(dev_buf), path, val);
+       snprintf(dev_buf, sizeof(dev_buf), path, device);
        system_set_sysctl(dev_buf, val);
 }
 
@@ -235,6 +235,9 @@ found:
        if (dev->type != &simple_device_type)
                return;
 
+       if (add && system_if_force_external(dev->ifname))
+               return;
+
        device_set_present(dev, add);
 }
 
@@ -629,7 +632,7 @@ system_if_get_settings(struct device *dev, struct device_settings *s)
        }
 }
 
-static void
+void
 system_if_apply_settings(struct device *dev, struct device_settings *s)
 {
        struct ifreq ifr;
@@ -646,7 +649,7 @@ system_if_apply_settings(struct device *dev, struct device_settings *s)
                if (ioctl(sock_ioctl, SIOCSIFTXQLEN, &ifr) < 0)
                        s->flags &= ~DEV_OPT_TXQUEUELEN;
        }
-       if (s->flags & DEV_OPT_MACADDR) {
+       if ((s->flags & DEV_OPT_MACADDR) && !dev->external) {
                ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
                memcpy(&ifr.ifr_hwaddr.sa_data, s->macaddr, sizeof(s->macaddr));
                if (ioctl(sock_ioctl, SIOCSIFHWADDR, &ifr) < 0)
@@ -913,7 +916,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 = (route->flags & DEVADDR_KERNEL) ? RTPROT_KERNEL : RTPROT_BOOT,
+               .rtm_protocol = (route->flags & DEVADDR_KERNEL) ? RTPROT_KERNEL : RTPROT_STATIC,
                .rtm_scope = scope,
                .rtm_type = (cmd == RTM_DELROUTE) ? 0: RTN_UNICAST,
        };