All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] bridge: iproute2 isolated port and selftests
@ 2018-07-03 12:42 Nikolay Aleksandrov
  2018-07-03 12:42 ` [PATCH iproute2 net-next] bridge: add support for isolated option Nikolay Aleksandrov
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Nikolay Aleksandrov @ 2018-07-03 12:42 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dsahern, idosch, stephen, Nikolay Aleksandrov

Add support to iproute2 for port isolation config and selftests for it.

Nikolay Aleksandrov (2):
  selftests: forwarding: lib: extract ping and ping6 so they can be
    reused
  selftests: forwarding: test for bridge port isolation

 .../net/forwarding/bridge_port_isolation.sh        | 151 +++++++++++++++++++++
 tools/testing/selftests/net/forwarding/lib.sh      |  22 ++-
 2 files changed, 167 insertions(+), 6 deletions(-)
 create mode 100755 tools/testing/selftests/net/forwarding/bridge_port_isolation.sh

-- 
2.11.0

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

* [PATCH iproute2 net-next] bridge: add support for isolated option
  2018-07-03 12:42 [PATCH net-next 0/2] bridge: iproute2 isolated port and selftests Nikolay Aleksandrov
@ 2018-07-03 12:42 ` Nikolay Aleksandrov
  2018-07-06 14:59   ` David Ahern
  2018-07-03 12:42 ` [PATCH net-next 1/2] selftests: forwarding: lib: extract ping and ping6 so they can be reused Nikolay Aleksandrov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Nikolay Aleksandrov @ 2018-07-03 12:42 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dsahern, idosch, stephen, Nikolay Aleksandrov

This patch adds support for the new isolated port option which, if set,
would allow the isolated ports to communicate only with non-isolated
ports and the bridge device. The option can be set via the bridge or ip
link type bridge_slave commands, e.g.:
$ ip link set dev eth0 type bridge_slave isolated on
$ bridge link set dev eth0 isolated on

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 bridge/link.c            | 11 +++++++++++
 ip/iplink_bridge_slave.c |  9 +++++++++
 man/man8/bridge.8        |  6 ++++++
 man/man8/ip-link.8.in    |  6 ++++--
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/bridge/link.c b/bridge/link.c
index 8d89aca2e638..9656ca338782 100644
--- a/bridge/link.c
+++ b/bridge/link.c
@@ -152,6 +152,9 @@ static void print_protinfo(FILE *fp, struct rtattr *attr)
 		if (prtb[IFLA_BRPORT_VLAN_TUNNEL])
 			print_onoff(fp, "vlan_tunnel",
 				    rta_getattr_u8(prtb[IFLA_BRPORT_VLAN_TUNNEL]));
+		if (prtb[IFLA_BRPORT_ISOLATED])
+			print_onoff(fp, "isolated",
+				    rta_getattr_u8(prtb[IFLA_BRPORT_ISOLATED]));
 	} else
 		print_portstate(rta_getattr_u8(attr));
 }
@@ -250,6 +253,7 @@ static void usage(void)
 	fprintf(stderr,	"                               [ mcast_flood {on | off} ]\n");
 	fprintf(stderr,	"                               [ neigh_suppress {on | off} ]\n");
 	fprintf(stderr,	"                               [ vlan_tunnel {on | off} ]\n");
+	fprintf(stderr,	"                               [ isolated {on | off} ]\n");
 	fprintf(stderr, "                               [ hwmode {vepa | veb} ]\n");
 	fprintf(stderr, "                               [ self ] [ master ]\n");
 	fprintf(stderr, "       bridge link show [dev DEV]\n");
@@ -291,6 +295,7 @@ static int brlink_modify(int argc, char **argv)
 	__s8 flood = -1;
 	__s8 vlan_tunnel = -1;
 	__s8 mcast_flood = -1;
+	__s8 isolated = -1;
 	__s8 hairpin = -1;
 	__s8 bpdu_guard = -1;
 	__s8 fast_leave = -1;
@@ -386,6 +391,10 @@ static int brlink_modify(int argc, char **argv)
 			if (!on_off("vlan_tunnel", &vlan_tunnel,
 				    *argv))
 				return -1;
+		} else if (strcmp(*argv, "isolated") == 0) {
+			NEXT_ARG();
+			if (!on_off("isolated", &isolated, *argv))
+				return -1;
 		} else {
 			usage();
 		}
