public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Ying Xue <ying.xue@windriver•com>
To: <erik.hugne@ericsson•com>, <jon.maloy@ericsson•com>,
	<richard.alpe@ericsson•com>, <netdev@vger•kernel.org>
Cc: <tipc-discussion@lists•sourceforge.net>
Subject: Re: [PATCH v2 net-next 1/2] tipc: refactor name table updates out of named packet receive routine
Date: Tue, 26 Aug 2014 17:33:03 +0800	[thread overview]
Message-ID: <53FC544F.70308@windriver.com> (raw)
In-Reply-To: <1409043477-22761-1-git-send-email-erik.hugne@ericsson.com>

On 08/26/2014 04:57 PM, erik.hugne@ericsson•com wrote:
> From: Erik Hugne <erik.hugne@ericsson•com>
> 
> We need to perform the same actions when processing deferred name
> table updates, so this functionality is moved to a separate
> function.
> 
> Signed-off-by: Erik Hugne <erik.hugne@ericsson•com>
> Signed-off-by: Jon Maloy <jon.maloy@ericsson•com>

Acked-by: Ying Xue <ying.xue@windriver•com>

> ---
>  net/tipc/name_distr.c | 74 ++++++++++++++++++++++++++-------------------------
>  1 file changed, 38 insertions(+), 36 deletions(-)
> 
> diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
> index dcc15bc..0591f33 100644
> --- a/net/tipc/name_distr.c
> +++ b/net/tipc/name_distr.c
> @@ -263,52 +263,54 @@ static void named_purge_publ(struct publication *publ)
>  }
>  
>  /**
> + * tipc_update_nametbl - try to process a nametable update and notify
> + *			 subscribers
> + *
> + * tipc_nametbl_lock must be held.
> + * Returns the publication item if successful, otherwise NULL.
> + */
> +struct publication *tipc_update_nametbl(struct distr_item *i, u32 node,
> +					u32 dtype)
> +{
> +	struct publication *publ = NULL;
> +
> +	if (dtype == PUBLICATION) {
> +		publ = tipc_nametbl_insert_publ(ntohl(i->type), ntohl(i->lower),
> +						ntohl(i->upper),
> +						TIPC_CLUSTER_SCOPE, node,
> +						ntohl(i->ref), ntohl(i->key));
> +		if (publ) {
> +			tipc_nodesub_subscribe(&publ->subscr, node, publ,
> +					       (net_ev_handler)
> +					       named_purge_publ);
> +		}
> +	} else if (dtype == WITHDRAWAL) {
> +		publ = tipc_nametbl_remove_publ(ntohl(i->type), ntohl(i->lower),
> +						node, ntohl(i->ref),
> +						ntohl(i->key));
> +		if (publ) {
> +			tipc_nodesub_unsubscribe(&publ->subscr);
> +			kfree(publ);
> +		}
> +	} else {
> +		pr_warn("Unrecognized name table message received\n");
> +	}
> +	return publ;
> +}
> +
> +/**
>   * tipc_named_rcv - process name table update message sent by another node
>   */
>  void tipc_named_rcv(struct sk_buff *buf)
>  {
> -	struct publication *publ;
>  	struct tipc_msg *msg = buf_msg(buf);
>  	struct distr_item *item = (struct distr_item *)msg_data(msg);
>  	u32 count = msg_data_sz(msg) / ITEM_SIZE;
>  
>  	write_lock_bh(&tipc_nametbl_lock);
>  	while (count--) {
> -		if (msg_type(msg) == PUBLICATION) {
> -			publ = tipc_nametbl_insert_publ(ntohl(item->type),
> -							ntohl(item->lower),
> -							ntohl(item->upper),
> -							TIPC_CLUSTER_SCOPE,
> -							msg_orignode(msg),
> -							ntohl(item->ref),
> -							ntohl(item->key));
> -			if (publ) {
> -				tipc_nodesub_subscribe(&publ->subscr,
> -						       msg_orignode(msg),
> -						       publ,
> -						       (net_ev_handler)
> -						       named_purge_publ);
> -			}
> -		} else if (msg_type(msg) == WITHDRAWAL) {
> -			publ = tipc_nametbl_remove_publ(ntohl(item->type),
> -							ntohl(item->lower),
> -							msg_orignode(msg),
> -							ntohl(item->ref),
> -							ntohl(item->key));
> -
> -			if (publ) {
> -				tipc_nodesub_unsubscribe(&publ->subscr);
> -				kfree(publ);
> -			} else {
> -				pr_err("Unable to remove publication by node 0x%x\n"
> -				       " (type=%u, lower=%u, ref=%u, key=%u)\n",
> -				       msg_orignode(msg), ntohl(item->type),
> -				       ntohl(item->lower), ntohl(item->ref),
> -				       ntohl(item->key));
> -			}
> -		} else {
> -			pr_warn("Unrecognized name table message received\n");
> -		}
> +		tipc_update_nametbl(item, msg_orignode(msg),
> +				    msg_type(msg));
>  		item++;
>  	}
>  	write_unlock_bh(&tipc_nametbl_lock);
> 

      parent reply	other threads:[~2014-08-26  9:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26  8:57 [PATCH v2 net-next 1/2] tipc: refactor name table updates out of named packet receive routine erik.hugne
2014-08-26  8:57 ` [PATCH v2 net-next 2/2] tipc: add name distributor resiliency queue erik.hugne
2014-08-26  9:33   ` Ying Xue
2014-08-26 14:32   ` Erik Hugne
2014-08-26 14:44     ` Jon Maloy
2014-08-26 14:48       ` Erik Hugne
2014-08-26 14:55         ` Jon Maloy
2014-08-26  9:33 ` Ying Xue [this message]

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=53FC544F.70308@windriver.com \
    --to=ying.xue@windriver$(echo .)com \
    --cc=erik.hugne@ericsson$(echo .)com \
    --cc=jon.maloy@ericsson$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=richard.alpe@ericsson$(echo .)com \
    --cc=tipc-discussion@lists$(echo .)sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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