All of lore.kernel.org
 help / color / mirror / Atom feed
* How to avoid getting ndo_open() immediately after probe
@ 2021-12-02 18:11 Arijit De
  2021-12-02 19:41 ` Stephen Hemminger
  2021-12-02 20:29 ` Lino Sanfilippo
  0 siblings, 2 replies; 4+ messages in thread
From: Arijit De @ 2021-12-02 18:11 UTC (permalink / raw)
  To: netdev

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.

enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:22:55:33:22:28  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 252  bytes 43066 (43.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions

What is the change required in the driver such that my network interface(enp1s0) should be in down state(BROADCAST & MULTICAST only) after probe()
and ndo_open() call should happen only when device gets configured?

Thanks
Arijit

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to avoid getting ndo_open() immediately after probe
  2021-12-02 18:11 How to avoid getting ndo_open() immediately after probe Arijit De
@ 2021-12-02 19:41 ` Stephen Hemminger
  2021-12-02 20:29 ` Lino Sanfilippo
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2021-12-02 19:41 UTC (permalink / raw)
  To: Arijit De; +Cc: netdev

On Thu, 2 Dec 2021 18:11:30 +0000
Arijit De <arijitde@marvell.com> 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.
> 
> enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
>         ether 00:22:55:33:22:28  txqueuelen 1000  (Ethernet)
>         RX packets 0  bytes 0 (0.0 B)
>         RX errors 0  dropped 0  overruns 0  frame 0
>         TX packets 252  bytes 43066 (43.0 KB)
>         TX errors 0  dropped 0 overruns 0  carrier 0  collisions
> 
> What is the change required in the driver such that my network interface(enp1s0) should be in down state(BROADCAST & MULTICAST only) after probe()
> and ndo_open() call should happen only when device gets configured?
> 
> Thanks
> Arijit

ndo_open gets called when userspace brings the device up.
Based on the device name, you are running on a distribution which renames
devices; probably systemd/networkd and it is starting the device.

You need to change userspace configuration 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to avoid getting ndo_open() immediately after probe
  2021-12-02 18:11 How to avoid getting ndo_open() immediately after probe Arijit De
  2021-12-02 19:41 ` Stephen Hemminger
@ 2021-12-02 20:29 ` Lino Sanfilippo
  2021-12-02 22:35   ` Andrew Lunn
  1 sibling, 1 reply; 4+ messages in thread
From: Lino Sanfilippo @ 2021-12-02 20:29 UTC (permalink / raw)
  To: Arijit De, netdev


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.

Regards,
Lino


>
> enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
>         ether 00:22:55:33:22:28  txqueuelen 1000  (Ethernet)
>         RX packets 0  bytes 0 (0.0 B)
>         RX errors 0  dropped 0  overruns 0  frame 0
>         TX packets 252  bytes 43066 (43.0 KB)
>         TX errors 0  dropped 0 overruns 0  carrier 0  collisions
>
> What is the change required in the driver such that my network interface(enp1s0) should be in down state(BROADCAST & MULTICAST only) after probe()
> and ndo_open() call should happen only when device gets configured?
>
> Thanks
> Arijit
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to avoid getting ndo_open() immediately after probe
  2021-12-02 20:29 ` Lino Sanfilippo
@ 2021-12-02 22:35   ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2021-12-02 22:35 UTC (permalink / raw)
  To: Lino Sanfilippo; +Cc: Arijit De, netdev

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-02 22:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02 18:11 How to avoid getting ndo_open() immediately after probe Arijit De
2021-12-02 19:41 ` Stephen Hemminger
2021-12-02 20:29 ` Lino Sanfilippo
2021-12-02 22:35   ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.