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 {