net: Add a callback to ifnet to notify of link state changes
This commit is contained in:
parent
c9f4e317e7
commit
13c88b88b0
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if.c,v 1.480 2020/09/26 11:57:05 roy Exp $ */
|
||||
/* $NetBSD: if.c,v 1.481 2020/09/26 18:35:12 roy 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.480 2020/09/26 11:57:05 roy Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.481 2020/09/26 18:35:12 roy Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_inet.h"
|
||||
@ -1212,6 +1212,8 @@ if_deactivate(struct ifnet *ifp)
|
||||
ifp->if_slowtimo = if_nullslowtimo;
|
||||
ifp->if_drain = if_nulldrain;
|
||||
|
||||
ifp->if_link_state_changed = NULL;
|
||||
|
||||
/* No more packets may be enqueued. */
|
||||
ifp->if_snd.ifq_maxlen = 0;
|
||||
|
||||
@ -2415,6 +2417,9 @@ if_link_state_change_process(struct ifnet *ifp, int link_state)
|
||||
carp_carpdev_state(ifp);
|
||||
#endif
|
||||
|
||||
if (ifp->if_link_state_changed != NULL)
|
||||
ifp->if_link_state_changed(ifp, link_state);
|
||||
|
||||
DOMAIN_FOREACH(dp) {
|
||||
if (dp->dom_if_link_state_change != NULL)
|
||||
dp->dom_if_link_state_change(ifp, link_state);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if.h,v 1.286 2020/09/26 11:57:05 roy Exp $ */
|
||||
/* $NetBSD: if.h,v 1.287 2020/09/26 18:35:12 roy Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
@ -419,6 +419,7 @@ typedef struct ifnet {
|
||||
uint16_t if_link_queue; /* q: masked link state change queue */
|
||||
/* q: is link state work scheduled? */
|
||||
bool if_link_scheduled;
|
||||
void (*if_link_state_changed)(struct ifnet *, int);
|
||||
struct pslist_entry
|
||||
if_pslist_entry;/* i: */
|
||||
struct psref_target
|
||||
|
Loading…
Reference in New Issue
Block a user