diff options
author | Antoine Tenart <antoine.tenart@bootlin.com> | 2020-03-03 11:36:19 +0100 |
---|---|---|
committer | David Ahern <dsahern@gmail.com> | 2020-03-04 19:57:41 +0000 |
commit | c15674d80d49dac94d659de443675f19e23a734e (patch) | |
tree | 09811582140982aaa8e71ca224ce6a9944115aa9 | |
parent | 69166f909b16fff8cd0af28f705b48606380c6e4 (diff) | |
download | iproute2-c15674d80d49dac94d659de443675f19e23a734e.tar.gz |
macsec: add an accessor for validate_str
This patch adds an accessor for the validate_str array, to handle future
changes adding a member.
Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
-rw-r--r-- | ip/ipmacsec.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/ip/ipmacsec.c b/ip/ipmacsec.c index 6104a3a55..4e500e4e4 100644 --- a/ip/ipmacsec.c +++ b/ip/ipmacsec.c @@ -653,6 +653,14 @@ static const char *cs_id_to_name(__u64 cid) } } +static const char *validate_to_str(__u8 validate) +{ + if (validate >= ARRAY_SIZE(validate_str)) + return "(unknown)"; + + return validate_str[validate]; +} + static const char *offload_to_str(__u8 offload) { if (offload >= ARRAY_SIZE(offload_str)) @@ -669,7 +677,7 @@ static void print_attrs(struct rtattr *attrs[]) __u8 val = rta_getattr_u8(attrs[MACSEC_SECY_ATTR_VALIDATE]); print_string(PRINT_ANY, "validate", - "validate %s ", validate_str[val]); + "validate %s ", validate_to_str(val)); } print_flag(attrs, "sc", MACSEC_RXSC_ATTR_ACTIVE); @@ -1208,7 +1216,7 @@ static void macsec_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) print_string(PRINT_ANY, "validation", "validate %s ", - validate_str[val]); + validate_to_str(val)); } const char *inc_sci, *es, *replay; |