aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>1998-12-16 18:30:43 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>1998-12-16 18:30:43 +0000
commite8c2601dbf89c2b2f4b50f66e6684faf32852aec (patch)
tree406c8f40cc8694af25a73e17bcb49050484dd136
parent0b6205fecae171e1629a80014c2a024a6d073048 (diff)
downloadsrc-e8c2601dbf89c2b2f4b50f66e6684faf32852aec.tar.gz
src-e8c2601dbf89c2b2f4b50f66e6684faf32852aec.zip
Generalize the if_up() and if_down() functions under the names
if_route() and if_unroute(). This is first step towards sanitizing IFF_UP and IFF_RUNNING
Notes
Notes: svn path=/head/; revision=41879
-rw-r--r--sys/net/if.c50
-rw-r--r--sys/net/if_var.h7
2 files changed, 42 insertions, 15 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 0ac57383c61a..b0c7be766cee 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.c 8.3 (Berkeley) 1/4/94
- * $Id: if.c,v 1.62 1998/08/12 22:51:59 wpaul Exp $
+ * $Id: if.c,v 1.63 1998/12/04 22:54:52 archie Exp $
*/
#include "opt_compat.h"
@@ -401,16 +401,17 @@ link_rtrequest(cmd, rt, sa)
* NOTE: must be called at splnet or eqivalent.
*/
void
-if_down(ifp)
+if_unroute(ifp, flag, fam)
register struct ifnet *ifp;
+ int flag, fam;
{
register struct ifaddr *ifa;
- ifp->if_flags &= ~IFF_UP;
+ ifp->if_flags &= ~flag;
getmicrotime(&ifp->if_lastchange);
- for (ifa = ifp->if_addrhead.tqh_first; ifa;
- ifa = ifa->ifa_link.tqe_next)
- pfctlinput(PRC_IFDOWN, ifa->ifa_addr);
+ TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
+ if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family))
+ pfctlinput(PRC_IFDOWN, ifa->ifa_addr);
if_qflush(&ifp->if_snd);
rt_ifmsg(ifp);
}
@@ -421,20 +422,47 @@ if_down(ifp)
* NOTE: must be called at splnet or eqivalent.
*/
void
-if_up(ifp)
+if_route(ifp, flag, fam)
register struct ifnet *ifp;
+ int flag, fam;
{
register struct ifaddr *ifa;
- ifp->if_flags |= IFF_UP;
+ ifp->if_flags |= flag;
getmicrotime(&ifp->if_lastchange);
- for (ifa = ifp->if_addrhead.tqh_first; ifa;
- ifa = ifa->ifa_link.tqe_next)
- pfctlinput(PRC_IFUP, ifa->ifa_addr);
+ TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
+ if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family))
+ pfctlinput(PRC_IFUP, ifa->ifa_addr);
rt_ifmsg(ifp);
}
/*
+ * Mark an interface down and notify protocols of
+ * the transition.
+ * NOTE: must be called at splnet or eqivalent.
+ */
+void
+if_down(ifp)
+ register struct ifnet *ifp;
+{
+
+ if_unroute(ifp, IFF_UP, AF_UNSPEC);
+}
+
+/*
+ * Mark an interface up and notify protocols of
+ * the transition.
+ * NOTE: must be called at splnet or eqivalent.
+ */
+void
+if_up(ifp)
+ register struct ifnet *ifp;
+{
+
+ if_route(ifp, IFF_UP, AF_UNSPEC);
+}
+
+/*
* Flush an interface queue.
*/
static void
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 0feaf2322d29..31ce8f63c15d 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* From: @(#)if.h 8.1 (Berkeley) 6/10/93
- * $Id: if_var.h,v 1.8 1998/06/07 17:12:06 dfr Exp $
+ * $Id: if_var.h,v 1.9 1998/06/12 03:48:09 julian Exp $
*/
#ifndef _NET_IF_VAR_H_
@@ -300,10 +300,9 @@ int if_allmulti __P((struct ifnet *, int));
void if_attach __P((struct ifnet *));
int if_delmulti __P((struct ifnet *, struct sockaddr *));
void if_down __P((struct ifnet *));
+void if_route __P((struct ifnet *, int flag, int fam));
+void if_unroute __P((struct ifnet *, int flag, int fam));
void if_up __P((struct ifnet *));
-#ifdef vax
-void ifubareset __P((int));
-#endif
/*void ifinit __P((void));*/ /* declared in systm.h for main() */
int ifioctl __P((struct socket *, u_long, caddr_t, struct proc *));
int ifpromisc __P((struct ifnet *, int));