From 54a0ade6d4f9dc1f3e4c13c8c9a83c755f0b1045 Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Thu, 17 Jan 2019 17:08:01 +0200 Subject: [PATCH 01/55] clang-format: add configuration file The codebase of iproute2 follows Linux kernel coding style, so it will be very helpful to reuse existing clang configuration file to reliably format code. For more information see kernel commit d4ef8d3ff005 ("clang-format: add configuration file"). Updated upto commit v5.0-rc1 with small number of ForEachMacros. Signed-off-by: Leon Romanovsky Signed-off-by: David Ahern --- .clang-format | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..901467bd --- /dev/null +++ b/.clang-format @@ -0,0 +1,130 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# clang-format configuration file. Intended for clang-format >= 4. +# +# For more information, see: +# +# Documentation/process/clang-format.rst +# https://clang.llvm.org/docs/ClangFormat.html +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html +# +--- +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +#AlignEscapedNewlines: Left # Unknown to clang-format-4.0 +AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + #AfterExternBlock: false # Unknown to clang-format-5.0 + BeforeCatch: false + BeforeElse: false + IndentBraces: false + #SplitEmptyFunction: true # Unknown to clang-format-4.0 + #SplitEmptyRecord: true # Unknown to clang-format-4.0 + #SplitEmptyNamespace: true # Unknown to clang-format-4.0 +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0 +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: false +#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0 +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: false +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +#CompactNamespaces: false # Unknown to clang-format-4.0 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +#FixNamespaceComments: false # Unknown to clang-format-4.0 + +# Taken from: +# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \ +# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \ +# | sort | uniq +ForEachMacros: + - 'list_for_each_entry' + - 'list_for_each_entry_safe' + - 'mnl_attr_for_each_nested' + - 'hlist_for_each' + - 'hlist_for_each_safe' + - 'hlist_for_each_entry' + +#IncludeBlocks: Preserve # Unknown to clang-format-5.0 +IncludeCategories: + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +#IndentPPDirectives: None # Unknown to clang-format-5.0 +IndentWidth: 8 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0 +ObjCBlockIndentWidth: 8 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true + +# Taken from git's rules +#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0 +PenaltyBreakBeforeFirstCallParameter: 30 +PenaltyBreakComment: 10 +PenaltyBreakFirstLessLess: 0 +PenaltyBreakString: 10 +PenaltyExcessCharacter: 100 +PenaltyReturnTypeOnItsOwnLine: 60 + +PointerAlignment: Right +ReflowComments: false +SortIncludes: false +#SortUsingDeclarations: false # Unknown to clang-format-4.0 +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0 +#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0 +SpaceBeforeParens: ControlStatements +#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0 +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp03 +TabWidth: 8 +UseTab: Always +... From b058f969dfe2de3d8c973f2a8f009845ee55cfb0 Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Thu, 17 Jan 2019 17:14:43 +0200 Subject: [PATCH 02/55] rdma: Add unbound workqueue to list of poll context types Kernel commit f794809a7259 ("IB/core: Add an unbound WQ type to the new CQ API") added new CQ poll context type, reflect this change in rdmatool. Signed-off-by: Leon Romanovsky Signed-off-by: David Ahern --- rdma/res.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdma/res.c b/rdma/res.c index cbb2efe6..6b0f5fe3 100644 --- a/rdma/res.c +++ b/rdma/res.c @@ -703,7 +703,7 @@ static void print_users(struct rd *rd, uint64_t val) static const char *poll_ctx_to_str(uint8_t idx) { static const char * const cm_id_states_str[] = { - "DIRECT", "SOFTIRQ", "WORKQUEUE"}; + "DIRECT", "SOFTIRQ", "WORKQUEUE", "UNBOUND_WORKQUEUE"}; if (idx < ARRAY_SIZE(cm_id_states_str)) return cm_id_states_str[idx]; From dad02ef47803d4d1e24dfadb6ff7b1764622daa5 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Mon, 21 Jan 2019 08:29:26 -0800 Subject: [PATCH 03/55] Update kernel headers Update kernel headers to commit 28f9d1a3d4fe ("Merge branch 'mlxsw-spectrum_router-Add-GRE-tunnel-support-for-Spectrum-2'") Signed-off-by: David Ahern --- include/uapi/linux/devlink.h | 25 +++++++++++++++++++++++++ include/uapi/linux/pkt_cls.h | 13 +++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index d0a33d79..6d0fad90 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -89,6 +89,13 @@ enum devlink_command { DEVLINK_CMD_REGION_DEL, DEVLINK_CMD_REGION_READ, + DEVLINK_CMD_HEALTH_REPORTER_GET, + DEVLINK_CMD_HEALTH_REPORTER_SET, + DEVLINK_CMD_HEALTH_REPORTER_RECOVER, + DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE, + DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET, + DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR, + /* add new commands above here */ __DEVLINK_CMD_MAX, DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 @@ -285,6 +292,24 @@ enum devlink_attr { DEVLINK_ATTR_REGION_CHUNK_ADDR, /* u64 */ DEVLINK_ATTR_REGION_CHUNK_LEN, /* u64 */ + DEVLINK_ATTR_HEALTH_BUFFER_OBJECT, /* nested */ + DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_PAIR, /* nested */ + DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_NAME, /* string */ + DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE, /* nested */ + DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_ARRAY, /* nested */ + DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_TYPE, /* u8 */ + DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_DATA, /* dynamic */ + + DEVLINK_ATTR_HEALTH_REPORTER, /* nested */ + DEVLINK_ATTR_HEALTH_REPORTER_NAME, /* string */ + DEVLINK_ATTR_HEALTH_REPORTER_STATE, /* u8 */ + DEVLINK_ATTR_HEALTH_REPORTER_ERR, /* u64 */ + DEVLINK_ATTR_HEALTH_REPORTER_RECOVER, /* u64 */ + DEVLINK_ATTR_HEALTH_REPORTER_DUMP_AVAIL, /* u8 */ + DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS, /* u64 */ + DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD, /* u64 */ + DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER, /* u8 */ + /* add new attributes above here, update the policy in devlink.c */ __DEVLINK_ATTR_MAX, diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index 95d0db2a..02ac251b 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -333,12 +333,19 @@ enum { /* Basic filter */ +struct tc_basic_pcnt { + __u64 rcnt; + __u64 rhit; +}; + enum { TCA_BASIC_UNSPEC, TCA_BASIC_CLASSID, TCA_BASIC_EMATCHES, TCA_BASIC_ACT, TCA_BASIC_POLICE, + TCA_BASIC_PCNT, + TCA_BASIC_PAD, __TCA_BASIC_MAX }; @@ -527,11 +534,17 @@ enum { /* Match-all classifier */ +struct tc_matchall_pcnt { + __u64 rhit; +}; + enum { TCA_MATCHALL_UNSPEC, TCA_MATCHALL_CLASSID, TCA_MATCHALL_ACT, TCA_MATCHALL_FLAGS, + TCA_MATCHALL_PCNT, + TCA_MATCHALL_PAD, __TCA_MATCHALL_MAX, }; From b0ca46a1f8b1c8f4d252583820d6ad7369186d45 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 17 Jan 2019 13:18:55 -0800 Subject: [PATCH 04/55] tc: add hit counter for matchall Cc: Martin Olsson Cc: Jamal Hadi Salim Cc: Jiri Pirko Cc: David Ahern Signed-off-by: Cong Wang Signed-off-by: David Ahern --- tc/f_matchall.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tc/f_matchall.c b/tc/f_matchall.c index 5ebd0415..03dd51de 100644 --- a/tc/f_matchall.c +++ b/tc/f_matchall.c @@ -114,6 +114,7 @@ static int matchall_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle) { struct rtattr *tb[TCA_MATCHALL_MAX+1]; + struct tc_matchall_pcnt *pf = NULL; if (opt == NULL) return 0; @@ -143,6 +144,19 @@ static int matchall_print_opt(struct filter_util *qu, FILE *f, print_bool(PRINT_ANY, "not_in_hw", "\n not_in_hw", true); } + if (tb[TCA_MATCHALL_PCNT]) { + if (RTA_PAYLOAD(tb[TCA_MATCHALL_PCNT]) < sizeof(*pf)) { + print_string(PRINT_FP, NULL, "Broken perf counters\n", NULL); + return -1; + } + pf = RTA_DATA(tb[TCA_MATCHALL_PCNT]); + } + + if (show_stats && NULL != pf) + print_u64(PRINT_ANY, "rule_hit", " (rule hit %llu)", + (unsigned long long) pf->rhit); + + if (tb[TCA_MATCHALL_ACT]) tc_print_action(f, tb[TCA_MATCHALL_ACT], 0); From a6af9f2e6195dc67d5355d6cb94fc8512c6fba1c Mon Sep 17 00:00:00 2001 From: Benedict Wong Date: Fri, 18 Jan 2019 11:12:17 -0800 Subject: [PATCH 05/55] xfrm: add option to hide keys in state output ip xfrm state show currently dumps keys unconditionally. This limits its use in logging, as security information can be leaked. This patch adds a nokeys option to ip xfrm ( state show | monitor ), which prevents the printing of keys. This allows ip xfrm state show to be used in logging without exposing keys. Signed-off-by: Benedict Wong Signed-off-by: David Ahern --- ip/ipxfrm.c | 49 +++++++++++++++++++++++++--------------------- ip/xfrm.h | 5 +++-- ip/xfrm_monitor.c | 7 +++++-- ip/xfrm_state.c | 27 ++++++++++++++++++++----- man/man8/ip-xfrm.8 | 15 +++++++++++++- 5 files changed, 71 insertions(+), 32 deletions(-) diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c index 2dea4e37..b153b863 100644 --- a/ip/ipxfrm.c +++ b/ip/ipxfrm.c @@ -497,7 +497,8 @@ void xfrm_selector_print(struct xfrm_selector *sel, __u16 family, } static void __xfrm_algo_print(struct xfrm_algo *algo, int type, int len, - FILE *fp, const char *prefix, int newline) + FILE *fp, const char *prefix, int newline, + bool nokeys) { int keylen; int i; @@ -521,7 +522,9 @@ static void __xfrm_algo_print(struct xfrm_algo *algo, int type, int len, goto fin; } - if (keylen > 0) { + if (nokeys) + fprintf(fp, "<