[Bridge] [PATCH net-next v5 0/5] bridge: Add a limit on learned FDB entries

2023-10-16 Thread Johannes Nixdorf via Bridge
Introduce a limit on the amount of learned FDB entries on a bridge, configured by netlink with a build time default on bridge creation in the kernel config. For backwards compatibility the kernel config default is disabling the limit (0). Without any limit a malicious actor may OOM a kernel by

[Bridge] [PATCH net-next v5 5/5] selftests: forwarding: bridge_fdb_learning_limit: Add a new selftest

2023-10-16 Thread Johannes Nixdorf via Bridge
Add a suite covering the fdb_n_learned and fdb_max_learned bridge features, touching all special cases in accounting at least once. Acked-by: Nikolay Aleksandrov Signed-off-by: Johannes Nixdorf --- tools/testing/selftests/net/forwarding/Makefile| 3 +-

[Bridge] [PATCH net-next v5 1/5] net: bridge: Set BR_FDB_ADDED_BY_USER early in fdb_add_entry

2023-10-16 Thread Johannes Nixdorf via Bridge
In preparation of the following fdb limit for dynamically learned entries, allow fdb_create to detect that the entry was added by the user. This way it can skip applying the limit in this case. Reviewed-by: Ido Schimmel Acked-by: Nikolay Aleksandrov Signed-off-by: Johannes Nixdorf ---

[Bridge] [PATCH net-next v5 2/5] net: bridge: Track and limit dynamically learned FDB entries

2023-10-16 Thread Johannes Nixdorf via Bridge
A malicious actor behind one bridge port may spam the kernel with packets with a random source MAC address, each of which will create an FDB entry, each of which is a dynamic allocation in the kernel. There are roughly 2^48 different MAC addresses, further limited by the rhashtable they are

[Bridge] [PATCH net-next v5 4/5] net: bridge: Set strict_start_type for br_policy

2023-10-16 Thread Johannes Nixdorf via Bridge
Set any new attributes added to br_policy to be parsed strictly, to prevent userspace from passing garbage. Signed-off-by: Johannes Nixdorf --- net/bridge/br_netlink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index

[Bridge] [PATCH net-next v5 3/5] net: bridge: Add netlink knobs for number / max learned FDB entries

2023-10-16 Thread Johannes Nixdorf via Bridge
The previous patch added accounting and a limit for the number of dynamically learned FDB entries per bridge. However it did not provide means to actually configure those bounds or read back the count. This patch does that. Two new netlink attributes are added for the accounting and limit of

[Bridge] [PATCH net-next 13/13] selftests: vxlan_mdb: Use MDB get instead of dump

2023-10-16 Thread Ido Schimmel via Bridge
Test the new MDB get functionality by converting dump and grep to MDB get. Signed-off-by: Ido Schimmel --- tools/testing/selftests/net/test_vxlan_mdb.sh | 108 +- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/tools/testing/selftests/net/test_vxlan_mdb.sh

[Bridge] [PATCH net-next 12/13] selftests: bridge_mdb: Use MDB get instead of dump

2023-10-16 Thread Ido Schimmel via Bridge
Test the new MDB get functionality by converting dump and grep to MDB get. Signed-off-by: Ido Schimmel --- .../selftests/net/forwarding/bridge_mdb.sh| 184 +++--- 1 file changed, 71 insertions(+), 113 deletions(-) diff --git

[Bridge] [PATCH net-next 11/13] rtnetlink: Add MDB get support

2023-10-16 Thread Ido Schimmel via Bridge
Now that both the bridge and VXLAN drivers implement the MDB get net device operation, expose the functionality to user space by registering a handler for RTM_GETMDB messages. Derive the net device from the ifindex specified in the ancillary header and invoke its MDB get NDO. Note that unlike

[Bridge] [PATCH net-next 09/13] bridge: mcast: Add MDB get support

2023-10-16 Thread Ido Schimmel via Bridge
Implement support for MDB get operation by looking up a matching MDB entry, allocating the skb according to the entry's size and then filling in the response. The operation is performed under the bridge multicast lock to ensure that the entry does not change between the time the reply size is

[Bridge] [PATCH net-next 10/13] vxlan: mdb: Add MDB get support

