1. 04 12月, 2020 4 次提交
    • S
      batman-adv: Drop deprecated debugfs support · aff6f5a6
      Sven Eckelmann 提交于
      The debugfs support in batman-adv was marked as deprecated by the commit
      00caf6a2 ("batman-adv: Mark debugfs functionality as deprecated") and
      scheduled for removal in 2021.
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      aff6f5a6
    • S
      batman-adv: Drop deprecated sysfs support · 76e9f276
      Sven Eckelmann 提交于
      The sysfs in batman-adv support was marked as deprecated by the commit
      42cdd521 ("batman-adv: ABI: Mark sysfs files as deprecated") and
      scheduled for removal in 2021.
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      76e9f276
    • S
      batman-adv: Allow selection of routing algorithm over rtnetlink · a5ad457e
      Sven Eckelmann 提交于
      A batadv net_device is associated to a B.A.T.M.A.N. routing algorithm. This
      algorithm has to be selected before the interface is initialized and cannot
      be changed after that. The only way to select this algorithm was a module
      parameter which specifies the default algorithm used during the creation of
      the net_device.
      
      This module parameter is writeable over
      /sys/module/batman_adv/parameters/routing_algo and thus allows switching of
      the routing algorithm:
      
      1. change routing_algo parameter
      2. create new batadv net_device
      
      But this is not race free because another process can be scheduled between
      1 + 2 and in that time frame change the routing_algo parameter again.
      
      It is much cleaner to directly provide this information inside the
      rtnetlink's RTM_NEWLINK message. The two processes would be (in regards of
      the creation parameter of their batadv interfaces) be isolated. This also
      eases the integration of batadv devices inside tools like network-manager
      or systemd-networkd which are not expecting to operate on /sys before a new
      net_device is created.
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      a5ad457e
    • S
      batman-adv: Prepare infrastructure for newlink settings · 128254ce
      Sven Eckelmann 提交于
      The batadv generic netlink family can be used to retrieve the current state
      and set various configuration settings. But there are also settings which
      must be set before the actual interface is created.
      
      The rtnetlink already uses IFLA_INFO_DATA to allow net_device families to
      transfer such configurations. The minimal required functionality for this
      is now available for the batadv rtnl_link_ops. Also a new IFLA class of
      attributes will be attached to it because rtnetlink only allows 51
      different attributes but batadv_nl_attrs already contains 62 attributes.
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      128254ce
  2. 15 9月, 2020 2 次提交
    • L
      batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh · 74c09b72
      Linus Lüssing 提交于
      Scenario:
      * Multicast frame send from mesh to a BLA backbone (multiple nodes
        with their bat0 bridged together, with BLA enabled)
      
      Issue:
      * BLA backbone nodes receive the frame multiple times on bat0,
        once from mesh->bat0 and once from each backbone_gw from LAN
      
      For unicast, a node will send only to the best backbone gateway
      according to the TQ. However for multicast we currently cannot determine
      if multiple destination nodes share the same backbone if they don't share
      the same backbone with us. So we need to keep sending the unicasts to
      all backbone gateways and let the backbone gateways decide which one
      will forward the frame. We can use the CLAIM mechanism to make this
      decision.
      
      One catch: The batman-adv gateway feature for DHCP packets potentially
      sends multicast packets in the same batman-adv unicast header as the
      multicast optimizations code. And we are not allowed to drop those even
      if we did not claim the source address of the sender, as for such
      packets there is only this one multicast-in-unicast packet.
      
      How can we distinguish the two cases?
      
      The gateway feature uses a batman-adv unicast 4 address header. While
      the multicast-to-unicasts feature uses a simple, 3 address batman-adv
      unicast header. So let's use this to distinguish.
      
      Fixes: fe2da6ff ("batman-adv: check incoming packet type for bla")
      Signed-off-by: NLinus Lüssing <linus.luessing@c0d3.blue>
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      74c09b72
    • L
      batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN · 3236d215
      Linus Lüssing 提交于
      Scenario:
      * Multicast frame send from a BLA backbone (multiple nodes with
        their bat0 bridged together, with BLA enabled)
      
      Issue:
      * BLA backbone nodes receive the frame multiple times on bat0
      
      For multicast frames received via batman-adv broadcast packets the
      originator of the broadcast packet is checked before decapsulating and
      forwarding the frame to bat0 (batadv_bla_is_backbone_gw()->
      batadv_recv_bcast_packet()). If it came from a node which shares the
      same BLA backbone with us then it is not forwarded to bat0 to avoid a
      loop.
      
      When sending a multicast frame in a non-4-address batman-adv unicast
      packet we are currently missing this check - and cannot do so because
      the batman-adv unicast packet has no originator address field.
      
      However, we can simply fix this on the sender side by only sending the
      multicast frame via unicasts to interested nodes which do not share the
      same BLA backbone with us. This also nicely avoids some unnecessary
      transmissions on mesh side.
      
      Note that no infinite loop was observed, probably because of dropping
      via batadv_interface_tx()->batadv_bla_tx(). However the duplicates still
      utterly confuse switches/bridges, ICMPv6 duplicate address detection and
      neighbor discovery and therefore leads to long delays before being able
      to establish TCP connections, for instance. And it also leads to the Linux
      bridge printing messages like:
      "br-lan: received packet on eth1 with own address as source address ..."
      
      Fixes: 2d3f6ccc ("batman-adv: Modified forwarding behaviour for multicast packets")
      Signed-off-by: NLinus Lüssing <linus.luessing@c0d3.blue>
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      3236d215
  3. 19 8月, 2020 1 次提交
  4. 26 6月, 2020 1 次提交
  5. 10 6月, 2020 1 次提交
    • C
      net: change addr_list_lock back to static key · 845e0ebb
      Cong Wang 提交于
      The dynamic key update for addr_list_lock still causes troubles,
      for example the following race condition still exists:
      
      CPU 0:				CPU 1:
      (RCU read lock)			(RTNL lock)
      dev_mc_seq_show()		netdev_update_lockdep_key()
      				  -> lockdep_unregister_key()
       -> netif_addr_lock_bh()
      
      because lockdep doesn't provide an API to update it atomically.
      Therefore, we have to move it back to static keys and use subclass
      for nest locking like before.
      
      In commit 1a33e10e ("net: partially revert dynamic lockdep key
      changes"), I already reverted most parts of commit ab92d68f
      ("net: core: add generic lockdep keys").
      
      This patch reverts the rest and also part of commit f3b0a18b
      ("net: remove unnecessary variables and callback"). After this
      patch, addr_list_lock changes back to using static keys and
      subclasses to satisfy lockdep. Thanks to dev->lower_level, we do
      not have to change back to ->ndo_get_lock_subclass().
      
      And hopefully this reduces some syzbot lockdep noises too.
      
      Reported-by: syzbot+f3a0e80c34b3fc28ac5e@syzkaller.appspotmail.com
      Cc: Taehee Yoo <ap420073@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Signed-off-by: NCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      845e0ebb
  6. 22 5月, 2020 1 次提交
  7. 05 5月, 2020 1 次提交
  8. 01 1月, 2020 1 次提交
  9. 03 11月, 2019 2 次提交
  10. 25 10月, 2019 1 次提交
    • T
      net: core: add generic lockdep keys · ab92d68f
      Taehee Yoo 提交于
      Some interface types could be nested.
      (VLAN, BONDING, TEAM, MACSEC, MACVLAN, IPVLAN, VIRT_WIFI, VXLAN, etc..)
      These interface types should set lockdep class because, without lockdep
      class key, lockdep always warn about unexisting circular locking.
      
      In the current code, these interfaces have their own lockdep class keys and
      these manage itself. So that there are so many duplicate code around the
      /driver/net and /net/.
      This patch adds new generic lockdep keys and some helper functions for it.
      
      This patch does below changes.
      a) Add lockdep class keys in struct net_device
         - qdisc_running, xmit, addr_list, qdisc_busylock
         - these keys are used as dynamic lockdep key.
      b) When net_device is being allocated, lockdep keys are registered.
         - alloc_netdev_mqs()
      c) When net_device is being free'd llockdep keys are unregistered.
         - free_netdev()
      d) Add generic lockdep key helper function
         - netdev_register_lockdep_key()
         - netdev_unregister_lockdep_key()
         - netdev_update_lockdep_key()
      e) Remove unnecessary generic lockdep macro and functions
      f) Remove unnecessary lockdep code of each interfaces.
      
      After this patch, each interface modules don't need to maintain
      their lockdep keys.
      Signed-off-by: NTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ab92d68f
  11. 02 10月, 2019 1 次提交
    • F
      netfilter: drop bridge nf reset from nf_reset · 895b5c9f
      Florian Westphal 提交于
      commit 174e2381
      ("sk_buff: drop all skb extensions on free and skb scrubbing") made napi
      recycle always drop skb extensions.  The additional skb_ext_del() that is
      performed via nf_reset on napi skb recycle is not needed anymore.
      
      Most nf_reset() calls in the stack are there so queued skb won't block
      'rmmod nf_conntrack' indefinitely.
      
      This removes the skb_ext_del from nf_reset, and renames it to a more
      fitting nf_reset_ct().
      
      In a few selected places, add a call to skb_ext_reset to make sure that
      no active extensions remain.
      
      I am submitting this for "net", because we're still early in the release
      cycle.  The patch applies to net-next too, but I think the rename causes
      needless divergence between those trees.
      Suggested-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      895b5c9f
  12. 23 7月, 2019 1 次提交
    • S
      batman-adv: Replace usage of strlcpy with strscpy · 529a8f93
      Sven Eckelmann 提交于
      The strscpy was introduced to fix some API problems around strlcpy. And
      checkpatch started to report recently that strlcpy is deprecated and
      strscpy is preferred.
      
      The functionality introduced in commit 30035e45 ("string: provide
      strscpy()") improves following points compared to strlcpy:
      
      * it doesn't read from memory beyond (src + size)
      * provides an easy way to check for destination buffer overflow
      * robust against asynchronous source buffer changes
      
      Since batman-adv doesn't depend on any of the previously mentioned behavior
      changes, the usage of strlcpy can simply be replaced by strscpy to silence
      checkpatch.
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      529a8f93
  13. 25 5月, 2019 2 次提交
  14. 25 3月, 2019 2 次提交
  15. 13 2月, 2019 1 次提交
    • E
      batman-adv: fix uninit-value in batadv_interface_tx() · 4ffcbfac
      Eric Dumazet 提交于
      KMSAN reported batadv_interface_tx() was possibly using a
      garbage value [1]
      
      batadv_get_vid() does have a pskb_may_pull() call
      but batadv_interface_tx() does not actually make sure
      this did not fail.
      
      [1]
      BUG: KMSAN: uninit-value in batadv_interface_tx+0x908/0x1e40 net/batman-adv/soft-interface.c:231
      CPU: 0 PID: 10006 Comm: syz-executor469 Not tainted 4.20.0-rc7+ #5
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x173/0x1d0 lib/dump_stack.c:113
       kmsan_report+0x12e/0x2a0 mm/kmsan/kmsan.c:613
       __msan_warning+0x82/0xf0 mm/kmsan/kmsan_instr.c:313
       batadv_interface_tx+0x908/0x1e40 net/batman-adv/soft-interface.c:231
       __netdev_start_xmit include/linux/netdevice.h:4356 [inline]
       netdev_start_xmit include/linux/netdevice.h:4365 [inline]
       xmit_one net/core/dev.c:3257 [inline]
       dev_hard_start_xmit+0x607/0xc40 net/core/dev.c:3273
       __dev_queue_xmit+0x2e42/0x3bc0 net/core/dev.c:3843
       dev_queue_xmit+0x4b/0x60 net/core/dev.c:3876
       packet_snd net/packet/af_packet.c:2928 [inline]
       packet_sendmsg+0x8306/0x8f30 net/packet/af_packet.c:2953
       sock_sendmsg_nosec net/socket.c:621 [inline]
       sock_sendmsg net/socket.c:631 [inline]
       __sys_sendto+0x8c4/0xac0 net/socket.c:1788
       __do_sys_sendto net/socket.c:1800 [inline]
       __se_sys_sendto+0x107/0x130 net/socket.c:1796
       __x64_sys_sendto+0x6e/0x90 net/socket.c:1796
       do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291
       entry_SYSCALL_64_after_hwframe+0x63/0xe7
      RIP: 0033:0x441889
      Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 bb 10 fc ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007ffdda6fd468 EFLAGS: 00000216 ORIG_RAX: 000000000000002c
      RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 0000000000441889
      RDX: 000000000000000e RSI: 00000000200000c0 RDI: 0000000000000003
      RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000216 R12: 00007ffdda6fd4c0
      R13: 00007ffdda6fd4b0 R14: 0000000000000000 R15: 0000000000000000
      
      Uninit was created at:
       kmsan_save_stack_with_flags mm/kmsan/kmsan.c:204 [inline]
       kmsan_internal_poison_shadow+0x92/0x150 mm/kmsan/kmsan.c:158
       kmsan_kmalloc+0xa6/0x130 mm/kmsan/kmsan_hooks.c:176
       kmsan_slab_alloc+0xe/0x10 mm/kmsan/kmsan_hooks.c:185
       slab_post_alloc_hook mm/slab.h:446 [inline]
       slab_alloc_node mm/slub.c:2759 [inline]
       __kmalloc_node_track_caller+0xe18/0x1030 mm/slub.c:4383
       __kmalloc_reserve net/core/skbuff.c:137 [inline]
       __alloc_skb+0x309/0xa20 net/core/skbuff.c:205
       alloc_skb include/linux/skbuff.h:998 [inline]
       alloc_skb_with_frags+0x1c7/0xac0 net/core/skbuff.c:5220
       sock_alloc_send_pskb+0xafd/0x10e0 net/core/sock.c:2083
       packet_alloc_skb net/packet/af_packet.c:2781 [inline]
       packet_snd net/packet/af_packet.c:2872 [inline]
       packet_sendmsg+0x661a/0x8f30 net/packet/af_packet.c:2953
       sock_sendmsg_nosec net/socket.c:621 [inline]
       sock_sendmsg net/socket.c:631 [inline]
       __sys_sendto+0x8c4/0xac0 net/socket.c:1788
       __do_sys_sendto net/socket.c:1800 [inline]
       __se_sys_sendto+0x107/0x130 net/socket.c:1796
       __x64_sys_sendto+0x6e/0x90 net/socket.c:1796
       do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291
       entry_SYSCALL_64_after_hwframe+0x63/0xe7
      
      Fixes: c6c8fea2 ("net: Add batman-adv meshing protocol")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Cc:	Marek Lindner <mareklindner@neomailbox.ch>
      Cc:	Simon Wunderlich <sw@simonwunderlich.de>
      Cc:	Antonio Quartulli <a@unstable.cc>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4ffcbfac
  16. 09 2月, 2019 1 次提交
    • S
      batman-adv: Add gateway mesh genl configuration · e2d0d35b
      Sven Eckelmann 提交于
      The mesh/soft-interface can optimize the handling of DHCP packets. Instead
      of flooding them through the whole mesh, it can be forwarded as unicast to
      a specific gateway server. The originator which injects the packets in the
      mesh has to select (based on sel_class thresholds) a responsible gateway
      server. This is done by switching this originator to the gw_mode client.
      The servers announce their forwarding bandwidth (download/upload) when the
      gw_mode server was selected.
      
      The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
      configuration of this feature using the attributes:
      
      * u8 BATADV_ATTR_GW_MODE (0 == off, 1 == client, 2 == server)
      * u32 BATADV_ATTR_GW_BANDWIDTH_DOWN (in 100 kbit/s steps)
      * u32 BATADV_ATTR_GW_BANDWIDTH_UP (in 100 kbit/s steps)
      * u32 BATADV_ATTR_GW_SEL_CLASS
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      e2d0d35b
  17. 04 1月, 2019 1 次提交
  18. 01 1月, 2019 1 次提交
    • S
      batman-adv: Force mac header to start of data on xmit · 9114daa8
      Sven Eckelmann 提交于
      The caller of ndo_start_xmit may not already have called
      skb_reset_mac_header. The returned value of skb_mac_header/eth_hdr
      therefore can be in the wrong position and even outside the current skbuff.
      This for example happens when the user binds to the device using a
      PF_PACKET-SOCK_RAW with enabled qdisc-bypass:
      
        int opt = 4;
        setsockopt(sock, SOL_PACKET, PACKET_QDISC_BYPASS, &opt, sizeof(opt));
      
      Since eth_hdr is used all over the codebase, the batadv_interface_tx
      function must always take care of resetting it.
      
      Fixes: c6c8fea2 ("net: Add batman-adv meshing protocol")
      Reported-by: syzbot+9d7405c7faa390e60b4e@syzkaller.appspotmail.com
      Reported-by: syzbot+7d20bc3f1ddddc0f9079@syzkaller.appspotmail.com
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      9114daa8
  19. 31 12月, 2018 1 次提交
    • L
      batman-adv: Snoop DHCPACKs for DAT · b61ec31c
      Linus Lüssing 提交于
      In a 1000 nodes mesh network (Freifunk Hamburg) we can still see
      30KBit/s of ARP traffic (equalling about 25% of all layer two
      specific overhead, remaining after some filtering) flooded through
      the mesh. These 30KBit/s are mainly ARP Requests from the
      gateways / DHCP servers.
      
      By snooping DHCPACKs we can learn about MAC/IP address pairs
      in the DHCP range without relying on ARP. This patch is in preparation
      to eliminate the need for mesh wide message flooding for IPv4 address
      resolution.
      
      Also this allows to quickly update a MAC/IP pair at least in the DHT when
      DHCP reassigns an IP address to a new host.
      Signed-off-by: NLinus Lüssing <linus.luessing@c0d3.blue>
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      b61ec31c
  20. 15 9月, 2018 2 次提交
    • S
      batman-adv: Enable LockLess TX for softif · a7ea49af
      Sven Eckelmann 提交于
      The batadv interfaces are virtual interfaces which just tunnel the traffic
      over other ethernet compatible interfaces. It doesn't need serialization
      during the tx phase and is using RCU for most of its internal
      datastructures. Since it doesn't have actual queues which could be locked
      independently, the throughput gets significantly reduced by the extra lock
      in the core net code.
      
      8 parallel TCP connections forwarded by an IPQ4019 based hardware over
      5GHz could reach:
      
      * without LLTX: 349 Mibit/s
      * with LLTX:    563 Mibit/s
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      a7ea49af
    • S
      batman-adv: Move OGM rebroadcast stats to orig_ifinfo · dee222c7
      Sven Eckelmann 提交于
      B.A.T.M.A.N. IV requires the number of rebroadcast from a neighboring
      originator. These statistics are gathered per interface which transmitted
      the OGM (and then received it again). Since an originator is not interface
      specific, a resizable array was used in each originator.
      
      This resizable array had an entry for each interface and had to be resizes
      (for all OGMs) when the number of active interface was modified. This could
      cause problems when a large number of interface is added and not enough
      continuous memory is available to allocate the array.
      
      There is already a per interface originator structure "batadv_orig_ifinfo"
      which can be used to store this information.
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      dee222c7
  21. 06 9月, 2018 1 次提交
    • S
      batman-adv: Prevent duplicated softif_vlan entry · 94cb82f5
      Sven Eckelmann 提交于
      The function batadv_softif_vlan_get is responsible for adding new
      softif_vlan to the softif_vlan_list. It first checks whether the entry
      already is in the list or not. If it is, then the creation of a new entry
      is aborted.
      
      But the lock for the list is only held when the list is really modified.
      This could lead to duplicated entries because another context could create
      an entry with the same key between the check and the list manipulation.
      
      The check and the manipulation of the list must therefore be in the same
      locked code section.
      
      Fixes: 5d2c05b2 ("batman-adv: add per VLAN interface attribute framework")
      Signed-off-by: NSven Eckelmann <sven@narfation.org>
      Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
      94cb82f5
  22. 26 4月, 2018 1 次提交
  23. 22 4月, 2018 1 次提交
  24. 27 2月, 2018 1 次提交
  25. 26 2月, 2018 1 次提交
  26. 22 12月, 2017 1 次提交
  27. 16 12月, 2017 4 次提交
  28. 12 10月, 2017 1 次提交
  29. 05 10月, 2017 1 次提交