Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys carp: Register carp_carpdev_state to link-state change hook
details: https://anonhg.NetBSD.org/src/rev/c82ae03c4e2f
branches: trunk
changeset: 1023870:c82ae03c4e2f
user: yamaguchi <yamaguchi%NetBSD.org@localhost>
date: Thu Sep 30 03:43:25 2021 +0000
description:
carp: Register carp_carpdev_state to link-state change hook
diffstat:
sys/net/if.c | 9 ++-------
sys/netinet/ip_carp.c | 22 ++++++++++++++--------
2 files changed, 16 insertions(+), 15 deletions(-)
diffs (98 lines):
diff -r a74b99893434 -r c82ae03c4e2f sys/net/if.c
--- a/sys/net/if.c Thu Sep 30 03:39:39 2021 +0000
+++ b/sys/net/if.c Thu Sep 30 03:43:25 2021 +0000
@@ -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 @@
/* 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);
diff -r a74b99893434 -r c82ae03c4e2f sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c Thu Sep 30 03:39:39 2021 +0000
+++ b/sys/netinet/ip_carp.c Thu Sep 30 03:43:25 2021 +0000
@@ -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 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 @@
static void
carpdetach(struct carp_softc *sc)
{
+ struct ifnet *ifp;
struct carp_if *cif;
int s;
@@ -929,13 +931,16 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index