09 Feb, 2019

1 commit

  • 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: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     

04 Jan, 2019

1 commit


31 Dec, 2018

1 commit

  • 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: Linus Lüssing
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Linus Lüssing
     

26 Sep, 2018

1 commit


15 Sep, 2018

2 commits

  • 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: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    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: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     

06 Sep, 2018

1 commit

  • 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: 5d2c05b21337 ("batman-adv: add per VLAN interface attribute framework")
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     

26 Apr, 2018

1 commit

  • The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
    which is a typedef for an enum type, but the implementation in this
    driver returns an 'int'.

    Fix this by returning 'netdev_tx_t' in this driver too.

    Signed-off-by: Luc Van Oostenryck
    [sven@narfation.org: fixed alignment]
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Luc Van Oostenryck
     

22 Apr, 2018

1 commit


06 Mar, 2018

1 commit


27 Feb, 2018

1 commit


26 Feb, 2018

1 commit

  • eth_type_trans() internally calls skb_pull(), which does not adjust the
    skb checksum; skb_postpull_rcsum() is necessary to avoid log spam of the
    form "bat0: hw csum failure" when packets with CHECKSUM_COMPLETE are
    received.

    Note that in usual setups, packets don't reach batman-adv with
    CHECKSUM_COMPLETE (I assume NICs bail out of checksumming when they see
    batadv's ethtype?), which is why the log messages do not occur on every
    system using batman-adv. I could reproduce this issue by stacking
    batman-adv on top of a VXLAN interface.

    Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
    Tested-by: Maximilian Wilhelm
    Signed-off-by: Matthias Schiffer
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Matthias Schiffer
     

22 Dec, 2017

1 commit

  • The header file is used by different userspace programs to inject packets
    or to decode sniffed packets. It should therefore be available to them as
    userspace header.

    Also other components in the kernel (like the flow dissector) require
    access to the packet definitions to be able to decode ETH_P_BATMAN ethernet
    packets.

    Signed-off-by: Sven Eckelmann
    Signed-off-by: David S. Miller

    Sven Eckelmann
     

16 Dec, 2017

4 commits

  • According to the kernel-doc documentation, externally visible functions
    should be documented. This refers to all all non-static function which can
    (and will) be used by functions in other sources files.

    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     
  • The documentation describing kernel-doc comments for functions ("How to
    format kernel-doc comments") uses parentheses at the end of the function
    name. Using this format allows to use a consistent style when adding
    documentation to a function and when referencing this function in a
    different kernel-doc section.

    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     
  • The linux/gfp.h provides the GFP_ATOMIC and GFP_KERNEL define. It should
    therefore be included instead of linux/fs.h.

    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     
  • The "Linux kernel licensing rules" require that each file has a SPDX
    license identifier as first line (and sometimes as second line).

    The FSFE REUSE practices [1] would also require the same tags but have no
    restrictions on the placement in the source file. Using the "Linux kernel
    licensing rules" is therefore also fulfilling the FSFE REUSE practices
    requirements at the same time.

    [1] https://reuse.software/practices/

    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     

12 Oct, 2017

1 commit


07 Oct, 2017

1 commit


05 Oct, 2017

1 commit


28 Sep, 2017

2 commits


23 Sep, 2017

1 commit


08 Jun, 2017

1 commit

  • Network devices can allocate reasources and private memory using
    netdev_ops->ndo_init(). However, the release of these resources
    can occur in one of two different places.

    Either netdev_ops->ndo_uninit() or netdev->destructor().

    The decision of which operation frees the resources depends upon
    whether it is necessary for all netdev refs to be released before it
    is safe to perform the freeing.

    netdev_ops->ndo_uninit() presumably can occur right after the
    NETDEV_UNREGISTER notifier completes and the unicast and multicast
    address lists are flushed.

    netdev->destructor(), on the other hand, does not run until the
    netdev references all go away.

    Further complicating the situation is that netdev->destructor()
    almost universally does also a free_netdev().

    This creates a problem for the logic in register_netdevice().
    Because all callers of register_netdevice() manage the freeing
    of the netdev, and invoke free_netdev(dev) if register_netdevice()
    fails.

    If netdev_ops->ndo_init() succeeds, but something else fails inside
    of register_netdevice(), it does call ndo_ops->ndo_uninit(). But
    it is not able to invoke netdev->destructor().

    This is because netdev->destructor() will do a free_netdev() and
    then the caller of register_netdevice() will do the same.

    However, this means that the resources that would normally be released
    by netdev->destructor() will not be.

    Over the years drivers have added local hacks to deal with this, by
    invoking their destructor parts by hand when register_netdevice()
    fails.

    Many drivers do not try to deal with this, and instead we have leaks.

    Let's close this hole by formalizing the distinction between what
    private things need to be freed up by netdev->destructor() and whether
    the driver needs unregister_netdevice() to perform the free_netdev().

    netdev->priv_destructor() performs all actions to free up the private
    resources that used to be freed by netdev->destructor(), except for
    free_netdev().

    netdev->needs_free_netdev is a boolean that indicates whether
    free_netdev() should be done at the end of unregister_netdevice().

    Now, register_netdevice() can sanely release all resources after
    ndo_ops->ndo_init() succeeds, by invoking both ndo_ops->ndo_uninit()
    and netdev->priv_destructor().

    And at the end of unregister_netdevice(), we invoke
    netdev->priv_destructor() and optionally call free_netdev().

    Signed-off-by: David S. Miller

    David S. Miller
     

07 Apr, 2017

1 commit

  • Simon Wunderlich says:

    ====================
    This feature/cleanup patchset includes the following patches:

    - bump version strings, by Simon Wunderlich

    - Code and Style cleanups, by Sven Eckelmann (5 patches)

    - Remove an unneccessary memset, by Tobias Klauser

    - DAT and BLA optimizations for various corner cases, by Andreas Pape
    (5 patches)

    - forward/rebroadcast packet restructuring, by Linus Luessing
    (2 patches)

    - ethtool cleanup and remove unncessary code, by Sven Eckelmann
    (4 patches)

    - use net_device_stats from net_device instead of private copy,
    by Tobias Klauser
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

05 Apr, 2017

1 commit


03 Apr, 2017

4 commits

  • The ethtool code was spread in soft-interface.c. This makes reading the
    code and working on it unnecessary complicated. Having everything in a
    common place next to the other code which references it, makes it slightly
    easier.

    Signed-off-by: Sven Eckelmann
    Acked-by: Marek Lindner
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     
  • The .get_settings function pointer and the related API was deprecated.
    Fortunately, batman-adv is a virtual interface and never provided any
    useful information via .get_settings. The stub can therefore be
    removed.

    This also avoids that incorrect information is shown in ethtool about the
    batadv interface.

    Signed-off-by: Sven Eckelmann
    Acked-by: Marek Lindner
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     
  • batadv devices don't support msglevel. The ethtool stubs therefore returned
    that it isn't supported. But instead, the complete function can be dropped
    to avoid that bogus values are shown in ethtool.

    Signed-off-by: Sven Eckelmann
    Acked-by: Marek Lindner
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     
  • The ethtool_ops of batman-adv never contained more than a stub for the
    get_link function pointer. It was always returning that a link exists even
    when the devices was not yet up and therefore nothing resampling a link
    could have been available.

    Instead use the ethtool helper which returns the current carrier state.

    Signed-off-by: Sven Eckelmann
    Acked-by: Marek Lindner
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     

26 Mar, 2017

1 commit

  • This patch refactors the num_packets counter of a forw_packet in the
    following three ways:

    1) Removed dual-use of forw_packet::num_packets:
    -> now for aggregation purposes only
    2) Using forw_packet::skb::cb::num_bcasts instead:
    -> for easier access in aggregation code later
    3) make access to num_bcasts private to batadv_forw_packet_*()

    Signed-off-by: Linus Lüssing
    [sven@narfation.org: Change num_bcasts to unsigned]
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Linus Lüssing
     

