netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlad Yasevich <vyasevic@redhat.com>
To: netdev@vger.kernel.org
Cc: bridge@lists.linux-foundation.org, mst@redhat.com,
	Vlad Yasevich <vyasevic@redhat.com>
Subject: [PATCH v2 net-next 4/6] bridge: Allow user to program hw addresses to uplink devices.
Date: Fri, 19 Apr 2013 16:52:48 -0400	[thread overview]
Message-ID: <1366404770-28523-5-git-send-email-vyasevic@redhat.com> (raw)
In-Reply-To: <1366404770-28523-1-git-send-email-vyasevic@redhat.com>

Add support to bridge fdb handling to program hw addresses to the
bridge master device which will sync them to uplink devices.
The use sets a new flag in the ndmsg structure to say that
a given address should be added to or removed from uplinks.

Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
 include/uapi/linux/neighbour.h |    6 ++--
 net/bridge/br_fdb.c            |   50 ++++++++++++++++++++++++++++------------
 net/core/rtnetlink.c           |    4 +-
 3 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/include/uapi/linux/neighbour.h b/include/uapi/linux/neighbour.h
index f175212..fd1587d 100644
--- a/include/uapi/linux/neighbour.h
+++ b/include/uapi/linux/neighbour.h
@@ -34,11 +34,11 @@ enum {
  */
 
 #define NTF_USE		0x01
-#define NTF_PROXY	0x08	/* == ATF_PUBL */
-#define NTF_ROUTER	0x80
-
 #define NTF_SELF	0x02
 #define NTF_MASTER	0x04
+#define NTF_PROXY	0x08	/* == ATF_PUBL */
+#define NTF_UPLINK	0x10
+#define NTF_ROUTER	0x80
 
 /*
  *	Neighbor Cache Entry States.
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index c581f12..5585e00 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -671,7 +671,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 	       const unsigned char *addr, u16 nlh_flags)
 {
 	struct net_bridge_port *p;
-	int err = 0;
+	int err = -EINVAL;
 	struct net_port_vlans *pv;
 	unsigned short vid = VLAN_N_VID;
 
@@ -680,6 +680,16 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 		return -EINVAL;
 	}
 
+	p = br_port_get_rtnl(dev);
+	if (p == NULL) {
+		pr_info("bridge: RTM_NEWNEIGH %s not a bridge port\n",
+			dev->name);
+		return -EINVAL;
+	}
+
+	if (is_multicast_ether_addr(addr))
+		goto uplink;
+
 	if (tb[NDA_VLAN]) {
 		if (nla_len(tb[NDA_VLAN]) != sizeof(unsigned short)) {
 			pr_info("bridge: RTM_NEWNEIGH with invalid vlan\n");
@@ -695,13 +705,6 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 		}
 	}
 
-	p = br_port_get_rtnl(dev);
-	if (p == NULL) {
-		pr_info("bridge: RTM_NEWNEIGH %s not a bridge port\n",
-			dev->name);
-		return -EINVAL;
-	}
-
 	pv = nbp_get_vlan_info(p);
 	if (vid != VLAN_N_VID) {
 		if (!pv || !test_bit(vid, pv->vlan_bitmap)) {
@@ -729,6 +732,13 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 		}
 	}
 
+uplink:
+	/* Check to see if  the user requested this address be added to
+	 * uplink
+	 */
+	if (ndm->ndm_flags & NTF_UPLINK)
+		err = ndo_dflt_fdb_add(ndm, tb, p->br->dev, addr, nlh_flags);
+
 out:
 	return err;
 }
