Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/ifwatchd Remove rescan_interfaces as the interface ...



details:   https://anonhg.NetBSD.org/src/rev/7b220ef48b9f
branches:  trunk
changeset: 348159:7b220ef48b9f
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Oct 06 11:08:55 2016 +0000

description:
Remove rescan_interfaces as the interface announcement message
contains the interface index.

diffstat:

 usr.sbin/ifwatchd/ifwatchd.c |  22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)

diffs (61 lines):

diff -r b525805a764e -r 7b220ef48b9f usr.sbin/ifwatchd/ifwatchd.c
--- a/usr.sbin/ifwatchd/ifwatchd.c      Thu Oct 06 10:33:05 2016 +0000
+++ b/usr.sbin/ifwatchd/ifwatchd.c      Thu Oct 06 11:08:55 2016 +0000
@@ -1,6 +1,6 @@
-/*     $NetBSD: ifwatchd.c,v 1.38 2016/10/06 10:33:05 roy Exp $        */
+/*     $NetBSD: ifwatchd.c,v 1.39 2016/10/06 11:08:55 roy Exp $        */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: ifwatchd.c,v 1.38 2016/10/06 10:33:05 roy Exp $");
+__RCSID("$NetBSD: ifwatchd.c,v 1.39 2016/10/06 11:08:55 roy Exp $");
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,6 @@
 static void list_interfaces(const char *ifnames);
 static void check_announce(const struct if_announcemsghdr *ifan);
 static void check_carrier(const struct if_msghdr *ifm);
-static void rescan_interfaces(void);
 static void free_interfaces(void);
 static struct interface_data * find_interface(int index);
 static void run_initial_ups(void);
@@ -257,7 +256,6 @@
                check_addrs(msg);
                break;
        case RTM_IFANNOUNCE:
-               rescan_interfaces();
                check_announce(msg);
                break;
        case RTM_IFINFO:
@@ -503,9 +501,12 @@
 
                switch (ifan->ifan_what) {
                case IFAN_ARRIVAL:
+                       p->index = ifan->ifan_index;
                        invoke_script(p->ifname, ARRIVAL, NULL, NULL);
                        break;
                case IFAN_DEPARTURE:
+                       p->index = -1;
+                       p->last_carrier_status = LINK_STATE_UNKNOWN;
                        invoke_script(p->ifname, DEPARTURE, NULL, NULL);
                        break;
                default:
@@ -519,19 +520,6 @@
 }
 
 static void
-rescan_interfaces(void)
-{
-       struct interface_data * p;
-
-       SLIST_FOREACH(p, &ifs, next) {
-               p->index = if_nametoindex(p->ifname);
-               if (verbose)
-                       printf("interface \"%s\" has index %d\n", p->ifname,
-                           p->index);
-       }
-}
-
-static void
 free_interfaces(void)
 {
        struct interface_data * p;



Home | Main Index | Thread Index | Old Index