Skip to contentSkip to conversation

Added support for selection of new HSR version

PATCH In review Peter Heise 2 participants 3 messages May 30, 2016 – May 31, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added support for selection of new HSR version

A new HSR version was added in 4.7 that can be enabled via iproute2. Per default the old version is selected, however, with "ip link add [..] type hsr [..] version 1" the newer version can be enabled.

---
 ip/iplink_hsr.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
ip/iplink_hsr.c +11 -2
index 65fbec8..84d3a65 100644
@@ -25,7 +25,7 @@ static void print_usage(FILE *f)
 {
 	fprintf(f,
 "Usage:\tip link add name NAME type hsr slave1 SLAVE1-IF slave2 SLAVE2-IF\n"
-"\t[ supervision ADDR-BYTE ]\n"
+"\t[ supervision ADDR-BYTE ] [version VERSION]\n"
 "\n"
 "NAME\n"
 "	name of new hsr device (e.g. hsr0)\n"
@@ -33,7 +33,9 @@ static void print_usage(FILE *f)
 "	the two slave devices bound to the HSR device\n"
 "ADDR-BYTE\n"
 "	0-255; the last byte of the multicast address used for HSR supervision\n"
-"	frames (default = 0)\n");
+"	frames (default = 0)\n"
+"VERSION\n"
+"	0,1; the protocol version to be used. (default = 0)\n");
 }
 
 static void usage(void)
@@ -46,6 +48,7 @@ static int hsr_parse_opt(struct link_util *lu, int argc, char **argv,
 {
 	int ifindex;
 	unsigned char multicast_spec;
+	unsigned char protocol_version;
 
 	while (argc > 0) {
 		if (matches(*argv, "supervision") == 0) {
@@ -54,6 +57,12 @@ static int hsr_parse_opt(struct link_util *lu, int argc, char **argv,
 				invarg("ADDR-BYTE is invalid", *argv);
 			addattr_l(n, 1024, IFLA_HSR_MULTICAST_SPEC,
 				  &multicast_spec, 1);
+		} else if (matches(*argv, "version") == 0) {
+				NEXT_ARG();
+				if (!(get_u8(&protocol_version, *argv, 0) == 0 || get_u8(&protocol_version, *argv, 0) == 1))
+					invarg("VERSION is invalid", *argv);
+				addattr_l(n, 1024, IFLA_HSR_VERSION,
+					  &protocol_version, 1);
 		} else if (matches(*argv, "slave1") == 0) {
 			NEXT_ARG();
 			ifindex = ll_name_to_index(*argv);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 6 lines · On Mon, 30 May 2016 15:32:07 +0200 Peter Heise <[email protected]> wrote:

A new HSR version was added in 4.7 that can be enabled via iproute2. Per default the old version is selected, however, with "ip link add [..] type hsr [..] version 1" the newer version can be enabled.

Sure, applied. What about man page?

#2 lore raw
In reply to Peter Heise
Quoted 7 lines · On Mon, 30 May 2016 15:32:07 +0200 Peter Heise <[email protected]> wrote:

A new HSR version was added in 4.7 that can be enabled via iproute2. Per default the old version is selected, however, with "ip link add [..] type hsr [..] version 1" the newer version can be enabled.

---

I fixed two things in this patch.
1) Don't use ALL CAPS in the error message
2) Indentation was all messed up and line was too long.

Please use checkpatch in future to check your submissions.