15 Aug, 2019

1 commit

  • batadv_netlink_get_ifindex() needs to make sure user passed
    a correct u32 attribute.

    syzbot reported :
    BUG: KMSAN: uninit-value in batadv_netlink_dump_hardif+0x70d/0x880 net/batman-adv/netlink.c:968
    CPU: 1 PID: 11705 Comm: syz-executor888 Not tainted 5.1.0+ #1
    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+0x191/0x1f0 lib/dump_stack.c:113
    kmsan_report+0x130/0x2a0 mm/kmsan/kmsan.c:622
    __msan_warning+0x75/0xe0 mm/kmsan/kmsan_instr.c:310
    batadv_netlink_dump_hardif+0x70d/0x880 net/batman-adv/netlink.c:968
    genl_lock_dumpit+0xc6/0x130 net/netlink/genetlink.c:482
    netlink_dump+0xa84/0x1ab0 net/netlink/af_netlink.c:2253
    __netlink_dump_start+0xa3a/0xb30 net/netlink/af_netlink.c:2361
    genl_family_rcv_msg net/netlink/genetlink.c:550 [inline]
    genl_rcv_msg+0xfc1/0x1a40 net/netlink/genetlink.c:627
    netlink_rcv_skb+0x431/0x620 net/netlink/af_netlink.c:2486
    genl_rcv+0x63/0x80 net/netlink/genetlink.c:638
    netlink_unicast_kernel net/netlink/af_netlink.c:1311 [inline]
    netlink_unicast+0xf3e/0x1020 net/netlink/af_netlink.c:1337
    netlink_sendmsg+0x127e/0x12f0 net/netlink/af_netlink.c:1926
    sock_sendmsg_nosec net/socket.c:651 [inline]
    sock_sendmsg net/socket.c:661 [inline]
    ___sys_sendmsg+0xcc6/0x1200 net/socket.c:2260
    __sys_sendmsg net/socket.c:2298 [inline]
    __do_sys_sendmsg net/socket.c:2307 [inline]
    __se_sys_sendmsg+0x305/0x460 net/socket.c:2305
    __x64_sys_sendmsg+0x4a/0x70 net/socket.c:2305
    do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291
    entry_SYSCALL_64_after_hwframe+0x63/0xe7
    RIP: 0033:0x440209

    Fixes: b60620cf567b ("batman-adv: netlink: hardif query")
    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Eric Dumazet
     

25 May, 2019

