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-15-git-send-email-ahmed@gandi.net>
Date:	Wed, 24 Sep 2014 17:52:10 +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 14/24] net: rbridge: Add get_node function

allow daemon to get any node information
daemon has to provide a netlink message containing the nickname of
requested node.
This function is provided but not used by the daemon for the moment
it can be used to check information accuracy in futur version

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 | 61 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/net/bridge/rbridge/rbr_netlink.c b/net/bridge/rbridge/rbr_netlink.c
index bb893f0..983d647 100644
--- a/net/bridge/rbridge/rbr_netlink.c
+++ b/net/bridge/rbridge/rbr_netlink.c
@@ -123,7 +123,68 @@ static int trill_cmd_set_nicks_info(struct sk_buff *skb, struct genl_info *info)
 
 static int trill_cmd_get_nicks_info(struct sk_buff *skb, struct genl_info *info)
 {
+	struct sk_buff *msg;
+	struct nlattr *attr;
+	struct rbr_nickinfo rbr_ni;
+	void *data;
+	struct trill_nl_header *trnlhdr;
+	struct net_device *source_port = NULL;
+	struct net *net = sock_net(skb->sk);
+	struct net_bridge_port *p = NULL;
+	struct rbr_node *rbr_node;
+	int err = -EINVAL;
+
+	nla_memcpy(&rbr_ni, info->attrs[TRILL_ATTR_BIN], sizeof(rbr_ni));
+	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;
+
+	rbr_node = rbr_find_node(p->br->rbr, rbr_ni.nick);
+	if (!rbr_node)
+		goto fail;
+
+	err = -ENOMEM;
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+	if (!msg)
+		goto fail_put;
+
+	trnlhdr = genlmsg_put(msg, info->snd_portid, info->snd_seq,
+			      &trill_genl_family, sizeof(*trnlhdr),
+			      TRILL_CMD_GET_NICKS_INFO);
+	if (!trnlhdr)
+		goto fail_free;
+
+	attr = nla_reserve(msg, TRILL_ATTR_BIN,
+			   RBR_NI_TOTALSIZE(rbr_node->rbr_ni));
+	if (!attr)
+		goto fail_free;
+
+	data = nla_data(attr);
+	trnlhdr->ifindex = KERNL_RESPONSE_INTERFACE;
+	memcpy(data, rbr_node->rbr_ni, RBR_NI_TOTALSIZE(rbr_node->rbr_ni));
+	genlmsg_end(msg, trnlhdr);
+	rbr_node_put(rbr_node);
+
+	err = genlmsg_reply(msg, info);
+	if (err)
+		goto fail_put;
+
 	return 0;
+
+ fail_free:
+	nlmsg_free(msg);
+ fail_put:
+	rbr_node_put(rbr_node);
+ fail:
+	printk(KERN_WARNING "trill_cmd_get_nicks_info FAILED\n");
+	return err;
 }
 
 static int trill_cmd_add_nicks_info(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