From 395370035e109c3ff4fa6b673a80ecb8af8da65b Mon Sep 17 00:00:00 2001 From: Ido Schimmel Date: Mon, 12 Aug 2019 13:17:06 +0300 Subject: [PATCH 1/5] tc: Fix block-handle support for filter operations The revert of batchsize accidently reverted more than it should and broke shared block functionality. Fix this by restoring the original functionality. To reproduce: dst_ip 192.0.2.0/24 action drop Unknown filter "block", hence option "10" is unparsable Fixes: e991c04d64c0 ("Revert "tc: Add batchsize feature for filter and actions"") Signed-off-by: Ido Schimmel Acked-by: Jiri Pirko Signed-off-by: Stephen Hemminger --- tc/tc_filter.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tc/tc_filter.c b/tc/tc_filter.c index 53759a7a..23e21d89 100644 --- a/tc/tc_filter.c +++ b/tc/tc_filter.c @@ -74,6 +74,7 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv) __u32 prio = 0; __u32 protocol = 0; int protocol_set = 0; + __u32 block_index = 0; __u32 chain_index; int chain_index_set = 0; char *fhandle = NULL; @@ -89,7 +90,21 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv) NEXT_ARG(); if (d[0]) duparg("dev", *argv); + if (block_index) { + fprintf(stderr, "Error: \"dev\" and \"block\" are mutually exclusive\n"); + return -1; + } strncpy(d, *argv, sizeof(d)-1); + } else if (matches(*argv, "block") == 0) { + NEXT_ARG(); + if (block_index) + duparg("block", *argv); + if (d[0]) { + fprintf(stderr, "Error: \"dev\" and \"block\" are mutually exclusive\n"); + return -1; + } + if (get_u32(&block_index, *argv, 0) || !block_index) + invarg("invalid block index value", *argv); } else if (strcmp(*argv, "root") == 0) { if (req.t.tcm_parent) { fprintf(stderr, @@ -184,6 +199,9 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv) fprintf(stderr, "Cannot find device \"%s\"\n", d); return 1; } + } else if (block_index) { + req.t.tcm_ifindex = TCM_IFINDEX_MAGIC_BLOCK; + req.t.tcm_block_index = block_index; } if (q) { From 42a66ee5f37604f95d1f6fbeeea4dbd0269c4069 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 12 Aug 2019 10:58:49 -0700 Subject: [PATCH 2/5] uapi: update socket.h Upstream change to resolve gcc-9 issues. Signed-off-by: Stephen Hemminger --- include/uapi/linux/socket.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/uapi/linux/socket.h b/include/uapi/linux/socket.h index 268b9482..debcf26f 100644 --- a/include/uapi/linux/socket.h +++ b/include/uapi/linux/socket.h @@ -6,17 +6,24 @@ * Desired design of maximum size and alignment (see RFC2553) */ #define _K_SS_MAXSIZE 128 /* Implementation specific max size */ -#define _K_SS_ALIGNSIZE (__alignof__ (struct sockaddr *)) - /* Implementation specific desired alignment */ typedef unsigned short __kernel_sa_family_t; +/* + * The definition uses anonymous union and struct in order to control the + * default alignment. + */ struct __kernel_sockaddr_storage { - __kernel_sa_family_t ss_family; /* address family */ - /* Following field(s) are implementation specific */ - char __data[_K_SS_MAXSIZE - sizeof(unsigned short)]; + union { + struct { + __kernel_sa_family_t ss_family; /* address family */ + /* Following field(s) are implementation specific */ + char __data[_K_SS_MAXSIZE - sizeof(unsigned short)]; /* space to achieve desired size, */ /* _SS_MAXSIZE value minus size of ss_family */ -} __attribute__ ((aligned(_K_SS_ALIGNSIZE))); /* force desired alignment */ + }; + void *__align; /* implementation specific desired alignment */ + }; +}; #endif /* _LINUX_SOCKET_H */ From 69df9bf981358141161cc77ed490969d0c6a7930 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 12 Aug 2019 18:18:51 -0700 Subject: [PATCH 3/5] tc: fix spelling errors Minor spelling errors found by codespell Signed-off-by: Stephen Hemminger --- tc/em_ipt.c | 2 +- tc/q_netem.c | 2 +- tc/tc_cbq.c | 2 +- tc/tc_filter.c | 4 ++-- tc/tc_red.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tc/em_ipt.c b/tc/em_ipt.c index aa2edd63..b15c3ba5 100644 --- a/tc/em_ipt.c +++ b/tc/em_ipt.c @@ -1,5 +1,5 @@ /* - * em_ipt.c IPtables extenstions matching Ematch + * em_ipt.c IPtables extensions matching Ematch * * (C) 2018 Eyal Birger * diff --git a/tc/q_netem.c b/tc/q_netem.c index 6d748f68..d01450fc 100644 --- a/tc/q_netem.c +++ b/tc/q_netem.c @@ -39,7 +39,7 @@ static void explain(void) " [ loss state P13 [P31 [P32 [P23 P14]]]\n" \ " [ loss gemodel PERCENT [R [1-H [1-K]]]\n" \ " [ ecn ]\n" \ - " [ reorder PRECENT [CORRELATION] [ gap DISTANCE ]]\n" \ + " [ reorder PERCENT [CORRELATION] [ gap DISTANCE ]]\n" \ " [ rate RATE [PACKETOVERHEAD] [CELLSIZE] [CELLOVERHEAD]]\n" \ " [ slot MIN_DELAY [MAX_DELAY] [packets MAX_PACKETS]" \ " [bytes MAX_BYTES]]\n" \ diff --git a/tc/tc_cbq.c b/tc/tc_cbq.c index c811456b..f56011ad 100644 --- a/tc/tc_cbq.c +++ b/tc/tc_cbq.c @@ -1,5 +1,5 @@ /* - * tc_cbq.c CBQ maintanance routines. + * tc_cbq.c CBQ maintenance routines. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/tc/tc_filter.c b/tc/tc_filter.c index 23e21d89..f7d2e4a6 100644 --- a/tc/tc_filter.c +++ b/tc/tc_filter.c @@ -414,7 +414,7 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv) if (d[0]) duparg("dev", *argv); if (block_index) { - fprintf(stderr, "Error: \"dev\" and \"block\" are mutually exlusive\n"); + fprintf(stderr, "Error: \"dev\" and \"block\" are mutually exclusive\n"); return -1; } strncpy(d, *argv, sizeof(d)-1); @@ -423,7 +423,7 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv) if (block_index) duparg("block", *argv); if (d[0]) { - fprintf(stderr, "Error: \"dev\" and \"block\" are mutually exlusive\n"); + fprintf(stderr, "Error: \"dev\" and \"block\" are mutually exclusive\n"); return -1; } if (get_u32(&block_index, *argv, 0) || !block_index) diff --git a/tc/tc_red.c b/tc/tc_red.c index 3ce3ca42..681ca297 100644 --- a/tc/tc_red.c +++ b/tc/tc_red.c @@ -1,5 +1,5 @@ /* - * tc_red.c RED maintanance routines. + * tc_red.c RED maintenance routines. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License From 260dc56ae3efbac6aa80e946d18eb0c66b95c5a4 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 12 Aug 2019 18:21:10 -0700 Subject: [PATCH 4/5] lib: fix spelling errors Signed-off-by: Stephen Hemminger --- lib/json_print.c | 2 +- lib/utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/json_print.c b/lib/json_print.c index 4eb2d0dc..43ea69bb 100644 --- a/lib/json_print.c +++ b/lib/json_print.c @@ -224,7 +224,7 @@ void print_color_null(enum output_type type, } } -/* Print line seperator (if not in JSON mode) */ +/* Print line separator (if not in JSON mode) */ void print_nl(void) { if (!_jw) diff --git a/lib/utils.c b/lib/utils.c index 4c43f8fd..95d46ff2 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -168,7 +168,7 @@ static int get_netmask(unsigned int *val, const char *arg, int base) if (!get_unsigned(val, arg, base)) return 0; - /* try coverting dotted quad to CIDR */ + /* try converting dotted quad to CIDR */ if (!get_addr_1(&addr, arg, AF_INET) && addr.family == AF_INET) { int b = mask2bits(addr.data[0]); From dba639a598369bdbbd0bd40f0cd127375f0b615a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 9 Aug 2019 20:18:42 -0400 Subject: [PATCH 5/5] ip nexthop: Add space to display properly when showing a group When displaying a nexthop group made up of other nexthops, the display line shows this when you have additional data at the end: id 42 group 43/44/45/46/47/48/49/50/51/52/53/54/55/56/57/58/59/60/61/62/63/64/65/66/67/68/69/70/71/72/73/74proto zebra Modify code so that it shows: id 42 group 43/44/45/46/47/48/49/50/51/52/53/54/55/56/57/58/59/60/61/62/63/64/65/66/67/68/69/70/71/72/73/74 proto zebra Signed-off-by: Donald Sharp Reviewed-by: David Ahern Signed-off-by: Stephen Hemminger --- ip/ipnexthop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c index 97f09e74..f35aab52 100644 --- a/ip/ipnexthop.c +++ b/ip/ipnexthop.c @@ -186,6 +186,7 @@ static void print_nh_group(FILE *fp, const struct rtattr *grps_attr) close_json_object(); } + print_string(PRINT_FP, NULL, "%s", " "); close_json_array(PRINT_JSON, NULL); }