Subject: Re: [RFC][PATCH] ipv6: fix the check when handle RA

From: Hannes Frederic Sowa <[email-masked]>
Date: Thu, 10 Jul 2014 11:26:50 +0200

Hi,

On Do, 2014-07-10 at 16:29 +0800, [email-masked] wrote:
> From: Li RongQing <[email-masked]>
> 
> d9333196572(ipv6:  Allow accepting RA from local IP addresses.) made
> ndisc_router_discovery to skip to handle RA when accept_ra_from_local
> is 0 and saddr of packet is not the device address, in fact, this
> condition should be handled
> 
> Fixes: d9333196572(ipv6:  Allow accepting RA from local IP addresses.)
> Cc: Ben Greear <[email-masked]>
> Signed-off-by: Li RongQing <[email-masked]>
>  net/ipv6/ndisc.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
> index a845e3d..e70e805 100644
> --- a/net/ipv6/ndisc.c
> +++ b/net/ipv6/ndisc.c
> @@ -1152,8 +1152,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
>  	 * accept_ra_from_local is set to true.
>  	 */
>  	if (!(in6_dev->cnf.accept_ra_from_local ||
> -	      ipv6_chk_addr(dev_net(in6_dev->dev), &ipv6_hdr(skb)->saddr,
> -			    NULL, 0))) {
> +	      !ipv6_chk_addr(dev_net(in6_dev->dev), &ipv6_hdr(skb)->saddr,
> +			     NULL, 0))) {

Uh!

Instead of double negotiation can you please write

if (!in6_dev->cnf.accept_ra_from_local &&
    ipv6_chk_addr(...)) {
	printk(...);
	goto skip;
}

Thanks for fixing this, good catch!

Thanks,
Hannes