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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1411573940-14079-10-git-send-email-ahmed@gandi.net>
Date:	Wed, 24 Sep 2014 17:52:05 +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 09/24] net: rbridge: Get Rbridge nickname from daemon

added get and set nickname functions that allows daemon to check if
RBridge aleady have a nickname (daemon crash scenario)
if yes and nickname uniqueness is verified on toplogy no set nickname is provided by the daemon
if nickname is not unique or not existant daemon will set the automatically generated nickanme

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/rbridge/rbr_netlink.c | 92 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/net/bridge/rbridge/rbr_netlink.c b/net/bridge/rbridge/rbr_netlink.c
index eb7c902..ccba5ae 100644
--- a/net/bridge/rbridge/rbr_netlink.c
+++ b/net/bridge/rbridge/rbr_netlink.c
@@ -59,14 +59,106 @@ static int trill_cmd_set_treeroot_id(struct sk_buff *skb,
 	return 0;
 }
 
+/* trill_cmd_get_rbridge when started daemon inquire for already
+ * existant nickname
+ * bridge with TRILL capability may already have a nickname
+ * is daemon have crashed
+ */
 static int trill_cmd_get_rbridge(struct sk_buff *skb, struct genl_info *info)
 {
+	struct trill_nl_header *trnlhdr;
+	struct sk_buff *msg;
+	struct net_bridge_port *p;
+	struct net_device *source_port = NULL;
+	struct net *net = sock_net(skb->sk);
+	u16 nickname;
+	int err = -EINVAL;
+	int trill_genlseqnb = info->snd_seq;
+
+	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))
+		goto fail;
+
+	if (p->br->rbr)
+		nickname = ntohs(p->br->rbr->nick);
+	else
+		nickname = RBRIDGE_NICKNAME_NONE;
+
+	err = -ENOMEM;
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+	if (!msg)
+		goto fail;
+
+	trnlhdr = genlmsg_put(msg, info->snd_portid, trill_genlseqnb,
+			      &trill_genl_family, sizeof(*trnlhdr),
+			      TRILL_CMD_GET_RBRIDGE);
+	if (!trnlhdr)
+		goto fail_free;
+
+	trnlhdr->ifindex = KERNL_RESPONSE_INTERFACE;
+	nla_put_u16(msg, TRILL_ATTR_U16, nickname);
+	genlmsg_end(msg, trnlhdr);
+
+	err = genlmsg_reply(msg, info);
+	if (err)
+		goto fail;
+
 	return 0;
+
+ fail_free:
+	nlmsg_free(msg);
+ fail:
+	printk(KERN_WARNING "trill_cmd_get_rbridge FAILED\n");
+	return err;
 }
 
 static int trill_cmd_set_rbridge(struct sk_buff *skb, struct genl_info *info)
 {
+	struct trill_nl_header *trnlhdr;
+	struct net_device *source_port = NULL;
+	struct net_bridge_port *p = NULL;
+	struct net_bridge *br = NULL;
+	struct net *net = sock_net(skb->sk);
+	u16 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))
+		goto fail;
+
+	br = p->br;
+
+	/* if daemon has started and bridge TRILL capability
+	 * is not enabled then start it
+	 */
+	if (br->trill_enabled == BR_NO_TRILL)
+		br_trill_set_enabled(br, 1);
+
+	if (!(br->rbr))
+		goto fail;
+
+	spin_lock_bh(&br->lock);
+	br->rbr->nick = htons(nickname);
+	spin_unlock_bh(&br->lock);
+
 	return 0;
+
+ fail:
+	printk(KERN_WARNING "trill_cmd_set_bridge FAILED\n");
+	return -EINVAL;
 }
 
 static int trill_cmd_port_flush(struct sk_buff *skb, struct genl_info *info)
-- 
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