Module Name: src
Committed By: yamaguchi
Date: Thu Sep 30 03:43:25 UTC 2021
Modified Files:
src/sys/net: if.c
src/sys/netinet: ip_carp.c
Log Message:
carp: Register carp_carpdev_state to link-state change hook
To generate a diff of this commit:
cvs rdiff -u -r1.494 -r1.495 src/sys/net/if.c
cvs rdiff -u -r1.115 -r1.116 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/net/if.c
diff -u src/sys/net/if.c:1.494 src/sys/net/if.c:1.495
--- src/sys/net/if.c:1.494 Thu Sep 30 03:39:39 2021
+++ src/sys/net/if.c Thu Sep 30 03:43:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.494 2021/09/30 03:39:39 yamaguchi Exp $ */
+/* $NetBSD: if.c,v 1.495 2021/09/30 03:43:25 yamaguchi Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.494 2021/09/30 03:39:39 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.495 2021/09/30 03:43:25 yamaguchi Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -2397,11 +2397,6 @@ if_link_state_change_process(struct ifne
/* Notify that the link state has changed. */
rt_ifmsg(ifp);
-#if NCARP > 0
- if (ifp->if_carp)
- carp_carpdev_state(ifp);
-#endif
-
if (ifp->if_link_state_changed != NULL)
ifp->if_link_state_changed(ifp, link_state);
Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.115 src/sys/netinet/ip_carp.c:1.116
--- src/sys/netinet/ip_carp.c:1.115 Wed Jun 16 00:21:19 2021
+++ src/sys/netinet/ip_carp.c Thu Sep 30 03:43:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_carp.c,v 1.115 2021/06/16 00:21:19 riastradh Exp $ */
+/* $NetBSD: ip_carp.c,v 1.116 2021/09/30 03:43:25 yamaguchi 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.115 2021/06/16 00:21:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.116 2021/09/30 03:43:25 yamaguchi Exp $");
/*
* TODO:
@@ -113,6 +113,7 @@ struct carp_softc {
struct ethercom sc_ac;
#define sc_if sc_ac.ec_if
#define sc_carpdev sc_ac.ec_if.if_carpdev
+ void *sc_linkstate_hook;
int ah_cookie;
int lh_cookie;
struct ip_moptions sc_imo;
@@ -907,6 +908,7 @@ carp_clone_destroy(struct ifnet *ifp)
static void
carpdetach(struct carp_softc *sc)
{
+ struct ifnet *ifp;
struct carp_if *cif;
int s;
@@ -929,13 +931,16 @@ carpdetach(struct carp_softc *sc)
KERNEL_LOCK(1, NULL);
s = splnet();
- if (sc->sc_carpdev != NULL) {
- /* XXX linkstatehook removal */
- cif = (struct carp_if *)sc->sc_carpdev->if_carp;
+ ifp = sc->sc_carpdev;
+ if (ifp != NULL) {
+ if_linkstate_change_disestablish(ifp,
+ sc->sc_linkstate_hook, NULL);
+
+ cif = (struct carp_if *)ifp->if_carp;
TAILQ_REMOVE(&cif->vhif_vrs, sc, sc_list);
if (!--cif->vhif_nvrs) {
- ifpromisc(sc->sc_carpdev, 0);
- sc->sc_carpdev->if_carp = NULL;
+ ifpromisc(ifp, 0);
+ ifp->if_carp = NULL;
free(cif, M_IFADDR);
}
}
@@ -1708,9 +1713,10 @@ carp_set_ifp(struct carp_softc *sc, stru
if (sc->sc_naddrs || sc->sc_naddrs6)
sc->sc_if.if_flags |= IFF_UP;
carp_set_enaddr(sc);
+ sc->sc_linkstate_hook = if_linkstate_change_establish(ifp,
+ carp_carpdev_state, (void *)ifp);
KERNEL_LOCK(1, NULL);
s = splnet();
- /* XXX linkstatehooks establish */
carp_carpdev_state(ifp);
splx(s);
KERNEL_UNLOCK_ONE(NULL);