lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1411573940-14079-11-git-send-email-ahmed@gandi.net>
Date:	Wed, 24 Sep 2014 17:52:06 +0200
From:	Ahmed Amamou <ahmed@...di.net>
To:	netdev@...r.kernel.org
Cc:	william@...di.net, f.cachereul@...halink.fr,
	Ahmed Amamou <ahmed@...di.net>,
	Kamel Haddadou <kamel@...di.net>
Subject: [RFC PATCH 10/24] net: rbridge: Add elected dtroot

provide function to get the locally elected distributed tree root from the daemon
in TRILL RFC multiple tree root can be elected but this is not mendatory
for this first version we use a unique distributed tree root

Signed-off-by: Ahmed Amamou <ahmed@...di.net>
Signed-off-by: Kamel Haddadou <kamel@...di.net>
Signed-off-by: François Cachereul <f.cachereul@...halink.fr>
Signed-off-by: William Dauchy <william@...di.net>
---
 net/bridge/br_private.h          |  1 +
 net/bridge/rbridge/rbr.c         | 17 +++++++++++++++++
 net/bridge/rbridge/rbr_netlink.c | 21 +++++++++++++++++++++
 3 files changed, 39 insertions(+)

diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 6952db8..2d15b35 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -815,6 +815,7 @@ ssize_t br_show_bridge_id(char *buf, const struct bridge_id *id);
 /* rbridge/rbr.c */
 #ifdef CONFIG_TRILL
 void br_trill_set_enabled(struct net_bridge *br, unsigned long val);
+extern int set_treeroot(struct rbr *rbr, uint16_t treeroot);
 #endif
 
 /* br_stp_bpdu.c */
diff --git a/net/bridge/rbridge/rbr.c b/net/bridge/rbridge/rbr.c
index 41d47db..8d6d37e 100644
--- a/net/bridge/rbridge/rbr.c
+++ b/net/bridge/rbridge/rbr.c
@@ -76,3 +76,20 @@ void br_trill_set_enabled(struct net_bridge *br, unsigned long val)
 			br_trill_stop(br);
 	}
 }
+
+int set_treeroot(struct rbr *rbr, uint16_t treeroot)
+{
+	if (unlikely(!VALID_NICK(treeroot))) {
+		pr_warn_ratelimited
+		    ("rbr_set_treeroot: given tree root not valid\n");
+		goto set_tree_root_fail;
+	}
+	if (rbr->treeroot != treeroot) {
+		spin_lock_bh(&rbr->br->lock);
+		rbr->treeroot = treeroot;
+		spin_unlock_bh(&rbr->br->lock);
+	}
+	return 0;
+ set_tree_root_fail:
+	return ENOENT;
+}
diff --git a/net/bridge/rbridge/rbr_netlink.c b/net/bridge/rbridge/rbr_netlink.c
index ccba5ae..889e6c8 100644
--- a/net/bridge/rbridge/rbr_netlink.c
+++ b/net/bridge/rbridge/rbr_netlink.c
@@ -56,7 +56,28 @@ static int trill_cmd_add_nicks_info(struct sk_buff *skb, struct genl_info *info)
 static int trill_cmd_set_treeroot_id(struct sk_buff *skb,
 				     struct genl_info *info)
 {
+	int err = -EINVAL;
+	u16 nickname;
+	struct trill_nl_header *trnlhdr;
+	struct net_device *source_port = NULL;
+	struct net *net = sock_net(skb->sk);
+	struct net_bridge_port *p = NULL;
+	nickname = nla_get_u16(info->attrs[TRILL_ATTR_U16]);
+	trnlhdr = info->userhdr;
+	if (trnlhdr->ifindex)
+		source_port = __dev_get_by_index(net, trnlhdr->ifindex);
+	if (!source_port)
+		goto fail;
+	p = br_port_get_rcu(source_port);
+	if (!p || !(p->br) || !(p->br->rbr))
+		goto fail;
+	err = set_treeroot(p->br->rbr, htons(nickname));
+	if (err)
+		goto fail;
 	return 0;
+ fail:
+	printk(KERN_WARNING "trill_cmd_set_treeroot_id FAILED\n");
+	return err;
 }
 
 /* trill_cmd_get_rbridge when started daemon inquire for already
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