07 Jun, 2017

1 commit


02 Jun, 2017

1 commit

  • When the transition of NO_STP -> KERNEL_STP was fixed by always calling
    mod_timer in br_stp_start, it introduced a new regression which causes
    the timer to be armed even when the bridge is down, and since we stop
    the timers in its ndo_stop() function, they never get disabled if the
    device is destroyed before it's upped.

    To reproduce:
    $ while :; do ip l add br0 type bridge hello_time 100; brctl stp br0 on;
    ip l del br0; done;

    CC: Xin Long
    CC: Ivan Vecera
    CC: Sebastian Ott
    Reported-by: Sebastian Ott
    Fixes: 6d18c732b95c ("bridge: start hello_timer when enabling KERNEL_STP in br_stp_start")
    Signed-off-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     

23 May, 2017

2 commits

  • David S. Miller
     
  • Current bridge code incorrectly handles starting/stopping of hello and
    hold timers during STP enable/disable.

    1. Timers are stopped in br_stp_start() during NO_STP->USER_STP
    transition. The timers are already stopped in NO_STP state so
    this is confusing no-op.

    2. During USER_STP->NO_STP transition the timers are started. This
    does not make sense and is confusion because the timer should not be
    active in NO_STP state.

    Cc: davem@davemloft.net
    Cc: sashok@cumulusnetworks.com
    Cc: stephen@networkplumber.org
    Cc: bridge@lists.linux-foundation.org
    Cc: lucien.xin@gmail.com
    Cc: nikolay@cumulusnetworks.com
    Signed-off-by: Ivan Vecera
    Reviewed-by: Xin Long
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Ivan Vecera
     

22 May, 2017

