interface: enable force_link by default for proto=static
authorFelix Fietkau <nbd@openwrt.org>
Sun, 27 Jul 2014 11:21:22 +0000 (13:21 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 27 Jul 2014 11:21:22 +0000 (13:21 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
interface.c
proto-static.c
proto.h

index e66b58a1da658b876f1af4a939592f4924f2396e..ed6095936700e0cd35c4c91779822bd73769f5e2 100644 (file)
@@ -652,6 +652,7 @@ interface_alloc(const char *name, struct blob_attr *config)
        struct blob_attr *cur;
        const char *proto_name = NULL;
        char *iface_name;
+       bool force_link = false;
 
        iface = calloc_a(sizeof(*iface), &iface_name, strlen(name) + 1);
        iface->name = strcpy(iface_name, name);
@@ -673,9 +674,11 @@ interface_alloc(const char *name, struct blob_attr *config)
                proto_name = blobmsg_data(cur);
 
        proto_attach_interface(iface, proto_name);
+       if (iface->proto_handler->flags & PROTO_FLAG_FORCE_LINK_DEFAULT)
+               force_link = true;
 
        iface->autostart = blobmsg_get_bool_default(tb[IFACE_ATTR_AUTO], true);
-       iface->force_link = blobmsg_get_bool_default(tb[IFACE_ATTR_FORCE_LINK], false);
+       iface->force_link = blobmsg_get_bool_default(tb[IFACE_ATTR_FORCE_LINK], force_link);
        iface->proto_ip.no_defaultroute =
                !blobmsg_get_bool_default(tb[IFACE_ATTR_DEFAULTROUTE], true);
        iface->proto_ip.no_dns =
index 51e20836e55db23083cc847122ad1fbda6c1e5f4..3e33c3d872930d08b9e1bef907afa14c0db7507c 100644 (file)
@@ -100,7 +100,8 @@ error:
 
 static struct proto_handler static_proto = {
        .name = "static",
-       .flags = PROTO_FLAG_IMMEDIATE,
+       .flags = PROTO_FLAG_IMMEDIATE |
+                PROTO_FLAG_FORCE_LINK_DEFAULT,
        .config_params = &proto_ip_attr,
        .attach = static_attach,
 };
diff --git a/proto.h b/proto.h
index e7d84ac057e98832f142253045e8bc6ccab8bc2c..7210f4850319d6e3b694e4c437284d5dd984eff9 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -36,6 +36,7 @@ enum {
        PROTO_FLAG_NODEV = (1 << 1),
        PROTO_FLAG_INIT_AVAILABLE = (1 << 2),
        PROTO_FLAG_RENEW_AVAILABLE = (1 << 3),
+       PROTO_FLAG_FORCE_LINK_DEFAULT = (1 << 4),
 };
 
 struct interface_proto_state {