[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <16241f25-79a3-1eb3-9f82-46d736b09d68@6wind.com>
Date: Tue, 20 Sep 2022 09:35:15 +0200
From: Nicolas Dichtel <nicolas.dichtel@...nd.com>
To: Patrick Rohr <prohr@...gle.com>,
"David S . Miller" <davem@...emloft.net>
Cc: Linux Network Development Mailing List <netdev@...r.kernel.org>,
Maciej Żenczykowski <maze@...gle.com>,
Lorenzo Colitti <lorenzo@...gle.com>,
Jason Wang <jasowang@...hat.com>
Subject: Re: [PATCH] tun: support not enabling carrier in TUNSETIFF
Le 17/09/2022 à 01:45, Patrick Rohr a écrit :
> This change adds support for not enabling carrier during TUNSETIFF
> interface creation by specifying the IFF_NO_CARRIER flag.
>
> Our tests make heavy use of tun interfaces. In some scenarios, the test
> process creates the interface but another process brings it up after the
> interface is discovered via netlink notification. In that case, it is
> not possible to create a tun/tap interface with carrier off without it
> racing against the bring up. Immediately setting carrier off via
> TUNSETCARRIER is still too late.
>
> Since ifr_flags is only a short, the value for IFF_DETACH_QUEUE is
> reused for IFF_NO_CARRIER. IFF_DETACH_QUEUE has currently no meaning in
> TUNSETIFF.
>
> Signed-off-by: Patrick Rohr <prohr@...gle.com>
> Cc: Maciej Żenczykowski <maze@...gle.com>
> Cc: Lorenzo Colitti <lorenzo@...gle.com>
> Cc: Jason Wang <jasowang@...hat.com>
> ---
> drivers/net/tun.c | 15 ++++++++++++---
> include/uapi/linux/if_tun.h | 2 ++
> 2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 259b2b84b2b3..502f56095650 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -2709,6 +2709,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
> struct net_device *dev;
> int err;
>
> + /* Do not save the IFF_NO_CARRIER flag as it uses the same value as
> + * IFF_DETACH_QUEUE.
> + */
> + bool no_carrier = ifr->ifr_flags & IFF_NO_CARRIER;
nit: please, declare all variables at the beginning and use reverse x-mas tree.
Powered by blists - more mailing lists