From fda0a61dde744abe69d4227f62b66238460c9011 Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Tue, 3 Apr 2018 10:28:42 +0300 Subject: [PATCH 1/4] rdma: Ignore unknown netlink attributes The check if netlink attributes supplied more than maximum supported is to strict and may lead to backward compatibility issues with old application with a newer kernel that supports new attribute. CC: Steve Wise Fixes: 74bd75c2b68d ("rdma: Add basic infrastructure for RDMA tool") Signed-off-by: Leon Romanovsky Reviewed-by: Steve Wise Signed-off-by: Stephen Hemminger --- rdma/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rdma/utils.c b/rdma/utils.c index a2e08e91..5c1e736a 100644 --- a/rdma/utils.c +++ b/rdma/utils.c @@ -399,7 +399,8 @@ int rd_attr_cb(const struct nlattr *attr, void *data) int type; if (mnl_attr_type_valid(attr, RDMA_NLDEV_ATTR_MAX) < 0) - return MNL_CB_ERROR; + /* We received uknown attribute */ + return MNL_CB_OK; type = mnl_attr_get_type(attr); From 2f75c5cf1af2a090bbc50e34742cb12c426e135d Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Tue, 3 Apr 2018 17:39:54 +0200 Subject: [PATCH 2/4] ip/l2tp: remove offset and peer-offset options Ignore options "peer-offset" and "offset" when creating sessions. Keep them when dumping sessions in order to avoid breaking external scripts. "peer-offset" has always been a noop in iproute2. "offset" is now ignored in Linux 4.16 (and was broken before that). Signed-off-by: Guillaume Nault Signed-off-by: Stephen Hemminger --- ip/ipl2tp.c | 23 ++++------------------- man/man8/ip-l2tp.8 | 16 ---------------- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/ip/ipl2tp.c b/ip/ipl2tp.c index 750f912a..427e0249 100644 --- a/ip/ipl2tp.c +++ b/ip/ipl2tp.c @@ -42,8 +42,6 @@ struct l2tp_parm { uint32_t peer_tunnel_id; uint32_t session_id; uint32_t peer_session_id; - uint32_t offset; - uint32_t peer_offset; enum l2tp_encap_type encap; uint16_t local_udp_port; uint16_t peer_udp_port; @@ -174,8 +172,6 @@ static int create_session(struct l2tp_parm *p) if (p->reorder_timeout) addattr64(&req.n, 1024, L2TP_ATTR_RECV_TIMEOUT, p->reorder_timeout); - if (p->offset) - addattr16(&req.n, 1024, L2TP_ATTR_OFFSET, p->offset); if (p->cookie_len) addattr_l(&req.n, 1024, L2TP_ATTR_COOKIE, p->cookie, p->cookie_len); @@ -310,8 +306,8 @@ static void print_session(struct l2tp_data *data) print_string(PRINT_FP, NULL, "%s", _SL_); } - print_uint(PRINT_ANY, "offset", " offset %u,", p->offset); - print_uint(PRINT_ANY, "peer_offset", " peer offset %u\n", p->peer_offset); + print_uint(PRINT_ANY, "offset", " offset %u,", 0); + print_uint(PRINT_ANY, "peer_offset", " peer offset %u\n", 0); if (p->cookie_len > 0) print_cookie("cookie", "cookie", @@ -362,8 +358,6 @@ static int get_response(struct nlmsghdr *n, void *arg) p->pw_type = rta_getattr_u16(attrs[L2TP_ATTR_PW_TYPE]); if (attrs[L2TP_ATTR_ENCAP_TYPE]) p->encap = rta_getattr_u16(attrs[L2TP_ATTR_ENCAP_TYPE]); - if (attrs[L2TP_ATTR_OFFSET]) - p->offset = rta_getattr_u16(attrs[L2TP_ATTR_OFFSET]); if (attrs[L2TP_ATTR_DATA_SEQ]) p->data_seq = rta_getattr_u16(attrs[L2TP_ATTR_DATA_SEQ]); if (attrs[L2TP_ATTR_CONN_ID]) @@ -550,7 +544,6 @@ static void usage(void) " tunnel_id ID\n" " session_id ID peer_session_id ID\n" " [ cookie HEXSTR ] [ peer_cookie HEXSTR ]\n" - " [ offset OFFSET ] [ peer_offset OFFSET ]\n" " [ seq { none | send | recv | both } ]\n" " [ l2spec_type L2SPEC ]\n" " ip l2tp del tunnel tunnel_id ID\n" @@ -678,19 +671,11 @@ static int parse_args(int argc, char **argv, int cmd, struct l2tp_parm *p) invarg("invalid option for udp6_csum_tx\n" , *argv); } else if (strcmp(*argv, "offset") == 0) { - __u8 uval; - + fprintf(stderr, "Ignoring option \"offset\"\n"); NEXT_ARG(); - if (get_u8(&uval, *argv, 0)) - invarg("invalid offset\n", *argv); - p->offset = uval; } else if (strcmp(*argv, "peer_offset") == 0) { - __u8 uval; - + fprintf(stderr, "Ignoring option \"peer_offset\"\n"); NEXT_ARG(); - if (get_u8(&uval, *argv, 0)) - invarg("invalid offset\n", *argv); - p->peer_offset = uval; } else if (strcmp(*argv, "cookie") == 0) { int slen; diff --git a/man/man8/ip-l2tp.8 b/man/man8/ip-l2tp.8 index 8ce630a6..9aba6bec 100644 --- a/man/man8/ip-l2tp.8 +++ b/man/man8/ip-l2tp.8 @@ -59,12 +59,6 @@ ip-l2tp - L2TPv3 static unmanaged tunnel configuration .br .RB "[ " seq " { " none " | " send " | " recv " | " both " } ]" .br -.RB "[ " offset -.IR OFFSET -.RB " ] [ " peer_offset -.IR OFFSET -.RB " ]" -.br .ti -8 .BR "ip l2tp del tunnel" .B tunnel_id @@ -285,16 +279,6 @@ Default is .br Valid values are: .BR none ", " send ", " recv ", " both "." -.TP -.BI offset " OFFSET" -sets the byte offset from the L2TP header where user data starts in -transmitted L2TP data packets. This is hardly ever used. If set, the -value must match the peer_offset value used at the peer. Default is 0. -.TP -.BI peer_offset " OFFSET" -sets the byte offset from the L2TP header where user data starts in -received L2TP data packets. This is hardly ever used. If set, the -value must match the offset value used at the peer. Default is 0. .SS ip l2tp del session - destroy a session .TP .BI tunnel_id " ID" From 0927bf83e7632f5c5a2c0eb77592955d61f8aea4 Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Wed, 4 Apr 2018 15:24:13 +0300 Subject: [PATCH 3/4] tc: Correct json output for actions Commit 9fd3f0b255d9 ("tc: enable json output for actions") added JSON support for tc-actions at the expense of breaking other use cases that reach tc_print_action(), as the latter don't expect the 'actions' array to be a new object. Consider the following taken duringrun of tc_chain.sh selftest, and see the latter command output is broken: $ ./tc/tc -j -p actions list action gact | grep -C 3 actions [ { "total acts": 1 },{ "actions": [ { "order": 0, $ ./tc/tc -p -j -s filter show dev enp3s0np2 ingress | grep -C 3 actions }, "skip_hw": true, "not_in_hw": true,{ "actions": [ { "order": 1, "kind": "gact", "control_action": { Relocate the open/close of the JSON object to declare the object only for the case that needs it. Signed-off-by: Yuval Mintz Tested-by: Roman Mashak Signed-off-by: Stephen Hemminger --- tc/m_action.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tc/m_action.c b/tc/m_action.c index 2f85d353..8993b93a 100644 --- a/tc/m_action.c +++ b/tc/m_action.c @@ -366,7 +366,6 @@ tc_print_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts) if (tab_flush && NULL != tb[0] && NULL == tb[1]) return tc_print_action_flush(f, tb[0]); - open_json_object(NULL); open_json_array(PRINT_JSON, "actions"); for (i = 0; i <= tot_acts; i++) { if (tb[i]) { @@ -383,7 +382,6 @@ tc_print_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts) } close_json_array(PRINT_JSON, NULL); - close_json_object(); return 0; } @@ -439,8 +437,9 @@ int print_action(const struct sockaddr_nl *who, } } - + open_json_object(NULL); tc_print_action(fp, tb[TCA_ACT_TAB], tot_acts ? *tot_acts:0); + close_json_object(); return 0; } From 458539ad35a78d0c439cbec87786c7d65b76980d Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Thu, 5 Apr 2018 19:24:17 +0200 Subject: [PATCH 4/4] l2tp: no need to export session offsets in JSON output The offset and peer_offset parameters are only printed to avoid confusing external scripts that may parse "ip l2tp show session" output. There's no reason to keep them in JSON. Signed-off-by: Guillaume Nault --- ip/ipl2tp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ip/ipl2tp.c b/ip/ipl2tp.c index 427e0249..05e96387 100644 --- a/ip/ipl2tp.c +++ b/ip/ipl2tp.c @@ -306,8 +306,9 @@ static void print_session(struct l2tp_data *data) print_string(PRINT_FP, NULL, "%s", _SL_); } - print_uint(PRINT_ANY, "offset", " offset %u,", 0); - print_uint(PRINT_ANY, "peer_offset", " peer offset %u\n", 0); + /* Show offsets only for plain console output (for legacy scripts) */ + print_uint(PRINT_FP, "offset", " offset %u,", 0); + print_uint(PRINT_FP, "peer_offset", " peer offset %u\n", 0); if (p->cookie_len > 0) print_cookie("cookie", "cookie",