Source-Changes-HG archive

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

[src/trunk]: src/sys inet: Treat LINK_STATE_UNKNOWN as LINK_STATE_UP when cha...



details:   https://anonhg.NetBSD.org/src/rev/90e3cf3e2bb1
branches:  trunk
changeset: 955455:90e3cf3e2bb1
user:      roy <roy%NetBSD.org@localhost>
date:      Tue Sep 29 19:33:36 2020 +0000

description:
inet: Treat LINK_STATE_UNKNOWN as LINK_STATE_UP when changing

It's something we have always done.
it's really rare for anything to transition to UNKNOWN from either
UP or DOWN, but technically it is possible.

diffstat:

 sys/netinet/in.c   |  17 +++++++++--------
 sys/netinet6/in6.c |  17 +++++++++--------
 2 files changed, 18 insertions(+), 16 deletions(-)

diffs (80 lines):

diff -r 30b775e11e34 -r 90e3cf3e2bb1 sys/netinet/in.c
--- a/sys/netinet/in.c  Tue Sep 29 19:20:08 2020 +0000
+++ b/sys/netinet/in.c  Tue Sep 29 19:33:36 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in.c,v 1.240 2020/09/11 15:22:12 roy Exp $     */
+/*     $NetBSD: in.c,v 1.241 2020/09/29 19:33:36 roy Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.240 2020/09/11 15:22:12 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.241 2020/09/29 19:33:36 roy Exp $");
 
 #include "arp.h"
 
@@ -1579,14 +1579,15 @@
 in_if_link_state_change(struct ifnet *ifp, int link_state)
 {
 
-       switch (link_state) {
-       case LINK_STATE_DOWN:
+       /*
+        * Treat LINK_STATE_UNKNOWN as UP.
+        * LINK_STATE_UNKNOWN transitions to LINK_STATE_DOWN when
+        * if_link_state_change() transitions to LINK_STATE_UP.
+        */
+       if (link_state == LINK_STATE_DOWN)
                in_if_link_down(ifp);
-               break;
-       case LINK_STATE_UP:
+       else
                in_if_link_up(ifp);
-               break;
-       }
 }
 
 /*
diff -r 30b775e11e34 -r 90e3cf3e2bb1 sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Tue Sep 29 19:20:08 2020 +0000
+++ b/sys/netinet6/in6.c        Tue Sep 29 19:33:36 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.c,v 1.281 2020/06/16 17:12:18 maxv Exp $   */
+/*     $NetBSD: in6.c,v 1.282 2020/09/29 19:33:36 roy Exp $    */
 /*     $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $   */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.281 2020/06/16 17:12:18 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.282 2020/09/29 19:33:36 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2250,14 +2250,15 @@
 in6_if_link_state_change(struct ifnet *ifp, int link_state)
 {
 
-       switch (link_state) {
-       case LINK_STATE_DOWN:
+       /*
+        * Treat LINK_STATE_UNKNOWN as UP.
+        * LINK_STATE_UNKNOWN transitions to LINK_STATE_DOWN when
+        * if_link_state_change() transitions to LINK_STATE_UP.
+        */
+       if (link_state == LINK_STATE_DOWN)
                in6_if_link_down(ifp);
-               break;
-       case LINK_STATE_UP:
+       else
                in6_if_link_up(ifp);
-               break;
-       }
 }
 
 int



Home | Main Index | Thread Index | Old Index