[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YalKSIlxgt1utNOk@lunn.ch>
Date: Thu, 2 Dec 2021 23:35:52 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Lino Sanfilippo <LinoSanfilippo@....de>
Cc: Arijit De <arijitde@...vell.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: How to avoid getting ndo_open() immediately after probe
On Thu, Dec 02, 2021 at 09:29:21PM +0100, Lino Sanfilippo wrote:
>
> Hi,
>
> On 02.12.21 at 19:11, Arijit De wrote:
> > Hi,
> >
> > I have handled the probe() and registered the netdev structure using register_netdev().
> > I have observed in other opensource driver(i.e. Intel e1000e driver) that ndo_open() gets called only when we try to bring up the interface (i.e. ifconfig <ip> ifconfig eth0 <ip-addr> netmask <net-mask> up).
> > But in my network driver I am getting ndo_open() call immediately after I handle the probe(). It's a wrong behavior, also my network interface is getting to UP/RUNNING state(as shown below) even without any valid ip address.
>
> There is nothing wrong here. As soon as you register the netdevice with the kernel it is available
> for userspace and userspace is free to bring it up. This may happen immediately after registration,
> so your driver has to be prepared for this.
> Its absolutely fine to bring up a network device without any ip address assigned.
And if you are using NFS root, the kernel can actually call ndo_open()
before register_netdev() even completes.
This is a common bug i look for in new drivers, register_netdev()
pretty much has to be the last thing done inside the probe function.
Andrew
Powered by blists - more mailing lists