Module Name:    src
Committed By:   roy
Date:           Wed Oct 14 13:43:56 UTC 2020

Modified Files:
        src/sys/netinet: ip_carp.c

Log Message:
carp: Don't set a link level address if vhid == -1

Link level address for carp is dervied from vhid.
Until vhid is set, carp is useless, so don't give it a link level address
until a vhid is set.

This fixes recent test case breakage where carp was fixed to actually
print the ethernet address set by default. Note that neither carp nor
the test case itself was actually broken as the error is the common
ATF net code assuming that a cloned interface's link level address is
unique upon creation.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/netinet/ip_carp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.113 src/sys/netinet/ip_carp.c:1.114
--- src/sys/netinet/ip_carp.c:1.113	Mon Oct 12 15:18:48 2020
+++ src/sys/netinet/ip_carp.c	Wed Oct 14 13:43:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_carp.c,v 1.113 2020/10/12 15:18:48 roy Exp $	*/
+/*	$NetBSD: ip_carp.c,v 1.114 2020/10/14 13:43:56 roy Exp $	*/
 /*	$OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.113 2020/10/12 15:18:48 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.114 2020/10/14 13:43:56 roy Exp $");
 
 /*
  * TODO:
@@ -878,7 +878,7 @@ carp_clone_create(struct if_clone *ifc, 
 	IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
 	IFQ_SET_READY(&ifp->if_snd);
 	rv = if_initialize(ifp);
-	if (rv != 0) {	
+	if (rv != 0) {
 		callout_destroy(&sc->sc_ad_tmo);
 		callout_destroy(&sc->sc_md_tmo);
 		callout_destroy(&sc->sc_md6_tmo);
@@ -1733,7 +1733,15 @@ carp_set_ifp(struct carp_softc *sc, stru
 static void
 carp_set_enaddr(struct carp_softc *sc)
 {
+	struct ifnet *ifp = &sc->sc_if;
 	uint8_t enaddr[ETHER_ADDR_LEN];
+
+	if (sc->sc_vhid == -1) {
+		ifp->if_addrlen = 0;
+		if_alloc_sadl(ifp);
+		return;
+	}
+
 	if (sc->sc_carpdev && sc->sc_carpdev->if_type == IFT_ISO88025) {
 		enaddr[0] = 3;
 		enaddr[1] = 0;
@@ -1749,7 +1757,8 @@ carp_set_enaddr(struct carp_softc *sc)
 		enaddr[4] = 1;
 		enaddr[5] = sc->sc_vhid;
 	}
-	if_set_sadl(&sc->sc_if, enaddr, sizeof(enaddr), false);
+
+	if_set_sadl(ifp, enaddr, sizeof(enaddr), false);
 }
 
 #if 0

Reply via email to