netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Kaarel Pärtel" <kaarelp2rtel@gmail.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-can@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: add operstate for vcan and dummy
Date: Thu, 2 Jun 2022 20:39:04 -0700	[thread overview]
Message-ID: <20220602203904.65f7261f@hermes.local> (raw)
In-Reply-To: <20220602081929.21929-1-kaarelp2rtel@gmail.com>

On Thu,  2 Jun 2022 11:19:29 +0300
Kaarel Pärtel <kaarelp2rtel@gmail.com> wrote:

> The idea here is simple. The vcan and the dummy network devices
> currently do not set the operational state of the interface.
> The result is that the interface state will be UNKNOWN.
> 
> The kernel considers the unknown state to be the same as up:
> https://elixir.bootlin.com/linux/latest/source/include/linux/netdevice.h#L4125
> 
> However for users this creates confusion:
> https://serverfault.com/questions/629676/dummy-network-interface-in-linux
> 
> The change in this patch is very simple. When the interface is set up, the
> operational state is set to IF_OPER_UP.
> 
> Signed-off-by: Kaarel Pärtel <kaarelp2rtel@gmail.com>
> ---
>  drivers/net/can/vcan.c | 1 +
>  drivers/net/dummy.c    | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
> index a15619d883ec..79768f9d4294 100644
> --- a/drivers/net/can/vcan.c
> +++ b/drivers/net/can/vcan.c
> @@ -162,6 +162,7 @@ static void vcan_setup(struct net_device *dev)
>  
>  	dev->netdev_ops		= &vcan_netdev_ops;
>  	dev->needs_free_netdev	= true;
> +	dev->operstate = IF_OPER_UP;
>  }
>  
>  static struct rtnl_link_ops vcan_link_ops __read_mostly = {
> diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
> index f82ad7419508..ab128f66de00 100644
> --- a/drivers/net/dummy.c
> +++ b/drivers/net/dummy.c
> @@ -133,6 +133,7 @@ static void dummy_setup(struct net_device *dev)
>  
>  	dev->min_mtu = 0;
>  	dev->max_mtu = 0;
> +	dev->operstate = IF_OPER_UP;
>  }
>  
>  static int dummy_validate(struct nlattr *tb[], struct nlattr *data[],

Normally carrier state is propogated to operstate by linkwatch.
You may need to add a call for that.


      parent reply	other threads:[~2022-06-03  3:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02  8:19 [PATCH] net: add operstate for vcan and dummy Kaarel Pärtel
2022-06-03  2:46 ` Jakub Kicinski
2022-06-03  3:39 ` Stephen Hemminger [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=20220602203904.65f7261f@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kaarelp2rtel@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wg@grandegger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).