All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2 net-next] bridge: add support for backup port
@ 2018-10-12 11:42 Nikolay Aleksandrov
  2018-10-12 15:40 ` Stephen Hemminger
  2018-10-14  2:30 ` David Ahern
  0 siblings, 2 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2018-10-12 11:42 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dsahern, Nikolay Aleksandrov

This patch adds support for the new backup port option that can be set
on a bridge port. If the port's carrier goes down all of the traffic
gets redirected to the configured backup port. We add the following new
arguments:
$ ip link set dev brport type bridge_slave backup_port brport2
$ ip link set dev brport type bridge_slave nobackup_port

$ bridge link set dev brport backup_port brport2
$ bridge link set dev brport nobackup_port

The man pages are updated respectively.
Also 2 minor style adjustments:
- add missing space to bridge man page's state argument
- use lower starting case for vlan_tunnel in ip-link man page (to be
consistent with the rest)

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 bridge/link.c            | 26 ++++++++++++++++++++++++++
 ip/iplink_bridge_slave.c | 18 ++++++++++++++++++
 man/man8/bridge.8        | 13 ++++++++++++-
 man/man8/ip-link.8.in    | 14 ++++++++++++--
 4 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/bridge/link.c b/bridge/link.c
index 09df489b26ab..4a14845da591 100644
--- a/bridge/link.c
+++ b/bridge/link.c
@@ -152,6 +152,16 @@ 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_BACKUP_PORT]) {
+			int ifidx;
+
+			ifidx = rta_getattr_u32(prtb[IFLA_BRPORT_BACKUP_PORT]);
+			print_string(PRINT_ANY,
+				     "backup_port", "backup_port %s ",
+				     ll_index_to_name(ifidx));
+		}
+
 		if (prtb[IFLA_BRPORT_ISOLATED])
 			print_onoff(fp, "isolated",
 				    rta_getattr_u8(prtb[IFLA_BRPORT_ISOLATED]));
@@ -255,6 +265,7 @@ static void usage(void)
 	fprintf(stderr,	"                               [ vlan_tunnel {on | off} ]\n");
 	fprintf(stderr,	"                               [ isolated {on | off} ]\n");
 	fprintf(stderr, "                               [ hwmode {vepa | veb} ]\n");
+	fprintf(stderr,	"                               [ backup_port DEVICE ] [ nobackup_port ]\n");
 	fprintf(stderr, "                               [ self ] [ master ]\n");
 	fprintf(stderr, "       bridge link show [dev DEV]\n");
 	exit(-1);
@@ -289,6 +300,7 @@ static int brlink_modify(int argc, char **argv)
 		.ifm.ifi_family = PF_BRIDGE,
 	};
 	char *d = NULL;
+	int backup_port_idx = -1;
 	__s8 neigh_suppress = -1;
 	__s8 learning = -1;
 	__s8 learning_sync = -1;
@@ -395,6 +407,16 @@ static int brlink_modify(int argc, char **argv)
 			NEXT_ARG();
 			if (!on_off("isolated", &isolated, *argv))
 				return -1;
+		} else if (strcmp(*argv, "backup_port") == 0) {
+			NEXT_ARG();
+			backup_port_idx = ll_name_to_index(*argv);
+			if (!backup_port_idx) {
+				fprintf(stderr, "Error: device %s does not exist\n",
+					*argv);
+				return -1;
+			}
+		} else if (strcmp(*argv, "nobackup_port") == 0) {
+			backup_port_idx = 0;
 		} else {
 			usage();
 		}
@@ -456,6 +478,10 @@ static int brlink_modify(int argc, char **argv)
 	if (isolated != -1)
 		addattr8(&req.n, sizeof(req), IFLA_BRPORT_ISOLATED, isolated);
 
