Blob Blame History Raw
From 9c3efe55ac335b744aa993351f20ea9488aeaae5 Mon Sep 17 00:00:00 2001
From: Davide Caratti <dcaratti@redhat.com>
Date: Fri, 25 Nov 2016 10:43:09 +0100
Subject: [PATCH] macsec: fix input of 'port', improve documentation of
 'address'

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1355629
Upstream Status: iproute2.git commit 5898bd667a48

commit 5898bd667a483c12ba0ca53aa0ef39f9b98d2fc9
Author: Davide Caratti <dcaratti@redhat.com>
Date:   Tue Aug 30 13:23:12 2016 +0200

    macsec: fix input of 'port', improve documentation of 'address'

    remove hardcoded base 10 parsing of 'port' parameter, update man page
    and fix usage() functions as well. Fix misleading line in man page that
    theoretically allowed specifying 'port' keyword right after 'sci' keyword.
    Provide documentation of 'address' parameter in man pages and in usage()
    functions as well.

    Signed-off-by: Davide Caratti <dcaratti@redhat.com>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
 ip/ipmacsec.c         |  6 +++---
 man/man8/ip-link.8.in | 14 +++++++++++---
 man/man8/ip-macsec.8  | 12 +++++++++---
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/ip/ipmacsec.c b/ip/ipmacsec.c
index 329be00..21e53be 100644
--- a/ip/ipmacsec.c
+++ b/ip/ipmacsec.c
@@ -110,7 +110,7 @@ static void ipmacsec_usage(void)
 	fprintf(stderr, "where  OPTS := [ pn <u32> ] [ on | off ]\n");
 	fprintf(stderr, "       ID   := 128-bit hex string\n");
 	fprintf(stderr, "       KEY  := 128-bit hex string\n");
-	fprintf(stderr, "       SCI  := { sci <u64> | port <u16> address <lladdr> }\n");
+	fprintf(stderr, "       SCI  := { sci <u64> | port { 1..2^16-1 } address <lladdr> }\n");
 
 	exit(-1);
 }
@@ -154,7 +154,7 @@ static int get_sci(__u64 *sci, const char *arg)
 
 static int get_port(__be16 *port, const char *arg)
 {
-	return get_be16(port, arg, 10);
+	return get_be16(port, arg, 0);
 }
 
 #define _STR(a) #a
@@ -1083,7 +1083,7 @@ static bool check_txsc_flags(bool es, bool scb, bool sci)
 static void usage(FILE *f)
 {
 	fprintf(f,
-		"Usage: ... macsec [ port PORT | sci SCI ]\n"
+		"Usage: ... macsec [ [ address <lladdr> ] port { 1..2^16-1 } | sci <u64> ]\n"
 		"                  [ cipher { default | gcm-aes-128 } ]\n"
 		"                  [ icvlen { 8..16 } ]\n"
 		"                  [ encrypt { on | off } ]\n"
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 8968cf2..fd665b8 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -782,7 +782,9 @@ For a link of type
 the following additional arguments are supported:
 
 .BI "ip link add link " DEVICE " name " NAME " type macsec"
-[
+[ [
+.BI address " <lladdr>"
+]
 .BI port " PORT"
 |
 .BI sci " SCI"
@@ -806,8 +808,14 @@ the following additional arguments are supported:
 
 .in +8
 .sp
-.BI  port " PORT "
-- sets the port number for this MACsec device.
+.BI address " <lladdr> "
+- sets the system identifier component of secure channel for this MACsec device.
+
+.sp
+.BI port " PORT "
+- sets the port number component of secure channel for this MACsec device, in a
+range from 1 to 65535 inclusive. Numbers with a leading " 0 " or " 0x " are
+interpreted as octal and hexadecimal, respectively.
 
 .sp
 .BI sci " SCI "
diff --git a/man/man8/ip-macsec.8 b/man/man8/ip-macsec.8
index 105aeec..1aca3bd 100644
--- a/man/man8/ip-macsec.8
+++ b/man/man8/ip-macsec.8
@@ -3,10 +3,12 @@
 ip-macsec \- MACsec device configuration
 .SH "SYNOPSIS"
 .BI "ip link add link " DEVICE " name " NAME " type macsec "
-[
+[ [
+.BI address " <lladdr>"
+]
 .BI port " PORT"
 |
-.BI sci  " SCI"
+.BI sci " <u64>"
 ] [
 .BR cipher " { " default " | " gcm-aes-128 " } ] ["
 .BI icvlen " ICVLEN"
@@ -62,8 +64,12 @@ ip-macsec \- MACsec device configuration
 .IR SCI " := { "
 .B sci
 .IR <u64> " | "
-.BI port " <u16> " address " <lladdr> "
+.BI port
+.IR PORT
+.BI address " <lladdr> "
 }
+.br
+.IR PORT " := { " 1..2^16-1 " } "
 
 
 .SH DESCRIPTION
-- 
1.8.3.1