[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5423FB61.6080804@cogentembedded.com>
Date: Thu, 25 Sep 2014 15:24:17 +0400
From: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To: Ahmed Amamou <ahmed@...di.net>, netdev@...r.kernel.org
CC: william@...di.net, f.cachereul@...halink.fr,
Kamel Haddadou <kamel@...di.net>
Subject: Re: [RFC PATCH 11/24] net: rbridge: Add rbr_node management function
Hello.
On 9/24/2014 7:52 PM, Ahmed Amamou wrote:
> rbr_node are used to save distant Rbridges information
> they are use by local Rbridge to take routing decision
> this patch add get/put/free/find/del function to rbr_node to
> avoid freeing a rbr_node that is still in use for routing
> Signed-off-by: Ahmed Amamou <ahmed@...di.net>
> Signed-off-by: Kamel Haddadou <kamel@...di.net>
> Signed-off-by: William Dauchy <william@...di.net>
> ---
> net/bridge/rbridge/rbr.c | 34 ++++++++++++++++++++++++++++++++++
> net/bridge/rbridge/rbr_private.h | 26 ++++++++++++++++++++++++++
> 2 files changed, 60 insertions(+)
> diff --git a/net/bridge/rbridge/rbr.c b/net/bridge/rbridge/rbr.c
> index 8d6d37e..1df8f8d 100644
> --- a/net/bridge/rbridge/rbr.c
> +++ b/net/bridge/rbridge/rbr.c
> @@ -93,3 +93,37 @@ int set_treeroot(struct rbr *rbr, uint16_t treeroot)
> set_tree_root_fail:
> return ENOENT;
> }
> +
> +struct rbr_node *rbr_find_node(struct rbr *rbr, __u16 nickname)
> +{
> + struct rbr_node *rbr_node;
There should be an empty line here, like in the next functions.
> + if (unlikely(!VALID_NICK(nickname)))
> + return NULL;
> + rbr_node = rcu_dereference(rbr->rbr_nodes[nickname]);
> + rbr_node_get(rbr_node);
> +
> + return rbr_node;
> +}
> +
> +static void rbr_del_node(struct rbr *rbr, uint16_t nickname)
> +{
> + struct rbr_node *rbr_node;
> +
> + if (likely(VALID_NICK(nickname))) {
> + rbr_node = rbr->rbr_nodes[nickname];
> + if (likely(rbr_node != NULL)) {
> + rcu_assign_pointer(rbr->rbr_nodes[nickname], NULL);
> + rbr_node_put(rbr_node);
> + }
> + }
> +}
> +
> +static void rbr_del_all(struct rbr *rbr)
> +{
> + unsigned int i;
> +
> + for (i = RBRIDGE_NICKNAME_MIN; i < RBRIDGE_NICKNAME_MAX; i++) {
> + if (likely(rbr->rbr_nodes[i] != NULL))
> + rbr_del_node(rbr, i);
> + }
> +}
[...]
WBR, Sergei
--
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