Subject: Re: WARNING: at net/batman-adv/hard-interface.c:92 batadv_is_on_batman_iface()

From: Antonio Quartulli <[email-masked]>
Date: Sat, 30 Mar 2013 12:52:45 +0100

Hello all,

On Sat, Mar 30, 2013 at 05:36:35PM +0800, Fengguang Wu wrote:
> Greetings,
> 
> I got the below WARNING in net-next/master (head commit f498354793d5)
> and the first bad commit is
> 
> commit c54419321455631079c7d6e60bc732dd0c5914c5
> Author: Pravin B Shelar <[email-masked]>
> Date:   Mon Mar 25 14:49:35 2013 +0000
> 
>     GRE: Refactor GRE tunneling code.
>     
>     Following patch refactors GRE code into ip tunneling code and GRE
>     specific code. Common tunneling code is moved to ip_tunnel module.
>     ip_tunnel module is written as generic library which can be used
>     by different tunneling implementations.
>     
>     ip_tunnel module contains following components:
>      - packet xmit and rcv generic code. xmit flow looks like
>        (gre_xmit/ipip_xmit)->ip_tunnel_xmit->ip_local_out.
>      - hash table of all devices.
>      - lookup for tunnel devices.
>      - control plane operations like device create, destroy, ioctl, netlink
>        operations code.
>      - registration for tunneling modules, like gre, ipip etc.
>      - define single pcpu_tstats dev->tstats.
>      - struct tnl_ptk_info added to pass parsed tunnel packet parameters.
>     
>     ipip.h header is renamed to ip_tunnel.h
>     
>     Signed-off-by: Pravin B Shelar <[email-masked]>
>     Signed-off-by: David S. Miller <[email-masked]>
> 
> [   27.507156] libceph: loaded (mon/osd proto 15/24)
> [   27.515409] ------------[ cut here ]------------
> [   27.518917] WARNING: at /c/kernel-tests/src/stable/net/batman-adv/hard-interface.c:92 batadv_is_on_batman_iface+0x5c/0x7a()
> [   27.521935] Hardware name: Bochs
> [   27.525356] Cannot find parent device
> [   27.528296] Modules linked in:
> [   27.529923] Pid: 1, comm: swapper/0 Not tainted 3.9.0-rc4-00896-g03ba910 #794
> [   27.531747] Call Trace:
> [   27.534683]  [<ffffffff81098ab4>] warn_slowpath_common+0x83/0x9e
> [   27.536338]  [<ffffffff81098b72>] warn_slowpath_fmt+0x46/0x48
> [   27.537872]  [<ffffffff828e6402>] ? rcu_read_unlock+0x1c/0x2d
> [   27.539441]  [<ffffffff810ca498>] ? local_clock+0x19/0x52
> [   27.541023]  [<ffffffff82c0e796>] batadv_is_on_batman_iface+0x5c/0x7a
> [   27.542803]  [<ffffffff82c0efe2>] batadv_hard_if_event+0x8f/0x285
> [   27.544551]  [<ffffffff828e4ff0>] register_netdevice_notifier+0x71/0x17e
> [   27.550617]  [<ffffffff8420a030>] ? batadv_iv_init+0x3f/0x3f
> [   27.552248]  [<ffffffff8420a114>] batadv_init+0xe4/0x104
> [   27.553770]  [<ffffffff810020be>] do_one_initcall+0x7f/0x13d
> [   27.555386]  [<ffffffff84177eb0>] kernel_init_freeable+0x141/0x1d0
> [   27.557177]  [<ffffffff84177734>] ? do_early_param+0x8c/0x8c
> [   27.558813]  [<ffffffff82c1f146>] ? rest_init+0xda/0xda
> [   27.560348]  [<ffffffff82c1f154>] kernel_init+0xe/0xdb
> [   27.561813]  [<ffffffff82c694ac>] ret_from_fork+0x7c/0xb0
> [   27.563356]  [<ffffffff82c1f146>] ? rest_init+0xda/0xda
> [   27.564974] ---[ end trace f78f9f0651ffcb0b ]---
> 

The reason why batman-adv it raising this warning is because this call is
returning NULL:

dev_get_by_index(&init_net, net_dev->iflink);

net_dev is an interface that has been registered now and batman-adv is trying to
analyse it to decide if it is a potential candidate for its virtual device or
not.

To the best of my knowledge, if the function above is returning NULL, it means
that the iflink attribute contains a broken value.

Am I wrong or iflink should never contain 0? If there is no parent device it
should contain the same value of ifindex. Right?

Regards,

-- 
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara