<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/net/bridge/br_vlan.c, branch linux-5.2.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.2.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.2.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2019-08-09T15:51:44Z</updated>
<entry>
<title>net: bridge: move default pvid init/deinit to NETDEV_REGISTER/UNREGISTER</title>
<updated>2019-08-09T15:51:44Z</updated>
<author>
<name>Nikolay Aleksandrov</name>
</author>
<published>2019-08-02T10:57:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=34491ab5ddb9f2f490d59735858ac11a341f1e13'/>
<id>urn:sha1:34491ab5ddb9f2f490d59735858ac11a341f1e13</id>
<content type='text'>
[ Upstream commit 091adf9ba6cdb432cbcc217b47e4ffb8aa0d8865 ]

Most of the bridge device's vlan init bugs come from the fact that its
default pvid is created at the wrong time, way too early in ndo_init()
before the device is even assigned an ifindex. It introduces a bug when the
bridge's dev_addr is added as fdb during the initial default pvid creation
the notification has ifindex/NDA_MASTER both equal to 0 (see example below)
which really makes no sense for user-space[0] and is wrong.
Usually user-space software would ignore such entries, but they are
actually valid and will eventually have all necessary attributes.
It makes much more sense to send a notification *after* the device has
registered and has a proper ifindex allocated rather than before when
there's a chance that the registration might still fail or to receive
it with ifindex/NDA_MASTER == 0. Note that we can remove the fdb flush
from br_vlan_flush() since that case can no longer happen. At
NETDEV_REGISTER br-&gt;default_pvid is always == 1 as it's initialized by
br_vlan_init() before that and at NETDEV_UNREGISTER it can be anything
depending why it was called (if called due to NETDEV_REGISTER error
it'll still be == 1, otherwise it could be any value changed during the
device life time).

For the demonstration below a small change to iproute2 for printing all fdb
notifications is added, because it contained a workaround not to show
entries with ifindex == 0.
Command executed while monitoring: $ ip l add br0 type bridge
Before (both ifindex and master == 0):
$ bridge monitor fdb
36:7e:8a:b3:56:ba dev * vlan 1 master * permanent

After (proper br0 ifindex):
$ bridge monitor fdb
e6:2a:ae:7a:b7:48 dev br0 vlan 1 master br0 permanent

v4: move only the default pvid init/deinit to NETDEV_REGISTER/UNREGISTER
v3: send the correct v2 patch with all changes (stub should return 0)
v2: on error in br_vlan_init set br-&gt;vlgrp to NULL and return 0 in
    the br_vlan_bridge_event stub when bridge vlans are disabled

[0] https://bugzilla.kernel.org/show_bug.cgi?id=204389

Reported-by: michael-dev &lt;michael-dev@fami-braun.de&gt;
Fixes: 5be5a2df40f0 ("bridge: Add filtering support for default_pvid")
Signed-off-by: Nikolay Aleksandrov &lt;nikolay@cumulusnetworks.com&gt;
Acked-by: Roopa Prabhu &lt;roopa@cumulusnetworks.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>net: bridge: delete local fdb on device init failure</title>
<updated>2019-08-09T15:51:43Z</updated>
<author>
<name>Nikolay Aleksandrov</name>
</author>
<published>2019-07-29T09:28:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=016df08464ba7daa1ccb0a1c1038a78882c5996d'/>
<id>urn:sha1:016df08464ba7daa1ccb0a1c1038a78882c5996d</id>
<content type='text'>
[ Upstream commit d7bae09fa008c6c9a489580db0a5a12063b97f97 ]

On initialization failure we have to delete the local fdb which was
inserted due to the default pvid creation. This problem has been present
since the inception of default_pvid. Note that currently there are 2 cases:
1) in br_dev_init() when br_multicast_init() fails
2) if register_netdevice() fails after calling ndo_init()

This patch takes care of both since br_vlan_flush() is called on both
occasions. Also the new fdb delete would be a no-op on normal bridge
device destruction since the local fdb would've been already flushed by
br_dev_delete(). This is not an issue for ports since nbp_vlan_init() is
called last when adding a port thus nothing can fail after it.

Reported-by: syzbot+88533dc8b582309bf3ee@syzkaller.appspotmail.com
Fixes: 5be5a2df40f0 ("bridge: Add filtering support for default_pvid")
Signed-off-by: Nikolay Aleksandrov &lt;nikolay@cumulusnetworks.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>treewide: Add SPDX license identifier for missed files</title>
<updated>2019-05-21T08:50:45Z</updated>
<author>
<name>Thomas Gleixner</name>
</author>
<published>2019-05-19T12:08:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=457c89965399115e5cd8bf38f9c597293405703d'/>
<id>urn:sha1:457c89965399115e5cd8bf38f9c597293405703d</id>
<content type='text'>
Add SPDX license identifiers to all files which:

 - Have no license information of any form

 - Have EXPORT_.*_SYMBOL_GPL inside which was used in the
   initial scan/conversion to ignore the file

These files fall under the project license, GPL v2 only. The resulting SPDX
license identifier is:

  GPL-2.0-only

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>bridge: update vlan dev link state for bridge netdev changes</title>
<updated>2019-04-19T20:58:17Z</updated>
<author>
<name>Mike Manning</name>
</author>
<published>2019-04-18T17:35:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8e1acd4fc552f5590e9d5ff6e5cb5eeafd638d30'/>
<id>urn:sha1:8e1acd4fc552f5590e9d5ff6e5cb5eeafd638d30</id>
<content type='text'>
If vlan bridge binding is enabled, then the link state of a vlan device
that is an upper device of the bridge tracks the state of bridge ports
that are members of that vlan. But this can only be done when the link
state of the bridge is up. If it is down, then the link state of the
vlan devices must also be down. This is to maintain existing behavior
for when STP is enabled and there are no live ports, in which case the
link state for the bridge and any vlan devices is down.

Signed-off-by: Mike Manning &lt;mmanning@vyatta.att-mail.com&gt;
Acked-by: Nikolay Aleksandrov &lt;nikolay@cumulusnetworks.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bridge: update vlan dev state when port added to or deleted from vlan</title>
<updated>2019-04-19T20:58:17Z</updated>
<author>
<name>Mike Manning</name>
</author>
<published>2019-04-18T17:35:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=80900acd3a30ed32d65ec591ded5d527d6ba373f'/>
<id>urn:sha1:80900acd3a30ed32d65ec591ded5d527d6ba373f</id>
<content type='text'>
If vlan bridge binding is enabled, then the link state of a vlan device
that is an upper device of the bridge should track the state of bridge
ports that are members of that vlan. So if a bridge port becomes or
stops being a member of a vlan, then update the link state of the
vlan device if necessary.

Signed-off-by: Mike Manning &lt;mmanning@vyatta.att-mail.com&gt;
Acked-by: Nikolay Aleksandrov &lt;nikolay@cumulusnetworks.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bridge: support binding vlan dev link state to vlan member bridge ports</title>
<updated>2019-04-19T20:58:17Z</updated>
<author>
<name>Mike Manning</name>
</author>
<published>2019-04-18T17:35:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9c0ec2e7182a508335364c752da0883a2a7f3999'/>
<id>urn:sha1:9c0ec2e7182a508335364c752da0883a2a7f3999</id>
<content type='text'>
In the case of vlan filtering on bridges, the bridge may also have the
corresponding vlan devices as upper devices. A vlan bridge binding mode
is added to allow the link state of the vlan device to track only the
state of the subset of bridge ports that are also members of the vlan,
rather than that of all bridge ports. This mode is set with a vlan flag
rather than a bridge sysfs so that the 8021q module is aware that it
should not set the link state for the vlan device.

If bridge vlan is configured, the bridge device event handling results
in the link state for an upper device being set, if it is a vlan device
with the vlan bridge binding mode enabled. This also sets a
vlan_bridge_binding flag so that subsequent UP/DOWN/CHANGE events for
the ports in that bridge result in a link state update of the vlan
device if required.

The link state of the vlan device is up if there is at least one bridge
port that is a vlan member that is admin &amp; oper up, otherwise its oper
state is IF_OPER_LOWERLAYERDOWN.

Signed-off-by: Mike Manning &lt;mmanning@vyatta.att-mail.com&gt;
Acked-by: Nikolay Aleksandrov &lt;nikolay@cumulusnetworks.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: use bit_spin_locks to protect hash bucket.</title>
<updated>2019-04-08T02:12:12Z</updated>
<author>
<name>NeilBrown</name>
</author>
<published>2019-04-01T23:07:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8f0db018006a421956965e1149234c4e8db718ee'/>
<id>urn:sha1:8f0db018006a421956965e1149234c4e8db718ee</id>
<content type='text'>
This patch changes rhashtables to use a bit_spin_lock on BIT(1) of the
bucket pointer to lock the hash chain for that bucket.

The benefits of a bit spin_lock are:
 - no need to allocate a separate array of locks.
 - no need to have a configuration option to guide the
   choice of the size of this array
 - locking cost is often a single test-and-set in a cache line
   that will have to be loaded anyway.  When inserting at, or removing
   from, the head of the chain, the unlock is free - writing the new
   address in the bucket head implicitly clears the lock bit.
   For __rhashtable_insert_fast() we ensure this always happens
   when adding a new key.
 - even when lockings costs 2 updates (lock and unlock), they are
   in a cacheline that needs to be read anyway.

