diff mbox series

[iproute2,v2] ip: Properly display AF_BRIDGE address information for neighbor events

Message ID 20180223191009.13286-1-sharpd@cumulusnetworks.com
State Accepted, archived
Delegated to: stephen hemminger
Headers show
Series [iproute2,v2] ip: Properly display AF_BRIDGE address information for neighbor events | expand

Commit Message

Donald Sharp Feb. 23, 2018, 7:10 p.m. UTC
The vxlan driver when a neighbor add/delete event occurs sends
NDA_DST filled with a union:

union vxlan_addr {
	struct sockaddr_in sin;
	struct sockaddr_in6 sin6;
	struct sockaddr sa;
};

This eventually calls rt_addr_n2a_r which had no handler for the
AF_BRIDGE family and "???" was being printed.

Add code to properly display this data when requested.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
---
 lib/utils.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Stephen Hemminger Feb. 23, 2018, 7:28 p.m. UTC | #1
On Fri, 23 Feb 2018 14:10:09 -0500
Donald Sharp <sharpd@cumulusnetworks.com> wrote:

> The vxlan driver when a neighbor add/delete event occurs sends
> NDA_DST filled with a union:
> 
> union vxlan_addr {
> 	struct sockaddr_in sin;
> 	struct sockaddr_in6 sin6;
> 	struct sockaddr sa;
> };
> 
> This eventually calls rt_addr_n2a_r which had no handler for the
> AF_BRIDGE family and "???" was being printed.
> 
> Add code to properly display this data when requested.
> 
> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>

I did some minor changes to the patch and applied it.
(need space after switch, and can don't need local variable family).
Thanks.
diff mbox series

Patch

diff --git a/lib/utils.c b/lib/utils.c
index 24aeddd8..fe5841f6 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -1004,6 +1004,25 @@  const char *rt_addr_n2a_r(int af, int len,
 	}
 	case AF_PACKET:
 		return ll_addr_n2a(addr, len, ARPHRD_VOID, buf, buflen);
+	case AF_BRIDGE:
+	{
+		const union {
+			struct sockaddr sa;
+			struct sockaddr_in sin;
+			struct sockaddr_in6 sin6;
+		} *sa = addr;
+		unsigned short family = sa->sa.sa_family;
+
+		switch(family) {
+		case AF_INET:
+			return inet_ntop(AF_INET, &sa->sin.sin_addr, buf, buflen);
+		case AF_INET6:
+			return inet_ntop(AF_INET6, &sa->sin6.sin6_addr,
+					 buf, buflen);
+		}
+
+		/* fallthrough */
+	}
 	default:
 		return "???";
 	}