From patchwork Thu May 15 16:56:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Yasevich X-Patchwork-Id: 349309 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D91A61400D8 for ; Fri, 16 May 2014 02:57:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755028AbaEOQ5U (ORCPT ); Thu, 15 May 2014 12:57:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11778 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754867AbaEOQ5R (ORCPT ); Thu, 15 May 2014 12:57:17 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4FGvEvm008484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 May 2014 12:57:15 -0400 Received: from vyasevic.redhat.com (vpn-50-142.rdu2.redhat.com [10.10.50.142]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4FGv00K015429; Thu, 15 May 2014 12:57:13 -0400 From: Vlad Yasevich To: netdev@vger.kernel.org Cc: bridge@lists.linux-foundation.org, shemminger@vyatta.com, mst@redhat.com, john.r.fastabend@intel.com, jhs@mojatatu.com, Vlad Yasevich Subject: [PATCH v2 net-next 8/8] bridge: Automatically manage promisc mode when vlan filtering is on. Date: Thu, 15 May 2014 12:56:56 -0400 Message-Id: <1400173016-8952-9-git-send-email-vyasevic@redhat.com> In-Reply-To: <1400173016-8952-1-git-send-email-vyasevic@redhat.com> References: <1400173016-8952-1-git-send-email-vyasevic@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If the user doesn't enable vlan filtering, we have to place all bridge ports in promsic mode so that we retain the capability of of receiving tagged frames. When vlan filtering is enabled, the each port will be provided with necessary vlan configuration and would be able to receive tagged traffic without promiscuous mode set, thus allowing us to automatically turn promiscuity on or off depending on the configuration. Signed-off-by: Vlad Yasevich Acked-by: Michael S. Tsirkin --- net/bridge/br_if.c | 12 ++++++++---- net/bridge/br_private.h | 9 +++++++++ net/bridge/br_vlan.c | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 1a3638e..33a83ea 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -131,12 +131,16 @@ static void br_port_clear_promisc(struct net_bridge_port *p) void br_manage_promisc(struct net_bridge *br) { struct net_bridge_port *p; + bool set_all = false; + + /* If vlan filtering is disabled or bridge interface is placed + * into promiscuous mode, place all ports in promiscuous mode. + */ + if ((br->dev->flags & IFF_PROMISC) || !br_vlan_enabled(br)) + set_all = true; list_for_each_entry(p, &br->port_list, list) { - if (br->dev->flags & IFF_PROMISC) { - /* PROMISC flag has been turned on for the bridge - * itself. Turn on promisc on all ports. - */ + if (set_all) { br_port_set_promisc(p); } else { /* If the number of auto-ports is <= 1, then all other diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 06976af..2b2286d 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -642,6 +642,10 @@ static inline u16 br_get_pvid(const struct net_port_vlans *v) return v->pvid ?: VLAN_N_VID; } +static inline int br_vlan_enabled(struct net_bridge *br) +{ + return br->vlan_enabled; +} #else static inline bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v, @@ -722,6 +726,11 @@ static inline u16 br_get_pvid(const struct net_port_vlans *v) { return VLAN_N_VID; /* Returns invalid vid */ } + +static inline int br_vlan_enabled(struct net_bridge *br); +{ + return 0; +} #endif /* br_netfilter.c */ diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index 4a37161..24c5cc5 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -332,6 +332,7 @@ int br_vlan_filter_toggle(struct net_bridge *br, unsigned long val) goto unlock; br->vlan_enabled = val; + br_manage_promisc(br); unlock: rtnl_unlock();