24 Sep, 2020

1 commit

  • Update kernel-doc line comments to fix warnings reported by make W=1.
    net/switchdev/switchdev.c:413: warning: Function parameter or
    member 'extack' not described in 'call_switchdev_notifiers'

    Signed-off-by: Tian Tao
    Acked-by: Ivan Vecera
    Signed-off-by: David S. Miller

    Tian Tao
     

14 Jul, 2020

1 commit


14 Jun, 2020

1 commit

  • Since commit 84af7a6194e4 ("checkpatch: kconfig: prefer 'help' over
    '---help---'"), the number of '---help---' has been gradually
    decreasing, but there are still more than 2400 instances.

    This commit finishes the conversion. While I touched the lines,
    I also fixed the indentation.

    There are a variety of indentation styles found.

    a) 4 spaces + '---help---'
    b) 7 spaces + '---help---'
    c) 8 spaces + '---help---'
    d) 1 space + 1 tab + '---help---'
    e) 1 tab + '---help---' (correct indentation)
    f) 1 tab + 1 space + '---help---'
    g) 1 tab + 2 spaces + '---help---'

    In order to convert all of them to 1 tab + 'help', I ran the
    following commend:

    $ find . -name 'Kconfig*' | xargs sed -i 's/^[[:space:]]*---help---/\thelp/'

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

27 Feb, 2020

1 commit

  • When configuring a tree of independent bridges, propagating changes
    from the upper bridge across a bridge master to the lower bridge
    ports brings surprises.

    For example, a lower bridge may have vlan filtering enabled. It
    may have a vlan interface attached to the bridge master, which may
    then be incorporated into another bridge. As soon as the lower
    bridge vlan interface is attached to the upper bridge, the lower
    bridge has vlan filtering disabled.

    This occurs because switchdev recursively applies its changes to
    all lower devices no matter what.

    Reviewed-by: Ido Schimmel
    Tested-by: Ido Schimmel
    Signed-off-by: Russell King
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Russell King
     

18 Feb, 2020

