summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-10-20 19:20:43 +0200
committerFelix Fietkau <nbd@openwrt.org>2011-10-20 19:20:43 +0200
commitfb0e4138070d7c2ce723af5780e763af3a1353d8 (patch)
tree4458bc84043b3ea181a33ce2028bd058abb57abb
parentcd6ff76cf1ae89d1148c3399b725103a144aca3e (diff)
downloadnetifd-fb0e4138070d7c2ce723af5780e763af3a1353d8.tar.gz
do not clear device state for devices created by proto-up with address-external set
-rw-r--r--device.c9
-rw-r--r--device.h3
-rw-r--r--proto-shell.c12
-rw-r--r--system-linux.c3
4 files changed, 18 insertions, 9 deletions
diff --git a/device.c b/device.c
index 717993a..428d001 100644
--- a/device.c
+++ b/device.c
@@ -308,12 +308,13 @@ int device_init(struct device *dev, const struct device_type *type, const char *
}
static struct device *
-device_create_default(const char *name)
+device_create_default(const char *name, bool external)
{
struct device *dev;
D(DEVICE, "Create simple device '%s'\n", name);
dev = calloc(1, sizeof(*dev));
+ dev->external = external;
device_init(dev, &simple_device_type, name);
dev->default_config = true;
return dev;
@@ -332,7 +333,7 @@ device_alias_get(const char *name)
}
struct device *
-device_get(const char *name, bool create)
+device_get(const char *name, int create)
{
struct device *dev;
@@ -349,7 +350,7 @@ device_get(const char *name, bool create)
if (!create)
return NULL;
- return device_create_default(name);
+ return device_create_default(name, create > 1);
}
static void
@@ -527,7 +528,7 @@ device_reset_old(void)
if (dev->type != &simple_device_type)
continue;
- ndev = device_create_default(dev->ifname);
+ ndev = device_create_default(dev->ifname, dev->external);
device_replace(ndev, dev);
}
}
diff --git a/device.h b/device.h
index 3d233d7..057506b 100644
--- a/device.h
+++ b/device.h
@@ -62,6 +62,7 @@ struct device {
bool config_pending;
bool present;
int active;
+ bool external;
bool current_config;
bool default_config;
@@ -133,7 +134,7 @@ void device_reset_old(void);
void device_init_virtual(struct device *dev, const struct device_type *type, const char *name);
int device_init(struct device *iface, const struct device_type *type, const char *ifname);
void device_cleanup(struct device *iface);
-struct device *device_get(const char *name, bool create);
+struct device *device_get(const char *name, int create);
void device_add_user(struct device_user *dep, struct device *iface);
void device_remove_user(struct device_user *dep);
diff --git a/proto-shell.c b/proto-shell.c
index 9ad28ac..a22c0e3 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -242,6 +242,7 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr **tb)
{
struct interface_ip_settings *ip;
struct blob_attr *cur;
+ int dev_create = 1;
bool addr_ext = false;
bool up;
@@ -254,6 +255,12 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr **tb)
return 0;
}
+ if ((cur = tb[NOTIFY_ADDR_EXT]) != NULL) {
+ addr_ext = blobmsg_get_bool(cur);
+ if (addr_ext)
+ dev_create = 2;
+ }
+
if (!tb[NOTIFY_IFNAME]) {
if (!state->proto.iface->main_dev.dev)
return UBUS_STATUS_INVALID_ARGUMENT;
@@ -262,7 +269,7 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr **tb)
device_remove_user(&state->l3_dev);
device_add_user(&state->l3_dev,
- device_get(blobmsg_data(tb[NOTIFY_IFNAME]), true));
+ device_get(blobmsg_data(tb[NOTIFY_IFNAME]), dev_create));
state->proto.iface->l3_dev = &state->l3_dev;
device_claim(&state->l3_dev);
}
@@ -270,9 +277,6 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr **tb)
ip = &state->proto.iface->proto_ip;
interface_update_start(state->proto.iface);
- if ((cur = tb[NOTIFY_ADDR_EXT]) != NULL)
- addr_ext = blobmsg_get_bool(cur);
-
if ((cur = tb[NOTIFY_IPADDR]) != NULL)
proto_shell_parse_addr_list(ip, cur, false, addr_ext);
diff --git a/system-linux.c b/system-linux.c
index 2a85b28..44332a2 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -370,6 +370,9 @@ void system_if_clear_state(struct device *dev)
char buf[256];
char *bridge;
+ if (dev->external)
+ return;
+
dev->ifindex = system_if_resolve(dev);
if (!dev->ifindex)
return;