netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 net-next] bridge: fdb: add support for sticky flag
@ 2018-09-27 13:35 Nikolay Aleksandrov
  2018-09-27 13:35 ` [PATCH net-next] selftests: forwarding: test for bridge " Nikolay Aleksandrov
  2018-09-28 17:54 ` [PATCH iproute2 net-next] bridge: fdb: add support for " David Ahern
  0 siblings, 2 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2018-09-27 13:35 UTC (permalink / raw)
  To: netdev; +Cc: roopa, Nikolay Aleksandrov, David Ahern

Add support for the new sticky flag that can be set on fdbs and update the
man page.

CC: David Ahern <dsahern@gmail.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 bridge/fdb.c      | 9 +++++++--
 man/man8/bridge.8 | 6 +++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/bridge/fdb.c b/bridge/fdb.c
index 4dbc894ceab9..828fdab264cb 100644
--- a/bridge/fdb.c
+++ b/bridge/fdb.c
@@ -37,8 +37,8 @@ static void usage(void)
 	fprintf(stderr,
 		"Usage: bridge fdb { add | append | del | replace } ADDR dev DEV\n"
 		"              [ self ] [ master ] [ use ] [ router ] [ extern_learn ]\n"
-		"              [ local | static | dynamic ] [ dst IPADDR ] [ vlan VID ]\n"
-		"              [ port PORT] [ vni VNI ] [ via DEV ]\n"
+		"              [ sticky ] [ local | static | dynamic ] [ dst IPADDR ]\n"
+		"              [ vlan VID ] [ port PORT] [ vni VNI ] [ via DEV ]\n"
 		"       bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ] [ state STATE ] ]\n");
 	exit(-1);
 }
@@ -101,6 +101,9 @@ static void fdb_print_flags(FILE *fp, unsigned int flags)
 	if (flags & NTF_MASTER)
 		print_string(PRINT_ANY, NULL, "%s ", "master");
 
+	if (flags & NTF_STICKY)
+		print_string(PRINT_ANY, NULL, "%s ", "sticky");
+
 	close_json_array(PRINT_JSON, NULL);
 }
 
@@ -414,6 +417,8 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
 			req.ndm.ndm_flags |= NTF_USE;
 		} else if (matches(*argv, "extern_learn") == 0) {
 			req.ndm.ndm_flags |= NTF_EXT_LEARNED;
+		} else if (matches(*argv, "sticky") == 0) {
+			req.ndm.ndm_flags |= NTF_STICKY;
 		} else {
 			if (strcmp(*argv, "to") == 0)
 				NEXT_ARG();
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 53cd3d0a3d93..c0415bc646df 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -63,7 +63,7 @@ bridge \- show / manipulate bridge addresses and devices
 .B dev
 .IR DEV " { "
 .BR local " | " static " | " dynamic " } [ "
-.BR self " ] [ " master " ] [ " router " ] [ " use " ] [ " extern_learn " ] [ "
+.BR self " ] [ " master " ] [ " router " ] [ " use " ] [ " extern_learn " ] [ " sticky " ] [ "
 .B dst
 .IR IPADDR " ] [ "
 .B vni
@@ -448,6 +448,10 @@ indicate to the kernel that an entry was hardware or user-space
 controller learnt dynamic entry. Kernel will not age such an entry.
 .sp
 
+.B sticky
+- this entry will not change its port due to learning.
+.sp
+
 .in -8
 The next command line parameters apply only
 when the specified device
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next] selftests: forwarding: test for bridge sticky flag
  2018-09-27 13:35 [PATCH iproute2 net-next] bridge: fdb: add support for sticky flag Nikolay Aleksandrov