+	if (backup_port_idx != -1)
+		addattr32(&req.n, sizeof(req), IFLA_BRPORT_BACKUP_PORT,
+			  backup_port_idx);
+
 	addattr_nest_end(&req.n, nest);
 
 	/* IFLA_AF_SPEC nested attribute. Contains IFLA_BRIDGE_FLAGS that
diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c
index 5a6e48559781..8b4f93f265be 100644
--- a/ip/iplink_bridge_slave.c
+++ b/ip/iplink_bridge_slave.c
@@ -41,6 +41,7 @@ static void print_explain(FILE *f)
 		"                        [ neigh_suppress {on | off} ]\n"
 		"                        [ vlan_tunnel {on | off} ]\n"
 		"                        [ isolated {on | off} ]\n"
+		"                        [ backup_port DEVICE ] [ nobackup_port ]\n"
 	);
 }
 
@@ -279,6 +280,13 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
 	if (tb[IFLA_BRPORT_ISOLATED])
 		_print_onoff(f, "isolated", "isolated",
 			     rta_getattr_u8(tb[IFLA_BRPORT_ISOLATED]));
+
+	if (tb[IFLA_BRPORT_BACKUP_PORT]) {
+		int backup_p = rta_getattr_u32(tb[IFLA_BRPORT_BACKUP_PORT]);
+
+		print_string(PRINT_ANY, "backup_port", "backup_port %s ",
+			     ll_index_to_name(backup_p));
+	}
 }
 
 static void bridge_slave_parse_on_off(char *arg_name, char *arg_val,
@@ -388,6 +396,16 @@ static int bridge_slave_parse_opt(struct link_util *lu, int argc, char **argv,
 			NEXT_ARG();
 			bridge_slave_parse_on_off("isolated", *argv, n,
 						  IFLA_BRPORT_ISOLATED);
+		} else if (matches(*argv, "backup_port") == 0) {
+			int ifindex;
+
+			NEXT_ARG();
+			ifindex = ll_name_to_index(*argv);
+			if (!ifindex)
+				invarg("Device does not exist\n", *argv);
+			addattr32(n, 1024, IFLA_BRPORT_BACKUP_PORT, ifindex);
+		} else if (matches(*argv, "nobackup_port") == 0) {
+			addattr32(n, 1024, IFLA_BRPORT_BACKUP_PORT, 0);
 		} else if (matches(*argv, "help") == 0) {
 			explain();
 			return -1;
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index c0415bc646df..72210f625e55 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -37,7 +37,7 @@ bridge \- show / manipulate bridge addresses and devices
 .B priority
 .IR PRIO " ] [ "
 .B state
-.IR STATE "] ["
+.IR STATE " ] [ "
 .BR guard " { " on " | " off " } ] [ "
 .BR hairpin " { " on " | " off " } ] [ "
 .BR fastleave " { " on " | " off " } ] [ "
@@ -50,6 +50,9 @@ bridge \- show / manipulate bridge addresses and devices
 .BR neigh_suppress " { " on " | " off " } ] [ "
 .BR vlan_tunnel " { " on " | " off " } ] [ "
 .BR isolated " { " on " | " off " } ] [ "
+.B backup_port
+.IR  DEVICE " ] ["
+.BR nobackup_port " ] [ "
 .BR self " ] [ " master " ]"
 
 .ti -8
@@ -373,6 +376,14 @@ Controls whether vlan to tunnel mapping is enabled on the port. By default this
 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 backup_port " DEVICE"
+If the port loses carrier all traffic will be redirected to the configured backup port
+
+.TP
+.BR nobackup_port
+Removes the currently configured backup port
+
 .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 9f345f96fab1..ecbbd4f499e7 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -2076,7 +2076,11 @@ the following additional arguments are supported:
 ] [
 .BR vlan_tunnel " { " on " | " off " }"
 ] [
-.BR isolated " { " on " | " off " } ]"
+.BR isolated " { " on " | " off " }"
+] [
+.BR backup_port " DEVICE"
+] [
+.BR nobackup_port " ]"
 
 .in +8
 .sp
@@ -2158,7 +2162,13 @@ option above.
 - controls whether neigh discovery (arp and nd) proxy and suppression is enabled on the port. By default this flag is off.
 
 .BR vlan_tunnel " { " on " | " off " }"
-- Controls whether vlan to tunnel mapping is enabled on the port. By default this flag is off.
+- controls whether vlan to tunnel mapping is enabled on the port. By default this flag is off.
+
+.BI backup_port " DEVICE"
+- if the port loses carrier all traffic will be redirected to the configured backup port
+
+.BR nobackup_port
+- removes the currently configured backup port
 
 .in -8
 
-- 
2.17.2

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

* Re: [PATCH iproute2 net-next] bridge: add support for backup port
  2018-10-12 11:42 [PATCH iproute2 net-next] bridge: add support for backup port Nikolay Aleksandrov
@ 2018-10-12 15:40 ` Stephen Hemminger
  2018-10-12 16:01   ` Nikolay Aleksandrov
  2018-10-14  2:30 ` David Ahern
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2018-10-12 15:40 UTC (permalink / raw)
  To: Nikolay Aleksandrov; +Cc: netdev, roopa, dsahern

On Fri, 12 Oct 2018 14:42:55 +0300
Nikolay Aleksandrov <nikolay@cumulusnetworks.com> wrote:

> This patch adds support for the new backup port option that can be set
> on a bridge port. If the port's carrier goes down all of the traffic
> gets redirected to the configured backup port. We add the following new
> arguments:
> $ ip link set dev brport type bridge_slave backup_port brport2
> $ ip link set dev brport type bridge_slave nobackup_port
> 
> $ bridge link set dev brport backup_port brport2
> $ bridge link set dev brport nobackup_port
> 
> The man pages are updated respectively.
> Also 2 minor style adjustments:
> - add missing space to bridge man page's state argument
> - use lower starting case for vlan_tunnel in ip-link man page (to be
> consistent with the rest)
> 
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

This seems a bit like feature creep in the bridge.
Why not use team or bonding?

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

* Re: [PATCH iproute2 net-next] bridge: add support for backup port
  2018-10-12 15:40 ` Stephen Hemminger
@ 2018-10-12 16:01   ` Nikolay Aleksandrov
  0 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2018-10-12 16:01 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, roopa, dsahern

On October 12, 2018 6:40:28 PM GMT+03:00, Stephen Hemminger <stephen@networkplumber.org> wrote:
>On Fri, 12 Oct 2018 14:42:55 +0300
>Nikolay Aleksandrov <nikolay@cumulusnetworks.com> wrote:
>
>> This patch adds support for the new backup port option that can be
>set
>> on a bridge port. If the port's carrier goes down all of the traffic
>> gets redirected to the configured backup port. We add the following
>new
>> arguments:
>> $ ip link set dev brport type bridge_slave backup_port brport2
>> $ ip link set dev brport type bridge_slave nobackup_port
>> 
>> $ bridge link set dev brport backup_port brport2
>> $ bridge link set dev brport nobackup_port
>> 
>> The man pages are updated respectively.
>> Also 2 minor style adjustments:
>> - add missing space to bridge man page's state argument
>> - use lower starting case for vlan_tunnel in ip-link man page (to be
>> consistent with the rest)
>> 
>> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
>
>This seems a bit like feature creep in the bridge.
>Why not use team or bonding?

Not really, the bond/team cannot work in such way. We did discuss it when the kernel patches were sent, for more information please check
https://www.spinics.net/lists/netdev/msg514642.html

Thanks,
  Nik

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

* Re: [PATCH iproute2 net-next] bridge: add support for backup port
  2018-10-12 11:42 [PATCH iproute2 net-next] bridge: add support for backup port Nikolay Aleksandrov
  2018-10-12 15:40 ` Stephen Hemminger
@ 2018-10-14  2:30 ` David Ahern
  1 sibling, 0 replies; 4+ messages in thread
From: David Ahern @ 2018-10-14  2:30 UTC (permalink / raw)
  To: Nikolay Aleksandrov, netdev; +Cc: roopa, dsahern

On 10/12/18 5:42 AM, Nikolay Aleksandrov wrote:
> This patch adds support for the new backup port option that can be set
> on a bridge port. If the port's carrier goes down all of the traffic
> gets redirected to the configured backup port. We add the following new
> arguments:
> $ ip link set dev brport type bridge_slave backup_port brport2
> $ ip link set dev brport type bridge_slave nobackup_port
> 
> $ bridge link set dev brport backup_port brport2
> $ bridge link set dev brport nobackup_port
> 
> The man pages are updated respectively.
> Also 2 minor style adjustments:
> - add missing space to bridge man page's state argument
> - use lower starting case for vlan_tunnel in ip-link man page (to be
> consistent with the rest)
> 
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
> ---
>  bridge/link.c            | 26 ++++++++++++++++++++++++++
>  ip/iplink_bridge_slave.c | 18 ++++++++++++++++++
>  man/man8/bridge.8        | 13 ++++++++++++-
>  man/man8/ip-link.8.in    | 14 ++++++++++++--
>  4 files changed, 68 insertions(+), 3 deletions(-)
> 

applied to iproute2-next. Thanks

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12 11:42 [PATCH iproute2 net-next] bridge: add support for backup port Nikolay Aleksandrov
2018-10-12 15:40 ` Stephen Hemminger
2018-10-12 16:01   ` Nikolay Aleksandrov
2018-10-14  2:30 ` David Ahern

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.