public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber•org>
To: David Ahern <dsahern@gmail•com>
Cc: netdev@vger•kernel.org, yoshfuji@linux-ipv6•org,
	idosch@mellanox•com, roopa@cumulusnetworks•com
Subject: Re: [PATCH v2 net-next] net/ipv6: Do not allow route add with a device that is down
Date: Wed, 24 Jan 2018 09:09:44 -0800	[thread overview]
Message-ID: <20180124090944.217c14b7@xeon-e3> (raw)
In-Reply-To: <20180124162924.6984-1-dsahern@gmail.com>

On Wed, 24 Jan 2018 08:29:24 -0800
David Ahern <dsahern@gmail•com> wrote:

> IPv6 allows routes to be installed when the device is not up (admin up).
> Worse, it does not mark it as LINKDOWN. IPv4 does not allow it and really
> there is no reason for IPv6 to allow it, so check the flags and deny if
> device is admin down.
> 
> Signed-off-by: David Ahern <dsahern@gmail•com>
> ---
> v2
> - missed setting err to -ENETDOWN (thanks for catching that Roopa)
> 
>  net/ipv6/route.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index f85da2f1e729..4e8fab766018 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -2734,6 +2734,12 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg,
>  	if (!dev)
>  		goto out;
>  
> +	err = -ENETDOWN;
> +	if (!(dev->flags & IFF_UP)) {
> +		NL_SET_ERR_MSG(extack, "Nexthop device is not up");
> +		goto out;
> +	}
> +
>  	if (!ipv6_addr_any(&cfg->fc_prefsrc)) {
>  		if (!ipv6_chk_addr(net, &cfg->fc_prefsrc, dev, 0)) {
>  			NL_SET_ERR_MSG(extack, "Invalid source address");

This looks like a good idea.

There are two equal ways to check for admin up. Either the dev flags or
look at link state via netif_running().  Maybe the latter would
be better.

  reply	other threads:[~2018-01-24 17:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24 16:29 [PATCH v2 net-next] net/ipv6: Do not allow route add with a device that is down David Ahern
2018-01-24 17:09 ` Stephen Hemminger [this message]
2018-01-24 17:37   ` David Ahern
2018-01-24 17:23 ` Eric Dumazet
2018-01-24 17:29   ` David Ahern

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=20180124090944.217c14b7@xeon-e3 \
    --to=stephen@networkplumber$(echo .)org \
    --cc=dsahern@gmail$(echo .)com \
    --cc=idosch@mellanox$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=roopa@cumulusnetworks$(echo .)com \
    --cc=yoshfuji@linux-ipv6$(echo .)org \
    /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