diff --git a/Makefile b/Makefile index 25d05fac..cadda235 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,8 @@ all: config.mk for i in $(SUBDIRS); \ do echo; echo $$i; $(MAKE) $(MFLAGS) -C $$i; done +.PHONY: clean clobber distclean check cscope version + help: @echo "Make Targets:" @echo " all - build binaries" @@ -73,7 +75,7 @@ help: @echo " install - install binaries on local machine" @echo " check - run tests" @echo " cscope - build cscope database" - @echo " snapshot - generate version number header" + @echo " version - update version" @echo "" @echo "Make Arguments:" @echo " V=[0|1] - set build verbosity level" @@ -93,9 +95,9 @@ install: all install -m 0644 bash-completion/devlink $(DESTDIR)$(BASH_COMPDIR) install -m 0644 include/bpf_elf.h $(DESTDIR)$(HDRDIR) -snapshot: - echo "static const char SNAPSHOT[] = \""`date +%y%m%d`"\";" \ - > include/SNAPSHOT.h +version: + echo "static const char version[] = \""`git describe --tags --long`"\";" \ + > include/version.h clean: @for i in $(SUBDIRS) testsuite; \ diff --git a/bridge/bridge.c b/bridge/bridge.c index a50d9d59..453d6897 100644 --- a/bridge/bridge.c +++ b/bridge/bridge.c @@ -12,7 +12,7 @@ #include #include -#include "SNAPSHOT.h" +#include "version.h" #include "utils.h" #include "br_common.h" #include "namespace.h" diff --git a/bridge/fdb.c b/bridge/fdb.c index d1f8afbe..37465e46 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -30,7 +30,8 @@ #include "rt_names.h" #include "utils.h" -static unsigned int filter_index, filter_vlan, filter_state, filter_master; +static unsigned int filter_index, filter_dynamic, filter_master, + filter_state, filter_vlan; static void usage(void) { @@ -40,9 +41,10 @@ static void usage(void) " [ sticky ] [ local | static | dynamic ] [ vlan VID ]\n" " { [ dst IPADDR ] [ port PORT] [ vni VNI ] | [ nhid NHID ] }\n" " [ via DEV ] [ src_vni VNI ]\n" - " bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ] [ state STATE ] ]\n" - " bridge fdb get ADDR [ br BRDEV ] { brport |dev } DEV [ vlan VID ]\n" - " [ vni VNI ]\n"); + " bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ]\n" + " [ state STATE ] [ dynamic ] ]\n" + " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" + " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n"); exit(-1); } @@ -62,7 +64,10 @@ static const char *state_n2a(unsigned int s) if (s & NUD_REACHABLE) return ""; - sprintf(buf, "state=%#x", s); + if (is_json_context()) + sprintf(buf, "%#x", s); + else + sprintf(buf, "state=%#x", s); return buf; } @@ -167,6 +172,9 @@ int print_fdb(struct nlmsghdr *n, void *arg) if (filter_vlan && filter_vlan != vid) return 0; + if (filter_dynamic && (r->ndm_state & NUD_PERMANENT)) + return 0; + open_json_object(NULL); if (n->nlmsg_type == RTM_DELNEIGH) print_bool(PRINT_ANY, "deleted", "Deleted ", true); @@ -326,6 +334,8 @@ static int fdb_show(int argc, char **argv) if (state_a2n(&state, *argv)) invarg("invalid state", *argv); filter_state |= state; + } else if (strcmp(*argv, "dynamic") == 0) { + filter_dynamic = 1; } else { if (matches(*argv, "help") == 0) usage(); @@ -582,6 +592,8 @@ static int fdb_get(int argc, char **argv) duparg2("vlan", *argv); NEXT_ARG(); vlan = atoi(*argv); + } else if (matches(*argv, "dynamic") == 0) { + filter_dynamic = 1; } else { if (strcmp(*argv, "to") == 0) NEXT_ARG(); diff --git a/devlink/devlink.c b/devlink/devlink.c index b3b4ab0c..8ec96c01 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -35,7 +35,7 @@ #include #include -#include "SNAPSHOT.h" +#include "version.h" #include "list.h" #include "mnlg.h" #include "json_print.h" @@ -7815,7 +7815,7 @@ int main(int argc, char **argv) switch (opt) { case 'V': - printf("devlink utility, iproute2-ss%s\n", SNAPSHOT); + printf("devlink utility, iproute2-%s\n", version); ret = EXIT_SUCCESS; goto dl_free; case 'f': diff --git a/genl/genl.c b/genl/genl.c index aba3c13a..6557e6bc 100644 --- a/genl/genl.c +++ b/genl/genl.c @@ -22,7 +22,7 @@ #include #include #include /* until we put our own header */ -#include "SNAPSHOT.h" +#include "version.h" #include "utils.h" #include "genl_utils.h" @@ -118,7 +118,7 @@ int main(int argc, char **argv) } else if (matches(argv[1], "-raw") == 0) { ++show_raw; } else if (matches(argv[1], "-Version") == 0) { - printf("genl utility, iproute2-ss%s\n", SNAPSHOT); + printf("genl utility, iproute2-%s\n", version); exit(0); } else if (matches(argv[1], "-help") == 0) { usage(); diff --git a/include/SNAPSHOT.h b/include/SNAPSHOT.h deleted file mode 100644 index 0d211784..00000000 --- a/include/SNAPSHOT.h +++ /dev/null @@ -1 +0,0 @@ -static const char SNAPSHOT[] = "200602"; diff --git a/include/version.h b/include/version.h new file mode 100644 index 00000000..0088493d --- /dev/null +++ b/include/version.h @@ -0,0 +1 @@ +static const char version[] = "5.8.0"; diff --git a/ip/ip.c b/ip/ip.c index 4249df03..ac445023 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -18,7 +18,7 @@ #include #include -#include "SNAPSHOT.h" +#include "version.h" #include "utils.h" #include "ip_common.h" #include "namespace.h" @@ -255,7 +255,7 @@ int main(int argc, char **argv) ++timestamp; ++timestamp_short; } else if (matches(opt, "-Version") == 0) { - printf("ip utility, iproute2-ss%s\n", SNAPSHOT); + printf("ip utility, iproute2-%s\n", version); exit(0); } else if (matches(opt, "-force") == 0) { ++force; diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c index bc12418b..e1ffafb3 100644 --- a/ip/ipmptcp.c +++ b/ip/ipmptcp.c @@ -273,7 +273,7 @@ static int mptcp_addr_show(int argc, char **argv) struct nlmsghdr *answer; int ret; - if (!argv) + if (argc <= 0) return mptcp_addr_dump(); ret = mptcp_parse_opt(argc, argv, &req.n, false); diff --git a/ip/rtmon.c b/ip/rtmon.c index bccddedd..01c19c80 100644 --- a/ip/rtmon.c +++ b/ip/rtmon.c @@ -19,7 +19,7 @@ #include #include -#include "SNAPSHOT.h" +#include "version.h" #include "utils.h" #include "libnetlink.h" @@ -107,7 +107,7 @@ main(int argc, char **argv) } else if (strcmp(argv[1], "-0") == 0) { family = AF_PACKET; } else if (matches(argv[1], "-Version") == 0) { - printf("rtmon utility, iproute2-ss%s\n", SNAPSHOT); + printf("rtmon utility, iproute2-%s\n", version); exit(0); } else if (matches(argv[1], "file") == 0) { argc--; diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index ad05cd7c..b0600576 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -81,9 +81,7 @@ bridge \- show / manipulate bridge addresses and devices .IR NHID " } " .ti -8 -.BR "bridge fdb" " [ " show " ] [ " -.B dev -.IR DEV " ] [ " +.BR "bridge fdb" " [ [ " show " ] [ " .B br .IR BRDEV " ] [ " .B brport @@ -91,18 +89,24 @@ bridge \- show / manipulate bridge addresses and devices .B vlan .IR VID " ] [ " .B state -.IR STATE " ]" +.IR STATE " ] [" +.B dynamic +.IR "] ]" .ti -8 -.B bridge fdb get -.I LLADDR " [ " -.B dev -.IR DEV " ] [ " +.BR "bridge fdb get" " [" +.B to +.IR "]" +.I LLADDR "[ " .B br -.IR BRDEV " ] [ " +.IR BRDEV " ]" +.B { brport | dev } +.IR DEV " [ " .B vlan -.IR VID " ] [" -.BR self " ] [ " master " ]" +.IR VID " ] [ " +.B vni +.IR VNI " ] [" +.BR self " ] [ " master " ] [ " dynamic " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } " diff --git a/man/man8/rtacct.8 b/man/man8/rtacct.8 index ccdbf6ca..988a6d1b 100644 --- a/man/man8/rtacct.8 +++ b/man/man8/rtacct.8 @@ -14,6 +14,13 @@ and .B rtacct are simple tools to monitor kernel snmp counters and network interface statistics. +.B nstat +can filter kernel snmp counters by name with one or several specified wildcards. Wildcards are case-insensitive and can include special symbols +.B ? +and +.B * +. + .SH OPTIONS .B \-h, \-\-help Print help diff --git a/misc/ifstat.c b/misc/ifstat.c index 60efe6cb..c05183d7 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -33,7 +33,7 @@ #include "libnetlink.h" #include "json_writer.h" -#include "SNAPSHOT.h" +#include "version.h" #include "utils.h" int dump_zeros; @@ -104,7 +104,7 @@ static int match(const char *id) return 1; for (i = 0; i < npatterns; i++) { - if (!fnmatch(patterns[i], id, 0)) + if (!fnmatch(patterns[i], id, FNM_CASEFOLD)) return 1; } return 0; @@ -869,7 +869,7 @@ int main(int argc, char *argv[]) break; case 'v': case 'V': - printf("ifstat utility, iproute2-ss%s\n", SNAPSHOT); + printf("ifstat utility, iproute2-%s\n", version); exit(0); case 'h': case '?': diff --git a/misc/lnstat.c b/misc/lnstat.c index e3c84211..89cb0e7e 100644 --- a/misc/lnstat.c +++ b/misc/lnstat.c @@ -38,6 +38,7 @@ #include #include "lnstat.h" +#include "version.h" static struct option opts[] = { { "version", 0, NULL, 'V' }, @@ -79,7 +80,7 @@ static int usage(char *name, int exit_code) " 2 = every 20 lines (default))\n" " -w --width n,n,n,... Width for each field\n" "\n", - name, LNSTAT_VERSION); + name, version); exit(exit_code); } diff --git a/misc/lnstat.h b/misc/lnstat.h index 199eb54a..433599cc 100644 --- a/misc/lnstat.h +++ b/misc/lnstat.h @@ -5,8 +5,6 @@ #include #include -#define LNSTAT_VERSION "0.02 041002" - #define PROC_NET_STAT "/proc/net/stat" #define LNSTAT_MAX_FILES 32 diff --git a/misc/nstat.c b/misc/nstat.c index 425e75ef..6fdd316c 100644 --- a/misc/nstat.c +++ b/misc/nstat.c @@ -29,7 +29,7 @@ #include #include -#include +#include "version.h" #include "utils.h" int dump_zeros; @@ -114,7 +114,7 @@ static int match(const char *id) return 1; for (i = 0; i < npatterns; i++) { - if (!fnmatch(patterns[i], id, 0)) + if (!fnmatch(patterns[i], id, FNM_CASEFOLD)) return 1; } return 0; @@ -621,7 +621,7 @@ int main(int argc, char *argv[]) break; case 'v': case 'V': - printf("nstat utility, iproute2-ss%s\n", SNAPSHOT); + printf("nstat utility, iproute2-%s\n", version); exit(0); case 'h': case '?': diff --git a/misc/rtacct.c b/misc/rtacct.c index c4bb5bc3..47b27e3f 100644 --- a/misc/rtacct.c +++ b/misc/rtacct.c @@ -30,7 +30,7 @@ #include "rt_names.h" -#include +#include "version.h" int reset_history; int ignore_history; @@ -463,7 +463,7 @@ int main(int argc, char *argv[]) break; case 'v': case 'V': - printf("rtacct utility, iproute2-ss%s\n", SNAPSHOT); + printf("rtacct utility, iproute2-%s\n", version); exit(0); case 'M': /* Some secret undocumented option, nobody diff --git a/misc/ss.c b/misc/ss.c index f0dd129e..e5565725 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -35,7 +35,7 @@ #include "ll_map.h" #include "libnetlink.h" #include "namespace.h" -#include "SNAPSHOT.h" +#include "version.h" #include "rt_names.h" #include "cg_map.h" @@ -1682,7 +1682,7 @@ static int unix_match(const inet_prefix *a, const inet_prefix *p) return 1; if (addr == NULL) addr = ""; - return !fnmatch(pattern, addr, 0); + return !fnmatch(pattern, addr, FNM_CASEFOLD); } static int run_ssfilter(struct ssfilter *f, struct sockstat *s) @@ -5504,7 +5504,7 @@ int main(int argc, char *argv[]) break; case 'v': case 'V': - printf("ss utility, iproute2-ss%s\n", SNAPSHOT); + printf("ss utility, iproute2-%s\n", version); exit(0); case 'z': show_sock_ctx++; diff --git a/rdma/rdma.c b/rdma/rdma.c index c24894d6..9ea2d17f 100644 --- a/rdma/rdma.c +++ b/rdma/rdma.c @@ -5,7 +5,7 @@ */ #include "rdma.h" -#include "SNAPSHOT.h" +#include "version.h" #include "color.h" static void help(char *name) @@ -133,8 +133,8 @@ int main(int argc, char **argv) long_options, NULL)) >= 0) { switch (opt) { case 'V': - printf("%s utility, iproute2-ss%s\n", - filename, SNAPSHOT); + printf("%s utility, iproute2-%s\n", + filename, version); return EXIT_SUCCESS; case 'p': pretty = 1; diff --git a/tc/m_estimator.c b/tc/m_estimator.c index ef62e1bb..b5f4c860 100644 --- a/tc/m_estimator.c +++ b/tc/m_estimator.c @@ -57,7 +57,7 @@ int parse_estimator(int *p_argc, char ***p_argv, struct tc_estimator *est) return -1; } if (show_raw) - fprintf(stderr, "[estimator i=%u e=%u]\n", est->interval, est->ewma_log); + fprintf(stderr, "[estimator i=%hhd e=%u]\n", est->interval, est->ewma_log); *p_argc = argc; *p_argv = argv; return 0; diff --git a/tc/tc.c b/tc/tc.c index b72657ec..5d57054b 100644 --- a/tc/tc.c +++ b/tc/tc.c @@ -24,7 +24,7 @@ #include #include -#include "SNAPSHOT.h" +#include "version.h" #include "utils.h" #include "tc_util.h" #include "tc_common.h" @@ -299,7 +299,7 @@ int main(int argc, char **argv) } else if (matches(argv[1], "-graph") == 0) { show_graph = 1; } else if (matches(argv[1], "-Version") == 0) { - printf("tc utility, iproute2-ss%s\n", SNAPSHOT); + printf("tc utility, iproute2-%s\n", version); return 0; } else if (matches(argv[1], "-iec") == 0) { ++use_iec; diff --git a/testsuite/tests/ip/link/add_type_bareudp.t b/testsuite/tests/ip/link/add_type_bareudp.t new file mode 100755 index 00000000..8a2a1edf --- /dev/null +++ b/testsuite/tests/ip/link/add_type_bareudp.t @@ -0,0 +1,86 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing Add BareUDP interface (unicast MPLS)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (unicast MPLS)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype mpls_uc + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (unicast MPLS)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype mpls_uc" +test_on "nomultiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (unicast MPLS)" link del dev $NEW_DEV + + +ts_log "[Testing Add BareUDP interface (multicast MPLS)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (multicast MPLS)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype mpls_mc + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (multicast MPLS)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype mpls_mc" +test_on "nomultiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (multicast MPLS)" link del dev $NEW_DEV + + +ts_log "[Testing Add BareUDP interface (unicast and multicast MPLS)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (unicast and multicast MPLS)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype mpls_uc multiproto + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (unicast and multicast MPLS)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype mpls_uc" +test_on "multiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (unicast and multicast MPLS)" link del dev $NEW_DEV + + +ts_log "[Testing Add BareUDP interface (IPv4)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (IPv4)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype ipv4 + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (IPv4)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype ip" +test_on "nomultiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (IPv4)" link del dev $NEW_DEV + + +ts_log "[Testing Add BareUDP interface (IPv6)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (IPv6)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype ipv6 + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (IPv6)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype ipv6" +test_on "nomultiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (IPv6)" link del dev $NEW_DEV + + +ts_log "[Testing Add BareUDP interface (IPv4 and IPv6)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (IPv4 and IPv6)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype ipv4 multiproto + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (IPv4 and IPv6)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype ip" +test_on "multiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (IPv4 and IPv6)" link del dev $NEW_DEV