Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet carp: Don't set a link level address if vhid == -1



details:   https://anonhg.NetBSD.org/src/rev/df16b64c08da
branches:  trunk
changeset: 940687:df16b64c08da
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Oct 14 13:43:56 2020 +0000

description:
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.

diffstat:

 sys/netinet/ip_carp.c |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (53 lines):

diff -r 5de1d034f66b -r df16b64c08da sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c     Wed Oct 14 13:37:14 2020 +0000
+++ b/sys/netinet/ip_carp.c     Wed Oct 14 13:43:56 2020 +0000
@@ -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 @@
        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 @@
 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 @@
                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



Home | Main Index | Thread Index | Old Index