The cost of using a bit spin_lock is a little bit of code complexity,
which I think is quite manageable.

Bit spin_locks are sometimes inappropriate because they are not fair -
if multiple CPUs repeatedly contend of the same lock, one CPU can
easily be starved.  This is not a credible situation with rhashtable.
Multiple CPUs may want to repeatedly add or remove objects, but they
will typically do so at different buckets, so they will attempt to
acquire different locks.

As we have more bit-locks than we previously had spinlocks (by at
least a factor of two) we can expect slightly less contention to
go with the slightly better cache behavior and reduced memory
consumption.

To enhance type checking, a new struct is introduced to represent the
  pointer plus lock-bit
that is stored in the bucket-table.  This is "struct rhash_lock_head"
and is empty.  A pointer to this needs to be cast to either an
unsigned lock, or a "struct rhash_head *" to be useful.
Variables of this type are most often called "bkt".

Previously "pprev" would sometimes point to a bucket, and sometimes a
-&gt;next pointer in an rhash_head.  As these are now different types,
pprev is NULL when it would have pointed to the bucket. In that case,
'blk' is used, together with correct locking protocol.

Signed-off-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: bridge: Fix VLANs memory leak</title>
<updated>2019-01-08T21:53:54Z</updated>
<author>
<name>Ido Schimmel</name>
</author>
<published>2019-01-08T16:48:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=279737939a8194f02fa352ab4476a1b241f44ef4'/>
<id>urn:sha1:279737939a8194f02fa352ab4476a1b241f44ef4</id>
<content type='text'>
When adding / deleting VLANs to / from a bridge port, the bridge driver
first tries to propagate the information via switchdev and falls back to
the 8021q driver in case the underlying driver does not support
switchdev. This can result in a memory leak [1] when VXLAN and mlxsw
ports are enslaved to the bridge:

$ ip link set dev vxlan0 master br0
# No mlxsw ports are enslaved to 'br0', so mlxsw ignores the switchdev
# notification and the bridge driver adds the VLAN on 'vxlan0' via the
# 8021q driver
$ bridge vlan add vid 10 dev vxlan0 pvid untagged
# mlxsw port is enslaved to the bridge
$ ip link set dev swp1 master br0
# mlxsw processes the switchdev notification and the 8021q driver is
# skipped
$ bridge vlan del vid 10 dev vxlan0

This results in 'struct vlan_info' and 'struct vlan_vid_info' being
leaked, as they were allocated by the 8021q driver during VLAN addition,
but never freed as the 8021q driver was skipped during deletion.

Fix this by introducing a new VLAN private flag that indicates whether
the VLAN was added on the port by switchdev or the 8021q driver. If the
VLAN was added by the 8021q driver, then we make sure to delete it via
the 8021q driver as well.

[1]
unreferenced object 0xffff88822d20b1e8 (size 256):
  comm "bridge", pid 2532, jiffies 4295216998 (age 1188.830s)
  hex dump (first 32 bytes):
    e0 42 97 ce 81 88 ff ff 00 00 00 00 00 00 00 00  .B..............
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;00000000f82d851d&gt;] kmem_cache_alloc_trace+0x1be/0x330
    [&lt;00000000e0178b02&gt;] vlan_vid_add+0x661/0x920
    [&lt;00000000218ebd5f&gt;] __vlan_add+0x1be9/0x3a00
    [&lt;000000006eafa1ca&gt;] nbp_vlan_add+0x8b3/0xd90
    [&lt;000000003535392c&gt;] br_vlan_info+0x132/0x410
    [&lt;00000000aedaa9dc&gt;] br_afspec+0x75c/0x870
    [&lt;00000000f5716133&gt;] br_setlink+0x3dc/0x6d0
    [&lt;00000000aceca5e2&gt;] rtnl_bridge_setlink+0x615/0xb30
    [&lt;00000000a2f2d23e&gt;] rtnetlink_rcv_msg+0x3a3/0xa80
    [&lt;0000000064097e69&gt;] netlink_rcv_skb+0x152/0x3c0
    [&lt;000000008be8d614&gt;] rtnetlink_rcv+0x21/0x30
    [&lt;000000009ab2ca25&gt;] netlink_unicast+0x52f/0x740
    [&lt;00000000e7d9ac96&gt;] netlink_sendmsg+0x9c7/0xf50
    [&lt;000000005d1e2050&gt;] sock_sendmsg+0xbe/0x120
    [&lt;00000000d51426bc&gt;] ___sys_sendmsg+0x778/0x8f0
    [&lt;00000000b9d7b2cc&gt;] __sys_sendmsg+0x112/0x270
