From patchwork Tue Mar 6 06:58:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 881935 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=networkplumber.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="ZqOHAgQp"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zwSKy6rF0z9sgX for ; Tue, 6 Mar 2018 17:58:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750865AbeCFG6n (ORCPT ); Tue, 6 Mar 2018 01:58:43 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:46084 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750769AbeCFG6j (ORCPT ); Tue, 6 Mar 2018 01:58:39 -0500 Received: by mail-pl0-f68.google.com with SMTP id y8-v6so11348219pll.13 for ; Mon, 05 Mar 2018 22:58:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ag1ZSrwrt05M83H9ri1Z5VTiF/uDdw4hjKqsuZeJevQ=; b=ZqOHAgQpvs12oK8OZxeNK55/SbALbmgsd69LIWRfcUML36UZsgG/udTIsKq/5rM5dU jbfuM7FzYVAkDvBHxjYQcJHuCVdqHwttzdfTod+f78klktgkPAOMH5I07xlAJzSVn9/3 d9T9TRFK318BNtmdpkg6EVAl+7irhf9GHf2MISRFUtOVxHrDstu8EZnDwxbALkM+edwB IrEVyWaRO8fHD+MxvJoiNuO6n29zT94UqmyzN+/rkc17viGodkY2hCWTB2rw0qpRDH4j 3+bj8UH4j5YYqIBVnI6nGPw1A+DjekJtLg6Q2NU+iYVq5kS1TIJowwR79ZiWh7AwcgWz hGKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ag1ZSrwrt05M83H9ri1Z5VTiF/uDdw4hjKqsuZeJevQ=; b=hth5cGB3HvdFcBCkg1sP7yVHEqk2rTftNJT8oz42iU2FUa52r8yVrTy/SILf9FdTIh YnjU9cEAEcMtifZ0dMJtv6PaI7Yi99M5MKTBx3Pwe2Rr6/tjIMP/Vs1oMI994Cs2cKDA PTyCdGLrH1TK7qLJVv7r5tP6th/ZRr4sdlGdONGggDwWSbjLnZ0vKwAmN0/KxCoaPHEc 0LddID9DZXKOf9Zib2qLTnhh1jEsVKuPnD0MNtNzCGf01/vYtaSioGPSFkbPxZ9Xsclr 1MF8gABDlzArGABlWz5W2/H65tofMTfhPdjQnKxhXIpBqTTfldvJ50aZH2OkMg7yUIXW tr+g== X-Gm-Message-State: AElRT7GOuHldwDde1JqKcAWV3clDCU8nuvS6AH9Xz93eTPvKL1eXtQex vaRJ86XuE+vwHiqcfUSo6CwnnQ== X-Google-Smtp-Source: AG47ELsxJM9FBZUNQff7DiaZz3Tw2CgF4tATBXUU9AIBeHbx4n5+EhVIWIwd09d1qskTNswTsyoPyQ== X-Received: by 2002:a17:902:6943:: with SMTP id k3-v6mr8651563plt.214.1520319519197; Mon, 05 Mar 2018 22:58:39 -0800 (PST) Received: from xeon-e3.lan (204-195-71-95.wavecable.com. [204.195.71.95]) by smtp.gmail.com with ESMTPSA id s9sm9087477pfh.64.2018.03.05.22.58.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 22:58:37 -0800 (PST) From: Stephen Hemminger To: dsahern@gmail.com, sd@queasysnail.net Cc: netdev@vger.kernel.org, Stephen Hemminger , Stephen Hemminger Subject: [PATCH iproute2-next 1/3] ip: macsec cleanup Date: Mon, 5 Mar 2018 22:58:28 -0800 Message-Id: <20180306065830.8961-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180306065830.8961-1-stephen@networkplumber.org> References: <20180306065830.8961-1-stephen@networkplumber.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Stephen Hemminger Break long lines and use const as recommended by checkpatch. Signed-off-by: Stephen Hemminger --- ip/ipmacsec.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/ip/ipmacsec.c b/ip/ipmacsec.c index c0b45f5a12d5..37faed821c10 100644 --- a/ip/ipmacsec.c +++ b/ip/ipmacsec.c @@ -23,9 +23,9 @@ #include "ll_map.h" #include "libgenl.h" -static const char *values_on_off[] = { "off", "on" }; +static const char * const values_on_off[] = { "off", "on" }; -static const char *VALIDATE_STR[] = { +static const char * const validate_str[] = { [MACSEC_VALIDATE_DISABLED] = "disabled", [MACSEC_VALIDATE_CHECK] = "check", [MACSEC_VALIDATE_STRICT] = "strict", @@ -81,26 +81,27 @@ static int genl_family = -1; static void ipmacsec_usage(void) { - fprintf(stderr, "Usage: ip macsec add DEV tx sa { 0..3 } [ OPTS ] key ID KEY\n"); - fprintf(stderr, " ip macsec set DEV tx sa { 0..3 } [ OPTS ]\n"); - fprintf(stderr, " ip macsec del DEV tx sa { 0..3 }\n"); - fprintf(stderr, " ip macsec add DEV rx SCI [ on | off ]\n"); - fprintf(stderr, " ip macsec set DEV rx SCI [ on | off ]\n"); - fprintf(stderr, " ip macsec del DEV rx SCI\n"); - fprintf(stderr, " ip macsec add DEV rx SCI sa { 0..3 } [ OPTS ] key ID KEY\n"); - fprintf(stderr, " ip macsec set DEV rx SCI sa { 0..3 } [ OPTS ]\n"); - fprintf(stderr, " ip macsec del DEV rx SCI sa { 0..3 }\n"); - fprintf(stderr, " ip macsec show\n"); - fprintf(stderr, " ip macsec show DEV\n"); - fprintf(stderr, "where OPTS := [ pn ] [ on | off ]\n"); - fprintf(stderr, " ID := 128-bit hex string\n"); - fprintf(stderr, " KEY := 128-bit hex string\n"); - fprintf(stderr, " SCI := { sci | port { 1..2^16-1 } address }\n"); + fprintf(stderr, + "Usage: ip macsec add DEV tx sa { 0..3 } [ OPTS ] key ID KEY\n" + " ip macsec set DEV tx sa { 0..3 } [ OPTS ]\n" + " ip macsec del DEV tx sa { 0..3 }\n" + " ip macsec add DEV rx SCI [ on | off ]\n" + " ip macsec set DEV rx SCI [ on | off ]\n" + " ip macsec del DEV rx SCI\n" + " ip macsec add DEV rx SCI sa { 0..3 } [ OPTS ] key ID KEY\n" + " ip macsec set DEV rx SCI sa { 0..3 } [ OPTS ]\n" + " ip macsec del DEV rx SCI sa { 0..3 }\n" + " ip macsec show\n" + " ip macsec show DEV\n" + "where OPTS := [ pn ] [ on | off ]\n" + " ID := 128-bit hex string\n" + " KEY := 128-bit hex string\n" + " SCI := { sci | port { 1..2^16-1 } address }\n"); exit(-1); } -static int one_of(const char *msg, const char *realval, const char **list, +static int one_of(const char *msg, const char *realval, const char * const *list, size_t len, int *index) { int i; @@ -597,7 +598,7 @@ static void print_attrs(const char *prefix, struct rtattr *attrs[]) if (attrs[MACSEC_SECY_ATTR_VALIDATE]) { __u8 val = rta_getattr_u8(attrs[MACSEC_SECY_ATTR_VALIDATE]); - printf("validate %s ", VALIDATE_STR[val]); + printf("validate %s ", validate_str[val]); } print_flag(stdout, attrs, "sc", MACSEC_RXSC_ATTR_ACTIVE); @@ -1077,7 +1078,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_str[val]); } const char *inc_sci, *es, *replay; @@ -1241,7 +1242,7 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv, } else if (strcmp(*argv, "validate") == 0) { NEXT_ARG(); ret = one_of("validate", *argv, - VALIDATE_STR, ARRAY_SIZE(VALIDATE_STR), + validate_str, ARRAY_SIZE(validate_str), (int *)&validate); if (ret != 0) return ret; @@ -1265,7 +1266,8 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv, } if (!check_txsc_flags(es, scb, send_sci)) { - fprintf(stderr, "invalid combination of send_sci/end_station/scb\n"); + fprintf(stderr, + "invalid combination of send_sci/end_station/scb\n"); return -1; }