Module Name:    src
Committed By:   roy
Date:           Sat Sep 26 18:35:12 UTC 2020

Modified Files:
        src/sys/net: if.c if.h

Log Message:
net: Add a callback to ifnet to notify of link state changes


To generate a diff of this commit:
cvs rdiff -u -r1.480 -r1.481 src/sys/net/if.c
cvs rdiff -u -r1.286 -r1.287 src/sys/net/if.h

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.480 src/sys/net/if.c:1.481
--- src/sys/net/if.c:1.480	Sat Sep 26 11:57:05 2020
+++ src/sys/net/if.c	Sat Sep 26 18:35:12 2020
@@ -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 ifne
 		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);

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.286 src/sys/net/if.h:1.287
--- src/sys/net/if.h:1.286	Sat Sep 26 11:57:05 2020
+++ src/sys/net/if.h	Sat Sep 26 18:35:12 2020
@@ -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

Reply via email to