2 commits

  • While it can be slightly beneficial for the build performance to use
    forward declarations instead of includes, the handling of them together
    with changes in the included headers makes it unnecessary complicated and
    fragile. Just replace them with actual includes since some parts (hwmon,
    ..) of the kernel even request avoidance of forward declarations and net/
    is mostly not using them in *.c file.

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

    Sven Eckelmann
     
  • The commit 54d50897d544 ("linux/kernel.h: split *_MAX and *_MIN macros into
    ") moved the U32_MAX/INT_MAX/ULONG_MAX from linux/kernel.h
    to linux/limits.h. Adjust the includes accordingly.

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

    Sven Eckelmann
     

28 Apr, 2019

1 commit

  • Add options to strictly validate messages and dump messages,
    sometimes perhaps validating dump messages non-strictly may
    be required, so add an option for that as well.

    Since none of this can really be applied to existing commands,
    set the options everwhere using the following spatch:

    @@
    identifier ops;
    expression X;
    @@
    struct genl_ops ops[] = {
    ...,
    {
    .cmd = X,
    + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
    ...
    },
    ...
    };

    For new commands one should just not copy the .validate 'opt-out'
    flags and thus get strict validation.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

29 Mar, 2019

1 commit

  • Simon Wunderlich says:

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

    - Drop license boilerplate (obsoleted by SPDX license IDs),
    by Sven Eckelmann

    - Drop documentation for sysfs and debugfs Documentation,
    by Sven Eckelmann (2 patches)

    - Mark sysfs as optional and deprecated, by Sven Eckelmann (3 patches)

    - Update MAINTAINERS Tree, Chat and Bugtracker,
    by Sven Eckelmann (3 patches)

    - Rename batadv_dat_send_data, by Sven Eckelmann

    - update DAT entries with incoming ARP replies, by Linus Luessing

    - add multicast-to-unicast support for limited destinations,
    by Linus Luessing
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

25 Mar, 2019

2 commits

  • With this patch multicast packets with a limited number of destinations
    (current default: 16) will be split and transmitted by the originator as
    individual unicast transmissions.

    Wifi broadcasts with their low bitrate are still a costly undertaking.
    In a mesh network this cost multiplies with the overall size of the mesh
    network. Therefore using multiple unicast transmissions instead of
    broadcast flooding is almost always less burdensome for the mesh
    network.

    The maximum amount of unicast packets can be configured via the newly
    introduced multicast_fanout parameter. If this limit is exceeded
    distribution will fall back to classic broadcast flooding.

    The multicast-to-unicast conversion is performed on the initial
    multicast sender node and counts on a final destination node, mesh-wide
    basis (and not next hop, neighbor node basis).

    Signed-off-by: Linus Lüssing
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Linus Lüssing
     
  • All files got a SPDX-License-Identifier with commit 7db7d9f369a4
    ("batman-adv: Add SPDX license identifier above copyright header"). All the
    required information about the license conditions can be found in
    LICENSES/.

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

    Sven Eckelmann
     

22 Mar, 2019

1 commit

  • Since maxattr is common, the policy can't really differ sanely,
    so make it common as well.

    The only user that did in fact manage to make a non-common policy
    is taskstats, which has to be really careful about it (since it's
    still using a common maxattr!). This is no longer supported, but
    we can fake it using pre_doit.

    This reduces the size of e.g. nl80211.o (which has lots of commands):

    text data bss dec hex filename
    398745 14323 2240 415308 6564c net/wireless/nl80211.o (before)
    397913 14331 2240 414484 65314 net/wireless/nl80211.o (after)
    --------------------------------
    -832 +8 0 -824

    Which is obviously just 8 bytes for each command, and an added 8
    bytes for the new policy pointer. I'm not sure why the ops list is
    counted as .text though.

    Most of the code transformations were done using the following spatch:
    @ops@
    identifier OPS;
    expression POLICY;
    @@
    struct genl_ops OPS[] = {
    ...,
    {
    - .policy = POLICY,
    },
    ...
    };

    @@
    identifier ops.OPS;
    expression ops.POLICY;
    identifier fam;
    expression M;
    @@
    struct genl_family fam = {
    .ops = OPS,
    .maxattr = M,
    + .policy = POLICY,
    ...
    };

    This also gets rid of devlink_nl_cmd_region_read_dumpit() accessing
    the cb->data as ops, which we want to change in a later genl patch.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

09 Feb, 2019

19 commits

  • The generic netlink code is expected to trigger notification messages when
    configuration might have been changed. But the configuration of batman-adv
    is most of the time still done using sysfs. So the sysfs interface should
    also trigger the corresponding netlink messages via the "config" multicast
    group.

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

    Sven Eckelmann
     
  • The B.A.T.M.A.N. V implementation tries to estimate the link throughput of
    an interface to an originator using different automatic methods. It is
    still possible to overwrite it the link throughput for all reachable
    originators via this interface.

    The BATADV_CMD_SET_HARDIF/BATADV_CMD_GET_HARDIF commands allow to set/get
    the configuration of this feature using the u32
    BATADV_ATTR_THROUGHPUT_OVERRIDE attribute. The used unit is in 100 Kbit/s.
    If the value is set to 0 then batman-adv will try to estimate the
    throughput by itself.

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

    Sven Eckelmann
     
  • The ELP packets are transmitted every elp_interval milliseconds on an
    slave/hard-interface. This value can be changed using the configuration
    interface.

    The BATADV_CMD_SET_HARDIF/BATADV_CMD_GET_HARDIF commands allow to set/get
    the configuration of this feature using the u32 BATADV_ATTR_ELP_INTERVAL
    attribute.

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

    Sven Eckelmann
     
  • The OGM packets are transmitted every orig_interval milliseconds. This
    value can be changed using the configuration interface.

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
    configuration of this feature using the u32 BATADV_ATTR_ORIG_INTERVAL
    attribute.

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

    Sven Eckelmann
     
  • The mesh interface can use (in an homogeneous mesh) network coding, a
    mechanism that aims to increase the overall network throughput by fusing
    multiple packets in one transmission.

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
    configuration of this feature using the BATADV_ATTR_NETWORK_CODING_ENABLED
    attribute. Setting the u8 to zero will disable this feature and setting it
    to something else is enabling this feature.

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

    Sven Eckelmann
     
  • The mesh interface can optimize the flooding of multicast packets based on
    the content of the global translation tables. To disable this behavior and
    use the broadcast-like flooding of the packets, forceflood has to be
    enabled.

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
    configuration of this feature using the
    BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED attribute. Setting the u8 to zero
    will disable this feature (allowing multicast optimizations) and setting it
    to something else is enabling this feature (forcing simple flooding).

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

    Sven Eckelmann
     
  • In contrast to other modules, batman-adv allows to set the debug message
    verbosity per mesh/soft-interface and not per module (via modparam).

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
    configuration of this feature using the u32 (bitmask) BATADV_ATTR_LOG_LEVEL
    attribute.

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

    Sven Eckelmann
     
  • The TQ (B.A.T.M.A.N. IV) and throughput values (B.A.T.M.A.N. V) are reduced
    when they are forwarded. One of the reductions is the penalty for
    traversing an additional hop. This hop_penalty (0-255) defines the
    percentage of reduction (0-100%).

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
    configuration of this feature using the u8 BATADV_ATTR_HOP_PENALTY
    attribute.

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

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

    Sven Eckelmann
     
  • The mesh interface can fragment unicast packets when the packet size
    exceeds the outgoing slave/hard-interface MTU.

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
    configuration of this feature using the BATADV_ATTR_FRAGMENTATION_ENABLED
    attribute. Setting the u8 to zero will disable this feature and setting it
    to something else is enabling this feature.

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

    Sven Eckelmann
     
  • The mesh interface can use a distributed hash table to answer ARP requests
    without flooding the request through the whole mesh.

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
    configuration of this feature using the
    BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED attribute. Setting the u8 to zero
    will disable this feature and setting it to something else is enabling this
    feature.

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

    Sven Eckelmann
     
  • The mesh interface can try to detect loops in the same mesh caused by
    (indirectly) bridged mesh/soft-interfaces of different nodes. Some of the
    loops can also be resolved without breaking the mesh.

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
    configuration of this feature using the
    BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED attribute. Setting the u8 to zero
    will disable this feature and setting it to something else is enabling this
    feature.

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

    Sven Eckelmann
     
  • The mesh interface can use multiple slave/hard-interface ports at the same
    time to transport the traffic to other nodes.

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
    configuration of this feature using the BATADV_ATTR_BONDING_ENABLED
    attribute. Setting the u8 to zero will disable this feature and setting it
    to something else is enabling this feature.

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

    Sven Eckelmann
     
  • The mesh interface can drop messages between clients to implement a
    mesh-wide AP isolation.

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH and
    BATADV_CMD_SET_VLAN/BATADV_CMD_GET_VLAN commands allow to set/get the
    configuration of this feature using the BATADV_ATTR_AP_ISOLATION_ENABLED
    attribute. Setting the u8 to zero will disable this feature and setting it
    to something else is enabling this feature.

    This feature also requires that skbuff which should be handled as isolated
    are marked. The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to
    set/get the mark/mask using the u32 attributes BATADV_ATTR_ISOLATION_MARK
    and BATADV_ATTR_ISOLATION_MASK.

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

    Sven Eckelmann
     
  • The mesh interface can delay OGM messages to aggregate different ogms
    together in a single OGM packet.

    The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the
    configuration of this feature using the BATADV_ATTR_AGGREGATED_OGMS_ENABLED
    attribute. Setting the u8 to zero will disable this feature and setting it
    to something else is enabling this feature.

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

    Sven Eckelmann
     
  • The batman-adv configuration interface was implemented solely using sysfs.
    This approach was condemned by non-batadv developers as "huge mistake".
    Instead a netlink/genl based implementation was suggested.

    Beside the mesh/soft-interface specific configuration, the VLANs on top of
    the mesh/soft-interface have configuration settings. The genl interface
    reflects this by allowing to get/set it using the vlan specific commands
    BATADV_CMD_GET_VLAN/BATADV_CMD_SET_VLAN.

    The set command BATADV_CMD_SET_MESH will also notify interested userspace
    listeners of the "config" mcast group using the BATADV_CMD_SET_VLAN command
    message type that settings might have been changed and what the current
    values are.

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

    Sven Eckelmann
     
  • The batman-adv configuration interface was implemented solely using sysfs.
    This approach was condemned by non-batadv developers as "huge mistake".
    Instead a netlink/genl based implementation was suggested.

    Beside the mesh/soft-interface specific configuration, the
    slave/hard-interface have B.A.T.M.A.N. V specific configuration settings.
    The genl interface reflects this by allowing to get/set it using the
    hard-interface specific commands.

    The BATADV_CMD_GET_HARDIFS (or short version BATADV_CMD_GET_HARDIF) is
    reused as get command because it already allow sto dump the content of
    other information from the slave/hard-interface which are not yet
    configuration specific.

    The set command BATADV_CMD_SET_HARDIF will also notify interested userspace
    listeners of the "config" mcast group using the BATADV_CMD_SET_HARDIF
    command message type that settings might have been changed and what the
    current values are.

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

    Sven Eckelmann
     
  • The batman-adv configuration interface was implemented solely using sysfs.
    This approach was condemned by non-batadv developers as "huge mistake".
    Instead a netlink/genl based implementation was suggested.

    The main objects for this configuration is the mesh/soft-interface object.
    Its actual object in memory already contains most of the available
    configuration settings. The genl interface reflects this by allowing to
    get/set it using the mesh specific commands.

    The BATADV_CMD_GET_MESH_INFO (or short version BATADV_CMD_GET_MESH) is
    reused as get command because it already provides the content of other
    information from the mesh/soft-interface which are not yet configuration
    specific.

    The set command BATADV_CMD_SET_MESH will also notify interested userspace
    listeners of the "config" mcast group using the BATADV_CMD_SET_MESH command
    message type that settings might have been changed and what the current
    values are.

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

    Sven Eckelmann
     
  • The commit ff4c92d85c6f ("genetlink: introduce pre_doit/post_doit hooks")
    intoduced a mechanism to run specific code for doit hooks before/after the
    hooks are run. Since all doit hooks are requiring the batadv softif, it
    should be retrieved/freed in these helpers to simplify the code.

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

    Sven Eckelmann
     

04 Jan, 2019

1 commit


12 Nov, 2018

1 commit

  • The netlink dump functionality transfers a large number of entries from the
    kernel to userspace. It is rather likely that the transfer has to
    interrupted and later continued. During that time, it can happen that
    either new entries are added or removed. The userspace could than either
    receive some entries multiple times or miss entries.

    Commit 670dc2833d14 ("netlink: advertise incomplete dumps") introduced a
    mechanism to inform userspace about this problem. Userspace can then decide
    whether it is necessary or not to retry dumping the information again.

    The netlink dump functions have to be switched to exclusive locks to avoid
    changes while the current message is prepared. And an external generation
    sequence counter is introduced which tracks all modifications of the list.

    Reported-by: Matthias Schiffer
    Signed-off-by: Sven Eckelmann
    Signed-off-by: Simon Wunderlich

    Sven Eckelmann
     

14 Mar, 2018

2 commits


27 Feb, 2018

1 commit


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

3 commits

  • 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
     

26 Jan, 2017

1 commit


30 Oct, 2016

2 commits


28 Oct, 2016

1 commit

  • Now genl_register_family() is the only thing (other than the
    users themselves, perhaps, but I didn't find any doing that)
    writing to the family struct.

    In all families that I found, genl_register_family() is only
    called from __init functions (some indirectly, in which case
    I've add __init annotations to clarifly things), so all can
    actually be marked __ro_after_init.

    This protects the data structure from accidental corruption.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg