macsec: fix byte ordering on input/display of 'sci'

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>
This commit is contained in:
Davide Caratti 2016-08-30 13:23:14 +02:00 committed by Stephen Hemminger
parent d0baa1389f
commit 0330f49ea0
2 changed files with 7 additions and 5 deletions

View 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);

View 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 "