summaryrefslogtreecommitdiffhomepage
path: root/device.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2014-04-07 13:30:52 +0200
committerFelix Fietkau <nbd@openwrt.org>2014-04-26 21:44:19 +0200
commit98ca67469da70accd710b14c28e77be2126170a8 (patch)
tree3cc649f08f9743fff2f8367dee74162ed30ace96 /device.c
parent08d35c7a59a182b9ef05d95ca3c583806b2ba924 (diff)
netifd: Add interface config support to enable/disable IPv6 in the kernel per device
Main use case is being able to disable IPv6 on (a) WAN interface(s) when only IPv4 connectivity is offered or 6rd is used. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'device.c')
-rw-r--r--device.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/device.c b/device.c
index 2fb68d7..f484c28 100644
--- a/device.c
+++ b/device.c
@@ -37,6 +37,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
[DEV_ATTR_MACADDR] = { .name = "macaddr", .type = BLOBMSG_TYPE_STRING },
[DEV_ATTR_TXQUEUELEN] = { .name = "txqueuelen", .type = BLOBMSG_TYPE_INT32 },
[DEV_ATTR_ENABLED] = { .name = "enabled", .type = BLOBMSG_TYPE_BOOL },
+ [DEV_ATTR_IPV6] = { .name = "ipv6", .type = BLOBMSG_TYPE_BOOL },
};
const struct uci_blob_param_list device_attr_list = {
@@ -139,6 +140,7 @@ device_merge_settings(struct device *dev, struct device_settings *n)
memcpy(n->macaddr,
(s->flags & DEV_OPT_MACADDR ? s->macaddr : os->macaddr),
sizeof(n->macaddr));
+ n->ipv6 = s->flags & DEV_OPT_IPV6 ? s->ipv6 : os->ipv6;
n->flags = s->flags | os->flags;
}
@@ -172,6 +174,11 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
}
}
+ if ((cur = tb[DEV_ATTR_IPV6])) {
+ s->ipv6 = blobmsg_get_bool(cur);
+ s->flags |= DEV_OPT_IPV6;
+ }
+
device_set_disabled(dev, disabled);
}
@@ -705,6 +712,8 @@ device_dump_status(struct blob_buf *b, struct device *dev)
blobmsg_add_string(b, "macaddr", format_macaddr(st.macaddr));
if (st.flags & DEV_OPT_TXQUEUELEN)
blobmsg_add_u32(b, "txqueuelen", st.txqueuelen);
+ if (st.flags & DEV_OPT_IPV6)
+ blobmsg_add_u8(b, "ipv6", st.ipv6);
}
s = blobmsg_open_table(b, "statistics");