From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Ahmed Amamou <ahmed@gandi.net>, netdev@vger.kernel.org
Cc: william@gandi.net, f.cachereul@alphalink.fr,
Kamel Haddadou <kamel@gandi.net>
Subject: Re: [RFC PATCH 13/24] net: rbridge: Add set_node function
Date: Thu, 25 Sep 2014 15:34:32 +0400 [thread overview]
Message-ID: <5423FDC8.5080901@cogentembedded.com> (raw)
In-Reply-To: <1411573940-14079-14-git-send-email-ahmed@gandi.net>
Hello.
On 9/24/2014 7:52 PM, Ahmed Amamou wrote:
> allow daemon to set distant Rbridges information in local database
> daemon has to periodically update distant Rbridges informations in local database
> create a new node only if change on distant RBridge information are detected
> Signed-off-by: Ahmed Amamou <ahmed@gandi.net>
> Signed-off-by: Kamel Haddadou <kamel@gandi.net>
> Signed-off-by: François Cachereul <f.cachereul@alphalink.fr>
> Signed-off-by: William Dauchy <william@gandi.net>
> ---
> net/bridge/rbridge/rbr_netlink.c | 78 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 78 insertions(+)
> diff --git a/net/bridge/rbridge/rbr_netlink.c b/net/bridge/rbridge/rbr_netlink.c
> index 889e6c8..bb893f0 100644
> --- a/net/bridge/rbridge/rbr_netlink.c
> +++ b/net/bridge/rbridge/rbr_netlink.c
> @@ -38,9 +38,87 @@ static struct genl_multicast_group trill_mcgrps[] = {
> [TRILL_MCGRP_OFFSET] = {.name = TRILL_MCAST_NAME,},
> };
>
> +static int create_node(struct net_bridge_port *p, struct rbr *rbr,
> + struct rbr_nickinfo *rbr_ni_partial,
> + struct genl_info *info)
> +{
> + size_t size = 0;
> + size_t old_size = 0;
> + struct rbr_node *old;
> + struct rbr_nickinfo *rbr_ni;
> +
> + if (rbr_ni_partial == NULL)
> + return -EINVAL;
> +
> + size = RBR_NI_TOTALSIZE(rbr_ni_partial);
> + if (size > PAGE_SIZE - sizeof(struct trill_nl_header)) {
> + pr_warn_ratelimited
> + ("create_node: size > (PAGE_SIZE-nickinfo_offset)\n");
> + return -EINVAL;
> + }
> + rbr_ni = kzalloc(size, GFP_KERNEL);
> + if (!rbr_ni)
> + return -ENOMEM;
> + old = rbr->rbr_nodes[rbr_ni_partial->nick];
> + nla_memcpy(rbr_ni, info->attrs[TRILL_ATTR_BIN], size);
> + if (old)
> + old_size = RBR_NI_TOTALSIZE(old->rbr_ni);
> + /* replace old node by a new one only if nickname information have changed */
s/have/has/.
> + if (old == NULL || old_size != size ||
> + memcmp(old->rbr_ni, rbr_ni, size)) {
> + struct rbr_node *new;
> +
> + new = kzalloc(sizeof(*old), GFP_KERNEL);
> + if (!new) {
> + kfree(rbr_ni);
> + return -ENOMEM;
> + }
> + atomic_set(&new->refs, 1);
> + new->rbr_ni = rbr_ni;
> + /* avoid deleting node while it is been used for routing */
Either "has been" or "is being".
> + rcu_assign_pointer(rbr->rbr_nodes[rbr_ni->nick], new);
> + if (old)
> + rbr_node_put(old);
> + } else {
> + kfree(rbr_ni);
> + }
> +
> + return 0;
> +}
> +
> static int trill_cmd_set_nicks_info(struct sk_buff *skb, struct genl_info *info)
> {
> + struct trill_nl_header *trnlhdr;
> + struct rbr_nickinfo rbr_ni;
> + struct net_device *source_port = NULL;
> + struct net *net = sock_net(skb->sk);
> + struct net_bridge_port *p = NULL;
> + int err = -EINVAL;
> +
> + nla_memcpy(&rbr_ni, info->attrs[TRILL_ATTR_BIN], sizeof(rbr_ni));
> + if (!VALID_NICK(rbr_ni.nick))
> + goto fail;
> +
> + 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))
Inner parens not needed.
> + goto fail;
> +
> + err = create_node(p, p->br->rbr, &rbr_ni, info);
> + if (err)
> + goto fail;
> +
> return 0;
> +
> + fail:
> + printk(KERN_WARNING "trill_cmd_set_nicks_info FAILED\n");
pr_warn().
[...]
WBR, Sergei
next prev parent reply other threads:[~2014-09-25 11:34 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-24 15:51 [RFC PATCH 00/24] TRILL implementation Ahmed Amamou
2014-09-24 15:51 ` [RFC PATCH 01/24] net: rbridge: add trill frame description Ahmed Amamou
2014-09-24 16:38 ` Stephen Hemminger
2014-09-24 16:48 ` William Dauchy
2014-09-24 17:26 ` Cong Wang
2014-09-24 17:34 ` William Dauchy
2014-09-24 17:01 ` Cong Wang
2014-09-24 15:51 ` [RFC PATCH 02/24] net: rbridge: Add layer 2 IS-IS Ethertype Ahmed Amamou
2014-09-24 15:51 ` [RFC PATCH 03/24] net: rbridge: Add RBridge structure Ahmed Amamou
2014-09-24 16:40 ` Stephen Hemminger
2014-09-24 16:55 ` William Dauchy
2014-09-24 17:18 ` Cong Wang
2014-09-24 15:52 ` [RFC PATCH 04/24] net: rbridge: Add CONFIG_TRILL Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 05/24] net: rbridge: Adapt Bridge structure Ahmed Amamou
2014-09-24 20:56 ` Francois Romieu
2014-09-24 15:52 ` [RFC PATCH 06/24] net: rbridge: Enable/disable TRILL capability Ahmed Amamou
2014-09-24 17:46 ` Vlad Yasevich
2014-09-24 15:52 ` [RFC PATCH 07/24] net: rbridge: Add sysfs for trill_state Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 08/24] net: rbridge: Add Rbridge netlink message skeleton Ahmed Amamou
2014-09-24 17:52 ` Vlad Yasevich
2014-09-24 15:52 ` [RFC PATCH 09/24] net: rbridge: Get Rbridge nickname from daemon Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 10/24] net: rbridge: Add elected dtroot Ahmed Amamou
2014-09-25 11:30 ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 11/24] net: rbridge: Add rbr_node management function Ahmed Amamou
2014-09-25 11:24 ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 12/24] net: rbridge: Clean up rbr_node on rbridge stop Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 13/24] net: rbridge: Add set_node function Ahmed Amamou
2014-09-25 11:34 ` Sergei Shtylyov [this message]
2014-09-24 15:52 ` [RFC PATCH 14/24] net: rbridge: Add get_node function Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 15/24] net: rbridge: Add basic trill frame handling function Ahmed Amamou
2014-09-24 19:23 ` Francois Romieu
2014-09-24 15:52 ` [RFC PATCH 16/24] net: rbridge: Update forwarding database Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 17/24] net: rbridge: Add test on trill flag before flood Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 18/24] net: rbridge: Add encapsulation process Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 19/24] net: rbridge: Add receive function Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 20/24] net: rbridge: Add multicast recv handling Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 21/24] net: rbridge: Add decapsulation function Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 22/24] net: rbridge: Add rbr_fwd Ahmed Amamou
2014-09-25 11:43 ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 23/24] net: rbridge: Add rbr_multidest_fwd Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 24/24] net: rbridge: replace net_port rx_handler Ahmed Amamou
2014-09-24 16:44 ` [RFC PATCH 00/24] TRILL implementation Stephen Hemminger
2014-09-24 16:54 ` William Dauchy
2014-09-24 17:24 ` Cong Wang
2014-09-24 17:33 ` William Dauchy
2014-09-24 20:57 ` Francois Romieu
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=5423FDC8.5080901@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=ahmed@gandi.net \
--cc=f.cachereul@alphalink.fr \
--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).