From c4cc60979637341ef3c2c9b52d5b7945f7b4fac1 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 23 Apr 2019 12:23:44 +0000 Subject: [PATCH] poib: assign link-local address according to RFC RFC 4391 specifies that the IB interface GID should be re-used as IPv6 link-local address. Since the code in in6_get_hw_ifid() ignored IFT_INFINIBAND case, ibX interfaces ended up with the local address borrowed from some other interface, which is non-compliant. Use lowest eight bytes from GID for filling the link-local address, same as Linux. Reviewed by: bz (previous version), ae, hselasky, slavash, Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D20006 --- sys/netinet6/in6_ifattach.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 4fb81f812dd2..a1a707449bf2 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -328,6 +328,14 @@ in6_get_hw_ifid(struct ifnet *ifp, struct in6_addr *in6) NET_EPOCH_EXIT(et); return -1; + case IFT_INFINIBAND: + if (addrlen != 20) { + NET_EPOCH_EXIT(et); + return -1; + } + bcopy(addr + 12, &in6->s6_addr[8], 8); + break; + default: NET_EPOCH_EXIT(et); return -1;