]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
macsec: fix byte ordering on input/display of 'sci'
authorDavide Caratti <dcaratti@redhat.com>
Tue, 30 Aug 2016 11:23:14 +0000 (13:23 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 1 Sep 2016 16:08:50 +0000 (09:08 -0700)
use 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.

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
ip/ipmacsec.c
man/man8/ip-link.8.in

index c75e9d3ca9def70f5b4ea227b0d0469f843aa813..2e670e9ecab9d6cc0b9f074d92a12e31281686eb 100644 (file)
@@ -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);
index 6fb5ad6c0b050651c7d821ee492e448ab1959beb..ffc4160a1b6e736e9daa7a442109cfb15be307ce 100644 (file)
@@ -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 "