From 69fed534a533f48b8772d935590f82206171ca96 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 9 Aug 2017 08:45:04 -0700 Subject: [PATCH 1/2] change how Config is used in Makefile's The recent LIBMNL changes was made more difficult to debug because of how Config is handle in clean make. The Config file is generated by top level make, but since it is not recursive, the values generated would not be visible on a clean make. The change is to not include Config in top level make, and move all the conditionals down into sub makefiles. Not ideal, but beter than going full autoconf route. Or forcing separate configure step. Signed-off-by: Stephen Hemminger --- Makefile | 15 +-------------- bridge/Makefile | 5 +++++ genl/Makefile | 5 +++++ misc/Makefile | 5 +++++ netem/Makefile | 7 +++++++ 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index a4b0dea5..1f88f7f5 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,4 @@ -# Include "Config" if already generated -ifneq ($(wildcard Config),) -include Config -endif +# Top level Makefile for iproute2 ifeq ($(VERBOSE),0) MAKEFLAGS += --no-print-directory @@ -57,16 +54,6 @@ SUBDIRS=lib ip tc bridge misc netem genl tipc devlink man LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a LDLIBS += $(LIBNETLINK) -ifeq ($(HAVE_ELF),y) - CFLAGS += -DHAVE_ELF - LDLIBS += -lelf -endif - -ifeq ($(HAVE_MNL),y) - CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags) - LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs) -endif - all: Config @set -e; \ for i in $(SUBDIRS); \ diff --git a/bridge/Makefile b/bridge/Makefile index 634c370a..fa448ea2 100644 --- a/bridge/Makefile +++ b/bridge/Makefile @@ -6,6 +6,11 @@ ifeq ($(IP_CONFIG_SETNS),y) CFLAGS += -DHAVE_SETNS endif +ifeq ($(HAVE_MNL),y) + CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags) + LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs) +endif + all: bridge bridge: $(BROBJ) $(LIBNETLINK) diff --git a/genl/Makefile b/genl/Makefile index f5a0bfe4..f0efe1ac 100644 --- a/genl/Makefile +++ b/genl/Makefile @@ -17,6 +17,11 @@ LDFLAGS += -Wl,-export-dynamic LDLIBS += -lm -ldl endif +ifeq ($(HAVE_MNL),y) + CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags) + LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs) +endif + all: genl genl: $(GENLOBJ) $(LIBNETLINK) $(LIBUTIL) $(GENLLIB) diff --git a/misc/Makefile b/misc/Makefile index 814a72fc..fa90308e 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -18,6 +18,11 @@ ifeq ($(IP_CONFIG_SETNS),y) CFLAGS += -DHAVE_SETNS endif +ifeq ($(HAVE_MNL),y) + CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags) + LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs) +endif + all: $(TARGETS) ss: $(SSOBJ) diff --git a/netem/Makefile b/netem/Makefile index a68e2fdb..2499f086 100644 --- a/netem/Makefile +++ b/netem/Makefile @@ -1,3 +1,5 @@ +include ../Config + DISTGEN = maketable normal pareto paretonormal DISTDATA = normal.dist pareto.dist paretonormal.dist experimental.dist @@ -5,6 +7,11 @@ HOSTCC ?= $(CC) CCOPTS = $(CBUILD_CFLAGS) LDLIBS += -lm +ifeq ($(HAVE_MNL),y) + CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags) + LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs) +endif + all: $(DISTGEN) $(DISTDATA) $(DISTGEN): From fcfcc40b7d19d8a5442d604de506844391103368 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 9 Aug 2017 08:50:25 -0700 Subject: [PATCH 2/2] vti: print keys in hex not dotted notation The ikey and okey value are normal u32 values. The input accepts them in dotted, hex or decimal form. For output, hex seems like the best form since they are not really addresses. Suggested-by: Christian Langrock Signed-off-by: Stephen Hemminger --- ip/link_vti.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ip/link_vti.c b/ip/link_vti.c index d5242ac7..3ffecfac 100644 --- a/ip/link_vti.c +++ b/ip/link_vti.c @@ -210,8 +210,9 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) { const char *local = "any"; const char *remote = "any"; + __u32 key; unsigned int link; - char s2[64]; + char s2[IFNAMSIZ]; if (!tb) return; @@ -244,15 +245,14 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) fprintf(f, "dev %u ", link); } - if (tb[IFLA_VTI_IKEY]) { - inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_IKEY]), s2, sizeof(s2)); - fprintf(f, "ikey %s ", s2); - } + if (tb[IFLA_VTI_IKEY] && + (key = rta_getattr_u32(tb[IFLA_VTI_IKEY]))) + fprintf(f, "ikey %#x ", ntohl(key)); - if (tb[IFLA_VTI_OKEY]) { - inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_OKEY]), s2, sizeof(s2)); - fprintf(f, "okey %s ", s2); - } + + if (tb[IFLA_VTI_OKEY] && + (key = rta_getattr_u32(tb[IFLA_VTI_OKEY]))) + fprintf(f, "okey %#x ", ntohl(key)); if (tb[IFLA_VTI_FWMARK] && rta_getattr_u32(tb[IFLA_VTI_FWMARK])) { fprintf(f, "fwmark 0x%x ",