summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/net/if_gre.c14
-rw-r--r--sys/net/if_gre.h7
-rw-r--r--sys/netinet/ip_gre.c5
3 files changed, 16 insertions, 10 deletions
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index 6aad82cd62f..00fca76d4ac 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gre.c,v 1.11 2001/05/27 11:54:32 angelos Exp $ */
+/* $OpenBSD: if_gre.c,v 1.12 2001/06/05 23:43:45 maja Exp $ */
/* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
@@ -101,7 +101,9 @@
#define LINK_MASK (IFF_LINK0|IFF_LINK1|IFF_LINK2)
-struct gre_softc gre_softc[NGRE];
+struct gre_softc *gre = 0;
+
+int ngre = 0;
/*
* We can control the acceptance of GRE and MobileIP packets by
@@ -114,12 +116,16 @@ int ip_mobile_allow = 0;
static void gre_compute_route(struct gre_softc *sc);
void
-greattach(void)
+greattach(n)
+ int n;
{
struct gre_softc *sc;
int i;
- for (i = 0, sc = gre_softc ; i < NGRE ; sc++ ) {
+ ngre = n;
+ gre = sc = malloc(ngre * sizeof(struct gre_softc), M_DEVBUF, M_WAIT);
+ bzero(sc, ngre * sizeof(struct gre_softc));
+ for (i = 0; i < ngre ; sc++) {
snprintf(sc->sc_if.if_xname, sizeof(sc->sc_if.if_xname),
"gre%d", i++);
sc->sc_if.if_softc = sc;
diff --git a/sys/net/if_gre.h b/sys/net/if_gre.h
index da1a37d9104..05a44579b87 100644
--- a/sys/net/if_gre.h
+++ b/sys/net/if_gre.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gre.h,v 1.2 2000/01/07 23:25:22 angelos Exp $ */
+/* $OpenBSD: if_gre.h,v 1.3 2001/06/05 23:43:46 maja Exp $ */
/* $NetBSD: if_gre.h,v 1.5 1999/11/19 20:41:19 thorpej Exp $ */
/*
@@ -138,11 +138,12 @@ struct mobip_h {
*/
#ifdef _KERNEL
-extern struct gre_softc gre_softc[];
+extern struct gre_softc *gre;
+extern int ngre;
extern int gre_allow;
extern int ip_mobile_allow;
-void greattach __P((void));
+void greattach __P((int));
int gre_ioctl __P((struct ifnet *, u_long, caddr_t));
int gre_output __P((struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *rt));
diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c
index 7269d946f3d..cb9db7f993c 100644
--- a/sys/netinet/ip_gre.c
+++ b/sys/netinet/ip_gre.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_gre.c,v 1.8 2001/02/27 09:54:21 niklas Exp $ */
+/* $OpenBSD: ip_gre.c,v 1.9 2001/06/05 23:43:46 maja Exp $ */
/* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
@@ -365,8 +365,7 @@ gre_lookup(m, proto)
struct gre_softc *sc;
int i;
- for (i = 0; i < NGRE; i++) {
- sc = &gre_softc[i];
+ for (i = 0, sc = gre; i < ngre; i++, sc++) {
if ((sc->g_dst.s_addr == ip->ip_src.s_addr) &&
(sc->g_src.s_addr == ip->ip_dst.s_addr) &&
(sc->g_proto == proto) &&