From 6ff66acc604ec62b179a8a144c548918ff67a53b Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 9 Aug 2017 08:38:51 -0700 Subject: [PATCH 1/2] tc, ip: more Makefile updates for LIBMNL Signed-off-by: Stephen Hemminger --- ip/Makefile | 5 +++++ tc/Makefile | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ip/Makefile b/ip/Makefile index 8424b1f6..572604d5 100644 --- a/ip/Makefile +++ b/ip/Makefile @@ -19,6 +19,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 + ALLOBJ=$(IPOBJ) $(RTMONOBJ) SCRIPTS=ifcfg rtpr routel routef TARGETS=ip rtmon diff --git a/tc/Makefile b/tc/Makefile index 678b3029..c364a053 100644 --- a/tc/Makefile +++ b/tc/Makefile @@ -102,6 +102,11 @@ endif TCOBJ += $(TCMODULES) LDLIBS += -L. -lm +ifeq ($(HAVE_MNL),y) + CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags) + LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs) +endif + ifeq ($(SHARED_LIBS),y) LDLIBS += -ldl LDFLAGS += -Wl,-export-dynamic From 2a80154fde40b48d0e8afd16ae0eaa046ca05c02 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 9 Aug 2017 08:39:27 -0700 Subject: [PATCH 2/2] vti6: fix local/remote any addr handling According to the IPv4 behavior of 'ip' it should be possible to omit the arguments for local and remote address. Without this patch omitting these parameters would lead to uninitialized memory being interpreted as IPv6 addresses. Reported-by: Christian Langrock Signed-off-by: Stephen Hemminger --- ip/link_vti6.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ip/link_vti6.c b/ip/link_vti6.c index be4e33ce..6ea1fc23 100644 --- a/ip/link_vti6.c +++ b/ip/link_vti6.c @@ -59,8 +59,8 @@ static int vti6_parse_opt(struct link_util *lu, int argc, char **argv, struct rtattr *tb[IFLA_MAX + 1]; struct rtattr *linkinfo[IFLA_INFO_MAX+1]; struct rtattr *vtiinfo[IFLA_VTI_MAX + 1]; - struct in6_addr saddr; - struct in6_addr daddr; + struct in6_addr saddr = IN6ADDR_ANY_INIT; + struct in6_addr daddr = IN6ADDR_ANY_INIT; unsigned int ikey = 0; unsigned int okey = 0; unsigned int link = 0; @@ -195,8 +195,11 @@ get_failed: addattr32(n, 1024, IFLA_VTI_IKEY, ikey); addattr32(n, 1024, IFLA_VTI_OKEY, okey); - addattr_l(n, 1024, IFLA_VTI_LOCAL, &saddr, sizeof(saddr)); - addattr_l(n, 1024, IFLA_VTI_REMOTE, &daddr, sizeof(daddr)); + + if (memcmp(&saddr, &in6addr_any, sizeof(in6addr_any))) + addattr_l(n, 1024, IFLA_VTI_LOCAL, &saddr, sizeof(saddr)); + if (memcmp(&daddr, &in6addr_any, sizeof(in6addr_any))) + addattr_l(n, 1024, IFLA_VTI_REMOTE, &daddr, sizeof(daddr)); addattr32(n, 1024, IFLA_VTI_FWMARK, fwmark); if (link) addattr32(n, 1024, IFLA_VTI_LINK, link);