2023-10-16 Thread Ido Schimmel via Bridge
Implement support for MDB get operation by looking up a matching MDB entry, allocating the skb according to the entry's size and then filling in the response. Signed-off-by: Ido Schimmel --- drivers/net/vxlan/vxlan_core.c| 1 + drivers/net/vxlan/vxlan_mdb.c | 150

[Bridge] [PATCH net-next 08/13] net: Add MDB get device operation

2023-10-16 Thread Ido Schimmel via Bridge
Add MDB net device operation that will be invoked by rtnetlink code in response to received RTM_GETMDB messages. Subsequent patches will implement the operation in the bridge and VXLAN drivers. Signed-off-by: Ido Schimmel --- include/linux/netdevice.h | 4 1 file changed, 4 insertions(+)

[Bridge] [PATCH net-next 05/13] vxlan: mdb: Adjust function arguments

2023-10-16 Thread Ido Schimmel via Bridge
Adjust the function's arguments and rename it to allow it to be reused by future call sites that only have access to 'struct vxlan_mdb_entry_key', but not to 'struct vxlan_mdb_config'. No functional changes intended. Signed-off-by: Ido Schimmel --- drivers/net/vxlan/vxlan_mdb.c | 10 --

[Bridge] [PATCH net-next 06/13] vxlan: mdb: Factor out a helper for remote entry size calculation

2023-10-16 Thread Ido Schimmel via Bridge
Currently, netlink notifications are sent for individual remote entries and not for the entire MDB entry itself. Subsequent patches are going to add MDB get support which will require the VXLAN driver to reply with an entire MDB entry. Therefore, as a preparation, factor out a helper to

[Bridge] [PATCH net-next 07/13] bridge: add MDB get uAPI attributes

2023-10-16 Thread Ido Schimmel via Bridge
Add MDB get attributes that correspond to the MDB set attributes used in RTM_NEWMDB messages. Specifically, add 'MDBA_GET_ENTRY' which will hold a 'struct br_mdb_entry' and 'MDBA_GET_ENTRY_ATTRS' which will hold 'MDBE_ATTR_*' attributes that are used as indexes (source IP and source VNI). An

[Bridge] [PATCH net-next 03/13] bridge: mcast: Factor out a helper for PG entry size calculation

2023-10-16 Thread Ido Schimmel via Bridge
Currently, netlink notifications are sent for individual port group entries and not for the entire MDB entry itself. Subsequent patches are going to add MDB get support which will require the bridge driver to reply with an entire MDB entry. Therefore, as a preparation, factor out an helper to

[Bridge] [PATCH net-next 04/13] bridge: mcast: Rename MDB entry get function

2023-10-16 Thread Ido Schimmel via Bridge
The current name is going to conflict with the upcoming net device operation for the MDB get operation. Rename the function to br_mdb_entry_skb_get(). No functional changes intended. Signed-off-by: Ido Schimmel --- net/bridge/br_device.c| 2 +- net/bridge/br_input.c | 2 +-

[Bridge] [PATCH net-next 01/13] bridge: mcast: Dump MDB entries even when snooping is disabled

2023-10-16 Thread Ido Schimmel via Bridge
Currently, the bridge driver does not dump MDB entries when multicast snooping is disabled although the entries are present in the kernel: # bridge mdb add dev br0 port swp1 grp 239.1.1.1 permanent # bridge mdb show dev br0 dev br0 port swp1 grp 239.1.1.1 permanent dev br0 port br0 grp

[Bridge] [PATCH net-next 02/13] bridge: mcast: Account for missing attributes

2023-10-16 Thread Ido Schimmel via Bridge
The 'MDBA_MDB' and 'MDBA_MDB_ENTRY' nest attributes are not accounted for when calculating the size of MDB notifications. Add them along with comments for existing attributes. Signed-off-by: Ido Schimmel --- net/bridge/br_mdb.c | 15 +++ 1 file changed, 11 insertions(+), 4

[Bridge] [PATCH net-next 00/13] Add MDB get support

2023-10-16 Thread Ido Schimmel via Bridge
This patchset adds MDB get support, allowing user space to request a single MDB entry to be retrieved instead of dumping the entire MDB. Support is added in both the bridge and VXLAN drivers. Patches #1-#6 are small preparations in both drivers. Patches #7-#8 add the required uAPI attributes for