diff --git a/backport-bridge-fix-potential-snprintf-overflow.patch b/backport-bridge-fix-potential-snprintf-overflow.patch new file mode 100644 index 0000000000000000000000000000000000000000..08390d30463d82068c9d6d9cf11bfa063e7b6010 --- /dev/null +++ b/backport-bridge-fix-potential-snprintf-overflow.patch @@ -0,0 +1,44 @@ +From 4d80122ae82aea86cb740b5202f6c3fde6183538 Mon Sep 17 00:00:00 2001 +From: Stephen Hemminger +Date: Mon, 18 Sep 2023 11:34:42 -0700 +Subject: [PATCH] bridge: fix potential snprintf overflow + +There is a theoretical snprintf overflow in bridge slave bitmask +print code found by CodeQL scan. +Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=4d80122ae82aea86cb740b5202f6c3fde6183538 + +Signed-off-by: Stephen Hemminger +--- + ip/iplink_bridge_slave.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c +index dc73c865..3821923b 100644 +--- a/ip/iplink_bridge_slave.c ++++ b/ip/iplink_bridge_slave.c +@@ -100,13 +100,20 @@ static void _bitmask2str(__u16 bitmask, char *dst, size_t dst_size, + int len, i; + + for (i = 0, len = 0; bitmask; i++, bitmask >>= 1) { ++ int n; ++ + if (bitmask & 0x1) { + if (tbl[i]) +- len += snprintf(dst + len, dst_size - len, "%s,", ++ n = snprintf(dst + len, dst_size - len, "%s,", + tbl[i]); + else +- len += snprintf(dst + len, dst_size - len, "0x%x,", ++ n = snprintf(dst + len, dst_size - len, "0x%x,", + (1 << i)); ++ ++ if (n < 0 || n >= dst_size - len) ++ break; ++ ++ len += n; + } + } + +-- +2.33.0 + diff --git a/backport-ila-fix-potential-snprintf-buffer-overflow.patch b/backport-ila-fix-potential-snprintf-buffer-overflow.patch new file mode 100644 index 0000000000000000000000000000000000000000..1f4ed6d6e199b2138df7bc2218737da08ca0d53d --- /dev/null +++ b/backport-ila-fix-potential-snprintf-buffer-overflow.patch @@ -0,0 +1,31 @@ +From e8a3fca81cd4b8fee14cfb14a5ce9c1b3b63e797 Mon Sep 17 00:00:00 2001 +From: Stephen Hemminger +Date: Mon, 18 Sep 2023 11:36:32 -0700 +Subject: [PATCH] ila: fix potential snprintf buffer overflow + +The code to print 64 bit address has a theoretical overflow +of snprintf buffer found by CodeQL scan. +Address by checking result. +Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=e8a3fca81cd4b8fee14cfb14a5ce9c1b3b63e797 + +Signed-off-by: Stephen Hemminger +--- + ip/ipila.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/ip/ipila.c b/ip/ipila.c +index 4f6d578f..23b19a10 100644 +--- a/ip/ipila.c ++++ b/ip/ipila.c +@@ -60,6 +60,8 @@ static void print_addr64(__u64 addr, char *buff, size_t len) + sep = ""; + + ret = snprintf(&buff[written], len - written, "%x%s", v, sep); ++ if (ret < 0 || ret >= len - written) ++ break; + written += ret; + } + } +-- +2.33.0 + diff --git a/backport-ip-fix-memory-leak-in-ip-maddr-show.patch b/backport-ip-fix-memory-leak-in-ip-maddr-show.patch new file mode 100644 index 0000000000000000000000000000000000000000..af5a2727cc95a0d165e789654bf38cae20580901 --- /dev/null +++ b/backport-ip-fix-memory-leak-in-ip-maddr-show.patch @@ -0,0 +1,48 @@ +From 575322b09c3c6bc1806f2faa31edcfb64df302bb Mon Sep 17 00:00:00 2001 +From: Maxim Petrov +Date: Sun, 15 Oct 2023 16:32:12 +0200 +Subject: [PATCH] ip: fix memory leak in 'ip maddr show' + +In `read_dev_mcast`, the list of ma_info is allocated, but not cleared +after use. Free the list in the end to make valgrind happy. + +Detected by valgrind: "valgrind ./ip/ip maddr show" +Reference:https://github.com/iproute2/iproute2/commit/575322b09c3c6bc1806f2faa31edcfb64df302bb + +Signed-off-by: Maxim Petrov +--- + ip/ipmaddr.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c +index 176f6ab7..2418b303 100644 +--- a/ip/ipmaddr.c ++++ b/ip/ipmaddr.c +@@ -79,6 +79,16 @@ static void maddr_ins(struct ma_info **lst, struct ma_info *m) + *lst = m; + } + ++static void maddr_clear(struct ma_info *lst) ++{ ++ struct ma_info *mp; ++ ++ while ((mp = lst) != NULL) { ++ lst = mp->next; ++ free(mp); ++ } ++} ++ + static void read_dev_mcast(struct ma_info **result_p) + { + char buf[256]; +@@ -286,6 +296,7 @@ static int multiaddr_list(int argc, char **argv) + if (!filter.family || filter.family == AF_INET6) + read_igmp6(&list); + print_mlist(stdout, list); ++ maddr_clear(list); + return 0; + } + +-- +2.33.0 + diff --git a/backport-iproute2-prevent-memory-leak.patch b/backport-iproute2-prevent-memory-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..e68960e1fc24a90ab859a05c9ae9a6461e71a381 --- /dev/null +++ b/backport-iproute2-prevent-memory-leak.patch @@ -0,0 +1,152 @@ +From 2c3ebb2ae08a634615e56303d784ddb366e47f04 Mon Sep 17 00:00:00 2001 +From: heminhong +Date: Thu, 16 Nov 2023 11:13:08 +0800 +Subject: [PATCH] iproute2: prevent memory leak + +When the return value of rtnl_talk() is not less than 0, +'answer' will be allocated. The 'answer' should be free +after using, otherwise it will cause memory leak. +Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=2c3ebb2ae08a634615e56303d784ddb366e47f04 + +Fixes: a066cc6623e1 ("gre/gre6: Unify local/remote endpoint address parsing") +Signed-off-by: heminhong +Reviewed-by: Andrea Claudi +Signed-off-by: Stephen Hemminger +--- + ip/link_gre.c | 3 ++- + ip/link_gre6.c | 3 ++- + ip/link_ip6tnl.c | 3 ++- + ip/link_iptnl.c | 3 ++- + ip/link_vti.c | 3 ++- + ip/link_vti6.c | 3 ++- + 6 files changed, 12 insertions(+), 6 deletions(-) + +diff --git a/ip/link_gre.c b/ip/link_gre.c +index 74a5b5e9..6d71864c 100644 +--- a/ip/link_gre.c ++++ b/ip/link_gre.c +@@ -76,7 +76,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, + .i.ifi_family = preferred_family, + .i.ifi_index = ifi->ifi_index, + }; +- struct nlmsghdr *answer; ++ struct nlmsghdr *answer = NULL; + struct rtattr *tb[IFLA_MAX + 1]; + struct rtattr *linkinfo[IFLA_INFO_MAX+1]; + struct rtattr *greinfo[IFLA_GRE_MAX + 1]; +@@ -113,6 +113,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, + get_failed: + fprintf(stderr, + "Failed to get existing tunnel info.\n"); ++ free(answer); + return -1; + } + +diff --git a/ip/link_gre6.c b/ip/link_gre6.c +index b03bd65a..4d1c6574 100644 +--- a/ip/link_gre6.c ++++ b/ip/link_gre6.c +@@ -79,7 +79,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, + .i.ifi_family = preferred_family, + .i.ifi_index = ifi->ifi_index, + }; +- struct nlmsghdr *answer; ++ struct nlmsghdr *answer = NULL; + struct rtattr *tb[IFLA_MAX + 1]; + struct rtattr *linkinfo[IFLA_INFO_MAX+1]; + struct rtattr *greinfo[IFLA_GRE_MAX + 1]; +@@ -115,6 +115,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, + get_failed: + fprintf(stderr, + "Failed to get existing tunnel info.\n"); ++ free(answer); + return -1; + } + +diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c +index b27d696f..3a30dca9 100644 +--- a/ip/link_ip6tnl.c ++++ b/ip/link_ip6tnl.c +@@ -72,7 +72,7 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv, + .i.ifi_family = preferred_family, + .i.ifi_index = ifi->ifi_index, + }; +- struct nlmsghdr *answer; ++ struct nlmsghdr *answer = NULL; + struct rtattr *tb[IFLA_MAX + 1]; + struct rtattr *linkinfo[IFLA_INFO_MAX+1]; + struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1]; +@@ -101,6 +101,7 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv, + get_failed: + fprintf(stderr, + "Failed to get existing tunnel info.\n"); ++ free(answer); + return -1; + } + +diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c +index 1315aebe..879202f7 100644 +--- a/ip/link_iptnl.c ++++ b/ip/link_iptnl.c +@@ -73,7 +73,7 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv, + .i.ifi_family = preferred_family, + .i.ifi_index = ifi->ifi_index, + }; +- struct nlmsghdr *answer; ++ struct nlmsghdr *answer = NULL; + struct rtattr *tb[IFLA_MAX + 1]; + struct rtattr *linkinfo[IFLA_INFO_MAX+1]; + struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1]; +@@ -105,6 +105,7 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv, + get_failed: + fprintf(stderr, + "Failed to get existing tunnel info.\n"); ++ free(answer); + return -1; + } + +diff --git a/ip/link_vti.c b/ip/link_vti.c +index 50943254..7a95dc02 100644 +--- a/ip/link_vti.c ++++ b/ip/link_vti.c +@@ -48,7 +48,7 @@ static int vti_parse_opt(struct link_util *lu, int argc, char **argv, + .i.ifi_family = preferred_family, + .i.ifi_index = ifi->ifi_index, + }; +- struct nlmsghdr *answer; ++ struct nlmsghdr *answer = NULL; + struct rtattr *tb[IFLA_MAX + 1]; + struct rtattr *linkinfo[IFLA_INFO_MAX+1]; + struct rtattr *vtiinfo[IFLA_VTI_MAX + 1]; +@@ -69,6 +69,7 @@ static int vti_parse_opt(struct link_util *lu, int argc, char **argv, + get_failed: + fprintf(stderr, + "Failed to get existing tunnel info.\n"); ++ free(answer); + return -1; + } + +diff --git a/ip/link_vti6.c b/ip/link_vti6.c +index 5764221e..aaf701d3 100644 +--- a/ip/link_vti6.c ++++ b/ip/link_vti6.c +@@ -50,7 +50,7 @@ static int vti6_parse_opt(struct link_util *lu, int argc, char **argv, + .i.ifi_family = preferred_family, + .i.ifi_index = ifi->ifi_index, + }; +- struct nlmsghdr *answer; ++ struct nlmsghdr *answer = NULL; + struct rtattr *tb[IFLA_MAX + 1]; + struct rtattr *linkinfo[IFLA_INFO_MAX+1]; + struct rtattr *vtiinfo[IFLA_VTI_MAX + 1]; +@@ -71,6 +71,7 @@ static int vti6_parse_opt(struct link_util *lu, int argc, char **argv, + get_failed: + fprintf(stderr, + "Failed to get existing tunnel info.\n"); ++ free(answer); + return -1; + } + +-- +2.33.0 + diff --git a/backport-libnetlink-validate-nlmsg-header-length-first.patch b/backport-libnetlink-validate-nlmsg-header-length-first.patch new file mode 100644 index 0000000000000000000000000000000000000000..2f48ea47ef9ea2edef743e2e953a990437f70640 --- /dev/null +++ b/backport-libnetlink-validate-nlmsg-header-length-first.patch @@ -0,0 +1,43 @@ +From 78eebdbc7d2f96b01a18d7db33c1c99266efc4bc Mon Sep 17 00:00:00 2001 +From: Max Kunzelmann +Date: Tue, 7 Nov 2023 01:20:55 +0000 +Subject: [PATCH] libnetlink: validate nlmsg header length first + +Validate the nlmsg header length before accessing the nlmsg payload +length. +Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=78eebdbc7d2f96b01a18d7db33c1c99266efc4bc + +Fixes: 892a25e286fb ("libnetlink: break up dump function") + +Signed-off-by: Max Kunzelmann +Reviewed-by: Benny Baumann +Reviewed-by: Robert Geislinger +Signed-off-by: Stephen Hemminger +--- + lib/libnetlink.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/lib/libnetlink.c b/lib/libnetlink.c +index 7edcd285..01648229 100644 +--- a/lib/libnetlink.c ++++ b/lib/libnetlink.c +@@ -727,13 +727,15 @@ int rtnl_dump_request_n(struct rtnl_handle *rth, struct nlmsghdr *n) + static int rtnl_dump_done(struct nlmsghdr *h, + const struct rtnl_dump_filter_arg *a) + { +- int len = *(int *)NLMSG_DATA(h); ++ int len; + + if (h->nlmsg_len < NLMSG_LENGTH(sizeof(int))) { + fprintf(stderr, "DONE truncated\n"); + return -1; + } + ++ len = *(int *)NLMSG_DATA(h); ++ + if (len < 0) { + errno = -len; + +-- +2.33.0 + diff --git a/backport-lnstat-Fix-deref-of-null-in-print_json-function.patch b/backport-lnstat-Fix-deref-of-null-in-print_json-function.patch new file mode 100644 index 0000000000000000000000000000000000000000..b73f0d0f07af0539759eb72c4f186fb7cda22867 --- /dev/null +++ b/backport-lnstat-Fix-deref-of-null-in-print_json-function.patch @@ -0,0 +1,36 @@ +From a193733b7a7ef1e65e1b88045c32f96ed16caeb9 Mon Sep 17 00:00:00 2001 +From: Maks Mishin +Date: Sat, 6 Jan 2024 22:04:23 +0300 +Subject: [PATCH] lnstat: Fix deref of null in print_json() function + +Now pointer `jw` is being checked for NULL before using +in function `jsonw_start_object`. +Added exit from function when `jw==NULL`. + +Found by RASU JSC +Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=a193733b7a7ef1e65e1b88045c32f96ed16caeb9 + +Signed-off-by: Maks Mishin +Signed-off-by: Stephen Hemminger +--- + misc/lnstat.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/misc/lnstat.c b/misc/lnstat.c +index c3f2999c..f802a0f3 100644 +--- a/misc/lnstat.c ++++ b/misc/lnstat.c +@@ -112,6 +112,10 @@ static void print_json(FILE *of, const struct lnstat_file *lnstat_files, + json_writer_t *jw = jsonw_new(of); + int i; + ++ if (jw == NULL) { ++ fprintf(stderr, "Failed to create JSON writer\n"); ++ exit(1); ++ } + jsonw_start_object(jw); + for (i = 0; i < fp->num; i++) { + const struct lnstat_field *lf = fp->params[i].lf; +-- +2.33.0 + diff --git a/backport-mnl_utils-sanitize-incoming-netlink-payload-size-in-.patch b/backport-mnl_utils-sanitize-incoming-netlink-payload-size-in-.patch new file mode 100644 index 0000000000000000000000000000000000000000..a2ea2438f3d74c23e011650a00b19a164d39e1e6 --- /dev/null +++ b/backport-mnl_utils-sanitize-incoming-netlink-payload-size-in-.patch @@ -0,0 +1,52 @@ +From 1a68525f4613b4e02e83d4b8004f22ac7ecbfedf Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Thu, 7 Dec 2023 13:53:51 +0100 +Subject: [PATCH] mnl_utils: sanitize incoming netlink payload size in + callbacks + +Don't trust the kernel to send payload of certain size. Sanitize that by +checking the payload length in mnlu_cb_stop() and mnlu_cb_error() and +only access the payload if it is of required size. + +Note that for mnlu_cb_stop(), this is happening already for example +with devlink resource. Kernel sends NLMSG_DONE with zero size payload. +Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=1a68525f4613b4e02e83d4b8004f22ac7ecbfedf + +Fixes: 049c58539f5d ("devlink: mnlg: Add support for extended ack") +Fixes: c934da8aaacb ("devlink: mnlg: Catch returned error value of dumpit commands") +Signed-off-by: Jiri Pirko +Signed-off-by: Stephen Hemminger +Signed-off-by: cuiyudong +--- + lib/mnl_utils.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/lib/mnl_utils.c b/lib/mnl_utils.c +index 1c782228..af5aa4f9 100644 +--- a/lib/mnl_utils.c ++++ b/lib/mnl_utils.c +@@ -61,6 +61,8 @@ static int mnlu_cb_error(const struct nlmsghdr *nlh, void *data) + { + const struct nlmsgerr *err = mnl_nlmsg_get_payload(nlh); + ++ if (mnl_nlmsg_get_payload_len(nlh) < sizeof(*err)) ++ return MNL_CB_STOP; + /* Netlink subsystems returns the errno value with different signess */ + if (err->error < 0) + errno = -err->error; +@@ -75,8 +77,11 @@ static int mnlu_cb_error(const struct nlmsghdr *nlh, void *data) + + static int mnlu_cb_stop(const struct nlmsghdr *nlh, void *data) + { +- int len = *(int *)NLMSG_DATA(nlh); ++ int len; + ++ if (mnl_nlmsg_get_payload_len(nlh) < sizeof(len)) ++ return MNL_CB_STOP; ++ len = *(int *)mnl_nlmsg_get_payload(nlh); + if (len < 0) { + errno = -len; + nl_dump_ext_ack_done(nlh, len); +-- +2.33.0 + diff --git a/backport-tc-remove-tcindex-classifier.patch b/backport-tc-remove-tcindex-classifier.patch new file mode 100644 index 0000000000000000000000000000000000000000..04a53b355c7c4fbf3a0581a5fa0b0ddd858984b6 --- /dev/null +++ b/backport-tc-remove-tcindex-classifier.patch @@ -0,0 +1,1238 @@ +From bc0c1661eb229b77a65f8c5f305fd6fa56e9667f Mon Sep 17 00:00:00 2001 +From: Stephen Hemminger +Date: Mon, 30 Oct 2023 11:26:33 -0700 +Subject: [PATCH] tc: remove tcindex classifier + +Support for tcindex classifier was removed by upstream commit +8c710f75256b (net/sched: Retire tcindex classifier, 2023-02-14) +Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=bc0c1661eb229b77a65f8c5f305fd6fa56e9667f + +Signed-off-by: Stephen Hemminger +Signed-off-by: cuiyudong +--- + bash-completion/tc | 7 +- + man/man8/tc-tcindex.8 | 58 --- + man/man8/tc.8 | 915 ------------------------------------------ + tc/Makefile | 1 - + tc/f_tcindex.c | 185 --------- + 5 files changed, 1 insertion(+), 1165 deletions(-) + delete mode 100644 man/man8/tc-tcindex.8 + delete mode 100644 man/man8/tc.8 + delete mode 100644 tc/f_tcindex.c + +diff --git a/bash-completion/tc b/bash-completion/tc +index 086cb7f..dd7661d 100644 +--- a/bash-completion/tc ++++ b/bash-completion/tc +@@ -5,7 +5,7 @@ + QDISC_KIND=' choke codel bfifo pfifo pfifo_head_drop fq fq_codel gred hhf \ + mqprio multiq netem pfifo_fast pie fq_pie red rr sfb sfq tbf atm \ + cbq drr dsmark hfsc htb prio qfq ' +-FILTER_KIND=' basic bpf cgroup flow flower fw route rsvp tcindex u32 matchall ' ++FILTER_KIND=' basic bpf cgroup flow flower fw route rsvp u32 matchall ' + ACTION_KIND=' gact mirred bpf sample ' + + # Takes a list of words in argument; each one of them is added to COMPREPLY if +@@ -487,11 +487,6 @@ _tc_filter_options() + COMPREPLY+=( $( compgen -W 'at' -- "$cur" ) ) + return 0 + ;; +- tcindex) +- _tc_once_attr 'hash mask shift classid action' +- _tc_one_of_list 'pass_on fall_through' +- return 0 +- ;; + u32) + _tc_once_attr 'match link classid action offset ht hashkey sample' + COMPREPLY+=( $( compgen -W 'ip ip6 udp tcp icmp u8 u16 u32 mark \ +diff --git a/man/man8/tc-tcindex.8 b/man/man8/tc-tcindex.8 +deleted file mode 100644 +index 9a4e5ff..0000000 +--- a/man/man8/tc-tcindex.8 ++++ /dev/null +@@ -1,58 +0,0 @@ +-.TH "Traffic control index filter" 8 "21 Oct 2015" "iproute2" "Linux" +- +-.SH NAME +-tcindex \- traffic control index filter +-.SH SYNOPSIS +-.in +8 +-.ti -8 +-.BR tc " " filter " ... " tcindex " [ " hash +-.IR SIZE " ] [ " +-.B mask +-.IR MASK " ] [ " +-.B shift +-.IR SHIFT " ] [ " +-.BR pass_on " | " fall_through " ] [ " classid +-.IR CLASSID " ] [ " +-.B action +-.BR ACTION_SPEC " ]" +-.SH DESCRIPTION +-This filter allows to match packets based on their +-.B tcindex +-field value, i.e. the combination of the DSCP and ECN fields as present in IPv4 +-and IPv6 headers. +-.SH OPTIONS +-.TP +-.BI action " ACTION_SPEC" +-Apply an action from the generic actions framework on matching packets. +-.TP +-.BI classid " CLASSID" +-Push matching packets into the class identified by +-.IR CLASSID . +-.TP +-.BI hash " SIZE" +-Hash table size in entries to use. Defaults to 64. +-.TP +-.BI mask " MASK" +-An optional bitmask to binary +-.BR AND " to the packet's " tcindex +-field before use. +-.TP +-.BI shift " SHIFT" +-The number of bits to right-shift a packet's +-.B tcindex +-value before use. If a +-.B mask +-has been set, masking is done before shifting. +-.TP +-.B pass_on +-If this flag is set, failure to find a class for the resulting ID will make the +-filter fail and lead to the next filter being consulted. +-.TP +-.B fall_through +-This is the opposite of +-.B pass_on +-and the default. The filter will classify the packet even if there is no class +-present for the resulting class ID. +- +-.SH SEE ALSO +-.BR tc (8) +diff --git a/man/man8/tc.8 b/man/man8/tc.8 +deleted file mode 100644 +index 4338572..0000000 +--- a/man/man8/tc.8 ++++ /dev/null +@@ -1,915 +0,0 @@ +-.TH TC 8 "16 December 2001" "iproute2" "Linux" +-.SH NAME +-tc \- show / manipulate traffic control settings +-.SH SYNOPSIS +-.B tc +-.RI "[ " OPTIONS " ]" +-.B qdisc [ add | change | replace | link | delete ] dev +-\fIDEV\fR +-.B +-[ parent +-\fIqdisc-id\fR +-.B | root ] +-.B [ handle +-\fIqdisc-id\fR ] +-.B [ ingress_block +-\fIBLOCK_INDEX\fR ] +-.B [ egress_block +-\fIBLOCK_INDEX\fR ] qdisc +-[ qdisc specific parameters ] +-.P +- +-.B tc +-.RI "[ " OPTIONS " ]" +-.B class [ add | change | replace | delete ] dev +-\fIDEV\fR +-.B parent +-\fIqdisc-id\fR +-.B [ classid +-\fIclass-id\fR ] qdisc +-[ qdisc specific parameters ] +-.P +- +-.B tc +-.RI "[ " OPTIONS " ]" +-.B filter [ add | change | replace | delete | get ] dev +-\fIDEV\fR +-.B [ parent +-\fIqdisc-id\fR +-.B | root ] [ handle \fIfilter-id\fR ] +-.B protocol +-\fIprotocol\fR +-.B prio +-\fIpriority\fR filtertype +-[ filtertype specific parameters ] +-.B flowid +-\fIflow-id\fR +- +-.B tc +-.RI "[ " OPTIONS " ]" +-.B filter [ add | change | replace | delete | get ] block +-\fIBLOCK_INDEX\fR +-.B [ handle \fIfilter-id\fR ] +-.B protocol +-\fIprotocol\fR +-.B prio +-\fIpriority\fR filtertype +-[ filtertype specific parameters ] +-.B flowid +-\fIflow-id\fR +- +-.B tc +-.RI "[ " OPTIONS " ]" +-.B chain [ add | delete | get ] dev +-\fIDEV\fR +-.B [ parent +-\fIqdisc-id\fR +-.B | root ]\fR filtertype +-[ filtertype specific parameters ] +- +-.B tc +-.RI "[ " OPTIONS " ]" +-.B chain [ add | delete | get ] block +-\fIBLOCK_INDEX\fR filtertype +-[ filtertype specific parameters ] +- +- +-.B tc +-.RI "[ " OPTIONS " ]" +-.RI "[ " FORMAT " ]" +-.B qdisc { show | list } [ dev +-\fIDEV\fR +-.B ] [ root | ingress | handle +-\fIQHANDLE\fR +-.B | parent +-\fICLASSID\fR +-.B ] [ invisible ] +-.P +-.B tc +-.RI "[ " OPTIONS " ]" +-.RI "[ " FORMAT " ]" +-.B class show dev +-\fIDEV\fR +-.P +-.B tc +-.RI "[ " OPTIONS " ]" +-.B filter show dev +-\fIDEV\fR +-.P +-.B tc +-.RI "[ " OPTIONS " ]" +-.B filter show block +-\fIBLOCK_INDEX\fR +-.P +-.B tc +-.RI "[ " OPTIONS " ]" +-.B chain show dev +-\fIDEV\fR +-.P +-.B tc +-.RI "[ " OPTIONS " ]" +-.B chain show block +-\fIBLOCK_INDEX\fR +- +-.P +-.B tc +-.RI "[ " OPTIONS " ]" +-.B monitor [ file +-\fIFILENAME\fR +-.B ] +- +-.P +-.ti 8 +-.IR OPTIONS " := {" +-\fB[ -force ] -b\fR[\fIatch\fR] \fB[ filename ] \fR| +-\fB[ \fB-n\fR[\fIetns\fR] name \fB] \fR| +-\fB[ \fB-N\fR[\fIumeric\fR] \fB] \fR| +-\fB[ \fB-nm \fR| \fB-nam\fR[\fIes\fR] \fB] \fR| +-\fB[ \fR{ \fB-cf \fR| \fB-c\fR[\fIonf\fR] \fR} \fB[ filename ] \fB] \fR +-\fB[ -t\fR[imestamp\fR] \fB\] \fR| \fB[ -t\fR[short\fR] \fR| \fB[ +--o\fR[neline\fR] \fB]\fR } +- +-.ti 8 +-.IR FORMAT " := {" +-\fB\-s\fR[\fItatistics\fR] | +-\fB\-d\fR[\fIetails\fR] | +-\fB\-r\fR[\fIaw\fR] | +-\fB\-i\fR[\fIec\fR] | +-\fB\-g\fR[\fIraph\fR] | +-\fB\-j\fR[\fIjson\fR] | +-\fB\-p\fR[\fIretty\fR] | +-\fB\-col\fR[\fIor\fR] } +- +-.SH DESCRIPTION +-.B Tc +-is used to configure Traffic Control in the Linux kernel. Traffic Control consists +-of the following: +- +-.TP +-SHAPING +-When traffic is shaped, its rate of transmission is under control. Shaping may +-be more than lowering the available bandwidth - it is also used to smooth out +-bursts in traffic for better network behaviour. Shaping occurs on egress. +- +-.TP +-SCHEDULING +-By scheduling the transmission of packets it is possible to improve interactivity +-for traffic that needs it while still guaranteeing bandwidth to bulk transfers. Reordering +-is also called prioritizing, and happens only on egress. +- +-.TP +-POLICING +-Whereas shaping deals with transmission of traffic, policing pertains to traffic +-arriving. Policing thus occurs on ingress. +- +-.TP +-DROPPING +-Traffic exceeding a set bandwidth may also be dropped forthwith, both on +-ingress and on egress. +- +-.P +-Processing of traffic is controlled by three kinds of objects: qdiscs, +-classes and filters. +- +-.SH QDISCS +-.B qdisc +-is short for 'queueing discipline' and it is elementary to +-understanding traffic control. Whenever the kernel needs to send a +-packet to an interface, it is +-.B enqueued +-to the qdisc configured for that interface. Immediately afterwards, the kernel +-tries to get as many packets as possible from the qdisc, for giving them +-to the network adaptor driver. +- +-A simple QDISC is the 'pfifo' one, which does no processing at all and is a pure +-First In, First Out queue. It does however store traffic when the network interface +-can't handle it momentarily. +- +-.SH CLASSES +-Some qdiscs can contain classes, which contain further qdiscs - traffic may +-then be enqueued in any of the inner qdiscs, which are within the +-.B classes. +-When the kernel tries to dequeue a packet from such a +-.B classful qdisc +-it can come from any of the classes. A qdisc may for example prioritize +-certain kinds of traffic by trying to dequeue from certain classes +-before others. +- +-.SH FILTERS +-A +-.B filter +-is used by a classful qdisc to determine in which class a packet will +-be enqueued. Whenever traffic arrives at a class with subclasses, it needs +-to be classified. Various methods may be employed to do so, one of these +-are the filters. All filters attached to the class are called, until one of +-them returns with a verdict. If no verdict was made, other criteria may be +-available. This differs per qdisc. +- +-It is important to notice that filters reside +-.B within +-qdiscs - they are not masters of what happens. +- +-The available filters are: +-.TP +-basic +-Filter packets based on an ematch expression. See +-.BR tc-ematch (8) +-for details. +-.TP +-bpf +-Filter packets using (e)BPF, see +-.BR tc-bpf (8) +-for details. +-.TP +-cgroup +-Filter packets based on the control group of their process. See +-. BR tc-cgroup (8) +-for details. +-.TP +-flow, flower +-Flow-based classifiers, filtering packets based on their flow (identified by selectable keys). See +-.BR tc-flow "(8) and" +-.BR tc-flower (8) +-for details. +-.TP +-fw +-Filter based on fwmark. Directly maps fwmark value to traffic class. See +-.BR tc-fw (8). +-.TP +-route +-Filter packets based on routing table. See +-.BR tc-route (8) +-for details. +-.TP +-rsvp +-Match Resource Reservation Protocol (RSVP) packets. +-.TP +-tcindex +-Filter packets based on traffic control index. See +-.BR tc-tcindex (8). +-.TP +-u32 +-Generic filtering on arbitrary packet data, assisted by syntax to abstract common operations. See +-.BR tc-u32 (8) +-for details. +-.TP +-matchall +-Traffic control filter that matches every packet. See +-.BR tc-matchall (8) +-for details. +- +-.SH QEVENTS +-Qdiscs may invoke user-configured actions when certain interesting events +-take place in the qdisc. Each qevent can either be unused, or can have a +-block attached to it. To this block are then attached filters using the "tc +-block BLOCK_IDX" syntax. The block is executed when the qevent associated +-with the attachment point takes place. For example, packet could be +-dropped, or delayed, etc., depending on the qdisc and the qevent in +-question. +- +-For example: +-.PP +-.RS +-tc qdisc add dev eth0 root handle 1: red limit 500K avpkt 1K \\ +- qevent early_drop block 10 +-.RE +-.RS +-tc filter add block 10 matchall action mirred egress mirror dev eth1 +-.RE +- +-.SH CLASSLESS QDISCS +-The classless qdiscs are: +-.TP +-choke +-CHOKe (CHOose and Keep for responsive flows, CHOose and Kill for unresponsive +-flows) is a classless qdisc designed to both identify and penalize flows that +-monopolize the queue. CHOKe is a variation of RED, and the configuration is +-similar to RED. +-.TP +-codel +-CoDel (pronounced "coddle") is an adaptive "no-knobs" active queue management +-algorithm (AQM) scheme that was developed to address the shortcomings of +-RED and its variants. +-.TP +-[p|b]fifo +-Simplest usable qdisc, pure First In, First Out behaviour. Limited in +-packets or in bytes. +-.TP +-fq +-Fair Queue Scheduler realises TCP pacing and scales to millions of concurrent +-flows per qdisc. +-.TP +-fq_codel +-Fair Queuing Controlled Delay is queuing discipline that combines Fair +-Queuing with the CoDel AQM scheme. FQ_Codel uses a stochastic model to classify +-incoming packets into different flows and is used to provide a fair share of the +-bandwidth to all the flows using the queue. Each such flow is managed by the +-CoDel queuing discipline. Reordering within a flow is avoided since Codel +-internally uses a FIFO queue. +-.TP +-fq_pie +-FQ-PIE (Flow Queuing with Proportional Integral controller Enhanced) is a +-queuing discipline that combines Flow Queuing with the PIE AQM scheme. FQ-PIE +-uses a Jenkins hash function to classify incoming packets into different flows +-and is used to provide a fair share of the bandwidth to all the flows using the +-qdisc. Each such flow is managed by the PIE algorithm. +-.TP +-gred +-Generalized Random Early Detection combines multiple RED queues in order to +-achieve multiple drop priorities. This is required to realize Assured +-Forwarding (RFC 2597). +-.TP +-hhf +-Heavy-Hitter Filter differentiates between small flows and the opposite, +-heavy-hitters. The goal is to catch the heavy-hitters and move them to a +-separate queue with less priority so that bulk traffic does not affect the +-latency of critical traffic. +-.TP +-ingress +-This is a special qdisc as it applies to incoming traffic on an interface, allowing for it to be filtered and policed. +-.TP +-mqprio +-The Multiqueue Priority Qdisc is a simple queuing discipline that allows +-mapping traffic flows to hardware queue ranges using priorities and a +-configurable priority to traffic class mapping. A traffic class in this context +-is a set of contiguous qdisc classes which map 1:1 to a set of hardware exposed +-queues. +-.TP +-multiq +-Multiqueue is a qdisc optimized for devices with multiple Tx queues. It has +-been added for hardware that wishes to avoid head-of-line blocking. It will +-cycle though the bands and verify that the hardware queue associated with the +-band is not stopped prior to dequeuing a packet. +-.TP +-netem +-Network Emulator is an enhancement of the Linux traffic control facilities that +-allow to add delay, packet loss, duplication and more other characteristics to +-packets outgoing from a selected network interface. +-.TP +-pfifo_fast +-Standard qdisc for 'Advanced Router' enabled kernels. Consists of a three-band +-queue which honors Type of Service flags, as well as the priority that may be +-assigned to a packet. +-.TP +-pie +-Proportional Integral controller-Enhanced (PIE) is a control theoretic active +-queue management scheme. It is based on the proportional integral controller but +-aims to control delay. +-.TP +-red +-Random Early Detection simulates physical congestion by randomly dropping +-packets when nearing configured bandwidth allocation. Well suited to very +-large bandwidth applications. +-.TP +-rr +-Round-Robin qdisc with support for multiqueue network devices. Removed from +-Linux since kernel version 2.6.27. +-.TP +-sfb +-Stochastic Fair Blue is a classless qdisc to manage congestion based on +-packet loss and link utilization history while trying to prevent +-non-responsive flows (i.e. flows that do not react to congestion marking +-or dropped packets) from impacting performance of responsive flows. +-Unlike RED, where the marking probability has to be configured, BLUE +-tries to determine the ideal marking probability automatically. +-.TP +-sfq +-Stochastic Fairness Queueing reorders queued traffic so each 'session' +-gets to send a packet in turn. +-.TP +-tbf +-The Token Bucket Filter is suited for slowing traffic down to a precisely +-configured rate. Scales well to large bandwidths. +-.SH CONFIGURING CLASSLESS QDISCS +-In the absence of classful qdiscs, classless qdiscs can only be attached at +-the root of a device. Full syntax: +-.P +-.B tc qdisc add dev +-\fIDEV\fR +-.B root +-QDISC QDISC-PARAMETERS +- +-To remove, issue +-.P +-.B tc qdisc del dev +-\fIDEV\fR +-.B root +- +-The +-.B pfifo_fast +-qdisc is the automatic default in the absence of a configured qdisc. +- +-.SH CLASSFUL QDISCS +-The classful qdiscs are: +-.TP +-ATM +-Map flows to virtual circuits of an underlying asynchronous transfer mode +-device. +-.TP +-CBQ +-Class Based Queueing implements a rich linksharing hierarchy of classes. +-It contains shaping elements as well as prioritizing capabilities. Shaping is +-performed using link idle time calculations based on average packet size and +-underlying link bandwidth. The latter may be ill-defined for some interfaces. +-.TP +-DRR +-The Deficit Round Robin Scheduler is a more flexible replacement for Stochastic +-Fairness Queuing. Unlike SFQ, there are no built-in queues \-\- you need to add +-classes and then set up filters to classify packets accordingly. This can be +-useful e.g. for using RED qdiscs with different settings for particular +-traffic. There is no default class \-\- if a packet cannot be classified, it is +-dropped. +-.TP +-DSMARK +-Classify packets based on TOS field, change TOS field of packets based on +-classification. +-.TP +-ETS +-The ETS qdisc is a queuing discipline that merges functionality of PRIO and DRR +-qdiscs in one scheduler. ETS makes it easy to configure a set of strict and +-bandwidth-sharing bands to implement the transmission selection described in +-802.1Qaz. +-.TP +-HFSC +-Hierarchical Fair Service Curve guarantees precise bandwidth and delay allocation for leaf classes and allocates excess bandwidth fairly. Unlike HTB, it makes use of packet dropping to achieve low delays which interactive sessions benefit from. +-.TP +-HTB +-The Hierarchy Token Bucket implements a rich linksharing hierarchy of +-classes with an emphasis on conforming to existing practices. HTB facilitates +-guaranteeing bandwidth to classes, while also allowing specification of upper +-limits to inter-class sharing. It contains shaping elements, based on TBF and +-can prioritize classes. +-.TP +-PRIO +-The PRIO qdisc is a non-shaping container for a configurable number of +-classes which are dequeued in order. This allows for easy prioritization +-of traffic, where lower classes are only able to send if higher ones have +-no packets available. To facilitate configuration, Type Of Service bits are +-honored by default. +-.TP +-QFQ +-Quick Fair Queueing is an O(1) scheduler that provides near-optimal guarantees, +-and is the first to achieve that goal with a constant cost also with respect to +-the number of groups and the packet length. The QFQ algorithm has no loops, and +-uses very simple instructions and data structures that lend themselves very +-well to a hardware implementation. +-.SH THEORY OF OPERATION +-Classes form a tree, where each class has a single parent. +-A class may have multiple children. Some qdiscs allow for runtime addition +-of classes (CBQ, HTB) while others (PRIO) are created with a static number of +-children. +- +-Qdiscs which allow dynamic addition of classes can have zero or more +-subclasses to which traffic may be enqueued. +- +-Furthermore, each class contains a +-.B leaf qdisc +-which by default has +-.B pfifo +-behaviour, although another qdisc can be attached in place. This qdisc may again +-contain classes, but each class can have only one leaf qdisc. +- +-When a packet enters a classful qdisc it can be +-.B classified +-to one of the classes within. Three criteria are available, although not all +-qdiscs will use all three: +-.TP +-tc filters +-If tc filters are attached to a class, they are consulted first +-for relevant instructions. Filters can match on all fields of a packet header, +-as well as on the firewall mark applied by iptables. +-.TP +-Type of Service +-Some qdiscs have built in rules for classifying packets based on the TOS field. +-.TP +-skb->priority +-Userspace programs can encode a \fIclass-id\fR in the 'skb->priority' field using +-the SO_PRIORITY option. +-.P +-Each node within the tree can have its own filters but higher level filters +-may also point directly to lower classes. +- +-If classification did not succeed, packets are enqueued to the leaf qdisc +-attached to that class. Check qdisc specific manpages for details, however. +- +-.SH NAMING +-All qdiscs, classes and filters have IDs, which can either be specified +-or be automatically assigned. +- +-IDs consist of a +-.BR major " number and a " minor +-number, separated by a colon - +-.BR major ":" minor "." +-Both +-.BR major " and " minor +-are hexadecimal numbers and are limited to 16 bits. There are two special +-values: root is signified by +-.BR major " and " minor +-of all ones, and unspecified is all zeros. +- +-.TP +-QDISCS +-A qdisc, which potentially can have children, gets assigned a +-.B major +-number, called a 'handle', leaving the +-.B minor +-number namespace available for classes. The handle is expressed as '10:'. +-It is customary to explicitly assign a handle to qdiscs expected to have children. +- +-.TP +-CLASSES +-Classes residing under a qdisc share their qdisc +-.B major +-number, but each have a separate +-.B minor +-number called a 'classid' that has no relation to their +-parent classes, only to their parent qdisc. The same naming custom as for +-qdiscs applies. +- +-.TP +-FILTERS +-Filters have a three part ID, which is only needed when using a hashed +-filter hierarchy. +- +-.SH PARAMETERS +-The following parameters are widely used in TC. For other parameters, +-see the man pages for individual qdiscs. +- +-.TP +-RATES +-Bandwidths or rates. +-These parameters accept a floating point number, possibly followed by +-either a unit (both SI and IEC units supported), or a float followed by a '%' +-character to specify the rate as a percentage of the device's speed +-(e.g. 5%, 99.5%). Warning: specifying the rate as a percentage means a fraction +-of the current speed; if the speed changes, the value will not be recalculated. +-.RS +-.TP +-bit or a bare number +-Bits per second +-.TP +-kbit +-Kilobits per second +-.TP +-mbit +-Megabits per second +-.TP +-gbit +-Gigabits per second +-.TP +-tbit +-Terabits per second +-.TP +-bps +-Bytes per second +-.TP +-kbps +-Kilobytes per second +-.TP +-mbps +-Megabytes per second +-.TP +-gbps +-Gigabytes per second +-.TP +-tbps +-Terabytes per second +- +-.P +-To specify in IEC units, replace the SI prefix (k-, m-, g-, t-) with +-IEC prefix (ki-, mi-, gi- and ti-) respectively. +- +-.P +-TC store rates as a 32-bit unsigned integer in bps internally, +-so we can specify a max rate of 4294967295 bps. +-.RE +- +-.TP +-TIMES +-Length of time. Can be specified as a floating point number +-followed by an optional unit: +-.RS +-.TP +-s, sec or secs +-Whole seconds +-.TP +-ms, msec or msecs +-Milliseconds +-.TP +-us, usec, usecs or a bare number +-Microseconds. +- +-.P +-TC defined its own time unit (equal to microsecond) and stores +-time values as 32-bit unsigned integer, thus we can specify a max time value +-of 4294967295 usecs. +-.RE +- +-.TP +-SIZES +-Amounts of data. Can be specified as a floating point number +-followed by an optional unit: +-.RS +-.TP +-b or a bare number +-Bytes. +-.TP +-kbit +-Kilobits +-.TP +-kb or k +-Kilobytes +-.TP +-mbit +-Megabits +-.TP +-mb or m +-Megabytes +-.TP +-gbit +-Gigabits +-.TP +-gb or g +-Gigabytes +- +-.P +-TC stores sizes internally as 32-bit unsigned integer in byte, +-so we can specify a max size of 4294967295 bytes. +-.RE +- +-.TP +-VALUES +-Other values without a unit. +-These parameters are interpreted as decimal by default, but you can +-indicate TC to interpret them as octal and hexadecimal by adding a '0' +-or '0x' prefix respectively. +- +-.SH TC COMMANDS +-The following commands are available for qdiscs, classes and filter: +-.TP +-add +-Add a qdisc, class or filter to a node. For all entities, a +-.B parent +-must be passed, either by passing its ID or by attaching directly to the root of a device. +-When creating a qdisc or a filter, it can be named with the +-.B handle +-parameter. A class is named with the +-.B \fBclassid\fR +-parameter. +- +-.TP +-delete +-A qdisc can be deleted by specifying its handle, which may also be 'root'. All subclasses and their leaf qdiscs +-are automatically deleted, as well as any filters attached to them. +- +-.TP +-change +-Some entities can be modified 'in place'. Shares the syntax of 'add', with the exception +-that the handle cannot be changed and neither can the parent. In other words, +-.B +-change +-cannot move a node. +- +-.TP +-replace +-Performs a nearly atomic remove/add on an existing node id. If the node does not exist yet +-it is created. +- +-.TP +-get +-Displays a single filter given the interface \fIDEV\fR, \fIqdisc-id\fR, +-\fIpriority\fR, \fIprotocol\fR and \fIfilter-id\fR. +- +-.TP +-show +-Displays all filters attached to the given interface. A valid parent ID must be passed. +- +-.TP +-link +-Only available for qdiscs and performs a replace where the node +-must exist already. +- +-.SH MONITOR +-The\fB\ tc\fR\ utility can monitor events generated by the kernel such as +-adding/deleting qdiscs, filters or actions, or modifying existing ones. +- +-The following command is available for\fB\ monitor\fR\ : +-.TP +-\fBfile\fR +-If the file option is given, the \fBtc\fR does not listen to kernel events, but opens +-the given file and dumps its contents. The file has to be in binary +-format and contain netlink messages. +- +-.SH OPTIONS +- +-.TP +-.BR "\-b", " \-b filename", " \-batch", " \-batch filename" +-read commands from provided file or standard input and invoke them. +-First failure will cause termination of tc. +- +-.TP +-.BR "\-force" +-don't terminate tc on errors in batch mode. +-If there were any errors during execution of the commands, the application return code will be non zero. +- +-.TP +-.BR "\-o" , " \-oneline" +-output each record on a single line, replacing line feeds +-with the +-.B '\e' +-character. This is convenient when you want to count records +-with +-.BR wc (1) +-or to +-.BR grep (1) +-the output. +- +-.TP +-.BR "\-n" , " \-net" , " \-netns " +-switches +-.B tc +-to the specified network namespace +-.IR NETNS . +-Actually it just simplifies executing of: +- +-.B ip netns exec +-.IR NETNS +-.B tc +-.RI "[ " OPTIONS " ] " OBJECT " { " COMMAND " | " +-.BR help " }" +- +-to +- +-.B tc +-.RI "-n[etns] " NETNS " [ " OPTIONS " ] " OBJECT " { " COMMAND " | " +-.BR help " }" +- +-.TP +-.BR "\-N" , " \-Numeric" +-Print the number of protocol, scope, dsfield, etc directly instead of +-converting it to human readable name. +- +-.TP +-.BR "\-cf" , " \-conf " +-specifies path to the config file. This option is used in conjunction with other options (e.g. +-.BR -nm ")." +- +-.TP +-.BR "\-t", " \-timestamp" +-When\fB\ tc monitor\fR\ runs, print timestamp before the event message in format: +- Timestamp:
usec +- +-.TP +-.BR "\-ts", " \-tshort" +-When\fB\ tc monitor\fR\ runs, prints short timestamp before the event message in format: +- [--
T.] +- +-.SH FORMAT +-The show command has additional formatting options: +- +-.TP +-.BR "\-s" , " \-stats", " \-statistics" +-output more statistics about packet usage. +- +-.TP +-.BR "\-d", " \-details" +-output more detailed information about rates and cell sizes. +- +-.TP +-.BR "\-r", " \-raw" +-output raw hex values for handles. +- +-.TP +-.BR "\-p", " \-pretty" +-for u32 filter, decode offset and mask values to equivalent filter commands based on TCP/IP. +-In JSON output, add whitespace to improve readability. +- +-.TP +-.BR "\-iec" +-print rates in IEC units (ie. 1K = 1024). +- +-.TP +-.BR "\-g", " \-graph" +-shows classes as ASCII graph. Prints generic stats info under each class if +-.BR "-s" +-option was specified. Classes can be filtered only by +-.BR "dev" +-option. +- +-.TP +-.BR \-c [ color ][ = { always | auto | never } +-Configure color output. If parameter is omitted or +-.BR always , +-color output is enabled regardless of stdout state. If parameter is +-.BR auto , +-stdout is checked to be a terminal before enabling color output. If parameter is +-.BR never , +-color output is disabled. If specified multiple times, the last one takes +-precedence. This flag is ignored if +-.B \-json +-is also given. +- +-.TP +-.BR "\-j", " \-json" +-Display results in JSON format. +- +-.TP +-.BR "\-nm" , " \-name" +-resolve class name from +-.B /etc/iproute2/tc_cls +-file or from file specified by +-.B -cf +-option. This file is just a mapping of +-.B classid +-to class name: +- +-.RS 10 +-# Here is comment +-.RE +-.RS 10 +-1:40 voip # Here is another comment +-.RE +-.RS 10 +-1:50 web +-.RE +-.RS 10 +-1:60 ftp +-.RE +-.RS 10 +-1:2 home +-.RE +- +-.RS +-.B tc +-will not fail if +-.B -nm +-was specified without +-.B -cf +-option but +-.B /etc/iproute2/tc_cls +-file does not exist, which makes it possible to pass +-.B -nm +-option for creating +-.B tc +-alias. +-.RE +- +-.TP +-.BR "\-br" , " \-brief" +-Print only essential data needed to identify the filter and action (handle, +-cookie, etc.) and stats. This option is currently only supported by +-.BR "tc filter show " and " tc actions ls " commands. +- +-.SH "EXAMPLES" +-.PP +-tc -g class show dev eth0 +-.RS 4 +-Shows classes as ASCII graph on eth0 interface. +-.RE +-.PP +-tc -g -s class show dev eth0 +-.RS 4 +-Shows classes as ASCII graph with stats info under each class. +-.RE +- +-.SH HISTORY +-.B tc +-was written by Alexey N. Kuznetsov and added in Linux 2.2. +-.SH SEE ALSO +-.BR tc-basic (8), +-.BR tc-bfifo (8), +-.BR tc-bpf (8), +-.BR tc-cake (8), +-.BR tc-cbq (8), +-.BR tc-cgroup (8), +-.BR tc-choke (8), +-.BR tc-codel (8), +-.BR tc-drr (8), +-.BR tc-ematch (8), +-.BR tc-ets (8), +-.BR tc-flow (8), +-.BR tc-flower (8), +-.BR tc-fq (8), +-.BR tc-fq_codel (8), +-.BR tc-fq_pie (8), +-.BR tc-fw (8), +-.BR tc-hfsc (7), +-.BR tc-hfsc (8), +-.BR tc-htb (8), +-.BR tc-mqprio (8), +-.BR tc-pfifo (8), +-.BR tc-pfifo_fast (8), +-.BR tc-pie (8), +-.BR tc-red (8), +-.BR tc-route (8), +-.BR tc-sfb (8), +-.BR tc-sfq (8), +-.BR tc-stab (8), +-.BR tc-tbf (8), +-.BR tc-tcindex (8), +-.BR tc-u32 (8), +-.br +-.RB "User documentation at " http://lartc.org/ ", but please direct bugreports and patches to: " +- +-.SH AUTHOR +-Manpage maintained by bert hubert (ahu@ds9a.nl) +diff --git a/tc/Makefile b/tc/Makefile +index 5a517af..18f7326 100644 +--- a/tc/Makefile ++++ b/tc/Makefile +@@ -31,7 +31,6 @@ TCMODULES += f_cgroup.o + TCMODULES += f_flower.o + TCMODULES += q_dsmark.o + TCMODULES += q_gred.o +-TCMODULES += f_tcindex.o + TCMODULES += q_ingress.o + TCMODULES += q_hfsc.o + TCMODULES += q_htb.o +diff --git a/tc/f_tcindex.c b/tc/f_tcindex.c +deleted file mode 100644 +index ae4cbf1..0000000 +--- a/tc/f_tcindex.c ++++ /dev/null +@@ -1,185 +0,0 @@ +-/* SPDX-License-Identifier: GPL-2.0 */ +-/* +- * f_tcindex.c Traffic control index filter +- * +- * Written 1998,1999 by Werner Almesberger +- */ +- +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include "utils.h" +-#include "tc_util.h" +- +-static void explain(void) +-{ +- fprintf(stderr, +- " Usage: ... tcindex [ hash SIZE ] [ mask MASK ] [ shift SHIFT ]\n" +- " [ pass_on | fall_through ]\n" +- " [ classid CLASSID ] [ action ACTION_SPEC ]\n"); +-} +- +-static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc, +- char **argv, struct nlmsghdr *n) +-{ +- struct tcmsg *t = NLMSG_DATA(n); +- struct rtattr *tail; +- char *end; +- +- if (handle) { +- t->tcm_handle = strtoul(handle, &end, 0); +- if (*end) { +- fprintf(stderr, "Illegal filter ID\n"); +- return -1; +- } +- } +- if (!argc) return 0; +- tail = addattr_nest(n, 4096, TCA_OPTIONS); +- while (argc) { +- if (!strcmp(*argv, "hash")) { +- int hash; +- +- NEXT_ARG(); +- hash = strtoul(*argv, &end, 0); +- if (*end || !hash || hash > 0x10000) { +- explain(); +- return -1; +- } +- addattr_l(n, 4096, TCA_TCINDEX_HASH, &hash, +- sizeof(hash)); +- } else if (!strcmp(*argv,"mask")) { +- __u16 mask; +- +- NEXT_ARG(); +- mask = strtoul(*argv, &end, 0); +- if (*end) { +- explain(); +- return -1; +- } +- addattr_l(n, 4096, TCA_TCINDEX_MASK, &mask, +- sizeof(mask)); +- } else if (!strcmp(*argv,"shift")) { +- int shift; +- +- NEXT_ARG(); +- shift = strtoul(*argv, &end, 0); +- if (*end) { +- explain(); +- return -1; +- } +- addattr_l(n, 4096, TCA_TCINDEX_SHIFT, &shift, +- sizeof(shift)); +- } else if (!strcmp(*argv,"fall_through")) { +- int value = 1; +- +- addattr_l(n, 4096, TCA_TCINDEX_FALL_THROUGH, &value, +- sizeof(value)); +- } else if (!strcmp(*argv,"pass_on")) { +- int value = 0; +- +- addattr_l(n, 4096, TCA_TCINDEX_FALL_THROUGH, &value, +- sizeof(value)); +- } else if (!strcmp(*argv,"classid")) { +- __u32 handle; +- +- NEXT_ARG(); +- if (get_tc_classid(&handle, *argv)) { +- fprintf(stderr, "Illegal \"classid\"\n"); +- return -1; +- } +- addattr_l(n, 4096, TCA_TCINDEX_CLASSID, &handle, 4); +- } else if (!strcmp(*argv,"police")) { +- NEXT_ARG(); +- if (parse_police(&argc, &argv, TCA_TCINDEX_POLICE, n)) { +- fprintf(stderr, "Illegal \"police\"\n"); +- return -1; +- } +- continue; +- } else if (!strcmp(*argv,"action")) { +- NEXT_ARG(); +- if (parse_action(&argc, &argv, TCA_TCINDEX_ACT, n)) { +- fprintf(stderr, "Illegal \"action\"\n"); +- return -1; +- } +- continue; +- } else { +- explain(); +- return -1; +- } +- argc--; +- argv++; +- } +- addattr_nest_end(n, tail); +- return 0; +-} +- +- +-static int tcindex_print_opt(struct filter_util *qu, FILE *f, +- struct rtattr *opt, __u32 handle) +-{ +- struct rtattr *tb[TCA_TCINDEX_MAX+1]; +- +- if (opt == NULL) +- return 0; +- +- parse_rtattr_nested(tb, TCA_TCINDEX_MAX, opt); +- +- if (handle != ~0) fprintf(f, "handle 0x%04x ", handle); +- if (tb[TCA_TCINDEX_HASH]) { +- __u16 hash; +- +- if (RTA_PAYLOAD(tb[TCA_TCINDEX_HASH]) < sizeof(hash)) +- return -1; +- hash = rta_getattr_u16(tb[TCA_TCINDEX_HASH]); +- fprintf(f, "hash %d ", hash); +- } +- if (tb[TCA_TCINDEX_MASK]) { +- __u16 mask; +- +- if (RTA_PAYLOAD(tb[TCA_TCINDEX_MASK]) < sizeof(mask)) +- return -1; +- mask = rta_getattr_u16(tb[TCA_TCINDEX_MASK]); +- fprintf(f, "mask 0x%04x ", mask); +- } +- if (tb[TCA_TCINDEX_SHIFT]) { +- int shift; +- +- if (RTA_PAYLOAD(tb[TCA_TCINDEX_SHIFT]) < sizeof(shift)) +- return -1; +- shift = rta_getattr_u32(tb[TCA_TCINDEX_SHIFT]); +- fprintf(f, "shift %d ", shift); +- } +- if (tb[TCA_TCINDEX_FALL_THROUGH]) { +- int fall_through; +- +- if (RTA_PAYLOAD(tb[TCA_TCINDEX_FALL_THROUGH]) < +- sizeof(fall_through)) +- return -1; +- fall_through = rta_getattr_u32(tb[TCA_TCINDEX_FALL_THROUGH]); +- fprintf(f, fall_through ? "fall_through " : "pass_on "); +- } +- if (tb[TCA_TCINDEX_CLASSID]) { +- SPRINT_BUF(b1); +- fprintf(f, "classid %s ", sprint_tc_classid(*(__u32 *) +- RTA_DATA(tb[TCA_TCINDEX_CLASSID]), b1)); +- } +- if (tb[TCA_TCINDEX_POLICE]) { +- fprintf(f, "\n"); +- tc_print_police(f, tb[TCA_TCINDEX_POLICE]); +- } +- if (tb[TCA_TCINDEX_ACT]) { +- fprintf(f, "\n"); +- tc_print_action(f, tb[TCA_TCINDEX_ACT], 0); +- } +- return 0; +-} +- +-struct filter_util tcindex_filter_util = { +- .id = "tcindex", +- .parse_fopt = tcindex_parse_opt, +- .print_fopt = tcindex_print_opt, +-}; +-- +2.33.0 + diff --git a/iproute.spec b/iproute.spec index 539eca0cd00b038b534e3e579d63839836346fc7..6a6a01a4e241b158643d8b03fdfd6fe47ed7216b 100644 --- a/iproute.spec +++ b/iproute.spec @@ -2,7 +2,7 @@ Name: iproute Version: 5.15.0 Epoch: 1 -Release: 17 +Release: 18 Summary: Linux network configuration utilities License: GPLv2+ and Public Domain URL: https://kernel.org/pub/linux/utils/net/iproute2/ @@ -59,6 +59,15 @@ Patch6042: backport-ss-Fix-socket-type-check-in-packet_show_line.patch Patch6043: backport-ss-print-unix-socket-ports-as-unsigned-int-inode.patch Patch6044: backport-utils-fix-get_integer-logic.patch +Patch6045: backport-bridge-fix-potential-snprintf-overflow.patch +Patch6046: backport-ila-fix-potential-snprintf-buffer-overflow.patch +Patch6047: backport-ip-fix-memory-leak-in-ip-maddr-show.patch +Patch6048: backport-tc-remove-tcindex-classifier.patch +Patch6049: backport-libnetlink-validate-nlmsg-header-length-first.patch +Patch6050: backport-iproute2-prevent-memory-leak.patch +Patch6051: backport-mnl_utils-sanitize-incoming-netlink-payload-size-in-.patch +Patch6052: backport-lnstat-Fix-deref-of-null-in-print_json-function.patch + Patch9000: feature-iproute-add-support-for-ipvlan-l2e-mode.patch Patch9001: bugfix-iproute2-cancel-some-test-cases.patch @@ -146,6 +155,19 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a %{_mandir}/* %changelog +* Thu Jul 4 2024 cuiyudong - 1:5.15.0-18 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: bridge: fix potential snprintf overflow + ila: fix potential snprintf buffer overflow + ip: fix memory leak in 'ip maddr show' + iproute2: prevent memory leak + libnetlink: validate nlmsg header length first + lnstat: Fix deref of null in print_json() function + tc: remove tcindex classifier + mnl_utils: sanitize incoming netlink payload size in callbacks + * Wed Jan 10 2024 liubo - 1:5.15.0-17 - Type:bugfix - ID:NA