summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-10-12 11:32:40 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-10-12 11:32:40 +0000
commitf3ccd0e21a274ba19f8d6d94e07eb673729c2639 (patch)
treeb6f49883882056f3f96cc75d4ca2be9ee4af4d01 /sys/net
parent1b4b7608cfa15be679f5f3d426d0470cce57e06b (diff)
Unify link state change notification.
ok mikeb@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c62
1 files changed, 21 insertions, 41 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 9ed60acb717..0399b0dd3d4 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.387 2015/10/12 10:49:40 dlg Exp $ */
+/* $OpenBSD: if.c,v 1.388 2015/10/12 11:32:39 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -137,13 +137,14 @@ int if_getgroupmembers(caddr_t);
int if_getgroupattribs(caddr_t);
int if_setgroupattribs(caddr_t);
+void if_linkstate(void *);
+
int if_clone_list(struct if_clonereq *);
struct if_clone *if_clone_lookup(const char *, int *);
int if_group_egress_build(void);
void if_watchdog_task(void *);
-void if_link_state_change_task(void *);
void if_input_process(void *);
@@ -408,7 +409,7 @@ if_attachsetup(struct ifnet *ifp)
timeout_set(ifp->if_slowtimo, if_slowtimo, ifp);
if_slowtimo(ifp);
- task_set(ifp->if_linkstatetask, if_link_state_change_task, ifp);
+ task_set(ifp->if_linkstatetask, if_linkstate, ifp);
if_idxmap_insert(ifp);
KASSERT(if_get(0) == NULL);
@@ -1383,7 +1384,6 @@ if_downall(void)
/*
* Mark an interface down and notify protocols of
* the transition.
- * NOTE: must be called at splsoftnet or equivalent.
*/
void
if_down(struct ifnet *ifp)
@@ -1398,24 +1398,13 @@ if_down(struct ifnet *ifp)
pfctlinput(PRC_IFDOWN, ifa->ifa_addr);
}
IFQ_PURGE(&ifp->if_snd);
-#if NCARP > 0
- if (ifp->if_carp)
- carp_carpdev_state(ifp);
-#endif
-#if NBRIDGE > 0
- if (ifp->if_bridgeport)
- bstp_ifstate(ifp);
-#endif
- rt_ifmsg(ifp);
-#ifndef SMALL_KERNEL
- rt_if_track(ifp);
-#endif
+
+ if_linkstate(ifp);
}
/*
* Mark an interface up and notify protocols of
* the transition.
- * NOTE: must be called at splsoftnet or equivalent.
*/
void
if_up(struct ifnet *ifp)
@@ -1424,42 +1413,24 @@ if_up(struct ifnet *ifp)
ifp->if_flags |= IFF_UP;
microtime(&ifp->if_lastchange);
-#if NCARP > 0
- if (ifp->if_carp)
- carp_carpdev_state(ifp);
-#endif
-#if NBRIDGE > 0
- if (ifp->if_bridgeport)
- bstp_ifstate(ifp);
-#endif
- rt_ifmsg(ifp);
+
#ifdef INET6
/* Userland expects the kernel to set ::1 on lo0. */
if (ifp == lo0ifp)
in6_ifattach(ifp);
#endif
-#ifndef SMALL_KERNEL
- rt_if_track(ifp);
-#endif
-}
-/*
- * Schedule a link state change task.
- */
-void
-if_link_state_change(struct ifnet *ifp)
-{
- /* put the routing table update task on systq */
- task_add(systq, ifp->if_linkstatetask);
+ if_linkstate(ifp);
}
/*
- * Process a link state change.
+ * Notify userland, the routing table and hooks owner of
+ * a link-state transition.
*/
void
-if_link_state_change_task(void *arg)
+if_linkstate(void *xifp)
{
- struct ifnet *ifp = arg;
+ struct ifnet *ifp = xifp;
int s;
s = splsoftnet();
@@ -1472,6 +1443,15 @@ if_link_state_change_task(void *arg)
}
/*
+ * Schedule a link state change task.
+ */
+void
+if_link_state_change(struct ifnet *ifp)
+{
+ task_add(systq, ifp->if_linkstatetask);
+}
+
+/*
* Handle interface watchdog timer routine. Called
* from softclock, we decrement timer (if set) and
* call the appropriate interface routine on expiration.