@@ -444,6 +453,8 @@ static int brlink_modify(int argc, char **argv)
 	if (vlan_tunnel != -1)
 		addattr8(&req.n, sizeof(req), IFLA_BRPORT_VLAN_TUNNEL,
 			 vlan_tunnel);
+	if (isolated != -1)
+		addattr8(&req.n, sizeof(req), IFLA_BRPORT_ISOLATED, isolated);
 
 	addattr_nest_end(&req.n, nest);
 
diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c
index 3fbfb878cdc4..5a6e48559781 100644
--- a/ip/iplink_bridge_slave.c
+++ b/ip/iplink_bridge_slave.c
@@ -40,6 +40,7 @@ static void print_explain(FILE *f)
 		"                        [ group_fwd_mask MASK ]\n"
 		"                        [ neigh_suppress {on | off} ]\n"
 		"                        [ vlan_tunnel {on | off} ]\n"
+		"                        [ isolated {on | off} ]\n"
 	);
 }
 
@@ -274,6 +275,10 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
 	if (tb[IFLA_BRPORT_VLAN_TUNNEL])
 		_print_onoff(f, "vlan_tunnel", "vlan_tunnel",
 			     rta_getattr_u8(tb[IFLA_BRPORT_VLAN_TUNNEL]));
+
+	if (tb[IFLA_BRPORT_ISOLATED])
+		_print_onoff(f, "isolated", "isolated",
+			     rta_getattr_u8(tb[IFLA_BRPORT_ISOLATED]));
 }
 
 static void bridge_slave_parse_on_off(char *arg_name, char *arg_val,
@@ -379,6 +384,10 @@ static int bridge_slave_parse_opt(struct link_util *lu, int argc, char **argv,
 			NEXT_ARG();
 			bridge_slave_parse_on_off("vlan_tunnel", *argv, n,
 						  IFLA_BRPORT_VLAN_TUNNEL);
+		} else if (matches(*argv, "isolated") == 0) {
+			NEXT_ARG();
+			bridge_slave_parse_on_off("isolated", *argv, n,
+						  IFLA_BRPORT_ISOLATED);
 		} else if (matches(*argv, "help") == 0) {
 			explain();
 			return -1;
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index e7f7148315e1..f6d228c5ebfe 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -48,6 +48,7 @@ bridge \- show / manipulate bridge addresses and devices
 .BR mcast_flood " { " on " | " off " } ] [ "
 .BR neigh_suppress " { " on " | " off " } ] [ "
 .BR vlan_tunnel " { " on " | " off " } ] [ "
+.BR isolated " { " on " | " off " } ] [ "
 .BR self " ] [ " master " ]"
 
 .ti -8
@@ -346,6 +347,11 @@ Controls whether neigh discovery (arp and nd) proxy and suppression is enabled o
 Controls whether vlan to tunnel mapping is enabled on the port. By default this flag is off.
 
 .TP
+.BR "isolated on " or " isolated off "
+Controls whether a given port will be isolated, which means it will be able to communicate with non-isolated ports only.
+By default this flag is off.
+
+.TP
 .BI self
 link setting is configured on specified physical device
 
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 83ef3cae54b9..48c238660347 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -2049,9 +2049,11 @@ the following additional arguments are supported:
 ] [
 .BR group_fwd_mask " MASK"
 ] [
-.BR neigh_suppress " { " on " | " off " } ]"
+.BR neigh_suppress " { " on " | " off " }"
+] [
+.BR vlan_tunnel " { " on " | " off " }"
 ] [
-.BR vlan_tunnel " { " on " | " off " } ]"
+.BR isolated " { " on " | " off " } ]"
 
 .in +8
 .sp
-- 
2.11.0

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

* [PATCH net-next 1/2] selftests: forwarding: lib: extract ping and ping6 so they can be reused
  2018-07-03 12:42 [PATCH net-next 0/2] bridge: iproute2 isolated port and selftests Nikolay Aleksandrov
  2018-07-03 12:42 ` [PATCH iproute2 net-next] bridge: add support for isolated option Nikolay Aleksandrov
@ 2018-07-03 12:42 ` Nikolay Aleksandrov
  2018-07-03 12:42 ` [PATCH net-next 2/2] selftests: forwarding: test for bridge port isolation Nikolay Aleksandrov
  2018-07-04 12:40 ` [PATCH net-next 0/2] bridge: iproute2 isolated port and selftests David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Nikolay Aleksandrov @ 2018-07-03 12:42 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dsahern, idosch, stephen, Nikolay Aleksandrov

Extract ping and ping6 command execution so the return value can be
checked by the caller, this is needed for port isolation tests that are
intended to fail.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 tools/testing/selftests/net/forwarding/lib.sh | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index e073918bbe15..2bb9cf303c53 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -659,30 +659,40 @@ multipath_eval()
 ##############################################################################
 # Tests
 
-ping_test()
+ping_do()
 {
 	local if_name=$1
 	local dip=$2
 	local vrf_name
 
-	RET=0
-
 	vrf_name=$(master_name_get $if_name)
 	ip vrf exec $vrf_name $PING $dip -c 10 -i 0.1 -w 2 &> /dev/null
+}
+
+ping_test()
+{
+	RET=0
+
+	ping_do $1 $2
 	check_err $?
 	log_test "ping"
 }
 
-ping6_test()
+ping6_do()
 {
 	local if_name=$1
 	local dip=$2
 	local vrf_name
 
-	RET=0
-
 	vrf_name=$(master_name_get $if_name)
 	ip vrf exec $vrf_name $PING6 $dip -c 10 -i 0.1 -w 2 &> /dev/null
+}
+
+ping6_test()
+{
+	RET=0
+
+	ping6_do $1 $2
 	check_err $?
 	log_test "ping6"
 }
-- 
2.11.0

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

* [PATCH net-next 2/2] selftests: forwarding: test for bridge port isolation
  2018-07-03 12:42 [PATCH net-next 0/2] bridge: iproute2 isolated port and selftests Nikolay Aleksandrov
  2018-07-03 12:42 ` [PATCH iproute2 net-next] bridge: add support for isolated option Nikolay Aleksandrov
  2018-07-03 12:42 ` [PATCH net-next 1/2] selftests: forwarding: lib: extract ping and ping6 so they can be reused Nikolay Aleksandrov
@ 2018-07-03 12:42 ` Nikolay Aleksandrov
  2018-07-04 12:40 ` [PATCH net-next 0/2] bridge: iproute2 isolated port and selftests David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Nikolay Aleksandrov @ 2018-07-03 12:42 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dsahern, idosch, stephen, Nikolay Aleksandrov

This test checks if the bridge port isolation feature works as expected
by performing ping/ping6 tests between hosts that are isolated (should
not work) and between an isolated and non-isolated hosts (should work).
Same test is performed for flooding from and to isolated and
non-isolated ports.

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

diff --git a/tools/testing/selftests/net/forwarding/bridge_port_isolation.sh b/tools/testing/selftests/net/forwarding/bridge_port_isolation.sh
new file mode 100755
index 000000000000..a43b4645c4de
--- /dev/null
+++ b/tools/testing/selftests/net/forwarding/bridge_port_isolation.sh
@@ -0,0 +1,151 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+ALL_TESTS="ping_ipv4 ping_ipv6 flooding"
+NUM_NETIFS=6
+CHECK_TC="yes"
+source lib.sh
+
+h1_create()
+{
+	simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
+}
+
+h1_destroy()
+{
+	simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
+}
+
+h2_create()
+{
+	simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/64
+}
+
+h2_destroy()
+{
+	simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64
+}
+
+h3_create()
+{
+	simple_if_init $h3 192.0.2.3/24 2001:db8:1::3/64
+}
+
+h3_destroy()
+{
+	simple_if_fini $h3 192.0.2.3/24 2001:db8:1::3/64
+}
+
+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 $swp3 master br0
+
+	ip link set dev $swp1 type bridge_slave isolated on
+	check_err $? "Can't set isolation on port $swp1"
+	ip link set dev $swp2 type bridge_slave isolated on
+	check_err $? "Can't set isolation on port $swp2"
+	ip link set dev $swp3 type bridge_slave isolated off
+	check_err $? "Can't disable isolation on port $swp3"
+
+	ip link set dev br0 up
+	ip link set dev $swp1 up
+	ip link set dev $swp2 up
+	ip link set dev $swp3 up
+}
+
+switch_destroy()
+{
+	ip link set dev $swp3 down
+	ip link set dev $swp2 down
+	ip link set dev $swp1 down
+
+	ip link del dev br0
+}
+
+setup_prepare()
+{
+	h1=${NETIFS[p1]}
+	swp1=${NETIFS[p2]}
+
+	swp2=${NETIFS[p3]}
+	h2=${NETIFS[p4]}
+
+	swp3=${NETIFS[p5]}
+	h3=${NETIFS[p6]}
+
+	vrf_prepare
+
+	h1_create
+	h2_create
+	h3_create
+
+	switch_create
+}
+
+cleanup()
+{
+	pre_cleanup
+
+	switch_destroy
+
+	h3_destroy
+	h2_destroy
+	h1_destroy
+
+	vrf_cleanup
+}
+
+ping_ipv4()
+{
+	RET=0
+	ping_do $h1 192.0.2.2
+	check_fail $? "Ping worked when it should not have"
+
+	RET=0
+	ping_do $h3 192.0.2.2
+	check_err $? "Ping didn't work when it should have"
+
+	log_test "Isolated port ping"
+}
+
+ping_ipv6()
+{
+	RET=0
+	ping6_do $h1 2001:db8:1::2
+	check_fail $? "Ping6 worked when it should not have"
+
+	RET=0
+	ping6_do $h3 2001:db8:1::2
+	check_err $? "Ping6 didn't work when it should have"
+
+	log_test "Isolated port ping6"
+}
+
+flooding()
+{
+	local mac=de:ad:be:ef:13:37
+	local ip=192.0.2.100
+
+	RET=0
+	flood_test_do false $mac $ip $h1 $h2
+	check_err $? "Packet was flooded when it should not have been"
+
+	RET=0
+	flood_test_do true $mac $ip $h3 $h2
+	check_err $? "Packet was not flooded when it should have been"
+
+	log_test "Isolated port flooding"
+}
+
+trap cleanup EXIT
+
+setup_prepare
+setup_wait
+
+tests_run
+
+exit $EXIT_STATUS
-- 
2.11.0

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

* Re: [PATCH net-next 0/2] bridge: iproute2 isolated port and selftests
  2018-07-03 12:42 [PATCH net-next 0/2] bridge: iproute2 isolated port and selftests Nikolay Aleksandrov
                   ` (2 preceding siblings ...)
  2018-07-03 12:42 ` [PATCH net-next 2/2] selftests: forwarding: test for bridge port isolation Nikolay Aleksandrov
@ 2018-07-04 12:40 ` David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-07-04 12:40 UTC (permalink / raw)
  To: nikolay; +Cc: netdev, roopa, dsahern, idosch, stephen

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Date: Tue,  3 Jul 2018 15:42:41 +0300

> Add support to iproute2 for port isolation config and selftests for it.

Series applied, thanks Nikolay.

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

* Re: [PATCH iproute2 net-next] bridge: add support for isolated option
  2018-07-03 12:42 ` [PATCH iproute2 net-next] bridge: add support for isolated option Nikolay Aleksandrov
@ 2018-07-06 14:59   ` David Ahern
  0 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2018-07-06 14:59 UTC (permalink / raw)
  To: Nikolay Aleksandrov, netdev; +Cc: roopa, dsahern, idosch, stephen

On 7/3/18 6:42 AM, Nikolay Aleksandrov wrote:
> This patch adds support for the new isolated port option which, if set,
> would allow the isolated ports to communicate only with non-isolated
> ports and the bridge device. The option can be set via the bridge or ip
> link type bridge_slave commands, e.g.:
> $ ip link set dev eth0 type bridge_slave isolated on
> $ bridge link set dev eth0 isolated on
> 
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
> ---
>  bridge/link.c            | 11 +++++++++++
>  ip/iplink_bridge_slave.c |  9 +++++++++
>  man/man8/bridge.8        |  6 ++++++
>  man/man8/ip-link.8.in    |  6 ++++--
>  4 files changed, 30 insertions(+), 2 deletions(-)
> 

applied to iproute2-next. Thanks

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

end of thread, other threads:[~2018-07-06 14:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-03 12:42 [PATCH net-next 0/2] bridge: iproute2 isolated port and selftests Nikolay Aleksandrov
2018-07-03 12:42 ` [PATCH iproute2 net-next] bridge: add support for isolated option Nikolay Aleksandrov
2018-07-06 14:59   ` David Ahern
2018-07-03 12:42 ` [PATCH net-next 1/2] selftests: forwarding: lib: extract ping and ping6 so they can be reused Nikolay Aleksandrov
2018-07-03 12:42 ` [PATCH net-next 2/2] selftests: forwarding: test for bridge port isolation Nikolay Aleksandrov
2018-07-04 12:40 ` [PATCH net-next 0/2] bridge: iproute2 isolated port and selftests David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.