1 commit

  • The current codebase makes use of the zero-length array language
    extension to the C90 standard, but the preferred mechanism to declare
    variable-length types such as these ones is a flexible array member[1][2],
    introduced in C99:

    struct foo {
    int stuff;
    struct boo array[];
    };

    By making use of the mechanism above, we will get a compiler warning
    in case the flexible array does not occur last in the structure, which
    will help us prevent some kind of undefined behavior bugs from being
    inadvertently introduced[3] to the codebase from now on.

    Also, notice that, dynamic memory allocations won't be affected by
    this change:

    "Flexible array members have incomplete type, and so the sizeof operator
    may not be applied. As a quirk of the original implementation of
    zero-length arrays, sizeof evaluates to zero."[1]

    This issue was found with the help of Coccinelle.

    [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
    [2] https://github.com/KSPP/linux/issues/21
    [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: David S. Miller

    Gustavo A. R. Silva
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


02 Mar, 2019

1 commit

  • There are no more in tree users of the
    switchdev_trans_item_{dequeue,enqueue} or switchdev_trans_item structure
    in the kernel since commit 00fc0c51e35b ("rocker: Change world_ops API
    and implementation to be switchdev independant").

    Remove this unused code and update the documentation accordingly since.

    Signed-off-by: Florian Fainelli
    Acked-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Florian Fainelli
     

28 Feb, 2019

2 commits

  • Drop switchdev_ops.switchdev_port_attr_set. Drop the uses of this field
    from all clients, which were migrated to use switchdev notification in
    the previous patches.

    Add a new function switchdev_port_attr_notify() that sends the switchdev
    notifications SWITCHDEV_PORT_ATTR_SET and calls the blocking (process)
    notifier chain.

    We have one odd case within net/bridge/br_switchdev.c with the
    SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS attribute identifier that
    requires executing from atomic context, we deal with that one
    specifically.

    Drop __switchdev_port_attr_set() and update switchdev_port_attr_set()
    likewise.

    Signed-off-by: Florian Fainelli
    Reviewed-by: Ido Schimmel
    Signed-off-by: David S. Miller

    Florian Fainelli
     
  • In preparation for allowing switchdev enabled drivers to veto specific
    attribute settings from within the context of the caller, introduce a
    new switchdev notifier type for port attributes.

    Suggested-by: Ido Schimmel
    Reviewed-by: Ido Schimmel
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Florian Fainelli
     

25 Feb, 2019

1 commit


07 Feb, 2019

1 commit

  • Now that we have a dedicated NDO for getting a port's parent ID, get rid
    of SWITCHDEV_ATTR_ID_PORT_PARENT_ID and convert all callers to use the
    NDO exclusively. This is a preliminary change to getting rid of
    switchdev_ops eventually.

    Signed-off-by: Florian Fainelli
    Reviewed-by: Ido Schimmel
    Signed-off-by: David S. Miller

    Florian Fainelli
     

18 Jan, 2019

1 commit


13 Dec, 2018

3 commits

  • Drivers use switchdev_handle_port_obj_add() to handle recursive descent
    through lower devices. Change this function prototype to take add_cb
    that itself takes an extack argument. Decode extack from
    switchdev_notifier_port_obj_info and pass it to add_cb.

    Update mlxsw and ocelot drivers which use this helper.

    Signed-off-by: Petr Machata
    Acked-by: Jiri Pirko
    Acked-by: Ivan Vecera
    Reviewed-by: Ido Schimmel
    Signed-off-by: David S. Miller

    Petr Machata
     
  • In order to pass extack to the drivers that need it, add an extack field
    to struct switchdev_notifier_info, and an extack argument to the
    function call_switchdev_blocking_notifiers(). Also add a helper function
    switchdev_notifier_info_to_extack().

    Signed-off-by: Petr Machata
    Acked-by: Jiri Pirko
    Acked-by: Ivan Vecera
    Reviewed-by: Ido Schimmel
    Signed-off-by: David S. Miller

    Petr Machata
     
  • After the previous patch, bridge driver has extack argument available to
    pass to switchdev. Therefore extend switchdev_port_obj_add() with this
    argument, updating all callers, and passing the argument through to
    switchdev_port_obj_notify().

    Signed-off-by: Petr Machata
    Acked-by: Jiri Pirko
    Acked-by: Ivan Vecera
    Reviewed-by: Ido Schimmel
    Signed-off-by: David S. Miller

    Petr Machata
     

24 Nov, 2018

3 commits

  • Drop switchdev_ops.switchdev_port_obj_add and _del. Drop the uses of
    this field from all clients, which were migrated to use switchdev
    notification in the previous patches.

    Add a new function switchdev_port_obj_notify() that sends the switchdev
    notifications SWITCHDEV_PORT_OBJ_ADD and _DEL.

    Update switchdev_port_obj_del_now() to dispatch to this new function.
    Drop __switchdev_port_obj_add() and update switchdev_port_obj_add()
    likewise.

    Signed-off-by: Petr Machata
    Reviewed-by: Ido Schimmel
    Signed-off-by: David S. Miller

    Petr Machata
     
  • After the transition from switchdev operations to notifier chain (which
    will take place in following patches), the onus is on the driver to find
    its own devices below possible layer of LAG or other uppers.

    The logic to do so is fairly repetitive: each driver is looking for its
    own devices among the lowers of the notified device. For those that it
    finds, it calls a handler. To indicate that the event was handled,
    struct switchdev_notifier_port_obj_info.handled is set. The differences
    lie only in what constitutes an "own" device and what handler to call.

    Therefore abstract this logic into two helpers,
    switchdev_handle_port_obj_add() and switchdev_handle_port_obj_del(). If
    a driver only supports physical ports under a bridge device, it will
    simply avoid this layer of indirection.

    One area where this helper diverges from the current switchdev behavior
    is the case of mixed lowers, some of which are switchdev ports and some
    of which are not. Previously, such scenario would fail with -EOPNOTSUPP.
    The helper could do that for lowers for which the passed-in predicate
    doesn't hold. That would however break the case that switchdev ports
    from several different drivers are stashed under one master, a scenario
    that switchdev currently happily supports. Therefore tolerate any and
    all unknown netdevices, whether they are backed by a switchdev driver
    or not.

    Signed-off-by: Petr Machata
    Reviewed-by: Ido Schimmel
    Signed-off-by: David S. Miller

    Petr Machata
     
  • In general one can't assume that a switchdev notifier is called in a
    non-atomic context, and correspondingly, the switchdev notifier chain is
    an atomic one.

    However, port object addition and deletion messages are delivered from a
    process context. Even the MDB addition messages, whose delivery is
    scheduled from atomic context, are queued and the delivery itself takes
    place in blocking context. For VLAN messages in particular, keeping the
    blocking nature is important for error reporting.

    Therefore introduce a blocking notifier chain and related service
    functions to distribute the notifications for which a blocking context
    can be assumed.

    Signed-off-by: Petr Machata
    Reviewed-by: Jiri Pirko
    Reviewed-by: Ido Schimmel
    Signed-off-by: David S. Miller

    Petr Machata
     

10 Nov, 2017

1 commit


08 Aug, 2017

2 commits

  • Currently the bridge port flags, vlans, FDBs and MDBs can be offloaded
    through the bridge code, making the switchdev's SELF bridge bypass
    implementation to be redundant. This implies several changes:
    - No need for dump infra in switchdev, DSA's special case is handled
    privately.
    - Remove obj_dump from switchdev_ops.
    - FDBs are removed from obj_add/del routines, due to the fact that they
    are offloaded through the bridge notification chain.
    - The switchdev_port_bridge_xx() and switchdev_port_fdb_xx() functions
    can be removed.

    Signed-off-by: Arkadi Sharshevsky
    Reviewed-by: Vivien Didelot
    Acked-by: Jiri Pirko
    Reviewed-by: Ivan Vecera
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Arkadi Sharshevsky
     
  • >From all switchdev devices only DSA requires special FDB dump. This is due
    to lack of ability for syncing the hardware learned FDBs with the bridge.
    Due to this it is removed from switchdev and moved inside DSA.

    Signed-off-by: Arkadi Sharshevsky
    Signed-off-by: David S. Miller

    Arkadi Sharshevsky
     

09 Jun, 2017

1 commit

  • In order to use the switchdev notifier chain for FDB sync with the
    device it has to be changed to atomic. The is done because the bridge
    can learn new FDBs in atomic context.

    Signed-off-by: Arkadi Sharshevsky
    Reviewed-by: Ido Schimmel
    Reviewed-by: Ivan Vecera
    Signed-off-by: Jiri Pirko
    Reviewed-by: Ivan Vecera
    Signed-off-by: David S. Miller

    Arkadi Sharshevsky
     

14 Apr, 2017

1 commit


31 Oct, 2016

1 commit


30 Oct, 2016

1 commit


19 Oct, 2016

1 commit

  • We recently got the following warning after setting up a vlan device on
    top of an offloaded bridge and executing 'bridge link':

    WARNING: CPU: 0 PID: 18566 at drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c:81 mlxsw_sp_port_orig_get.part.9+0x55/0x70 [mlxsw_spectrum]
    [...]
    CPU: 0 PID: 18566 Comm: bridge Not tainted 4.8.0-rc7 #1
    Hardware name: Mellanox Technologies Ltd. Mellanox switch/Mellanox switch, BIOS 4.6.5 05/21/2015
    0000000000000286 00000000e64ab94f ffff880406e6f8f0 ffffffff8135eaa3
    0000000000000000 0000000000000000 ffff880406e6f930 ffffffff8108c43b
    0000005106e6f988 ffff8803df398840 ffff880403c60108 ffff880406e6f990
    Call Trace:
    [] dump_stack+0x63/0x90
    [] __warn+0xcb/0xf0
    [] warn_slowpath_null+0x1d/0x20
    [] mlxsw_sp_port_orig_get.part.9+0x55/0x70 [mlxsw_spectrum]
    [] mlxsw_sp_port_attr_get+0xa5/0xb0 [mlxsw_spectrum]
    [] switchdev_port_attr_get+0x4f/0x140
    [] switchdev_port_attr_get+0x100/0x140
    [] switchdev_port_attr_get+0x100/0x140
    [] switchdev_port_bridge_getlink+0x5b/0xc0
    [] ? switchdev_port_fdb_dump+0x90/0x90
    [] rtnl_bridge_getlink+0xe7/0x190
    [] netlink_dump+0x122/0x290
    [] __netlink_dump_start+0x15f/0x190
    [] ? rtnl_bridge_dellink+0x230/0x230
    [] rtnetlink_rcv_msg+0x1a6/0x220
    [] ? __kmalloc_node_track_caller+0x208/0x2c0
    [] ? rtnl_bridge_dellink+0x230/0x230
    [] ? rtnl_newlink+0x890/0x890
    [] netlink_rcv_skb+0xa4/0xc0
    [] rtnetlink_rcv+0x28/0x30
    [] netlink_unicast+0x18c/0x240
    [] netlink_sendmsg+0x2fb/0x3a0
    [] sock_sendmsg+0x38/0x50
    [] SYSC_sendto+0x101/0x190
    [] ? __sys_recvmsg+0x51/0x90
    [] SyS_sendto+0xe/0x10
    [] entry_SYSCALL_64_fastpath+0x1a/0xa4

    The problem is that the 8021q module propagates the call to
    ndo_bridge_getlink() via switchdev ops, but the switch driver doesn't
    recognize the netdev, as it's not offloaded.

    While we can ignore calls being made to non-bridge ports inside the
    driver, a better fix would be to push this check up to the switchdev
    layer.

    Note that these ndos can be called for non-bridged netdev, but this only
    happens in certain PF drivers which don't call the corresponding
    switchdev functions anyway.

    Fixes: 99f44bb3527b ("mlxsw: spectrum: Enable L3 interfaces on top of bridge devices")
    Signed-off-by: Ido Schimmel
    Reported-by: Tamir Winetroub
    Tested-by: Tamir Winetroub
    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Ido Schimmel
     

28 Sep, 2016

2 commits


02 Sep, 2016

1 commit

  • fdb dumps spanning multiple skb's currently restart from the first
    interface again for every skb. This results in unnecessary
    iterations on the already visited interfaces and their fdb
    entries. In large scale setups, we have seen this to slow
    down fdb dumps considerably. On a system with 30k macs we
    see fdb dumps spanning across more than 300 skbs.

    To fix the problem, this patch replaces the existing single fdb
    marker with three markers: netdev hash entries, netdevs and fdb
    index to continue where we left off instead of restarting from the
    first netdev. This is consistent with link dumps.

    In the process of fixing the performance issue, this patch also
    re-implements fix done by
    commit 472681d57a5d ("net: ndo_fdb_dump should report -EMSGSIZE to rtnl_fdb_dump")
    (with an internal fix from Wilson Kok) in the following ways:
    - change ndo_fdb_dump handlers to return error code instead
    of the last fdb index
    - use cb->args strictly for dump frag markers and not error codes.
    This is consistent with other dump functions.

    Below results were taken on a system with 1000 netdevs
    and 35085 fdb entries:
    before patch:
    $time bridge fdb show | wc -l
    15065

    real 1m11.791s
    user 0m0.070s
    sys 1m8.395s

    (existing code does not return all macs)

    after patch:
    $time bridge fdb show | wc -l
    35085

    real 0m2.017s
    user 0m0.113s
    sys 0m1.942s

    Signed-off-by: Roopa Prabhu
    Signed-off-by: Wilson Kok
    Signed-off-by: David S. Miller

    Roopa Prabhu
     

27 Aug, 2016

2 commits

  • switchdev_port_fwd_mark_set() is used to set the 'offload_fwd_mark' of
    port netdevs so that packets being flooded by the device won't be
    flooded twice.

    It works by assigning a unique identifier (the ifindex of the first
    bridge port) to bridge ports sharing the same parent ID. This prevents
    packets from being flooded twice by the same switch, but will flood
    packets through bridge ports belonging to a different switch.

    This method is problematic when stacked devices are taken into account,
    such as VLANs. In such cases, a physical port netdev can have upper
    devices being members in two different bridges, thus requiring two
    different 'offload_fwd_mark's to be configured on the port netdev, which
    is impossible.

    The main problem is that packet and netdev marking is performed at the
    physical netdev level, whereas flooding occurs between bridge ports,
    which are not necessarily port netdevs.

    Instead, packet and netdev marking should really be done in the bridge
    driver with the switch driver only telling it which packets it already
    forwarded. The bridge driver will mark such packets using the mark
    assigned to the ingress bridge port and will prevent the packet from
    being forwarded through any bridge port sharing the same mark (i.e.
    having the same parent ID).

    Remove the current switchdev 'offload_fwd_mark' implementation and
    instead implement the proposed method. In addition, make rocker - the
    sole user of the mark - use the proposed method.

    Signed-off-by: Ido Schimmel
    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Ido Schimmel
     
  • switchdev_port_same_parent_id() currently expects port netdevs, but we
    need it to support stacked devices in the next patch, so drop the
    NO_RECURSE flag.

    Signed-off-by: Ido Schimmel
    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Ido Schimmel
     

16 Aug, 2016

1 commit


15 Jul, 2016

1 commit


18 May, 2016

1 commit

  • The problem is that fib_info->nh is [0] so the struct fib_info
    allocation size depends on number of nexthops. If we just copy fib_info,
    we do not copy the nexthops info and driver accesses memory which is not
    ours.

    Given the fact that fib4 does not defer operations and therefore it does
    not need copy, just pass the pointer down to drivers as it was done
    before.

    Fixes: 850d0cbc91 ("switchdev: remove pointers from switchdev objects")
    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Jiri Pirko
     

15 May, 2016

1 commit


25 Apr, 2016

1 commit

  • When using switchdev deferred operation (SWITCHDEV_F_DEFER), the operation
    is executed in different context and the application doesn't have any way
    to get the operation real status.

    Adding a completion callback fixes that. This patch adds fields to
    switchdev_attr and switchdev_obj "complete_priv" field which is used by
    the "complete" callback.

    Application can set a complete function which will be called once the
    operation executed.

    Signed-off-by: Elad Raz
    Signed-off-by: Jiri Pirko
    Reviewed-by: Ido Schimmel
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Elad Raz
     

25 Mar, 2016

1 commit


27 Feb, 2016

1 commit

  • When the send skbuff reaches the end, nlmsg_put and friends returns
    -EMSGSIZE but it is silently thrown away in ndo_fdb_dump. It is called
    within a for_each_netdev loop and the first fdb entry of a following
    netdev could fit in the remaining skbuff. This breaks the mechanism
    of cb->args[0] and idx to keep track of the entries that are already
    dumped, which results missing entries in bridge fdb show command.

    Signed-off-by: Minoura Makoto
    Signed-off-by: David S. Miller

    MINOURA Makoto / 箕浦 真
     

29 Jan, 2016

1 commit

  • When switchdev drivers process FDB notifications from the underlying
    device they resolve the netdev to which the entry points to and notify
    the bridge using the switchdev notifier.

    However, since the RTNL mutex is not held there is nothing preventing
    the netdev from disappearing in the middle, which will cause
    br_switchdev_event() to dereference a non-existing netdev.

    Make switchdev drivers hold the lock at the beginning of the
    notification processing session and release it once it ends, after
    notifying the bridge.

    Also, remove switchdev_mutex and fdb_lock, as they are no longer needed
    when RTNL mutex is held.

    Fixes: 03bf0c281234 ("switchdev: introduce switchdev notifier")
    Signed-off-by: Ido Schimmel
    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Ido Schimmel