From: Felix Fietkau Date: Tue, 13 Mar 2018 11:52:43 +0000 (+0100) Subject: device: add support for setting the isolate options for bridge ports X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c06f84238952211b35c2940a82fcce3fcc3221c1;p=oweals%2Fnetifd.git device: add support for setting the isolate options for bridge ports Signed-off-by: Felix Fietkau --- diff --git a/device.c b/device.c index ad470c9..09998f4 100644 --- a/device.c +++ b/device.c @@ -57,6 +57,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_UNICAST_FLOOD] = { .name ="unicast_flood", .type = BLOBMSG_TYPE_BOOL }, [DEV_ATTR_SENDREDIRECTS] = { .name = "sendredirects", .type = BLOBMSG_TYPE_BOOL }, [DEV_ATTR_NEIGHLOCKTIME] = { .name = "neighlocktime", .type = BLOBMSG_TYPE_INT32 }, + [DEV_ATTR_ISOLATE] = { .name = "isolate", .type = BLOBMSG_TYPE_BOOL }, }; const struct uci_blob_param_list device_attr_list = { @@ -362,6 +363,11 @@ device_init_settings(struct device *dev, struct blob_attr **tb) s->flags |= DEV_OPT_SENDREDIRECTS; } + if ((cur = tb[DEV_ATTR_ISOLATE])) { + s->isolate = blobmsg_get_bool(cur); + s->flags |= DEV_OPT_ISOLATE; + } + device_set_disabled(dev, disabled); } diff --git a/device.h b/device.h index dc45967..84acf52 100644 --- a/device.h +++ b/device.h @@ -50,6 +50,7 @@ enum { DEV_ATTR_NEIGHGCSTALETIME, DEV_ATTR_SENDREDIRECTS, DEV_ATTR_NEIGHLOCKTIME, + DEV_ATTR_ISOLATE, __DEV_ATTR_MAX, }; @@ -102,6 +103,7 @@ enum { DEV_OPT_MULTICAST_FAST_LEAVE = (1 << 20), DEV_OPT_SENDREDIRECTS = (1 << 21), DEV_OPT_NEIGHLOCKTIME = (1 << 22), + DEV_OPT_ISOLATE = (1 << 23), }; /* events broadcasted to all users of a device */ @@ -168,6 +170,7 @@ struct device_settings { bool learning; bool unicast_flood; bool sendredirects; + bool isolate; }; /* diff --git a/system-linux.c b/system-linux.c index 4f3b9b0..0ca5256 100644 --- a/system-linux.c +++ b/system-linux.c @@ -346,6 +346,11 @@ static void system_bridge_set_hairpin_mode(struct device *dev, const char *val) system_set_dev_sysctl("/sys/class/net/%s/brport/hairpin_mode", dev->ifname, val); } +static void system_bridge_set_isolate_mode(struct device *dev, const char *val) +{ + system_set_dev_sysctl("/sys/class/net/%s/brport/isolate_mode", dev->ifname, val); +} + static void system_bridge_set_multicast_router(struct device *dev, const char *val, bool bridge) { system_set_dev_sysctl(bridge ? "/sys/class/net/%s/bridge/multicast_router" : @@ -748,6 +753,10 @@ int system_bridge_addif(struct device *bridge, struct device *dev) !dev->settings.unicast_flood) system_bridge_set_unicast_flood(dev, "0"); + if (dev->settings.flags & DEV_OPT_ISOLATE && + dev->settings.isolate) + system_bridge_set_isolate_mode(dev, "1"); + return ret; }