summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1999-08-08 00:43:01 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1999-08-08 00:43:01 +0000
commite09cf6c78cf6abfe9238df036609a770d07895c7 (patch)
tree0372b157616721e3317d539fd56a6afe5e270c6a /sys/netinet
parent8caf3f08d55dcea309e251d36eca66a7159efe22 (diff)
Support detaching of network interfaces. Still work to do in ipf, and
other families than inet.
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/if_ether.c10
-rw-r--r--sys/netinet/if_ether.h4
-rw-r--r--sys/netinet/igmp.c18
-rw-r--r--sys/netinet/igmp.h6
-rw-r--r--sys/netinet/ip_mroute.c20
-rw-r--r--sys/netinet/ip_mroute.h29
-rw-r--r--sys/netinet/ip_nat.c24
-rw-r--r--sys/netinet/ip_nat.h5
8 files changed, 89 insertions, 27 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 5e5bc3a8cfa..3cf783738a4 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ether.c,v 1.16 1999/08/02 22:51:15 deraadt Exp $ */
+/* $OpenBSD: if_ether.c,v 1.17 1999/08/08 00:43:00 niklas Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
@@ -98,10 +98,10 @@ int useloopback = 1; /* use loopback interface for local traffic */
int arpinit_done = 0;
/* revarp state */
-static struct in_addr myip, srv_ip;
-static int myip_initialized = 0;
-static int revarp_in_progress = 0;
-static struct ifnet *myip_ifp = NULL;
+static struct in_addr myip, srv_ip;
+static int myip_initialized = 0;
+static int revarp_in_progress = 0;
+struct ifnet *myip_ifp = NULL;
static void arptimer __P((void *));
static void arprequest __P((struct arpcom *, u_int32_t *, u_int32_t *,
diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h
index 7521e3df53f..25045da1c93 100644
--- a/sys/netinet/if_ether.h
+++ b/sys/netinet/if_ether.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ether.h,v 1.8 1999/08/02 22:51:16 deraadt Exp $ */
+/* $OpenBSD: if_ether.h,v 1.9 1999/08/08 00:43:00 niklas Exp $ */
/* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */
/*
@@ -237,6 +237,8 @@ struct ether_multistep {
#ifdef _KERNEL
+extern struct ifnet *myip_ifp;
+
void arp_rtrequest __P((int, struct rtentry *, struct sockaddr *));
int arpresolve __P((struct arpcom *, struct rtentry *, struct mbuf *,
struct sockaddr *, u_char *));
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 2325d1a2fee..61c70584d87 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: igmp.c,v 1.4 1998/05/18 21:10:24 provos Exp $ */
+/* $OpenBSD: igmp.c,v 1.5 1999/08/08 00:43:00 niklas Exp $ */
/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
@@ -98,6 +98,22 @@ rti_find(ifp)
}
void
+rti_delete(ifp)
+ struct ifnet *ifp;
+{
+ struct router_info *rti, **prti = &rti_head;
+
+ for (rti = rti_head; rti != 0; rti = rti->rti_next) {
+ if (rti->rti_ifp == ifp) {
+ *prti = rti->rti_next;
+ free(rti, M_MRTABLE);
+ break;
+ }
+ prti = &rti->rti_next;
+ }
+}
+
+void
#if __STDC__
igmp_input(struct mbuf *m, ...)
#else
diff --git a/sys/netinet/igmp.h b/sys/netinet/igmp.h
index d04dfcf8188..ccdb5ff6bf1 100644
--- a/sys/netinet/igmp.h
+++ b/sys/netinet/igmp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: igmp.h,v 1.2 1997/02/24 14:06:34 niklas Exp $ */
+/* $OpenBSD: igmp.h,v 1.3 1999/08/08 00:43:00 niklas Exp $ */
/* $NetBSD: igmp.h,v 1.6 1995/05/31 06:08:21 mycroft Exp $ */
/*
@@ -91,3 +91,7 @@ struct igmp {
* Revert to v2 if we haven't heard from the router in this amount of time.
*/
#define IGMP_AGE_THRESHOLD 540
+
+#ifdef _KERNEL
+void rti_delete __P((struct ifnet *));
+#endif
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index b59d162d43c..4b92255467a 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_mroute.c,v 1.16 1999/04/28 09:28:16 art Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.17 1999/08/08 00:43:00 niklas Exp $ */
/* $NetBSD: ip_mroute.c,v 1.27 1996/05/07 02:40:50 thorpej Exp $ */
/*
@@ -689,6 +689,24 @@ del_vif(m)
return (0);
}
+void
+vif_delete(ifp)
+ struct ifnet *ifp;
+{
+ int i;
+
+ for (i = 0; i < numvifs; i++) {
+ vifp = &viftable[i];
+ if (vifp->v_ifp == ifp)
+ bzero((caddr_t)vifp, sizeof *vifp);
+ }
+
+ for (i = numvifs; i > 0; i--)
+ if (viftable[i - 1].v_lcl_addr.s_addr != 0)
+ break;
+ numvifs = i;
+}
+
static void
update_mfc(mfccp, rt)
struct mfcctl *mfccp;
diff --git a/sys/netinet/ip_mroute.h b/sys/netinet/ip_mroute.h
index 4c1b21b0ffc..975e834e858 100644
--- a/sys/netinet/ip_mroute.h
+++ b/sys/netinet/ip_mroute.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_mroute.h,v 1.3 1999/04/20 20:06:12 niklas Exp $ */
+/* $OpenBSD: ip_mroute.h,v 1.4 1999/08/08 00:43:00 niklas Exp $ */
/* $NetBSD: ip_mroute.h,v 1.10 1996/02/13 23:42:55 christos Exp $ */
/*
@@ -210,21 +210,22 @@ struct pkt_queue {
struct ip *pkt_ip; /* pointer to ip header */
};
-int ip_mrouter_set __P((int, struct socket *, struct mbuf **));
-int ip_mrouter_get __P((int, struct socket *, struct mbuf **));
-int mrt_ioctl __P((u_long, caddr_t));
-int ip_mrouter_done __P((void));
-void reset_vif __P((struct vif *));
+int ip_mrouter_set __P((int, struct socket *, struct mbuf **));
+int ip_mrouter_get __P((int, struct socket *, struct mbuf **));
+int mrt_ioctl __P((u_long, caddr_t));
+int ip_mrouter_done __P((void));
+void reset_vif __P((struct vif *));
+void vif_delete __P((struct ifnet *));
#ifdef RSVP_ISI
-int ip_mforward __P((struct mbuf *, struct ifnet *, struct ip_moptions *));
-int legal_vif_num __P((int));
-int ip_rsvp_vif_init __P((struct socket *, struct mbuf *));
-int ip_rsvp_vif_done __P((struct socket *, struct mbuf *));
-void ip_rsvp_force_done __P((struct socket *));
-void rsvp_input __P((struct mbuf *, struct ifnet *));
+int ip_mforward __P((struct mbuf *, struct ifnet *, struct ip_moptions *));
+int legal_vif_num __P((int));
+int ip_rsvp_vif_init __P((struct socket *, struct mbuf *));
+int ip_rsvp_vif_done __P((struct socket *, struct mbuf *));
+void ip_rsvp_force_done __P((struct socket *));
+void rsvp_input __P((struct mbuf *, struct ifnet *));
#else
-int ip_mforward __P((struct mbuf *, struct ifnet *));
+int ip_mforward __P((struct mbuf *, struct ifnet *));
#endif
-void ipip_input __P((struct mbuf *, ...));
+void ipip_input __P((struct mbuf *, ...));
#endif /* _KERNEL */
diff --git a/sys/netinet/ip_nat.c b/sys/netinet/ip_nat.c
index 219d56b6bec..b6eaf071b04 100644
--- a/sys/netinet/ip_nat.c
+++ b/sys/netinet/ip_nat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_nat.c,v 1.21 1999/06/07 22:00:34 deraadt Exp $ */
+/* $OpenBSD: ip_nat.c,v 1.22 1999/08/08 00:43:00 niklas Exp $ */
/*
* Copyright (C) 1995-1998 by Darren Reed.
*
@@ -10,7 +10,7 @@
*/
#if !defined(lint)
static const char sccsid[] = "@(#)ip_nat.c 1.11 6/5/96 (C) 1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: ip_nat.c,v 1.21 1999/06/07 22:00:34 deraadt Exp $";
+static const char rcsid[] = "@(#)$Id: ip_nat.c,v 1.22 1999/08/08 00:43:00 niklas Exp $";
#endif
#if defined(__FreeBSD__) && defined(KERNEL) && !defined(_KERNEL)
@@ -413,6 +413,26 @@ struct nat *natd;
KFREE(natd);
}
+void
+nat_ifdetach(ifp)
+ struct ifnet *ifp;
+{
+ ipnat_t *n, **np;
+
+ for (np = &nat_list; (n = *np) != NULL; np = &n->in_next) {
+ *np = n->in_next;
+ if (!n->in_use) {
+ if (n->in_apr)
+ ap_free(n->in_apr);
+ KFREE(n);
+ nat_stats.ns_rules--;
+ } else {
+ n->in_flags |= IPN_DELETE;
+ n->in_next = NULL;
+ }
+ n = NULL;
+ }
+}
/*
* nat_flushtable - clear the NAT table of all mapping entries.
diff --git a/sys/netinet/ip_nat.h b/sys/netinet/ip_nat.h
index 435758221b8..7aae04b8194 100644
--- a/sys/netinet/ip_nat.h
+++ b/sys/netinet/ip_nat.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_nat.h,v 1.11 1999/02/05 05:58:53 deraadt Exp $ */
+/* $OpenBSD: ip_nat.h,v 1.12 1999/08/08 00:43:00 niklas Exp $ */
/*
* Copyright (C) 1995-1998 by Darren Reed.
*
@@ -7,7 +7,7 @@
* to the original author and the contributors.
*
* @(#)ip_nat.h 1.5 2/4/96
- * $Id: ip_nat.h,v 1.11 1999/02/05 05:58:53 deraadt Exp $
+ * $Id: ip_nat.h,v 1.12 1999/08/08 00:43:00 niklas Exp $
*/
#ifndef __IP_NAT_H__
@@ -162,6 +162,7 @@ extern int nat_ioctl __P((caddr_t, u_long, int));
#else
extern int nat_ioctl __P((caddr_t, int, int));
#endif
+extern void nat_ifdetach __P((struct ifnet *));
extern nat_t *nat_new __P((ipnat_t *, ip_t *, fr_info_t *, u_short, int));
extern nat_t *nat_outlookup __P((void *, int, struct in_addr, u_short,
struct in_addr, u_short));