Re: [PATCH net-next] net:set valid name before calling ndo_init()

From: Changli Gao
Date: Thu May 12 2011 - 11:33:24 EST


On Thu, Mar 24, 2011 at 11:16 AM, Weiping Pan(æåå)
<panweiping3@xxxxxxxxx> wrote:
> From: Pan Weiping <panweiping3@xxxxxxxxx>
>
> A bug of bonding was invloved by e815d19ffe02bdfda1260949ef2b1806171,
> see example 1 and 2.
>
> In register_netdevice(), the name of net_device is not valid until
> dev_get_valid_name() is called. But dev->netdev_ops->ndo_init(that is
> bond_init) is called before dev_get_valid_name(),
> and it uses the invalid name of net_device.
>
> I think register_netdevice() should make sure that the name of net_device is
> valid before calling ndo_init().
>
> example 1:
> modprobe bonding
> ls Â/proc/net/bonding/bond%d
>
> ps -eLf
> root   Â3398   2 Â3398 Â0  Â1 21:34 ?    Â00:00:00 [bond%d]
>
> example 2:
> modprobe bonding max_bonds=3
>
> [ Â170.100292] bonding: Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
> [ Â170.101090] bonding: Warning: either miimon or arp_interval and arp_ip_target module parameters must be specified, otherwise bonding will not detect link failures! see bonding.txt for details.
> [ Â170.102469] ------------[ cut here ]------------
> [ Â170.103150] WARNING: at /home/pwp/net-next-2.6/fs/proc/generic.c:586 proc_register+0x126/0x157()
> [ Â170.104075] Hardware name: VirtualBox
> [ Â170.105065] proc_dir_entry 'bonding/bond%d' already registered
> [ Â170.105613] Modules linked in: bonding(+) sunrpc ipv6 uinput microcode ppdev parport_pc parport joydev e1000 pcspkr i2c_piix4 i2c_core [last unloaded: bonding]
> [ Â170.108397] Pid: 3457, comm: modprobe Not tainted 2.6.39-rc2+ #14
> [ Â170.108935] Call Trace:
> [ Â170.109382] Â[<c0438f3b>] warn_slowpath_common+0x6a/0x7f
> [ Â170.109911] Â[<c051a42a>] ? proc_register+0x126/0x157
> [ Â170.110329] Â[<c0438fc3>] warn_slowpath_fmt+0x2b/0x2f
> [ Â170.110846] Â[<c051a42a>] proc_register+0x126/0x157
> [ Â170.111870] Â[<c051a4dd>] proc_create_data+0x82/0x98
> [ Â170.112335] Â[<f94e6af6>] bond_create_proc_entry+0x3f/0x73 [bonding]
> [ Â170.112905] Â[<f94dd806>] bond_init+0x77/0xa5 [bonding]
> [ Â170.113319] Â[<c0721ac6>] register_netdevice+0x8c/0x1d3
> [ Â170.113848] Â[<f94e0e30>] bond_create+0x6c/0x90 [bonding]
> [ Â170.114322] Â[<f94f4763>] bonding_init+0x763/0x7b1 [bonding]
> [ Â170.114879] Â[<c0401240>] do_one_initcall+0x76/0x122
> [ Â170.115317] Â[<f94f4000>] ? 0xf94f3fff
> [ Â170.115799] Â[<c0463f1e>] sys_init_module+0x1286/0x140d
> [ Â170.116879] Â[<c07c6d9f>] sysenter_do_call+0x12/0x28
> [ Â170.117404] ---[ end trace 64e4fac3ae5fff1a ]---
> [ Â170.117924] bond%d: Warning: failed to register to debugfs
> [ Â170.128728] ------------[ cut here ]------------
> [ Â170.129360] WARNING: at /home/pwp/net-next-2.6/fs/proc/generic.c:586 proc_register+0x126/0x157()
> [ Â170.130323] Hardware name: VirtualBox
> [ Â170.130797] proc_dir_entry 'bonding/bond%d' already registered
> [ Â170.131315] Modules linked in: bonding(+) sunrpc ipv6 uinput microcode ppdev parport_pc parport joydev e1000 pcspkr i2c_piix4 i2c_core [last unloaded: bonding]
> [ Â170.133731] Pid: 3457, comm: modprobe Tainted: G Â Â Â ÂW Â 2.6.39-rc2+ #14
> [ Â170.134308] Call Trace:
> [ Â170.134743] Â[<c0438f3b>] warn_slowpath_common+0x6a/0x7f
> [ Â170.135305] Â[<c051a42a>] ? proc_register+0x126/0x157
> [ Â170.135820] Â[<c0438fc3>] warn_slowpath_fmt+0x2b/0x2f
> [ Â170.137168] Â[<c051a42a>] proc_register+0x126/0x157
> [ Â170.137700] Â[<c051a4dd>] proc_create_data+0x82/0x98
> [ Â170.138174] Â[<f94e6af6>] bond_create_proc_entry+0x3f/0x73 [bonding]
> [ Â170.138745] Â[<f94dd806>] bond_init+0x77/0xa5 [bonding]
> [ Â170.139278] Â[<c0721ac6>] register_netdevice+0x8c/0x1d3
> [ Â170.139828] Â[<f94e0e30>] bond_create+0x6c/0x90 [bonding]
> [ Â170.140361] Â[<f94f4763>] bonding_init+0x763/0x7b1 [bonding]
> [ Â170.140927] Â[<c0401240>] do_one_initcall+0x76/0x122
> [ Â170.141494] Â[<f94f4000>] ? 0xf94f3fff
> [ Â170.141975] Â[<c0463f1e>] sys_init_module+0x1286/0x140d
> [ Â170.142463] Â[<c07c6d9f>] sysenter_do_call+0x12/0x28
> [ Â170.142974] ---[ end trace 64e4fac3ae5fff1b ]---
> [ Â170.144949] bond%d: Warning: failed to register to debugfs
>
> Signed-off-by: Pan Weiping <panweiping3@xxxxxxxxx>
Acked-by: Changli Gao <xiaosuo@xxxxxxxxx>


--
Regards,
Changli Gao(xiaosuo@xxxxxxxxx)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/