@ 2018-09-27 13:35 ` Nikolay Aleksandrov
  2018-09-28 17:45   ` David Miller
  2018-09-28 17:54 ` [PATCH iproute2 net-next] bridge: fdb: add support for " David Ahern
  1 sibling, 1 reply; 4+ messages in thread
From: Nikolay Aleksandrov @ 2018-09-27 13:35 UTC (permalink / raw)
  To: netdev; +Cc: roopa, Nikolay Aleksandrov

This test adds an fdb entry with the sticky flag and sends traffic from
a different port with the same mac as a source address expecting the entry
to not change ports if the flag is operating correctly.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 .../selftests/net/forwarding/bridge_sticky_fdb.sh  | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100755 tools/testing/selftests/net/forwarding/bridge_sticky_fdb.sh

diff --git a/tools/testing/selftests/net/forwarding/bridge_sticky_fdb.sh b/tools/testing/selftests/net/forwarding/bridge_sticky_fdb.sh
new file mode 100755
index 000000000000..1f8ef0eff862
--- /dev/null
+++ b/tools/testing/selftests/net/forwarding/bridge_sticky_fdb.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+ALL_TESTS="sticky"
+NUM_NETIFS=4
+TEST_MAC=de:ad:be:ef:13:37
+source lib.sh
+
+switch_create()
+{
+	ip link add dev br0 type bridge
+
+	ip link set dev $swp1 master br0
+	ip link set dev $swp2 master br0
+
+	ip link set dev br0 up
+	ip link set dev $h1 up
+	ip link set dev $swp1 up
+	ip link set dev $h2 up
+	ip link set dev $swp2 up
+}
+
+switch_destroy()
+{
+	ip link set dev $swp2 down
+	ip link set dev $h2 down
+	ip link set dev $swp1 down
+	ip link set dev $h1 down
+
+	ip link del dev br0
+}
+
+setup_prepare()
+{
+	h1=${NETIFS[p1]}
+	swp1=${NETIFS[p2]}
+	h2=${NETIFS[p3]}
+	swp2=${NETIFS[p4]}
+
+	switch_create
+}
+
+cleanup()
+{
+	pre_cleanup
+	switch_destroy
+}
+
+sticky()
+{
+	bridge fdb add $TEST_MAC dev $swp1 master static sticky
+	check_err $? "Could not add fdb entry"
+	bridge fdb del $TEST_MAC dev $swp1 vlan 1 master static sticky
+	$MZ $h2 -c 1 -a $TEST_MAC -t arp "request" -q
+	bridge -j fdb show br br0 brport $swp1\
+		| jq -e ".[] | select(.mac == \"$TEST_MAC\")" &> /dev/null
+	check_err $? "Did not find FDB record when should"
+
+	log_test "Sticky fdb entry"
+}
+
+trap cleanup EXIT
+
+setup_prepare
+setup_wait
+
+tests_run
+
+exit $EXIT_STATUS
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] selftests: forwarding: test for bridge sticky flag
  2018-09-27 13:35 ` [PATCH net-next] selftests: forwarding: test for bridge " Nikolay Aleksandrov
@ 2018-09-28 17:45   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-09-28 17:45 UTC (permalink / raw)
  To: nikolay; +Cc: netdev, roopa

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Date: Thu, 27 Sep 2018 16:35:13 +0300

> This test adds an fdb entry with the sticky flag and sends traffic from
> a different port with the same mac as a source address expecting the entry
> to not change ports if the flag is operating correctly.
> 
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2 net-next] bridge: fdb: add support for sticky flag
  2018-09-27 13:35 [PATCH iproute2 net-next] bridge: fdb: add support for sticky flag Nikolay Aleksandrov
  2018-09-27 13:35 ` [PATCH net-next] selftests: forwarding: test for bridge " Nikolay Aleksandrov
@ 2018-09-28 17:54 ` David Ahern
  1 sibling, 0 replies; 4+ messages in thread
From: David Ahern @ 2018-09-28 17:54 UTC (permalink / raw)
  To: Nikolay Aleksandrov, netdev; +Cc: roopa

On 9/27/18 7:35 AM, Nikolay Aleksandrov wrote:
> Add support for the new sticky flag that can be set on fdbs and update the
> man page.
> 
> CC: David Ahern <dsahern@gmail.com>
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
> ---
>  bridge/fdb.c      | 9 +++++++--
>  man/man8/bridge.8 | 6 +++++-
>  2 files changed, 12 insertions(+), 3 deletions(-)
> 

applied to iproute2-next. Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-29  0:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-27 13:35 [PATCH iproute2 net-next] bridge: fdb: add support for sticky flag Nikolay Aleksandrov
2018-09-27 13:35 ` [PATCH net-next] selftests: forwarding: test for bridge " Nikolay Aleksandrov
2018-09-28 17:45   ` David Miller
2018-09-28 17:54 ` [PATCH iproute2 net-next] bridge: fdb: add support for " David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).