unreferenced object 0xffff888227454308 (size 32):
  comm "bridge", pid 2532, jiffies 4295216998 (age 1188.882s)
  hex dump (first 32 bytes):
    88 b2 20 2d 82 88 ff ff 88 b2 20 2d 82 88 ff ff  .. -...... -....
    81 00 0a 00 01 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;00000000f82d851d&gt;] kmem_cache_alloc_trace+0x1be/0x330
    [&lt;0000000018050631&gt;] vlan_vid_add+0x3e6/0x920
    [&lt;00000000218ebd5f&gt;] __vlan_add+0x1be9/0x3a00
    [&lt;000000006eafa1ca&gt;] nbp_vlan_add+0x8b3/0xd90
    [&lt;000000003535392c&gt;] br_vlan_info+0x132/0x410
    [&lt;00000000aedaa9dc&gt;] br_afspec+0x75c/0x870
    [&lt;00000000f5716133&gt;] br_setlink+0x3dc/0x6d0
    [&lt;00000000aceca5e2&gt;] rtnl_bridge_setlink+0x615/0xb30
    [&lt;00000000a2f2d23e&gt;] rtnetlink_rcv_msg+0x3a3/0xa80
    [&lt;0000000064097e69&gt;] netlink_rcv_skb+0x152/0x3c0
    [&lt;000000008be8d614&gt;] rtnetlink_rcv+0x21/0x30
    [&lt;000000009ab2ca25&gt;] netlink_unicast+0x52f/0x740
    [&lt;00000000e7d9ac96&gt;] netlink_sendmsg+0x9c7/0xf50
    [&lt;000000005d1e2050&gt;] sock_sendmsg+0xbe/0x120
    [&lt;00000000d51426bc&gt;] ___sys_sendmsg+0x778/0x8f0
    [&lt;00000000b9d7b2cc&gt;] __sys_sendmsg+0x112/0x270

Fixes: d70e42b22dd4 ("mlxsw: spectrum: Enable VxLAN enslavement to VLAN-aware bridges")
Signed-off-by: Ido Schimmel &lt;idosch@mellanox.com&gt;
Reviewed-by: Petr Machata &lt;petrm@mellanox.com&gt;
Cc: Roopa Prabhu &lt;roopa@cumulusnetworks.com&gt;
Cc: Nikolay Aleksandrov &lt;nikolay@cumulusnetworks.com&gt;
Cc: bridge@lists.linux-foundation.org
Acked-by: Nikolay Aleksandrov &lt;nikolay@cumulusnetworks.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: bridge: Propagate extack to switchdev</title>
<updated>2018-12-13T00:34:21Z</updated>
<author>
<name>Petr Machata</name>
</author>
<published>2018-12-12T17:02:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=169327d5850cb80d98d095cfaf8dfbb63d576864'/>
<id>urn:sha1:169327d5850cb80d98d095cfaf8dfbb63d576864</id>
<content type='text'>
ndo_bridge_setlink has been updated in the previous patch to have extack
available, and changelink RTNL op has had this argument since the time
extack was added. Propagate both through the bridge driver to eventually
reach br_switchdev_port_vlan_add(), where it will be used by subsequent
patches.

Signed-off-by: Petr Machata &lt;petrm@mellanox.com&gt;
Acked-by: Jiri Pirko &lt;jiri@mellanox.com&gt;
Acked-by: Nikolay Aleksandrov &lt;nikolay@cumulusnetworks.com&gt;
Acked-by: Ivan Vecera &lt;ivecera@redhat.com&gt;
Acked-by: Roopa Prabhu &lt;roopa@cumulusnetworks.com&gt;
Reviewed-by: Ido Schimmel &lt;idosch@mellanox.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: bridge: Extend br_vlan_get_pvid() for bridge ports</title>
<updated>2018-12-01T01:06:28Z</updated>
<author>
<name>Ido Schimmel</name>
</author>
<published>2018-11-28T20:06:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5a6db04ca8d44c873d6dd6bc3d2328aaa4c86a87'/>
<id>urn:sha1:5a6db04ca8d44c873d6dd6bc3d2328aaa4c86a87</id>
<content type='text'>
Currently, the function only works for the bridge device itself, but
subsequent patches will need to be able to query the PVID of a given
bridge port, so extend the function.

Signed-off-by: Ido Schimmel &lt;idosch@mellanox.com&gt;
Reviewed-by: Petr Machata &lt;petrm@mellanox.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