17 Mar, 2017

2 commits


05 Mar, 2017

1 commit

  • The gateway selection class variable is shared between different algorithm
    versions. But the interpretation of the content is algorithm specific. The
    initialization is therefore also algorithm specific.

    But this was implemented incorrectly and the initialization for BATMAN_V
    always overwrote the value previously written for BATMAN_IV. This could
    only be avoided when BATMAN_V was disabled during compile time.

    Using a special batadv_algo hook for this initialization avoids this
    problem.

    Fixes: 50164d8f500f ("batman-adv: B.A.T.M.A.N. V - implement GW selection logic")
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     

27 Jan, 2017

1 commit

  • Simon Wunderlich says:

    ====================
    This feature/cleanup patchset includes the following patches:

    - bump version strings, by Simon Wunderlich

    - ignore self-generated loop detect MAC addresses in translation table,
    by Simon Wunderlich

    - install uapi batman_adv.h header, by Sven Eckelmann

    - bump copyright years, by Sven Eckelmann

    - Remove an unused variable in translation table code, by Sven Eckelmann

    - Handle NET_XMIT_CN like NET_XMIT_SUCCESS (revised according to Davids
    suggestion), and a follow up code clean up, by Gao Feng (2 patches)
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

26 Jan, 2017

2 commits


19 Jan, 2017

1 commit

  • The network stack no longer uses the last_rx member of struct net_device
    since the bonding driver switched to use its own private last_rx in
    commit 9f242738376d ("bonding: use last_arp_rx in slave_last_rx()").

    However, some drivers still (ab)use the field for their own purposes and
    some driver just update it without actually using it.

    Previously, there was an accompanying comment for the last_rx member
    added in commit 4dc89133f49b ("net: add a comment on netdev->last_rx")
    which asked drivers not to update is, unless really needed. However,
    this commend was removed in commit f8ff080dacec ("bonding: remove
    useless updating of slave->dev->last_rx"), so some drivers added later
    on still did update last_rx.

    Remove all usage of last_rx and switch three drivers (sky2, atp and
    smc91c92_cs) which actually read and write it to use their own private
    copy in netdev_priv.

    Compile-tested with allyesconfig and allmodconfig on x86 and arm.

    Cc: Eric Dumazet
    Cc: Jay Vosburgh
    Cc: Veaceslav Falico
    Cc: Andy Gospodarek
    Cc: Mirko Lindner
    Cc: Stephen Hemminger
    Signed-off-by: Tobias Klauser
    Acked-by: Eric Dumazet
    Reviewed-by: Jay Vosburgh
    Signed-off-by: David S. Miller

    Tobias Klauser
     

30 Oct, 2016

2 commits