netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ahmed Amamou <ahmed@gandi.net>
To: netdev@vger.kernel.org
Cc: William Dauchy <william@gandi.net>,
	Ahmed Amamou <ahmed@gandi.net>, Kamel Haddadou <kamel@gandi.net>
Subject: [PATCH RFC v2 14/21] net: rbridge: update forwarding database
Date: Tue,  1 Sep 2015 17:43:09 +0200	[thread overview]
Message-ID: <1441122196-11662-15-git-send-email-ahmed@gandi.net> (raw)
In-Reply-To: <1441122196-11662-1-git-send-email-ahmed@gandi.net>

update forwarding database to include nickname information used
in encapsulation and decapsulation
add functions to get and update nickname

Signed-off-by: Ahmed Amamou <ahmed@gandi.net>
Signed-off-by: Kamel Haddadou <kamel@gandi.net>
Signed-off-by: William Dauchy <william@gandi.net>
---
 net/bridge/br_fdb.c     | 41 +++++++++++++++++++++++++++++++++++++++++
 net/bridge/br_private.h | 11 +++++++++++
 2 files changed, 52 insertions(+)

diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 9e9875d..14540f1 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -552,8 +552,14 @@ int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
 	return ret;
 }
 
+#ifdef CONFIG_TRILL
+void br_fdb_update_nick(struct net_bridge *br, struct net_bridge_port *source,
+			const unsigned char *addr, u16 vid, bool added_by_user,
+			uint16_t nick)
+#else
 void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 		   const unsigned char *addr, u16 vid, bool added_by_user)
+#endif
 {
 	struct hlist_head *head = &br->hash[br_mac_hash(addr, vid)];
 	struct net_bridge_fdb_entry *fdb;
@@ -587,6 +593,10 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 				fdb->added_by_user = 1;
 			if (unlikely(fdb_modified))
 				fdb_notify(br, fdb, RTM_NEWNEIGH);
+#ifdef CONFIG_TRILL
+			if (nick != RBRIDGE_NICKNAME_UNUSED)
+				fdb->nick = nick;
+#endif
 		}
 	} else {
 		spin_lock(&br->hash_lock);
@@ -605,6 +615,16 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 	}
 }
 
+#ifdef CONFIG_TRILL
+void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
+		   const unsigned char *addr, u16 vid, bool added_by_user)
+{
+	br_fdb_update_nick(br, source, addr, vid, added_by_user,
+			   RBRIDGE_NICKNAME_UNUSED);
+}
+
+#endif
+
 static int fdb_to_nud(const struct net_bridge_fdb_entry *fdb)
 {
 	if (fdb->is_local)
@@ -1076,3 +1096,24 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
 
 	return err;
 }
+
+#ifdef CONFIG_TRILL
+/* get_nick_from_mac: used to get correspondant nick to Mac address
+ * used only on ingress/Egress Rbridge (those how encapsulate
+ * and decapsulate frames)
+ * must be called while encapsulating  to get mac <-> nick correspondance
+ */
+uint16_t get_nick_from_mac(struct net_bridge_port *p, unsigned char *dest,
+			   u16 vid)
+{
+	struct hlist_head *head = &p->br->hash[br_mac_hash(dest, vid)];
+	struct net_bridge_fdb_entry *fdb;
+
+	if (is_multicast_ether_addr(dest))
+		return RBRIDGE_NICKNAME_NONE;
+	fdb = fdb_find(head, dest, vid);
+	if (likely(fdb))
+		return fdb->nick;
+	return RBRIDGE_NICKNAME_NONE;
+}
+#endif
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index ceaf5a9..a62e41e 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -120,6 +120,9 @@ struct net_bridge_fdb_entry
 					added_by_user:1,
 					added_by_external_learn:1;
 	__u16				vlan_id;
+#ifdef CONFIG_TRILL
+	__u16				nick; /* destination's nickname */
+#endif
 };
 
 struct net_bridge_port_group {
@@ -436,6 +439,14 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
 			      const unsigned char *addr, u16 vid);
 int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
 			      const unsigned char *addr, u16 vid);
+#ifdef CONFIG_TRILL
+void br_fdb_update_nick(struct net_bridge *br,
+			struct net_bridge_port *source,
+			const unsigned char *addr,
+			u16 vid, bool added_by_user, uint16_t nick);
+uint16_t get_nick_from_mac(struct net_bridge_port *p, unsigned char *dest,
+			   u16 vid);
+#endif
 
 /* br_forward.c */
 void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb);
-- 
2.1.4

  parent reply	other threads:[~2015-09-01 15:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01 15:42 [PATCH RFC v2 00/21] TRILL implementation Ahmed Amamou
2015-09-01 15:42 ` [PATCH RFC v2 01/21] net: rbridge: add trill frame description Ahmed Amamou
2015-09-01 15:42 ` [PATCH RFC v2 02/21] net: rbridge: add layer 2 IS-IS Ethertype Ahmed Amamou
2015-09-01 15:42 ` [PATCH RFC v2 03/21] net: rbridge: add RBridge structure Ahmed Amamou
2015-09-01 15:42 ` [PATCH RFC v2 04/21] net: rbridge: add CONFIG_TRILL Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 05/21] net: rbridge: adapt Bridge structure Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 06/21] net: rbridge: enable/disable TRILL capability Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 07/21] net: rbridge: add sysfs for trill_state Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 08/21] net: rbridge: get Rbridge nickname from daemon Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 09/21] net: rbridge: add elected dtroot Ahmed Amamou
2015-09-01 18:18   ` Sergei Shtylyov
2015-09-01 18:26     ` ahmed amamou
2015-09-01 15:43 ` [PATCH RFC v2 10/21] net: rbridge: add rbr_node management function Ahmed Amamou
2015-09-01 18:30   ` Sergei Shtylyov
2015-09-01 15:43 ` [PATCH RFC v2 11/21] net: rbridge: clean up rbr_node on rbridge stop Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 12/21] net: rbridge: update node table Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 13/21] net: rbridge: add basic trill frame handling function Ahmed Amamou
2015-09-01 15:43 ` Ahmed Amamou [this message]
2015-09-01 15:43 ` [PATCH RFC v2 15/21] net: rbridge: add test on trill flag before flood Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 16/21] net: rbridge: add encapsulation process Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 17/21] net: rbridge: add receive function Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 18/21] net: rbridge: add rbr_fwd Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 19/21] net: rbridge: add rbr_multidest_fwd Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 20/21] net: rbridge: replace net_port rx_handler Ahmed Amamou
2015-09-01 15:43 ` [PATCH RFC v2 21/21] net: handle packet split for trill Ahmed Amamou

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=1441122196-11662-15-git-send-email-ahmed@gandi.net \
    --to=ahmed@gandi.net \
    --cc=kamel@gandi.net \
    --cc=netdev@vger.kernel.org \
    --cc=william@gandi.net \
    /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).