@@ -765,10 +775,20 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
 		  const unsigned char *addr)
 {
 	struct net_bridge_port *p;
-	int err;
+	int err = -EINVAL;
 	struct net_port_vlans *pv;
 	unsigned short vid = VLAN_N_VID;
 
+	p = br_port_get_rtnl(dev);
+	if (p == NULL) {
+		pr_info("bridge: RTM_DELNEIGH %s not a bridge port\n",
+			dev->name);
+		return -EINVAL;
+	}
+
+	if (is_multicast_ether_addr(addr))
+		goto uplink;
+
 	if (tb[NDA_VLAN]) {
 		if (nla_len(tb[NDA_VLAN]) != sizeof(unsigned short)) {
 			pr_info("bridge: RTM_NEWNEIGH with invalid vlan\n");
@@ -783,12 +803,6 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
 			return -EINVAL;
 		}
 	}
-	p = br_port_get_rtnl(dev);
-	if (p == NULL) {
-		pr_info("bridge: RTM_DELNEIGH %s not a bridge port\n",
-			dev->name);
-		return -EINVAL;
-	}
 
 	pv = nbp_get_vlan_info(p);
 	if (vid != VLAN_N_VID) {
@@ -814,6 +828,12 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
 			err &= __br_fdb_delete(p, addr, vid);
 		}
 	}
+uplink:
+	/* Check to see if  the user requested this address be removed
+	 * from uplink
+	 */
+	if (ndm->ndm_flags & NTF_UPLINK)
+		err = ndo_dflt_fdb_del(ndm, tb, p->br->dev, addr);
 out:
 	return err;
 }
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 589d0ab..1d3c223 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2042,7 +2042,7 @@ int ndo_dflt_fdb_add(struct ndmsg *ndm,
 	/* If aging addresses are supported device will need to
 	 * implement its own handler for this.
 	 */
-	if (ndm->ndm_state && !(ndm->ndm_state & NUD_PERMANENT)) {
+	if (ndm->ndm_state && !(ndm->ndm_state & (NUD_PERMANENT | NUD_NOARP))) {
 		pr_info("%s: FDB only supports static addresses\n", dev->name);
 		return err;
 	}
@@ -2142,7 +2142,7 @@ int ndo_dflt_fdb_del(struct ndmsg *ndm,
 	/* If aging addresses are supported device will need to
 	 * implement its own handler for this.
 	 */
-	if (ndm->ndm_state & NUD_PERMANENT) {
+	if (ndm->ndm_state & (NUD_PERMANENT | NUD_NOARP)) {
 		pr_info("%s: FDB only supports static addresses\n", dev->name);
 		return -EINVAL;
 	}
-- 
1.7.7.6

  parent reply	other threads:[~2013-04-19 20:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-19 20:52 [PATCH v2 net-next 0/6] Allow bridge to function in non-promisc mode Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 1/6] bridge: Allow an ability to designate an uplink port Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 2/6] bridge: make flags sysfs interface a little bit more extensible Vlad Yasevich
2013-04-19 20:54   ` Stephen Hemminger
2013-04-19 21:35     ` Vlad Yasevich
2013-04-19 20:55   ` Stephen Hemminger
2013-04-19 21:33     ` Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 3/6] bridge: Implement IFF_UNICAST_FLT Vlad Yasevich
2013-04-19 20:52 ` Vlad Yasevich [this message]
2013-04-19 20:52 ` [PATCH v2 net-next 5/6] bridge: Automatically set promisc on uplink ports Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 6/6] bridge: Store bridge mac to uplinks Vlad Yasevich
2013-04-19 20:58 ` [PATCH v2 net-next 0/6] Allow bridge to function in non-promisc mode Stephen Hemminger
2013-04-19 21:48   ` Vlad Yasevich
2013-04-25 15:56 ` Stephen Hemminger
2013-04-25 16:45   ` Michael S. Tsirkin
2013-04-25 17:35     ` Stephen Hemminger
2013-04-25 21:13       ` Michael S. Tsirkin
2013-05-02 17:23 ` Stephen Hemminger
2013-05-02 17:41   ` Vlad Yasevich
2013-05-02 18:14     ` Stephen Hemminger
2013-05-02 18:37   ` Michael S. Tsirkin
2013-05-02 21:16     ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1366404770-28523-5-git-send-email-vyasevic@redhat.com \
    --to=vyasevic@redhat.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).