netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] bridge: skip fdb add if the port shouldn't learn
@ 2015-05-21 10:42 Nikolay Aleksandrov
  2015-05-25  2:59 ` David Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Nikolay Aleksandrov @ 2015-05-21 10:42 UTC (permalink / raw)
  To: netdev; +Cc: wkok, davem, stephen, bridge, Nikolay Aleksandrov

From: Wilson Kok <wkok@cumulusnetworks.com>

Check in fdb_add_entry() if the source port should learn, similar
check is used in br_fdb_update.
Note that new fdb entries which are added manually or
as local ones are still permitted.
This patch has been tested by running traffic via a bridge port and
switching the port's state, also by manually adding/removing entries
from the bridge's fdb.

Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
Nik: Maybe it'd be better if we returned an error even though it
     doesn't look necessary. I'm open to suggestions.

 net/bridge/br_fdb.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index e0670d7054f9..27de0b7bd76b 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -736,6 +736,12 @@ static int fdb_add_entry(struct net_bridge_port *source, const __u8 *addr,
 	struct net_bridge_fdb_entry *fdb;
 	bool modified = false;
 
+	/* If the port cannot learn allow only local and static entries */
+	if (!(state & NUD_PERMANENT) && !(state & NUD_NOARP) &&
+	    !(source->state == BR_STATE_LEARNING ||
+	      source->state == BR_STATE_FORWARDING))
+		return 0;
+
 	fdb = fdb_find(head, addr, vid);
 	if (fdb == NULL) {
 		if (!(flags & NLM_F_CREATE))
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-06-04  8:14 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-21 10:42 [PATCH net-next] bridge: skip fdb add if the port shouldn't learn Nikolay Aleksandrov
2015-05-25  2:59 ` David Miller
2015-05-25 11:35   ` Nikolay Aleksandrov
2015-05-25 11:41   ` Nikolay Aleksandrov
2015-05-25 13:39 ` [PATCH net-next v2] " Nikolay Aleksandrov
2015-05-26 17:28 ` [PATCH net-next] " Stephen Hemminger
2015-05-27  7:05   ` Nikolay Aleksandrov
2015-05-27  7:59     ` Scott Feldman
2015-05-27  8:35       ` Nikolay Aleksandrov
2015-05-27 16:01         ` Scott Feldman
2015-05-27 16:14           ` Nikolay Aleksandrov
2015-05-27 20:41             ` Scott Feldman
2015-06-02 17:14           ` roopa
2015-06-03  5:57             ` Scott Feldman
2015-06-04  8:14               ` Nikolay Aleksandrov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).