macsec: fix input of 'sci' and 'port'
Subsystems (2)
cover macsec: fix input of 'sci' and 'port'
This series provides an endianness fix for 'sci' parameter. Moreover, it allows entering 'port' in hexadecimal format. Finally, related lines in usage() functions and man pages have been fixed (including missing documentation of 'address' and missing 'macsec' item in OBJECT list).
Davide Caratti (3):
macsec: fix input of 'port', improve documentation of 'address'
man: ip.8: add missing 'macsec' item to OBJECT list
macsec: fix byte ordering on input/display of 'sci'
ip/ipmacsec.c | 14 +++++++------- man/man8/ip-link.8.in | 18 ++++++++++++++---- man/man8/ip-macsec.8 | 12 +++++++++--- man/man8/ip.8 | 3 ++- 4 files changed, 32 insertions(+), 15 deletions(-)
Signature · 1 line
2.5.5
PATCH 1/3 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.
--- ip/ipmacsec.c | 6 +++--- man/man8/ip-link.8.in | 14 +++++++++++--- man/man8/ip-macsec.8 | 12 +++++++++--- 3 files changed, 23 insertions(+), 9 deletions(-)
ip/ipmacsec.c +3 -3
@@ -95,7 +95,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 ); }
@@ -139,7 +139,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
@@ -1069,7 +1069,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"
man/man8/ip-link.8.in +11 -3
@@ -952,7 +952,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"
@@ -976,8 +978,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 "
man/man8/ip-macsec.8 +9 -3
@@ -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
Signature · 1 line
2.5.5
PATCH 2/3 man: ip.8: add missing 'macsec' item to OBJECT list
In reply to Davide Caratti--- man/man8/ip.8 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
man/man8/ip.8 +2 -1
@@ -21,7 +21,8 @@ ip \- show / manipulate routing, devices, policy routing and tunnels .IR OBJECT " := { " .BR link " | " address " | " addrlabel " | " route " | " rule " | " neigh " | "\ ntable " | " tunnel " | " tuntap " | " maddress " | " mroute " | " mrule " | "\ - monitor " | " xfrm " | " netns " | " l2tp " | " tcp_metrics " | " token " }" + monitor " | " xfrm " | " netns " | " l2tp " | " tcp_metrics " | " token " | "\ + macsec " }" .sp .ti -8
Signature · 1 line
2.5.5
PATCH 3/3 macsec: fix byte ordering on input/display of 'sci'
In reply to Davide Carattiuse get_be64() in place of get_u64() when parsing input 'sci' parameter, so that 'sci' can be entered using network byte order regardless the endianness of target system; use ntohll() when printing out 'sci'. While at it, improve documentation of 'sci' in ip-link.8.
--- ip/ipmacsec.c | 8 ++++---- man/man8/ip-link.8.in | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-)
ip/ipmacsec.c +4 -4
@@ -134,7 +134,7 @@ static int get_an(__u8 *val, const char *arg)static int get_sci (__u64 *sci,const char *arg) { -return get_u64 (sci, arg,16 ); +return get_be64 (sci, arg,16 ); }static int get_port (__be16 *port,const char *arg)
@@ -776,7 +776,7 @@ static void print_tx_sc(const char *prefix, __u64 sci, __u8 encoding_sa,struct rtattr *a;int rem; -printf ("%sTXSC: %016llx on SA %d\n" , prefix, sci, encoding_sa); +printf ("%sTXSC: %016llx on SA %d\n" , prefix,ntohll (sci), encoding_sa);print_secy_stats (prefix, secy_stats);print_txsc_stats (prefix, txsc_stats);
@@ -845,7 +845,7 @@ static void print_rx_sc(const char *prefix, __u64 sci, __u8 active,struct rtattr *a;int rem; -printf ("%sRXSC: %016llx, state %s\n" , prefix, sci, +printf ("%sRXSC: %016llx, state %s\n" , prefix,ntohll (sci), values_on_off[!!active]);print_rxsc_stats (prefix, rxsc_stats);
@@ -1018,7 +1018,7 @@ static void macsec_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])if (tb[IFLA_MACSEC_SCI ]) {fprintf (f,"sci %016llx " , -rta_getattr_u64 (tb[IFLA_MACSEC_SCI ])); +ntohll (rta_getattr_u64 (tb[IFLA_MACSEC_SCI ]))); }print_flag (f, tb,"protect" ,IFLA_MACSEC_PROTECT );
man/man8/ip-link.8.in +3 -1
@@ -989,7 +989,9 @@ interpreted as octal and hexadecimal, respectively. .sp .BI sci " SCI " -- sets the SCI for this MACsec device. +- sets the secure channel identifier for this MACsec device. +.I SCI +is a 64bit wide number in hexadecimal format. .sp .BI cipher " CIPHER_SUITE "
Signature · 1 line
2.5.5