From d756c08a3d45a9912ee422fa3ca78488b044ebd4 Mon Sep 17 00:00:00 2001 From: Puneet Sharma Date: Mon, 20 Sep 2021 11:00:01 -0400 Subject: [PATCH 1/4] tc/f_flower: fix port range parsing Provided port range in tc rule are parsed incorrectly. Even though range is passed as min-max. It throws an error. $ tc filter add dev eth0 ingress handle 100 priority 10000 protocol ipv4 flower ip_proto tcp dst_port 10368-61000 action pass max value should be greater than min value Illegal "dst_port" Fixes: 8930840e678b ("tc: flower: Classify packets based port ranges") Signed-off-by: Puneet Sharma Signed-off-by: Stephen Hemminger --- tc/f_flower.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tc/f_flower.c b/tc/f_flower.c index c5af0276..7f78195f 100644 --- a/tc/f_flower.c +++ b/tc/f_flower.c @@ -725,7 +725,7 @@ static int flower_parse_port(char *str, __u8 ip_proto, if (min && max) { __be16 min_port_type, max_port_type; - if (max <= min) { + if (ntohs(max) <= ntohs(min)) { fprintf(stderr, "max value should be greater than min value\n"); return -1; } From 2f5825cb38028a14961a79844a069be4e3057eca Mon Sep 17 00:00:00 2001 From: Andrea Claudi Date: Tue, 21 Sep 2021 11:33:24 +0200 Subject: [PATCH 2/4] lib: bpf_legacy: fix bpffs mount when /sys/fs/bpf exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bpf selftests using iproute2 fails with: $ ip link set dev veth0 xdp object ../bpf/xdp_dummy.o section xdp_dummy Continuing without mounted eBPF fs. Too old kernel? mkdir (null)/globals failed: No such file or directory Unable to load program This happens when the /sys/fs/bpf directory exists. In this case, mkdir in bpf_mnt_check_target() fails with errno == EEXIST, and the function returns -1. Thus bpf_get_work_dir() does not call bpf_mnt_fs() and the bpffs is not mounted. Fix this in bpf_mnt_check_target(), returning 0 when the mountpoint exists. Fixes: d4fcdbbec9df ("lib/bpf: Fix and simplify bpf_mnt_check_target()") Reported-by: Mingyu Shi Reported-by: Jiri Benc Suggested-by: Jiri Benc Signed-off-by: Andrea Claudi Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Stephen Hemminger --- lib/bpf_legacy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c index 91086aa2..275941dd 100644 --- a/lib/bpf_legacy.c +++ b/lib/bpf_legacy.c @@ -513,9 +513,12 @@ static int bpf_mnt_check_target(const char *target) int ret; ret = mkdir(target, S_IRWXU); - if (ret && errno != EEXIST) + if (ret) { + if (errno == EEXIST) + return 0; fprintf(stderr, "mkdir %s failed: %s\n", target, strerror(errno)); + } return ret; } From e7a98a96f08a6efc5d474c795cef371f00db4bbf Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Thu, 30 Sep 2021 17:19:25 +0200 Subject: [PATCH 3/4] mptcp: unbreak JSON endpoint list the following command: # ip -j mptcp endpoint show prints a JSON array that misses the terminating bracket. Fix this calling delete_json_obj() to balance the call to new_json_obj(). Fixes: 7e0767cd862b ("add support for mptcp netlink interface") Signed-off-by: Davide Caratti Acked-by: Andrea Claudi --- ip/ipmptcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c index 44af7234..fd042da8 100644 --- a/ip/ipmptcp.c +++ b/ip/ipmptcp.c @@ -278,7 +278,7 @@ static int mptcp_addr_dump(void) return -2; } - close_json_object(); + delete_json_obj(); fflush(stdout); return 0; } From 897772a73542d4d2a6fe030d102e883fa2cc58bb Mon Sep 17 00:00:00 2001 From: Frank Villaro-Dixon Date: Tue, 5 Oct 2021 15:19:39 +0200 Subject: [PATCH 4/4] cmd: use spaces instead of tabs for usage indentation Fix rogue "tab after spaces" used for indentation of the documentation. This causes rendering issues on terminals using a non-standard tab width. Signed-off-by: Frank Villaro-Dixon Signed-off-by: Stephen Hemminger --- bridge/bridge.c | 8 ++++---- ip/ipmroute.c | 4 ++-- ip/ipneigh.c | 11 ++++++----- ip/ipntable.c | 12 ++++++------ ip/iproute.c | 2 +- ip/ipseg6.c | 8 ++++---- ip/iptunnel.c | 22 +++++++++++----------- ip/iptuntap.c | 8 ++++---- ip/rtmon.c | 2 +- misc/nstat.c | 22 +++++++++++----------- 10 files changed, 50 insertions(+), 49 deletions(-) diff --git a/bridge/bridge.c b/bridge/bridge.c index 48b0e7f8..f3a4f08f 100644 --- a/bridge/bridge.c +++ b/bridge/bridge.c @@ -37,10 +37,10 @@ static void usage(void) fprintf(stderr, "Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n" " bridge [ -force ] -batch filename\n" -"where OBJECT := { link | fdb | mdb | vlan | monitor }\n" -" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n" -" -o[neline] | -t[imestamp] | -n[etns] name |\n" -" -c[ompressvlans] -color -p[retty] -j[son] }\n"); +"where OBJECT := { link | fdb | mdb | vlan | monitor }\n" +" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n" +" -o[neline] | -t[imestamp] | -n[etns] name |\n" +" -c[ompressvlans] -color -p[retty] -j[son] }\n"); exit(-1); } diff --git a/ip/ipmroute.c b/ip/ipmroute.c index 656ea0dc..981baf2a 100644 --- a/ip/ipmroute.c +++ b/ip/ipmroute.c @@ -37,8 +37,8 @@ static void usage(void) { fprintf(stderr, "Usage: ip mroute show [ [ to ] PREFIX ] [ from PREFIX ] [ iif DEVICE ]\n" - " [ table TABLE_ID ]\n" - "TABLE_ID := [ local | main | default | all | NUMBER ]\n" + " [ table TABLE_ID ]\n" + "TABLE_ID := [ local | main | default | all | NUMBER ]\n" #if 0 "Usage: ip mroute [ add | del ] DESTINATION from SOURCE [ iif DEVICE ] [ oif DEVICE ]\n" #endif diff --git a/ip/ipneigh.c b/ip/ipneigh.c index b778de00..4db776d7 100644 --- a/ip/ipneigh.c +++ b/ip/ipneigh.c @@ -50,12 +50,13 @@ static void usage(void) { fprintf(stderr, "Usage: ip neigh { add | del | change | replace }\n" - " { ADDR [ lladdr LLADDR ] [ nud STATE ] proxy ADDR }\n" - " [ dev DEV ] [ router ] [ extern_learn ] [ protocol PROTO ]\n" + " { ADDR [ lladdr LLADDR ] [ nud STATE ] proxy ADDR }\n" + " [ dev DEV ] [ router ] [ extern_learn ] [ protocol PROTO ]\n" "\n" - " ip neigh { show | flush } [ proxy ] [ to PREFIX ] [ dev DEV ] [ nud STATE ]\n" - " [ vrf NAME ]\n" - " ip neigh get { ADDR | proxy ADDR } dev DEV\n" + " ip neigh { show | flush } [ proxy ] [ to PREFIX ] [ dev DEV ] [ nud STATE ]\n" + " [ vrf NAME ]\n" + "\n" + " ip neigh get { ADDR | proxy ADDR } dev DEV\n" "\n" "STATE := { delay | failed | incomplete | noarp | none |\n" " permanent | probe | reachable | stale }\n"); diff --git a/ip/ipntable.c b/ip/ipntable.c index b5b06a3b..762c790d 100644 --- a/ip/ipntable.c +++ b/ip/ipntable.c @@ -47,15 +47,15 @@ static void usage(void) { fprintf(stderr, "Usage: ip ntable change name NAME [ dev DEV ]\n" - " [ thresh1 VAL ] [ thresh2 VAL ] [ thresh3 VAL ] [ gc_int MSEC ]\n" - " [ PARMS ]\n" + " [ thresh1 VAL ] [ thresh2 VAL ] [ thresh3 VAL ] [ gc_int MSEC ]\n" + " [ PARMS ]\n" "Usage: ip ntable show [ dev DEV ] [ name NAME ]\n" "PARMS := [ base_reachable MSEC ] [ retrans MSEC ] [ gc_stale MSEC ]\n" - " [ delay_probe MSEC ] [ queue LEN ]\n" - " [ app_probes VAL ] [ ucast_probes VAL ] [ mcast_probes VAL ]\n" - " [ anycast_delay MSEC ] [ proxy_delay MSEC ] [ proxy_queue LEN ]\n" - " [ locktime MSEC ]\n" + " [ delay_probe MSEC ] [ queue LEN ]\n" + " [ app_probes VAL ] [ ucast_probes VAL ] [ mcast_probes VAL ]\n" + " [ anycast_delay MSEC ] [ proxy_delay MSEC ] [ proxy_queue LEN ]\n" + " [ locktime MSEC ]\n" ); exit(-1); diff --git a/ip/iproute.c b/ip/iproute.c index 1e5e2002..9922cb04 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -82,7 +82,7 @@ static void usage(void) " [ ttl-propagate { enabled | disabled } ]\n" "INFO_SPEC := { NH | nhid ID } OPTIONS FLAGS [ nexthop NH ]...\n" "NH := [ encap ENCAPTYPE ENCAPHDR ] [ via [ FAMILY ] ADDRESS ]\n" - " [ dev STRING ] [ weight NUMBER ] NHFLAGS\n" + " [ dev STRING ] [ weight NUMBER ] NHFLAGS\n" "FAMILY := [ inet | inet6 | mpls | bridge | link ]\n" "OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ] [ as [ to ] ADDRESS ]\n" " [ rtt TIME ] [ rttvar TIME ] [ reordering NUMBER ]\n" diff --git a/ip/ipseg6.c b/ip/ipseg6.c index 56a76996..4f541ae4 100644 --- a/ip/ipseg6.c +++ b/ip/ipseg6.c @@ -34,10 +34,10 @@ static void usage(void) { fprintf(stderr, "Usage: ip sr { COMMAND | help }\n" - " ip sr hmac show\n" - " ip sr hmac set KEYID ALGO\n" - " ip sr tunsrc show\n" - " ip sr tunsrc set ADDRESS\n" + " ip sr hmac show\n" + " ip sr hmac set KEYID ALGO\n" + " ip sr tunsrc show\n" + " ip sr tunsrc set ADDRESS\n" "where ALGO := { sha1 | sha256 }\n"); exit(-1); } diff --git a/ip/iptunnel.c b/ip/iptunnel.c index 2369ee06..7a0e7237 100644 --- a/ip/iptunnel.c +++ b/ip/iptunnel.c @@ -34,18 +34,18 @@ static void usage(void) { fprintf(stderr, "Usage: ip tunnel { add | change | del | show | prl | 6rd } [ NAME ]\n" - " [ mode { gre | ipip | isatap | sit | vti } ]\n" - " [ remote ADDR ] [ local ADDR ]\n" - " [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n" - " [ prl-default ADDR ] [ prl-nodefault ADDR ] [ prl-delete ADDR ]\n" - " [ 6rd-prefix ADDR ] [ 6rd-relay_prefix ADDR ] [ 6rd-reset ]\n" - " [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n" + " [ mode { gre | ipip | isatap | sit | vti } ]\n" + " [ remote ADDR ] [ local ADDR ]\n" + " [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n" + " [ prl-default ADDR ] [ prl-nodefault ADDR ] [ prl-delete ADDR ]\n" + " [ 6rd-prefix ADDR ] [ 6rd-relay_prefix ADDR ] [ 6rd-reset ]\n" + " [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n" "\n" - "Where: NAME := STRING\n" - " ADDR := { IP_ADDRESS | any }\n" - " TOS := { STRING | 00..ff | inherit | inherit/STRING | inherit/00..ff }\n" - " TTL := { 1..255 | inherit }\n" - " KEY := { DOTTED_QUAD | NUMBER }\n"); + "Where: NAME := STRING\n" + " ADDR := { IP_ADDRESS | any }\n" + " TOS := { STRING | 00..ff | inherit | inherit/STRING | inherit/00..ff }\n" + " TTL := { 1..255 | inherit }\n" + " KEY := { DOTTED_QUAD | NUMBER }\n"); exit(-1); } diff --git a/ip/iptuntap.c b/ip/iptuntap.c index 96ca1ae7..385d2bd8 100644 --- a/ip/iptuntap.c +++ b/ip/iptuntap.c @@ -42,11 +42,11 @@ static void usage(void) { fprintf(stderr, "Usage: ip tuntap { add | del | show | list | lst | help } [ dev PHYS_DEV ]\n" - " [ mode { tun | tap } ] [ user USER ] [ group GROUP ]\n" - " [ one_queue ] [ pi ] [ vnet_hdr ] [ multi_queue ] [ name NAME ]\n" + " [ mode { tun | tap } ] [ user USER ] [ group GROUP ]\n" + " [ one_queue ] [ pi ] [ vnet_hdr ] [ multi_queue ] [ name NAME ]\n" "\n" - "Where: USER := { STRING | NUMBER }\n" - " GROUP := { STRING | NUMBER }\n"); + "Where: USER := { STRING | NUMBER }\n" + " GROUP := { STRING | NUMBER }\n"); exit(-1); } diff --git a/ip/rtmon.c b/ip/rtmon.c index 01c19c80..b021f773 100644 --- a/ip/rtmon.c +++ b/ip/rtmon.c @@ -65,7 +65,7 @@ static void usage(void) fprintf(stderr, "Usage: rtmon [ OPTIONS ] file FILE [ all | LISTofOBJECTS ]\n" "OPTIONS := { -f[amily] { inet | inet6 | link | help } |\n" - " -4 | -6 | -0 | -V[ersion] }\n" + " -4 | -6 | -0 | -V[ersion] }\n" "LISTofOBJECTS := [ link ] [ address ] [ route ]\n"); exit(-1); } diff --git a/misc/nstat.c b/misc/nstat.c index ecdd4ce8..7160c59b 100644 --- a/misc/nstat.c +++ b/misc/nstat.c @@ -547,17 +547,17 @@ static void usage(void) { fprintf(stderr, "Usage: nstat [OPTION] [ PATTERN [ PATTERN ] ]\n" - " -h, --help this message\n" - " -a, --ignore ignore history\n" - " -d, --scan=SECS sample every statistics every SECS\n" - " -j, --json format output in JSON\n" - " -n, --nooutput do history only\n" - " -p, --pretty pretty print\n" - " -r, --reset reset history\n" - " -s, --noupdate don't update history\n" - " -t, --interval=SECS report average over the last SECS\n" - " -V, --version output version information\n" - " -z, --zeros show entries with zero activity\n"); + " -h, --help this message\n" + " -a, --ignore ignore history\n" + " -d, --scan=SECS sample every statistics every SECS\n" + " -j, --json format output in JSON\n" + " -n, --nooutput do history only\n" + " -p, --pretty pretty print\n" + " -r, --reset reset history\n" + " -s, --noupdate don't update history\n" + " -t, --interval=SECS report average over the last SECS\n" + " -V, --version output version information\n" + " -z, --zeros show entries with zero activity\n"); exit(-1); }