All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vlad Yasevich <vladislav.yasevich@hp.com>
To: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>,
	error27@gmail.com, sri@us.ibm.com, yjwei@cn.fujitsu.com,
	cascardo@holoscopio.com, linux-sctp@vger.kernel.org,
	netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [Alternative PATCH net-next] sctp: fix test for end of loop
Date: Thu, 09 Sep 2010 13:57:31 +0000	[thread overview]
Message-ID: <4C88E7CB.7060804@hp.com> (raw)
In-Reply-To: <1283979861.2479.21.camel@Joe-Laptop>

On 09/08/2010 05:04 PM, Joe Perches wrote:
> Perhaps something like this is clearer?
> 
> Add a list_has_sctp_addr function to simplify loop
> 
> Based on a patches by Dan Carpenter and David Miller
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Thanks Joe

I like this.  Nice and clean. :)

Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com>

-vlad

> ---
>  net/sctp/sm_statefuns.c |   46 +++++++++++++++++++++++-----------------------
>  1 files changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index 8b28443..4b4eb7c 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
> @@ -1232,6 +1232,18 @@ out:
>  	return 0;
>  }
>  
> +static bool list_has_sctp_addr(const struct list_head *list,
> +			       union sctp_addr *ipaddr)
> +{
> +	struct sctp_transport *addr;
> +
> +	list_for_each_entry(addr, list, transports) {
> +		if (sctp_cmp_addr_exact(ipaddr, &addr->ipaddr))
> +			return true;
> +	}
> +
> +	return false;
> +}
>  /* A restart is occurring, check to make sure no new addresses
>   * are being added as we may be under a takeover attack.
>   */
> @@ -1240,10 +1252,10 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc,
>  				       struct sctp_chunk *init,
>  				       sctp_cmd_seq_t *commands)
>  {
> -	struct sctp_transport *new_addr, *addr;
> -	int found;
> +	struct sctp_transport *new_addr;
> +	int ret = 1;
>  
> -	/* Implementor's Guide - Sectin 5.2.2
> +	/* Implementor's Guide - Section 5.2.2
>  	 * ...
>  	 * Before responding the endpoint MUST check to see if the
>  	 * unexpected INIT adds new addresses to the association. If new
> @@ -1254,31 +1266,19 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc,
>  	/* Search through all current addresses and make sure
>  	 * we aren't adding any new ones.
>  	 */
> -	new_addr = NULL;
> -	found = 0;
> -
>  	list_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list,
> -			transports) {
> -		found = 0;
> -		list_for_each_entry(addr, &asoc->peer.transport_addr_list,
> -				transports) {
> -			if (sctp_cmp_addr_exact(&new_addr->ipaddr,
> -						&addr->ipaddr)) {
> -				found = 1;
> -				break;
> -			}
> -		}
> -		if (!found)
> +			    transports) {
> +		if (!list_has_sctp_addr(&asoc->peer.transport_addr_list,
> +					&new_addr->ipaddr)) {
> +			sctp_sf_send_restart_abort(&new_addr->ipaddr, init,
> +						   commands);
> +			ret = 0;
>  			break;
> -	}
> -
> -	/* If a new address was added, ABORT the sender. */
> -	if (!found && new_addr) {
> -		sctp_sf_send_restart_abort(&new_addr->ipaddr, init, commands);
> +		}
>  	}
>  
>  	/* Return success if all addresses were found. */
> -	return found;
> +	return ret;
>  }
>  
>  /* Populate the verification/tie tags based on overlapping INIT
> 
> 


WARNING: multiple messages have this Message-ID (diff)
From: Vlad Yasevich <vladislav.yasevich@hp.com>
To: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>,
	error27@gmail.com, sri@us.ibm.com, yjwei@cn.fujitsu.com,
	cascardo@holoscopio.com, linux-sctp@vger.kernel.org,
	netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [Alternative PATCH net-next] sctp: fix test for end of loop
Date: Thu, 09 Sep 2010 09:57:31 -0400	[thread overview]
Message-ID: <4C88E7CB.7060804@hp.com> (raw)
In-Reply-To: <1283979861.2479.21.camel@Joe-Laptop>

On 09/08/2010 05:04 PM, Joe Perches wrote:
> Perhaps something like this is clearer?
> 
> Add a list_has_sctp_addr function to simplify loop
> 
> Based on a patches by Dan Carpenter and David Miller
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Thanks Joe

I like this.  Nice and clean. :)

Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com>

-vlad

> ---
>  net/sctp/sm_statefuns.c |   46 +++++++++++++++++++++++-----------------------
>  1 files changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index 8b28443..4b4eb7c 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
> @@ -1232,6 +1232,18 @@ out:
>  	return 0;
>  }
>  
> +static bool list_has_sctp_addr(const struct list_head *list,
> +			       union sctp_addr *ipaddr)
> +{
> +	struct sctp_transport *addr;
> +
> +	list_for_each_entry(addr, list, transports) {
> +		if (sctp_cmp_addr_exact(ipaddr, &addr->ipaddr))
> +			return true;
> +	}
> +
> +	return false;
> +}
>  /* A restart is occurring, check to make sure no new addresses
>   * are being added as we may be under a takeover attack.
>   */
> @@ -1240,10 +1252,10 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc,
>  				       struct sctp_chunk *init,
>  				       sctp_cmd_seq_t *commands)
>  {
> -	struct sctp_transport *new_addr, *addr;
> -	int found;
> +	struct sctp_transport *new_addr;
> +	int ret = 1;
>  
> -	/* Implementor's Guide - Sectin 5.2.2
> +	/* Implementor's Guide - Section 5.2.2
>  	 * ...
>  	 * Before responding the endpoint MUST check to see if the
>  	 * unexpected INIT adds new addresses to the association. If new
> @@ -1254,31 +1266,19 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc,
>  	/* Search through all current addresses and make sure
>  	 * we aren't adding any new ones.
>  	 */
> -	new_addr = NULL;
> -	found = 0;
> -
>  	list_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list,
> -			transports) {
> -		found = 0;
> -		list_for_each_entry(addr, &asoc->peer.transport_addr_list,
> -				transports) {
> -			if (sctp_cmp_addr_exact(&new_addr->ipaddr,
> -						&addr->ipaddr)) {
> -				found = 1;
> -				break;
> -			}
> -		}
> -		if (!found)
> +			    transports) {
> +		if (!list_has_sctp_addr(&asoc->peer.transport_addr_list,
> +					&new_addr->ipaddr)) {
> +			sctp_sf_send_restart_abort(&new_addr->ipaddr, init,
> +						   commands);
> +			ret = 0;
>  			break;
> -	}
> -
> -	/* If a new address was added, ABORT the sender. */
> -	if (!found && new_addr) {
> -		sctp_sf_send_restart_abort(&new_addr->ipaddr, init, commands);
> +		}
>  	}
>  
>  	/* Return success if all addresses were found. */
> -	return found;
> +	return ret;
>  }
>  
>  /* Populate the verification/tie tags based on overlapping INIT
> 
> 


  reply	other threads:[~2010-09-09 13:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-06 12:26 [patch] sctp: fix test for end of loop Dan Carpenter
2010-09-06 12:26 ` Dan Carpenter
2010-09-07  8:46 ` Shan Wei
2010-09-07  8:46   ` Shan Wei
2010-09-07 11:31   ` Dan Carpenter
2010-09-07 11:31     ` Dan Carpenter
2010-09-08 20:24 ` David Miller
2010-09-08 20:24   ` David Miller
2010-09-08 20:34   ` Vlad Yasevich
2010-09-08 20:34     ` Vlad Yasevich
2010-09-08 20:37     ` David Miller
2010-09-08 20:37       ` David Miller
2010-09-08 21:04       ` [Alternative PATCH net-next] " Joe Perches
2010-09-08 21:04         ` Joe Perches
2010-09-09 13:57         ` Vlad Yasevich [this message]
2010-09-09 13:57           ` Vlad Yasevich
2010-09-09 22:00           ` David Miller
2010-09-09 22:00             ` David Miller
2010-09-08 20:26 ` [patch] " Vlad Yasevich
2010-09-08 20:26   ` Vlad Yasevich
2010-09-08 20:30   ` David Miller
2010-09-08 20:30     ` David Miller

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=4C88E7CB.7060804@hp.com \
    --to=vladislav.yasevich@hp.com \
    --cc=cascardo@holoscopio.com \
    --cc=davem@davemloft.net \
    --cc=error27@gmail.com \
    --cc=joe@perches.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sri@us.ibm.com \
    --cc=yjwei@cn.fujitsu.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.