From patchwork Sun Jul 12 16:50:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 1327564 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=phrozen.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=HIaHHCT9; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B4Xql3sVHz9sRK for ; Mon, 13 Jul 2020 02:51:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=513sJ6UIUrKMXPe/h97vS/uAyPgaEv0M71XKoTDDxdo=; b=HIaHHCT9u3sBNasPLTbVaBtNE DFuemLUUZpjObWE1BtPkJBXaREwyU+RPmySzjUsvYT0KY43y8Lkz0k3OAfbxxlEetn8zuvPROqwXa hlktEM3iSeOirvnescPJ+OE+Adpr7VeWVW4GgXCBeJQJZrsPCFfVq70XjhU9vvely2XY63N6PugRd NokJuCdXhS4HfhGVV2s16C+V5ESM7YPhT4lAhQHRF8giQnwr/2IzvVujspdz+OpekgSA3CJyR6dFP KJxt50AUUAYkqgrGvVXWXvqpbJoEPPJN+bcdLhJfpUk/7KCU8LuI38ie2wA8hLOU7DxkyOLA2wYMf LRKMi8Ntw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jufBU-00029n-47; Sun, 12 Jul 2020 16:50:36 +0000 Received: from nbd.name ([2a01:4f8:221:3d45::2]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jufBN-00027z-VW for openwrt-devel@lists.openwrt.org; Sun, 12 Jul 2020 16:50:31 +0000 Received: from [84.242.30.208] (helo=bertha9.lan) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1jufBJ-0007By-V3; Sun, 12 Jul 2020 18:50:26 +0200 From: John Crispin To: openwrt-devel@lists.openwrt.org Subject: [PATCH 1/3] bridge: allow turning on vlan_filtering Date: Sun, 12 Jul 2020 18:50:18 +0200 Message-Id: <20200712165020.249741-2-john@phrozen.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200712165020.249741-1-john@phrozen.org> References: <20200712165020.249741-1-john@phrozen.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200712_125030_235599_23D83974 X-CRM114-Status: GOOD ( 13.41 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Crispin Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org If we want a bridge to be vlan aware we need to be able to turn on filtering. Signed-off-by: John Crispin --- bridge.c | 6 ++++++ system-linux.c | 6 ++++++ system.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/bridge.c b/bridge.c index c1f4ffa..e4ec597 100644 --- a/bridge.c +++ b/bridge.c @@ -38,6 +38,7 @@ enum { BRIDGE_ATTR_QUERY_INTERVAL, BRIDGE_ATTR_QUERY_RESPONSE_INTERVAL, BRIDGE_ATTR_LAST_MEMBER_INTERVAL, + BRIDGE_ATTR_VLAN_FILTERING, __BRIDGE_ATTR_MAX }; @@ -57,6 +58,7 @@ static const struct blobmsg_policy bridge_attrs[__BRIDGE_ATTR_MAX] = { [BRIDGE_ATTR_QUERY_INTERVAL] = { "query_interval", BLOBMSG_TYPE_INT32 }, [BRIDGE_ATTR_QUERY_RESPONSE_INTERVAL] = { "query_response_interval", BLOBMSG_TYPE_INT32 }, [BRIDGE_ATTR_LAST_MEMBER_INTERVAL] = { "last_member_interval", BLOBMSG_TYPE_INT32 }, + [BRIDGE_ATTR_VLAN_FILTERING] = { "vlan_filtering", BLOBMSG_TYPE_BOOL }, }; static const struct uci_blob_param_info bridge_attr_info[__BRIDGE_ATTR_MAX] = { @@ -577,6 +579,7 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb) cfg->hash_max = 512; cfg->bridge_empty = false; cfg->priority = 0x7FFF; + cfg->vlan_filtering = false; if ((cur = tb[BRIDGE_ATTR_STP])) cfg->stp = blobmsg_get_bool(cur); @@ -633,6 +636,9 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb) if ((cur = tb[BRIDGE_ATTR_BRIDGE_EMPTY])) cfg->bridge_empty = blobmsg_get_bool(cur); + + if ((cur = tb[BRIDGE_ATTR_VLAN_FILTERING])) + cfg->vlan_filtering = blobmsg_get_bool(cur); } static enum dev_change_type diff --git a/system-linux.c b/system-linux.c index 3b09bbb..97b38e7 100644 --- a/system-linux.c +++ b/system-linux.c @@ -470,6 +470,11 @@ static void system_set_sendredirects(struct device *dev, const char *val) system_set_dev_sysctl("/proc/sys/net/ipv4/conf/%s/send_redirects", dev->ifname, val); } +static void system_bridge_set_vlan_filtering(struct device *dev, const char *val) +{ + system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/vlan_filtering", dev->ifname, val); +} + static int system_get_sysctl(const char *path, char *buf, const size_t buf_sz) { int fd = -1, ret = -1; @@ -1170,6 +1175,7 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg) system_bridge_set_forward_delay(bridge, buf); system_bridge_conf_multicast(bridge, cfg, buf, sizeof(buf)); + system_bridge_set_vlan_filtering(bridge, cfg->vlan_filtering ? "1" : "0"); snprintf(buf, sizeof(buf), "%d", cfg->priority); system_bridge_set_priority(bridge, buf); diff --git a/system.h b/system.h index 252fd92..258b1af 100644 --- a/system.h +++ b/system.h @@ -127,6 +127,8 @@ struct bridge_config { int hello_time; int max_age; int hash_max; + + bool vlan_filtering; }; enum macvlan_opt { From patchwork Sun Jul 12 16:50:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 1327563 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=phrozen.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=nlxSILTQ; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B4Xql31clz9sR4 for ; Mon, 13 Jul 2020 02:51:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8DMJcrgfSHPJB6ZqW8340zuQgrEsmLljyQZYcjgXo0U=; b=nlxSILTQaGC5t/Q8mFZuX+uwk BbSNZsyGTRPnebm0V261HnJ8iGvNM4XaZeQQcplB0cCAsrlQANFs3PTlpaXG+UX+mRjVUYp27lcau X7BHvjs++p3SMDFF55vnFY3GJ/N+r3V8rEpH2UHECCofoFpYdaijzRQYn/e/OoIz/tO1GqvHoiljm jOGwwQsRD0UBZxltrp+5t8ybhiD95muPOh4oeGmv8qLMPHfMEqsqbUSTVXXhZqskE8gJScKBP5vC7 whTBvOTt7xbNtKDVGN0ntaYSsIMgzWZPIPYto7fIae+2S7+EFuT7FDCHn6yOu9wcqXd24tPjZexen 491ceJFnw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jufBR-00029N-Kt; Sun, 12 Jul 2020 16:50:33 +0000 Received: from nbd.name ([2a01:4f8:221:3d45::2]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jufBN-000281-US for openwrt-devel@lists.openwrt.org; Sun, 12 Jul 2020 16:50:31 +0000 Received: from [84.242.30.208] (helo=bertha9.lan) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1jufBK-0007By-9p; Sun, 12 Jul 2020 18:50:26 +0200 From: John Crispin To: openwrt-devel@lists.openwrt.org Subject: [PATCH 2/3] bridge: allow adding vlans to a bridge Date: Sun, 12 Jul 2020 18:50:19 +0200 Message-Id: <20200712165020.249741-3-john@phrozen.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200712165020.249741-1-john@phrozen.org> References: <20200712165020.249741-1-john@phrozen.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200712_125030_094992_55C608FA X-CRM114-Status: GOOD ( 12.98 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Crispin Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Add a rtnl helper for adding vlans to a bridge interface. Signed-off-by: John Crispin --- system-linux.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ system.h | 1 + 2 files changed, 49 insertions(+) diff --git a/system-linux.c b/system-linux.c index 97b38e7..130d057 100644 --- a/system-linux.c +++ b/system-linux.c @@ -854,6 +854,54 @@ int system_bridge_delif(struct device *bridge, struct device *dev) return system_bridge_if(bridge->ifname, dev, SIOCBRDELIF, NULL); } +int system_bridge_vlan(const char *iface, int pvid, int vid, int tagged, + int self, int add) +{ + struct ifinfomsg ifi = { .ifi_family = PF_BRIDGE, }; + struct bridge_vlan_info vinfo = { .vid = vid, }; + unsigned short flags = 0; + struct nlattr *afspec; + struct nl_msg *nlm; + int ret = 0; + + ifi.ifi_index = if_nametoindex(iface); + if (!ifi.ifi_index) + return -1; + + nlm = nlmsg_alloc_simple(add ? RTM_SETLINK : RTM_DELLINK, NLM_F_REQUEST); + if (!nlm) + return -1; + + nlmsg_append(nlm, &ifi, sizeof(ifi), 0); + + if (self) + flags |= BRIDGE_FLAGS_SELF; + + if (pvid) + vinfo.flags |= BRIDGE_VLAN_INFO_PVID; + + if (!tagged) + vinfo.flags |= BRIDGE_VLAN_INFO_UNTAGGED; + + afspec = nla_nest_start(nlm, IFLA_AF_SPEC); + if (!afspec) { + ret = -ENOMEM; + goto failure; + } + + if (flags) + nla_put_u16(nlm, IFLA_BRIDGE_FLAGS, flags); + + nla_put(nlm, IFLA_BRIDGE_VLAN_INFO, sizeof(vinfo), &vinfo); + nla_nest_end(nlm, afspec); + + return system_rtnl_call(nlm); + +failure: + nlmsg_free(nlm); + return ret; +} + int system_if_resolve(struct device *dev) { struct ifreq ifr; diff --git a/system.h b/system.h index 258b1af..6a7f738 100644 --- a/system.h +++ b/system.h @@ -196,6 +196,7 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg); int system_bridge_delbr(struct device *bridge); int system_bridge_addif(struct device *bridge, struct device *dev); int system_bridge_delif(struct device *bridge, struct device *dev); +int system_bridge_vlan(const char *iface, int pvid, int vid, int tagged, int self, int add); int system_macvlan_add(struct device *macvlan, struct device *dev, struct macvlan_config *cfg); int system_macvlan_del(struct device *macvlan); From patchwork Sun Jul 12 16:50:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 1327566 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=phrozen.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=JqJPXf32; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B4Xqp3X52z9sR4 for ; Mon, 13 Jul 2020 02:51:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pG5MZOWBvPB8sMYS8P+Utme3VK8kjZAHWWKJSxxxbPo=; b=JqJPXf32Mb/Qc1f5GUSp+/GuS Vt94fKZsnc6sAp4cX90iPX7vIaxv3DCRmJRb289Gy4zEkSycS1VtlC1+OSfcL+ncgtHew0yfspV7F IJPeCJBy/vo/M36xFq5igU8z3nTDqeZB56J2RwRsRvAA3Y6/uP3WjaYjM63xo8EK8diIjTX5IKlHU dyjOOJbzRo3zgkKyfntWqXKHDk7rf5MG23d9fQ+x4WM7KqndKBrjFU5alWcFknWivqtWMLov1qXce 3FNCvyvF5L6KF5Ug0ZuTYl1y2gKlJ31reOOtG71wnmcy3EzS4YuocJb9j7qJFEAVOhEihKSF40++T cS5xnCcpA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jufBV-0002A9-Ra; Sun, 12 Jul 2020 16:50:37 +0000 Received: from nbd.name ([2a01:4f8:221:3d45::2]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jufBN-000282-Uy for openwrt-devel@lists.openwrt.org; Sun, 12 Jul 2020 16:50:32 +0000 Received: from [84.242.30.208] (helo=bertha9.lan) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1jufBK-0007By-IJ; Sun, 12 Jul 2020 18:50:26 +0200 From: John Crispin To: openwrt-devel@lists.openwrt.org Subject: [PATCH 3/3] wireless: allow adding bridge vlans Date: Sun, 12 Jul 2020 18:50:20 +0200 Message-Id: <20200712165020.249741-4-john@phrozen.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200712165020.249741-1-john@phrozen.org> References: <20200712165020.249741-1-john@phrozen.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200712_125030_248813_092AC831 X-CRM114-Status: GOOD ( 13.22 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Crispin Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org An AP/Vlan will only have a virtual 802.1q tag. Add code to make the bridge add the define vid and take care of possibly tagging when the packet leaves the bridge. Signed-off-by: John Crispin --- wireless.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ wireless.h | 4 ++++ 2 files changed, 53 insertions(+) diff --git a/wireless.c b/wireless.c index efb7992..0596b59 100644 --- a/wireless.c +++ b/wireless.c @@ -16,6 +16,7 @@ #include "wireless.h" #include "handler.h" #include "ubus.h" +#include "system.h" #define WIRELESS_SETUP_RETRY 3 @@ -49,6 +50,8 @@ enum { VIF_ATTR_NETWORK, VIF_ATTR_ISOLATE, VIF_ATTR_MODE, + VIF_ATTR_VID, + VIF_ATTR_UNTAG, __VIF_ATTR_MAX, }; @@ -57,6 +60,8 @@ static const struct blobmsg_policy vif_policy[__VIF_ATTR_MAX] = { [VIF_ATTR_NETWORK] = { .name = "network", .type = BLOBMSG_TYPE_ARRAY }, [VIF_ATTR_ISOLATE] = { .name = "isolate", .type = BLOBMSG_TYPE_BOOL }, [VIF_ATTR_MODE] = { .name = "mode", .type = BLOBMSG_TYPE_STRING }, + [VIF_ATTR_VID] = { .name = "vid", .type = BLOBMSG_TYPE_INT32 }, + [VIF_ATTR_UNTAG] = { .name = "vlan_untag", .type = BLOBMSG_TYPE_BOOL }, }; static const struct uci_blob_param_list vif_param = { @@ -68,6 +73,8 @@ enum { VLAN_ATTR_DISABLED, VLAN_ATTR_NETWORK, VLAN_ATTR_ISOLATE, + VLAN_ATTR_VID, + VLAN_ATTR_UNTAG, __VLAN_ATTR_MAX, }; @@ -75,6 +82,8 @@ static const struct blobmsg_policy vlan_policy[__VLAN_ATTR_MAX] = { [VLAN_ATTR_DISABLED] = { .name = "disabled", .type = BLOBMSG_TYPE_BOOL }, [VLAN_ATTR_NETWORK] = { .name = "network", .type = BLOBMSG_TYPE_ARRAY }, [VLAN_ATTR_ISOLATE] = { .name = "isolate", .type = BLOBMSG_TYPE_BOOL }, + [VLAN_ATTR_VID] = { .name = "vid", .type = BLOBMSG_TYPE_INT32 }, + [VLAN_ATTR_UNTAG] = { .name = "vlan_untag", .type = BLOBMSG_TYPE_BOOL }, }; static const struct uci_blob_param_list vlan_param = { @@ -313,6 +322,8 @@ static void wireless_interface_handle_link(struct wireless_interface *vif, bool } blobmsg_for_each_attr(cur, vif->network, rem) { + struct device *bridge; + network = blobmsg_data(cur); iface = vlist_find(&interfaces, network, iface, node); @@ -320,6 +331,16 @@ static void wireless_interface_handle_link(struct wireless_interface *vif, bool continue; interface_handle_link(iface, vif->ifname, up, true); + + if (!vif->vid) + continue; + + bridge = device_get(iface->ifname, 0); + if (!bridge || !bridge->type->bridge_capability) + continue; + + system_bridge_vlan(vif->ifname, 1, vif->vid, 0, 0, 1); + system_bridge_vlan(iface->ifname, 0, vif->vid, !vif->untag, 1, 1); } } @@ -343,6 +364,8 @@ static void wireless_vlan_handle_link(struct wireless_vlan *vlan, bool up) } blobmsg_for_each_attr(cur, vlan->network, rem) { + struct device *bridge; + network = blobmsg_data(cur); iface = vlist_find(&interfaces, network, iface, node); @@ -350,6 +373,16 @@ static void wireless_vlan_handle_link(struct wireless_vlan *vlan, bool up) continue; interface_handle_link(iface, vlan->ifname, up, true); + + if (!vlan->vid) + continue; + + bridge = device_get(iface->ifname, 0); + if (!bridge || !bridge->type->bridge_capability) + continue; + + system_bridge_vlan(vlan->ifname, 1, vlan->vid, 0, 0, 1); + system_bridge_vlan(iface->ifname, 0, vlan->vid, !vlan->untag, 1, 1); } } @@ -767,6 +800,14 @@ wireless_interface_init_config(struct wireless_interface *vif) cur = tb[VIF_ATTR_MODE]; if (cur) vif->ap_mode = !strcmp(blobmsg_get_string(cur), "ap"); + + cur = tb[VIF_ATTR_UNTAG]; + if (cur) + vif->untag = blobmsg_get_bool(cur); + + cur = tb[VIF_ATTR_VID]; + if (cur) + vif->vid = blobmsg_get_u32(cur); } static void @@ -829,6 +870,14 @@ wireless_vlan_init_config(struct wireless_vlan *vlan) cur = tb[VLAN_ATTR_ISOLATE]; if (cur) vlan->isolate = blobmsg_get_bool(cur); + + cur = tb[VLAN_ATTR_UNTAG]; + if (cur) + vlan->untag = blobmsg_get_bool(cur); + + cur = tb[VLAN_ATTR_VID]; + if (cur) + vlan->vid = blobmsg_get_u32(cur); } static void diff --git a/wireless.h b/wireless.h index 5fedd20..2160451 100644 --- a/wireless.h +++ b/wireless.h @@ -90,6 +90,8 @@ struct wireless_interface { struct blob_attr *network; bool isolate; bool ap_mode; + bool untag; + int vid; }; struct wireless_vlan { @@ -106,6 +108,8 @@ struct wireless_vlan { const char *ifname; struct blob_attr *network; bool isolate; + bool untag; + int vid; }; struct wireless_station {