1 commit

  • Since commit 76b91c32dd86 ("bridge: stp: when using userspace stp stop
    kernel hello and hold timers"), bridge would not start hello_timer if
    stp_enabled is not KERNEL_STP when br_dev_open.

    The problem is even if users set stp_enabled with KERNEL_STP later,
    the timer will still not be started. It causes that KERNEL_STP can
    not really work. Users have to re-ifup the bridge to avoid this.

    This patch is to fix it by starting br->hello_timer when enabling
    KERNEL_STP in br_stp_start.

    As an improvement, it's also to start hello_timer again only when
    br->stp_enabled is KERNEL_STP in br_hello_timer_expired, there is
    no reason to start the timer again when it's NO_STP.

    Fixes: 76b91c32dd86 ("bridge: stp: when using userspace stp stop kernel hello and hold timers")
    Reported-by: Haidong Li
    Signed-off-by: Xin Long
    Acked-by: Nikolay Aleksandrov
    Reviewed-by: Ivan Vecera
    Signed-off-by: David S. Miller

    Xin Long
     

07 Feb, 2017

1 commit

  • Move the fdb garbage collector to a workqueue which fires at least 10
    milliseconds apart and cleans chain by chain allowing for other tasks
    to run in the meantime. When having thousands of fdbs the system is much
    more responsive. Most importantly remove the need to check if the
    matched entry has expired in __br_fdb_get that causes false-sharing and
    is completely unnecessary if we cleanup entries, at worst we'll get 10ms
    of traffic for that entry before it gets deleted.

    Signed-off-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     

11 Dec, 2016

2 commits

  • Add a __br_set_topology_change helper to set the topology change value.

    This can be later extended to add actions when the topology change flag
    is set or cleared.

    Signed-off-by: Vivien Didelot
    Signed-off-by: David S. Miller

    Vivien Didelot
     
  • The SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME switchdev attr is actually set
    when initializing a bridge port, and when configuring the bridge ageing
    time from ioctl/netlink/sysfs.

    Add a __set_ageing_time helper to offload the ageing time to physical
    switches, and add the SWITCHDEV_F_DEFER flag since it can be called
    under bridge lock.

    Signed-off-by: Vivien Didelot
    Signed-off-by: David S. Miller

    Vivien Didelot
     

13 Sep, 2016

1 commit

  • If /sbin/bridge-stp is available on the system, bridge tries to execute
    it instead of the kernel implementation when starting/stopping STP.

    If anything goes wrong with /sbin/bridge-stp, bridge silently falls back
    to kernel STP, making hard to debug userspace STP.

    This patch adds a br_stp_call_user helper to start/stop userspace STP
    and debug errors from the program: abnormal exit status is stored in the
    lower byte and normal exit status is stored in higher byte.

    Below is a simple example on a kernel with dynamic debug enabled:

    # ln -s /bin/false /sbin/bridge-stp
    # brctl stp br0 on
    br0: failed to start userspace STP (256)
    # dmesg
    br0: /sbin/bridge-stp exited with code 1
    br0: failed to start userspace STP (256)
    br0: using kernel STP

    Signed-off-by: Vivien Didelot
    Signed-off-by: David S. Miller

    Vivien Didelot
     

26 Jul, 2016

1 commit


19 Feb, 2016

1 commit


07 Jan, 2016

1 commit


06 Jan, 2016

1 commit

  • [I stole this patch from Eric Biederman. He wrote:]

    > There is no defined mechanism to pass network namespace information
    > into /sbin/bridge-stp therefore don't even try to invoke it except
    > for bridge devices in the initial network namespace.
    >
    > It is possible for unprivileged users to cause /sbin/bridge-stp to be
    > invoked for any network device name which if /sbin/bridge-stp does not
    > guard against unreasonable arguments or being invoked twice on the
    > same network device could cause problems.

    [Hannes: changed patch using netns_eq]

    Cc: Eric W. Biederman
    Signed-off-by: Eric W. Biederman
    Signed-off-by: Hannes Frederic Sowa
    Signed-off-by: David S. Miller

    Hannes Frederic Sowa
     

01 Jan, 2016

1 commit


23 Dec, 2015

1 commit

  • The bridge's ageing time is offloaded to hardware when:
    1) A port joins a bridge
    2) The ageing time of the bridge is changed

    In the first case the ageing time is offloaded as jiffies, but in the
    second case it's offloaded as clock_t, which is what existing switchdev
    drivers expect to receive.

    Fixes: 6ac311ae8bfb ("Adding switchdev ageing notification on port bridged")
    Signed-off-by: Ido Schimmel
    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Ido Schimmel
     

16 Dec, 2015

1 commit

  • switchdev drivers need to know the netdev on which the switchdev op was
    invoked. For example, the STP state of a VLAN interface configured on top
    of a port can change while being member in a bridge. In this case, the
    underlying driver should only change the STP state of that particular
    VLAN and not of all the VLANs configured on the port.

    However, current switchdev infrastructure only passes the port netdev down
    to the driver. Solve that by passing the original device down to the
    driver as part of the required switchdev object / attribute.

    This doesn't entail any change in current switchdev drivers. It simply
    enables those supporting stacked devices to know the originating device
    and act accordingly.

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

    Ido Schimmel
     

17 Nov, 2015

