Bug #423
closedMoving a macvtap on top of batX to netns causes error
Added by Leonardo Mörlein over 2 years ago. Updated over 2 years ago.
100%
Description
Moving a macvtap interface on top of a batadv device into a netns causes an error. The following error is printed to dmesg:
[569490.277121] batman_adv: Cannot find parent device
The setup can be reproduced using the following script:
#!/bin/sh # preparation ip link add bat0 type batadv ip link set bat0 up ip netns add test ip link add link bat0 name vtap type macvtap # trigger the bug ip link set vtap netns test up # cleanup ip netns exec test ip link del vtap ip link del bat0 ip netns del testI can reproduce this with:
- 2021.3
- 2022.0
I haven't checked other versions.
Updated by Sven Eckelmann over 2 years ago
- Status changed from New to Feedback
- Assignee changed from batman-adv developers to Leonardo Mörlein
This message should just tell us that it was either not possible to get the correct parent net_namespace via rtnl or the parent dev via dev_get_iflink index (based on parent net_namespace). So the safety mechanism to prevent batman-adv over batman-adv is therefore disabled. But does it show any another kind of problems or only this message?
Updated by Leonardo Mörlein over 2 years ago
I did not observe any other consequences.
If this is more or less just a warning, maybe the can be changed from loglevel "error" to loglevel "warning"?
For me, this is only a problem since its loglevel is "error". Since I regularly create macvtap devices and move them to network namespaces, this "error" occurs regularly for me and monitoring complains about it. While I could also just silence this error in the monitoring, it seems to me it might make sense to change the loglevel here? What do you think?
Updated by Sven Eckelmann over 2 years ago
- Status changed from Feedback to In Progress
- Assignee changed from Leonardo Mörlein to Sven Eckelmann
- Target version set to 2022.1
Yes, I would agree. But I would delay the submission of the mini patch (pr_err -> pr_warn
+ adjusted text) until I got all facts straight. This might sound a little bit strange but I have to write an acceptable commit message for the submission and there are also other people which wanted to change the way how this is handled. Which could mean that batman-adv needs other changes (but for some reason was forgotten)
I have now reproduced this problem with your script. View log...View log...
Thread 1 hit Breakpoint 1, batadv_is_on_batman_iface (net_dev=net_dev@entry=0xffff88800ab28000) at /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/hard-interface.c:171 171 pr_err("Cannot find parent device\n"); (gdb) bt full #0 batadv_is_on_batman_iface (net_dev=net_dev@entry=0xffff88800ab28000) at /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/hard-interface.c:171 net = 0xffff88800cb00000 parent_dev = 0x0 <fixed_percpu_data> parent_net = 0xffff88800cb00000 ret = <optimized out> #1 0xffffffffa0023663 in batadv_is_valid_iface (net_dev=net_dev@entry=0xffff88800ab28000) at /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/hard-interface.c:195 No locals. #2 0xffffffffa002456e in batadv_hardif_add_interface (net_dev=net_dev@entry=0xffff88800ab28000) at /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/hard-interface.c:843 hard_iface = <optimized out> out = <optimized out> #3 0xffffffffa00258cc in batadv_hard_if_event (this=<optimized out>, event=5, ptr=<optimized out>) at /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/hard-interface.c:936 net_dev = 0xffff88800ab28000 hard_iface = 0x0 <fixed_percpu_data> primary_if = 0x0 <fixed_percpu_data> bat_priv = <optimized out> #4 0xffffffff8117e459 in notifier_call_chain (nl=nl@entry=0xffffffff853e0340 <netdev_chain>, val=val@entry=5, v=v@entry=0xffff88800abbee80, nr_to_call=-18, nr_to_call@entry=-1, nr_calls=nr_calls@entry=0x0 <fixed_percpu_data>) at kernel/notifier.c:84 ret = 0 nb = 0xffffffffa0074cc0 <batadv_hard_if_notifier> next_nb = 0xffffffff83853c20 <ndisc_netdev_notifier> #5 0xffffffff8117e542 in raw_notifier_call_chain (nh=nh@entry=0xffffffff853e0340 <netdev_chain>, val=val@entry=5, v=v@entry=0xffff88800abbee80) at kernel/notifier.c:392 No locals. #6 0xffffffff81ed3ee8 in call_netdevice_notifiers_info (val=val@entry=5, info=info@entry=0xffff88800abbee80) at net/core/dev.c:1919 net = <optimized out> ret = <optimized out> #7 0xffffffff81ee64da in call_netdevice_notifiers_extack (extack=0x0 <fixed_percpu_data>, dev=0xffff88800ab28000, val=5) at net/core/dev.c:1931 info = {dev = <optimized out>, extack = <optimized out>} #8 call_netdevice_notifiers (dev=0xffff88800ab28000, val=5) at net/core/dev.c:1945 No locals. #9 __dev_change_net_namespace (dev=dev@entry=0xffff88800ab28000, net=net@entry=0xffff88800cb00000, pat=pat@entry=0x0 <fixed_percpu_data>, new_ifindex=11) at net/core/dev.c:10607 net_old = 0xffffffff837a1100 <init_net> err = <optimized out> new_nsid = <optimized out> #10 0xffffffff81f313dc in do_setlink (skb=skb@entry=0xffff88800c0ce8c0, dev=dev@entry=0xffff88800ab28000, ifm=ifm@entry=0xffff88800a0b9c10, extack=extack@entry=0xffff88800abbf890, tb=tb@entry=0xffff88800abbf418, ifname=ifname@entry=0xffff88800abbf638 "", status=<optimized out>) at net/core/rtnetlink.c:2636 pat = 0x0 <fixed_percpu_data> net = <optimized out> new_ifindex = <optimized out> ops = 0xffffffff82e17f80 <macvlan_netdev_ops> err = <optimized out> #11 0xffffffff81f3421f in __rtnl_newlink (skb=skb@entry=0xffff88800c0ce8c0, nlh=nlh@entry=0xffff88800a0b9c00, attr=attr@entry=0xffff88800a0bb000, extack=extack@entry=0xffff88800abbf890) at net/core/rtnetlink.c:3416 status = <optimized out> slave_attr = {<optimized out> <repeats 41 times>} name_assign_type = 3 '\003' linkinfo = {<optimized out>, <optimized out>, <optimized out>, <optimized out>, <optimized out>, <optimized out>} m_ops = 0x0 <fixed_percpu_data> master_dev = 0x0 <fixed_percpu_data> net = 0xffffffff837a1100 <init_net> ops = <optimized out> tb = {<optimized out> <repeats 59 times>} dest_net = <optimized out> link_net = <optimized out> slave_data = <optimized out> kind = {<optimized out> <repeats 56 times>} dev = <optimized out> ifm = <optimized out> ifname = {<optimized out> <repeats 16 times>} data = <optimized out> err = <optimized out> #12 0xffffffff81f34b3f in rtnl_newlink (skb=0xffff88800c0ce8c0, nlh=0xffff88800a0b9c00, extack=0xffff88800abbf890) at net/core/rtnetlink.c:3531 attr = 0xffff88800a0bb000 ret = <optimized out> #13 0xffffffff81f38816 in rtnetlink_rcv_msg (skb=skb@entry=0xffff88800c0ce8c0, nlh=nlh@entry=0xffff88800a0b9c00, extack=extack@entry=0xffff88800abbf890) at net/core/rtnetlink.c:5596 --Type <RET> for more, q to quit, c to continue without paging--c net = <optimized out> link = <optimized out> owner = 0x0 <fixed_percpu_data> err = -95 doit = <optimized out> flags = <optimized out> kind = 0 family = <optimized out> type = 0 #14 0xffffffff820044cd in netlink_rcv_skb (skb=0xffff88800c0ce8c0, cb=<optimized out>) at net/netlink/af_netlink.c:2494 msglen = <optimized out> extack = {_msg = <optimized out>, bad_attr = <optimized out>, policy = <optimized out>, cookie = {<optimized out> <repeats 20 times>}, cookie_len = <optimized out>} nlh = 0xffff88800a0b9c00 err = 0 #15 0xffffffff82002b1d in netlink_unicast_kernel (ssk=0xffff88800d2ec000, skb=0xffff88800c0ce8c0, sk=0xffff8880058ee000) at net/netlink/af_netlink.c:1317 ret = <optimized out> nlk = 0xffff8880058ee000 ret = <optimized out> nlk = <optimized out> #16 netlink_unicast (ssk=ssk@entry=0xffff88800d2ec000, skb=skb@entry=0xffff88800c0ce8c0, portid=portid@entry=0, nonblock=<optimized out>) at net/netlink/af_netlink.c:1343 sk = 0xffff8880058ee000 err = <optimized out> timeo = <optimized out> #17 0xffffffff82003545 in netlink_sendmsg (sock=<optimized out>, msg=0xffff88800abbfe70, len=<optimized out>) at net/netlink/af_netlink.c:1919 sk = 0xffff88800d2ec000 nlk = 0xffff88800d2ec000 addr = <optimized out> dst_portid = 0 dst_group = 0 skb = 0xffff88800c0ce8c0 err = 0 scm = {pid = <optimized out>, fp = <optimized out>, creds = {pid = <optimized out>, uid = {val = <optimized out>}, gid = {val = <optimized out>}}} netlink_skb_flags = 8 #18 0xffffffff81e6ac2d in sock_sendmsg_nosec (msg=0xffff88800abbfe70, sock=0xffff88800c633c00) at ./include/linux/uio.h:246 ret = <optimized out> ret = <optimized out> #19 sock_sendmsg (msg=0xffff88800abbfe70, sock=0xffff88800c633c00) at net/socket.c:725 err = 0 err = <optimized out> #20 ____sys_sendmsg (sock=sock@entry=0xffff88800c633c00, msg_sys=msg_sys@entry=0xffff88800abbfe70, flags=<optimized out>, flags@entry=0, used_address=used_address@entry=0x0 <fixed_percpu_data>, allowed_msghdr_flags=allowed_msghdr_flags@entry=0) at net/socket.c:2413 ctl = {<optimized out> <repeats 36 times>} ctl_buf = 0xffff88800abbfb40 "" ctl_len = <optimized out> err = <optimized out> #21 0xffffffff81e6f9be in ___sys_sendmsg (sock=sock@entry=0xffff88800c633c00, msg=msg@entry=0x7ffd3984b100, msg_sys=msg_sys@entry=0xffff88800abbfe70, flags=flags@entry=0, used_address=used_address@entry=0x0 <fixed_percpu_data>, allowed_msghdr_flags=allowed_msghdr_flags@entry=0) at net/socket.c:2467 address = {{{ss_family = <optimized out>, __data = {<optimized out> <repeats 126 times>}}, __align = <optimized out>}} iovstack = {{iov_base = <optimized out>, iov_len = <optimized out>}, {iov_base = <optimized out>, iov_len = <optimized out>}, {iov_base = <optimized out>, iov_len = <optimized out>}, {iov_base = <optimized out>, iov_len = <optimized out>}, {iov_base = <optimized out>, iov_len = <optimized out>}, {iov_base = <optimized out>, iov_len = <optimized out>}, {iov_base = <optimized out>, iov_len = <optimized out>}, {iov_base = <optimized out>, iov_len = <optimized out>}} iov = <optimized out> err = 0 #22 0xffffffff81e6fc04 in __sys_sendmsg (fd=<optimized out>, msg=0x7ffd3984b100, flags=0, forbid_cmsg_compat=<optimized out>) at net/socket.c:2496 fput_needed = <optimized out> err = <optimized out> msg_sys = {msg_name = <optimized out>, msg_namelen = <optimized out>, msg_iter = {iter_type = <optimized out>, nofault = <optimized out>, data_source = <optimized out>, iov_offset = <optimized out>, count = <optimized out>, {iov = <optimized out>, kvec = <optimized out>, bvec = <optimized out>, xarray = <optimized out>, pipe = <optimized out>}, {nr_segs = <optimized out>, {head = <optimized out>, start_head = <optimized out>}, xarray_start = <optimized out>}}, {msg_control = <optimized out>, msg_control_user = <optimized out>}, msg_control_is_user = <optimized out>, msg_controllen = <optimized out>, msg_flags = <optimized out>, msg_iocb = <optimized out>} sock = 0xffff88800c633c00 #23 0xffffffff82619d8d in do_syscall_x64 (nr=<optimized out>, regs=0xffff88800abbff58) at arch/x86/entry/common.c:50 unr = <optimized out> #24 do_syscall_64 (regs=0xffff88800abbff58, nr=<optimized out>) at arch/x86/entry/common.c:80 No locals. #25 0xffffffff8280007c in entry_SYSCALL_64 () at arch/x86/entry/entry_64.S:113 No locals. #26 0x00007ffd3984b8d8 in ?? () No symbol table info available. #27 0x0000000000000000 in ?? () No symbol table info available. (gdb) print net $1 = (struct net *) 0xffff88800cb00000 (gdb) print parent_net $2 = (struct net *) 0xffff88800cb00000 (gdb) print *net_dev $3 = {name = "vtap", '\000' <repeats 11 times>, name_node = 0xffff888009fab580, ifalias = 0x0 <fixed_percpu_data>, mem_end = 0, mem_start = 0, base_addr = 0, state = 2, dev_list = {next = 0xffff88800cb00168, prev = 0xffff888006f6a040}, napi_list = { next = 0xffff88800ab28050, prev = 0xffff88800ab28050}, unreg_list = {next = 0xffff88800ab28060, prev = 0xffff88800ab28060}, close_list = {next = 0xffff88800ab28070, prev = 0xffff88800ab28070}, ptype_all = {next = 0xffff88800ab28080, prev = 0xffff88800ab28080}, ptype_specific = {next = 0xffff88800ab28090, prev = 0xffff88800ab28090}, adj_list = {upper = {next = 0xffff88800ab280a0, prev = 0xffff88800ab280a0}, lower = {next = 0xffff8880098ebf98, prev = 0xffff8880098ebf98}}, flags = 4098, priv_flags = 4295036928, netdev_ops = 0xffffffff82e17f80 <macvlan_netdev_ops>, ifindex = 11, gflags = 0, hard_header_len = 14, mtu = 1500, needed_headroom = 0, needed_tailroom = 0, features = 27109839369, hw_features = 720578139402586112, wanted_features = 18432, vlan_features = 27109818409, hw_enc_features = 27378274825, mpls_features = 1, gso_partial_features = 0, min_mtu = 68, max_mtu = 1500, type = 1, min_header_len = 14 '\016', name_assign_type = 3 '\003', group = 0, stats = {rx_packets = 0, tx_packets = 0, rx_bytes = 0, tx_bytes = 0, rx_errors = 0, tx_errors = 0, rx_dropped = 0, tx_dropped = 0, multicast = 0, collisions = 0, rx_length_errors = 0, rx_over_errors = 0, rx_crc_errors = 0, rx_frame_errors = 0, rx_fifo_errors = 0, rx_missed_errors = 0, tx_aborted_errors = 0, tx_carrier_errors = 0, tx_fifo_errors = 0, tx_heartbeat_errors = 0, tx_window_errors = 0, rx_compressed = 0, tx_compressed = 0}, rx_dropped = {counter = 0}, tx_dropped = {counter = 0}, rx_nohandler = {counter = 0}, carrier_up_count = { counter = 0}, carrier_down_count = {counter = 0}, ethtool_ops = 0xffffffff82e18200 <macvlan_ethtool_ops>, ndisc_ops = 0x0 <fixed_percpu_data>, header_ops = 0xffffffff82e18460 <macvlan_hard_header_ops>, operstate = 6 '\006', link_mode = 0 '\000', if_port = 0 '\000', dma = 0 '\000', perm_addr = '\000' <repeats 31 times>, addr_assign_type = 1 '\001', addr_len = 6 '\006', upper_level = 1 '\001', lower_level = 3 '\003', neigh_priv_len = 0, dev_id = 0, dev_port = 0, padded = 0, addr_list_lock = {{rlock = { raw_lock = {{val = {counter = 0}, {locked = 0 '\000', pending = 0 '\000'}, {locked_pending = 0, tail = 0}}}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff853db3e0 <macvlan_netdev_addr_lock_key>, class_cache = {0xffffffff84898520 <lock_classes+228352>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82e17aa0 "&macvlan_netdev_addr_lock_key", wait_type_outer = 0 '\000', wait_type_inner = 2 '\002', lock_type = 0 '\000', cpu = 0, ip = 18446744071594595689}}, { __padding = "\000\000\000\000\255N\255\336\377\377\377\377\000\000\000\000\377\377\377\377\377\377\377\377", dep_map = {key = 0xffffffff853db3e0 <macvlan_netdev_addr_lock_key>, class_cache = {0xffffffff84898520 <lock_classes+228352>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82e17aa0 "&macvlan_netdev_addr_lock_key", wait_type_outer = 0 '\000', wait_type_inner = 2 '\002', lock_type = 0 '\000', cpu = 0, ip = 18446744071594595689}}}}, irq = 0, uc = {list = {next = 0xffff88800ab282a0, prev = 0xffff88800ab282a0}, count = 0, tree = {rb_node = 0x0 <fixed_percpu_data>}}, mc = {list = {next = 0xffff88800a11c000, prev = 0xffff88800a11c000}, count = 1, tree = {rb_node = 0xffff88800a11c010}}, dev_addrs = {list = {next = 0xffff88800a058100, prev = 0xffff88800a058100}, count = 1, tree = {rb_node = 0xffff88800a058110}}, queues_kset = 0xffff888009ba9800, unlink_list = {next = 0xffff88800ab28308, prev = 0xffff88800ab28308}, promiscuity = 0, allmulti = 0, uc_promisc = false, nested_level = 2 '\002', vlan_info = 0x0 <fixed_percpu_data>, ip_ptr = 0xffff88800a9bf800, ip6_ptr = 0xffff88800d2ce000, ieee80211_ptr = 0x0 <fixed_percpu_data>, ieee802154_ptr = 0x0 <fixed_percpu_data>, dev_addr = 0xffff88800a058128 "\346\263X#\327", <incomplete sequence \342>, _rx = 0xffff888009ba9900, num_rx_queues = 1, real_num_rx_queues = 1, xdp_prog = 0x0 <fixed_percpu_data>, gro_flush_timeout = 0, napi_defer_hard_irqs = 0, gro_max_size = 65536, rx_handler = 0xffffffff81de0a60 <tap_handle_frame>, rx_handler_data = 0xffff88800ab28a80, ingress_queue = 0x0 <fixed_percpu_data>, broadcast = "\377\377\377\377\377\377", '\000' <repeats 25 times>, rx_cpu_rmap = 0x0 <fixed_percpu_data>, index_hlist = {next = 0x0 <fixed_percpu_data>, pprev = 0xffff888006b6b058}, _tx = 0xffff88800a1d8800, num_tx_queues = 1, real_num_tx_queues = 1, qdisc = 0xffffffff837e27c0 <noop_qdisc>, tx_queue_len = 500, tx_global_lock = {{rlock = {raw_lock = {{val = {counter = 0}, {locked = 0 '\000', pending = 0 '\000'}, {locked_pending = 0, tail = 0}}}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff853dfac0 <__key.6>, class_cache = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82e46660 "&dev->tx_global_lock", wait_type_outer = 0 '\000', wait_type_inner = 2 '\002', lock_type = 0 '\000', cpu = 0, ip = 0}}, {__padding = "\000\000\000\000\255N\255\336\377\377\377\377\000\000\000\000\377\377\377\377\377\377\377\377", dep_map = {key = 0xffffffff853dfac0 <__key.6>, class_cache = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82e46660 "&dev->tx_global_lock", wait_type_outer = 0 '\000', wait_type_inner = 2 '\002', lock_type = 0 '\000', cpu = 0, ip = 0}}}}, xdp_bulkq = 0x0 <fixed_percpu_data>, xps_maps = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, watchdog_timer = {entry = {next = 0x0 <fixed_percpu_data>, pprev = 0x0 <fixed_percpu_data>}, expires = 0, function = 0xffffffff81fea860 <dev_watchdog>, flags = 0, lockdep_map = {key = 0xffffffff853e1300 <__key.0>, class_cache = { 0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82e64be0 "(&dev->watchdog_timer)", wait_type_outer = 0 '\000', wait_type_inner = 0 '\000', lock_type = 0 '\000', cpu = 0, ip = 0}}, watchdog_timeo = 0, proto_down_reason = 0, todo_list = { next = 0x0 <fixed_percpu_data>, prev = 0x0 <fixed_percpu_data>}, pcpu_refcnt = 0x607fe5204adc, refcnt_tracker = {<No data fields>}, link_watch_list = {next = 0xffff88800ab284f8, prev = 0xffff88800ab284f8}, reg_state = NETREG_REGISTERED, dismantle = false, rtnl_link_state = RTNL_LINK_INITIALIZED, needs_free_netdev = true, priv_destructor = 0x0 <fixed_percpu_data>, nd_net = {net = 0xffff88800cb00000}, ml_priv = 0x0 <fixed_percpu_data>, ml_priv_type = ML_PRIV_NONE, {lstats = 0x0 <fixed_percpu_data>, tstats = 0x0 <fixed_percpu_data>, dstats = 0x0 <fixed_percpu_data>}, dev = {kobj = {name = 0xffff888006a51aa0 "vtap", entry = {next = 0xffff88800923b808, prev = 0xffff888006f6a540}, parent = 0xffff8880071de800, kset = 0xffff888006241700, ktype = 0xffffffff8371bf80 <device_ktype>, sd = 0xffff88800e62d0f0, kref = {refcount = {refs = {counter = 5}}}, state_initialized = 1, state_in_sysfs = 1, state_add_uevent_sent = 1, state_remove_uevent_sent = 1, uevent_suppress = 0}, parent = 0x0 <fixed_percpu_data>, p = 0xffff88800a1d9400, init_name = 0x0 <fixed_percpu_data>, type = 0x0 <fixed_percpu_data>, bus = 0x0 <fixed_percpu_data>, driver = 0x0 <fixed_percpu_data>, platform_data = 0xffff88800ab28000, driver_data = 0x0 <fixed_percpu_data>, lockdep_mutex = {owner = {counter = 0}, wait_lock = {raw_lock = {{val = {counter = 0}, {locked = 0 '\000', pending = 0 '\000'}, {locked_pending = 0, tail = 0}}}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff84149ee0 <__key.0>, class_cache = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82c6e200 "&lock->wait_lock", wait_type_outer = 0 '\000', wait_type_inner = 2 '\002', lock_type = 0 '\000', cpu = 0, ip = 0}}, osq = {tail = {counter = 0}}, wait_list = {next = 0xffff88800ab28610, prev = 0xffff88800ab28610}, magic = 0xffff88800ab285b8, dep_map = {key = 0xffffffff853d9900 <__key.12>, class_cache = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82df85a0 "&dev->lockdep_mutex", wait_type_outer = 0 '\000', wait_type_inner = 3 '\003', lock_type = 0 '\000', cpu = 0, ip = 0}}, mutex = {owner = {counter = 0}, wait_lock = {raw_lock = {{val = {counter = 0}, { locked = 0 '\000', pending = 0 '\000'}, {locked_pending = 0, tail = 0}}}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff84149ee0 <__key.0>, class_cache = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82c6e200 "&lock->wait_lock", wait_type_outer = 0 '\000', wait_type_inner = 2 '\002', lock_type = 0 '\000', cpu = 0, ip = 0}}, osq = {tail = {counter = 0}}, wait_list = {next = 0xffff88800ab286b0, prev = 0xffff88800ab286b0}, magic = 0xffff88800ab28658, dep_map = {key = 0xffffffff84149fe0 <__lockdep_no_validate__>, class_cache = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82df8560 "&dev->mutex", wait_type_outer = 0 '\000', wait_type_inner = 3 '\003', lock_type = 0 '\000', cpu = 0, ip = 0}}, links = {suppliers = {next = 0xffff88800ab286f8, prev = 0xffff88800ab286f8}, consumers = {next = 0xffff88800ab28708, prev = 0xffff88800ab28708}, defer_sync = {next = 0xffff88800ab28718, prev = 0xffff88800ab28718}, status = DL_DEV_NO_DRIVER}, power = {power_state = {event = 0}, can_wakeup = 0, async_suspend = 0, in_dpm_list = false, is_prepared = false, is_suspended = false, is_noirq_suspended = false, is_late_suspended = false, no_pm = false, early_init = true, direct_complete = false, driver_flags = 0, lock = {{rlock = {raw_lock = {{val = {counter = 0}, {locked = 0 '\000', pending = 0 '\000'}, {locked_pending = 0, tail = 0}}}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff853d9880 <__key.10>, class_cache = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82df8620 "&dev->power.lock", wait_type_outer = 0 '\000', wait_type_inner = 2 '\002', lock_type = 0 '\000', cpu = 0, ip = 0}}, {__padding = "\000\000\000\000\255N\255\336\377\377\377\377\000\000\000\000\377\377\377\377\377\377\377\377", dep_map = {key = 0xffffffff853d9880 <__key.10>, class_cache = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82df8620 "&dev->power.lock", wait_type_outer = 0 '\000', wait_type_inner = 2 '\002', lock_type = 0 '\000', cpu = 0, ip = 0}}}}, should_wakeup = 0, subsys_data = 0x0 <fixed_percpu_data>, set_latency_tolerance = 0x0 <fixed_percpu_data>, qos = 0x0 <fixed_percpu_data>}, pm_domain = 0x0 <fixed_percpu_data>, msi = {domain = 0x0 <fixed_percpu_data>, data = 0x0 <fixed_percpu_data>}, dma_ops = 0x0 <fixed_percpu_data>, dma_mask = 0x0 <fixed_percpu_data>, coherent_dma_mask = 0, bus_dma_limit = 0, dma_range_map = 0x0 <fixed_percpu_data>, dma_parms = 0x0 <fixed_percpu_data>, dma_pools = {next = 0xffff88800ab287f0, prev = 0xffff88800ab287f0}, dma_io_tlb_mem = 0xffffffff84c4edc0 <io_tlb_default_mem>, archdata = {<No data fields>}, of_node = 0x0 <fixed_percpu_data>, fwnode = 0x0 <fixed_percpu_data>, devt = 0, id = 0, devres_lock = {{rlock = {raw_lock = {{val = {counter = 0}, {locked = 0 '\000', pending = 0 '\000'}, {locked_pending = 0, tail = 0}}}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff853d98c0 <__key.11>, class_cache = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82df85e0 "&dev->devres_lock", wait_type_outer = 0 '\000', wait_type_inner = 2 '\002', lock_type = 0 '\000', cpu = 0, ip = 0}}, {__padding = "\000\000\000\000\255N\255\336\377\377\377\377\000\000\000\000\377\377\377\377\377\377\377\377", dep_map = {key = 0xffffffff853d98c0 <__key.11>, class_cache = {0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, name = 0xffffffff82df85e0 "&dev->devres_lock", wait_type_outer = 0 '\000', wait_type_inner = 2 '\002', lock_type = 0 '\000', cpu = 0, ip = 0}}}}, devres_head = {next = 0xffff88800ab28868, prev = 0xffff88800ab28868}, class = 0xffffffff830ca360 <net_class>, groups = 0xffff88800ab288a8, release = 0x0 <fixed_percpu_data>, iommu_group = 0x0 <fixed_percpu_data>, iommu = 0x0 <fixed_percpu_data>, removable = DEVICE_REMOVABLE_NOT_SUPPORTED, offline_disabled = false, offline = false, of_node_reused = false, state_synced = false, can_match = false}, sysfs_groups = {0xffffffff82e5d060 <netstat_group>, 0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>, 0x0 <fixed_percpu_data>}, sysfs_rx_queue_group = 0x0 <fixed_percpu_data>, rtnl_link_ops = 0xffffffff8391a160 <macvtap_link_ops>, gso_max_size = 65536, gso_max_segs = 65535, num_tc = 0, tc_to_txq = {{count = 0, offset = 0} <repeats 16 times>}, prio_tc_map = '\000' <repeats 15 times>, priomap = 0x0 <fixed_percpu_data>, phydev = 0x0 <fixed_percpu_data>, sfp_bus = 0x0 <fixed_percpu_data>, qdisc_tx_busylock = 0xffffffff853db3a0 <qdisc_tx_busylock_key>, proto_down = false, wol_enabled = 0, threaded = 0, net_notifier_list = {next = 0xffff88800ab28958, prev = 0xffff88800ab28958}, udp_tunnel_nic_info = 0x0 <fixed_percpu_data>, udp_tunnel_nic = 0x0 <fixed_percpu_data>, xdp_state = {{prog = 0x0 <fixed_percpu_data>, link = 0x0 <fixed_percpu_data>}, {prog = 0x0 <fixed_percpu_data>, link = 0x0 <fixed_percpu_data>}, {prog = 0x0 <fixed_percpu_data>, link = 0x0 <fixed_percpu_data>}}, dev_addr_shadow = "\346\263X#\327\342", '\000' <repeats 25 times>, linkwatch_dev_tracker = {<No data fields>}, watchdog_dev_tracker = {<No data fields>}} (gdb) frame 3 #3 0xffffffffa00258cc in batadv_hard_if_event (this=<optimized out>, event=5, ptr=<optimized out>) at /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/hard-interface.c:936 936 hard_iface = batadv_hardif_add_interface(net_dev); (gdb) print event $4 = 5 (gdb) print (int)NETDEV_REGISTER $5 = 5 (gdb) frame 0 #0 batadv_is_on_batman_iface (net_dev=net_dev@entry=0xffff88800ab28000) at /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/hard-interface.c:171 171 pr_err("Cannot find parent device\n"); (gdb) print net_dev $6 = (const struct net_device *) 0xffff88800ab28000 (gdb) print net_dev->rtnl_link_ops $7 = (const struct rtnl_link_ops *) 0xffffffff8391a160 <macvtap_link_ops> (gdb) print net_dev->rtnl_link_ops->get_link_net $8 = (struct net *(*)(const struct net_device *)) 0x0 <fixed_percpu_data> (gdb) print net_dev->netdev_ops $9 = (const struct net_device_ops *) 0xffffffff82e17f80 <macvlan_netdev_ops> (gdb) print net_dev->netdev_ops->ndo_get_iflink $10 = (int (*)(const struct net_device *)) 0xffffffff81dd0900 <macvlan_dev_get_iflink>
I've added following small change to check the state:
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 59d19097..eb62d426 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -162,6 +162,7 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev) parent_net = batadv_getlink_net(net_dev, net); + printk("%p %d\n", parent_net, dev_get_iflink(net_dev)); /* recurse over the parent device */ parent_dev = __dev_get_by_index((struct net *)parent_net, dev_get_iflink(net_dev));
The result was here:
[ 50.293921][ T240] ffff88800cb00000 10
As you can see, the macvtap doesn't provide a way to figure out the link net but it returns an ifindex of 10 via its netdev_ops - which isn't valid in the "test" ns (which batman-adv uses as fallback in case the device itself returns the correct namespace of its link). The ifindex 10 btw. is bat0 in the init_net namespace:
root@node01:~# ip netns exec test ip link 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/gre 0.0.0.0 brd 0.0.0.0 3: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 4: erspan0@NONE: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/sit 0.0.0.0 brd 0.0.0.0 11: vtap@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 500 link/ether e6:b3:58:23:d7:e2 brd ff:ff:ff:ff:ff:ff root@node01:~# ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: dummy0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue master bat0 state UNKNOWN mode DEFAULT group default qlen 1000 link/ether 7a:62:40:45:d0:d3 brd ff:ff:ff:ff:ff:ff 3: enp0s1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bat0 state UP mode DEFAULT group default qlen 1000 link/ether 02:ba:de:af:fe:01 brd ff:ff:ff:ff:ff:ff 4: enp0s2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 06:ba:de:af:fe:01 brd ff:ff:ff:ff:ff:ff 5: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bat0 state UP mode DEFAULT group default qlen 1000 link/ether 12:ba:de:af:fe:01 brd ff:ff:ff:ff:ff:ff 6: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/gre 0.0.0.0 brd 0.0.0.0 7: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 8: erspan0@NONE: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 9: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/sit 0.0.0.0 brd 0.0.0.0 10: bat0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/ether f2:b8:43:a3:75:7b brd ff:ff:ff:ff:ff:ff
I want to check if batman-adv is maybe not doing the checking correctly. But at least at the moment, it looks to me like rtnl (used by iproute2) is doing it similar (why it is shown in the iflink as "if10")
Updated by Sven Eckelmann over 2 years ago
- % Done changed from 0 to 50
There is now an RFC for the change in batman-adv https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/20220227235257.1324636-4-sven@narfation.org/
And one for macvtap https://patchwork.kernel.org/project/netdevbpf/patch/20220228003240.1337426-1-sven@narfation.org/
Updated by Sven Eckelmann over 2 years ago
- Status changed from In Progress to Resolved
- % Done changed from 50 to 100
Both macvtap and batman-adv are now in the kernel. Following files are providing .ndo_get_iflink
- drivers/infiniband/ulp/ipoib/ipoib_main.c
- drivers/net/can/vxcan.c
- drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
- drivers/net/ipvlan/ipvlan_main.c
- drivers/net/macsec.c
- drivers/net/macvlan.c
- drivers/net/veth.c
- drivers/net/wireless/virt_wifi.c
- net/8021q/vlan_dev.c
- net/dsa/slave.c
- net/ieee802154/6lowpan/core.c
- net/ipv4/ip_gre.c
And following are providing .get_link_net
- drivers/net/can/vxcan.c
- drivers/net/ipvlan/ipvlan_main.c
- drivers/net/macsec.c
- drivers/net/macvlan.c
- drivers/net/macvtap.c
- drivers/net/ppp/ppp_generic.c
- drivers/net/veth.c
- drivers/net/vxlan.c
- net/8021q/vlan_netlink.c
- net/ipv4/ip_gre.c
- net/ipv4/ip_vti.c
- net/ipv4/ipip.c
- net/ipv6/ip6_gre.c
- net/ipv6/ip6_tunnel.c
- net/ipv6/ip6_vti.c
- net/ipv6/sit.c
- net/xfrm/xfrm_interface.c
- net/ipv4/ip_vti.c
- net/ipv4/ipip.c
- net/ipv4/ipmr.c
- net/ipv6/ip6_gre.c
- net/ipv6/ip6_tunnel.c
- net/ipv6/ip6_vti.c
- net/ipv6/ip6mr.c
- net/ipv6/sit.c
- net/xfrm/xfrm_interface.c
So there might be more devices types which have the same problem.
Updated by Sven Eckelmann over 2 years ago
- Status changed from Resolved to Closed