1 commit

  • When NET_SWITCHDEV=n, switchdev_port_attr_set simply returns EOPNOTSUPP.
    In this case we should not emit errors and warnings to the kernel log.

    Reported-by: Sander Eikelenboom
    Tested-by: Christian Borntraeger
    Fixes: 0bc05d585d38 ("switchdev: allow caller to explicitly request
    attr_set as deferred")
    Fixes: 6ac311ae8bfb ("Adding switchdev ageing notification on port
    bridged")
    Signed-off-by: Ido Schimmel
    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Ido Schimmel
     

21 Oct, 2015

1 commit


29 Jul, 2015

1 commit

  • These should be handled only by the respective STP which is in control.
    They become problematic for devices with limited resources with many
    ports because the hold_timer is per port and fires each second and the
    hello timer fires each 2 seconds even though it's global. While in
    user-space STP mode these timers are completely unnecessary so it's better
    to keep them off.
    Also ensure that when the bridge is up these timers are started only when
    running with kernel STP.

    Signed-off-by: Satish Ashok
    Signed-off-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     

24 Jun, 2015

1 commit

  • Add a new argument to br_fdb_delete_by_port which allows to specify a
    vid to match when flushing entries and use it in nbp_vlan_delete() to
    flush the dynamically learned entries of the vlan/port pair when removing
    a vlan from a port. Before this patch only the local mac was being
    removed and the dynamically learned ones were left to expire.
    Note that the do_all argument is still respected and if specified, the
    vid will be ignored.

    Signed-off-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     

18 Jun, 2015

1 commit

  • After the ->set() spinlocks were removed br_stp_set_bridge_priority
    was left running without any protection when used via sysfs. It can
    race with port add/del and could result in use-after-free cases and
    corrupted lists. Tested by running port add/del in a loop with stp
    enabled while setting priority in a loop, crashes are easily
    reproducible.
    The spinlocks around sysfs ->set() were removed in commit:
    14f98f258f19 ("bridge: range check STP parameters")
    There's also a race condition in the netlink priority support that is
    fixed by this change, but it was introduced recently and the fixes tag
    covers it, just in case it's needed the commit is:
    af615762e972 ("bridge: add ageing_time, stp_state, priority over netlink")

    Signed-off-by: Nikolay Aleksandrov
    Fixes: 14f98f258f19 ("bridge: range check STP parameters")
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     

02 Oct, 2014

1 commit

  • In preparation for being able to propagate port states to e.g: notifiers
    or other kernel parts, do not manipulate the port state directly, but
    instead use a helper function which will allow us to do a bit more than
    just setting the state.

    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Florian Fainelli
     

11 Feb, 2014

1 commit

  • Vlan code may need fdb change when changing mac address of bridge device
    even if it is caused by the mac address changing of a bridge port.

    Example configuration:
    ip link set eth0 address 12:34:56:78:90:ab
    ip link set eth1 address aa:bb:cc:dd:ee:ff
    brctl addif br0 eth0
    brctl addif br0 eth1 # br0 will have mac address 12:34:56:78:90:ab
    bridge vlan add dev br0 vid 10 self
    bridge vlan add dev eth0 vid 10
    We will have fdb entry such that f->dst == NULL, f->vlan_id == 10 and
    f->addr == 12:34:56:78:90:ab at this time.
    Next, change the mac address of eth0 to greater value.
    ip link set eth0 address ee:ff:12:34:56:78
    Then, mac address of br0 will be recalculated and set to aa:bb:cc:dd:ee:ff.
    However, an entry aa:bb:cc:dd:ee:ff will not be created and we will be not
    able to communicate using br0 on vlan 10.

    Address this issue by deleting and adding local entries whenever
    changing the mac address of the bridge device.

    If there already exists an entry that has the same address, for example,
    in case that br_fdb_changeaddr() has already inserted it,
    br_fdb_change_mac_address() will simply fail to insert it and no
    duplicated entry will be made, as it was.

    This approach also needs br_add_if() to call br_fdb_insert() before
    br_stp_recalculate_bridge_id() so that we don't create an entry whose
    dst == NULL in this function to preserve previous behavior.

    Note that this is a slight change in behavior where the bridge device can
    receive the traffic to the new address before calling
    br_stp_recalculate_bridge_id() in br_add_if().
    However, it is not a problem because we have already the address on the
    new port and such a way to insert new one before recalculating bridge id
    is taken in br_device_event() as well.

    Signed-off-by: Toshiaki Makita
    Acked-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Toshiaki Makita
     

18 Oct, 2013

1 commit

  • Commit be4f154d5ef0ca147ab6bcd38857a774133f5450
    bridge: Clamp forward_delay when enabling STP
    had a typo when attempting to clamp maximum forward delay.

    It is possible to set bridge_forward_delay to be higher then
    permitted maximum when STP is off. When turning STP on, the
    higher then allowed delay has to be clamed down to max value.

    CC: Herbert Xu
    CC: Stephen Hemminger
    Signed-off-by: Vlad Yasevich
    Reviewed-by: Veaceslav Falico
    Acked-by: Herbert Xu
    Signed-off-by: David S. Miller

    Vlad Yasevich
     

13 Sep, 2013

1 commit

  • At some point limits were added to forward_delay. However, the
    limits are only enforced when STP is enabled. This created a
    scenario where you could have a value outside the allowed range
    while STP is disabled, which then stuck around even after STP
    is enabled.

    This patch fixes this by clamping the value when we enable STP.

    I had to move the locking around a bit to ensure that there is
    no window where someone could insert a value outside the range
    while we're in the middle of enabling STP.

    Signed-off-by: Herbert Xu

    Cheers,
    Signed-off-by: David S. Miller

    Herbert Xu
     

16 Apr, 2013

1 commit


12 Feb, 2013

1 commit


30 Dec, 2012

1 commit

  • The bridge link detection should follow the operational state
    of the lower device, rather than the carrier bit. This allows devices
    like tunnels that are controlled by userspace control plane to work
    with bridge STP link management.

    Signed-off-by: Stephen Hemminger
    Reviewed-by: Flavio Leitner
    Signed-off-by: David S. Miller

    stephen hemminger
     

10 May, 2012

1 commit

  • Use the new bool function ether_addr_equal to add
    some clarity and reduce the likelihood for misuse
    of compare_ether_addr for sorting.

    Done via cocci script:

    $ cat compare_ether_addr.cocci
    @@
    expression a,b;
    @@
    - !compare_ether_addr(a, b)
    + ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - compare_ether_addr(a, b)
    + !ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - !ether_addr_equal(a, b) == 0
    + ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - !ether_addr_equal(a, b) != 0
    + !ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - ether_addr_equal(a, b) == 0
    + !ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - ether_addr_equal(a, b) != 0
    + ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - !!ether_addr_equal(a, b)
    + ether_addr_equal(a, b)

    Signed-off-by: Joe Perches
    Signed-off-by: David S. Miller

    Joe Perches
     

08 Mar, 2012

1 commit


01 Nov, 2011

1 commit

  • To fix this, once the implicit presence of module.h is removed:

    net/bridge/br_stp_if.c: In function ‘br_stp_start’:
    net/bridge/br_stp_if.c:131: error: implicit declaration of function ‘call_usermodehelper’
    net/bridge/br_stp_if.c:131: error: ‘UMH_WAIT_PROC’ undeclared (first use in this function)

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

23 Jul, 2011

1 commit


05 Apr, 2011

1 commit

  • Apply restrictions on STP parameters based 802.1D 1998 standard.
    * Fixes missing locking in set path cost ioctl
    * Uses common code for both ioctl and sysfs

    This is based on an earlier patch Sasikanth V but with overhaul.

    Note:
    1. It does NOT enforce the restriction on the relationship max_age and
    forward delay or hello time because in existing implementation these are
    set as independant operations.

    2. If STP is disabled, there is no restriction on forward delay

    3. No restriction on holding time because users use Linux code to act
    as hub or be sticky.

    4. Although standard allow 0-255, Linux only allows 0-63 for port priority
    because more bits are reserved for port number.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: David S. Miller

    stephen hemminger
     

30 Mar, 2011

1 commit


28 Mar, 2011

1 commit


04 Jan, 2011

1 commit

  • net/bridge//br_stp_if.c:148:66: warning: conversion of
    net/bridge//br_stp_if.c:148:66: int to
    net/bridge//br_stp_if.c:148:66: int enum umh_wait

    net/bridge//netfilter/ebtables.c:1150:30: warning: Using plain integer as NULL pointer

    Signed-off-by: Tomas Winkler
    Signed-off-by: David S. Miller

    Tomas Winkler
     

16 May, 2010

1 commit


28 Feb, 2010

1 commit


18 Jun, 2008

1 commit


12 Jun, 2008

1 commit