From 82902fa3d86ea4768ffb2851bb2f6308cddf3db3 Mon Sep 17 00:00:00 2001 From: Nick Sayer Date: Sat, 29 Jul 2000 02:00:12 +0000 Subject: [PATCH] Make the bridge_refresh operation automatic when ethernet interfaces are attached or detached. --- sys/net/bridge.c | 7 ++++++- sys/net/bridge.h | 2 ++ sys/net/if_ethersubr.c | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/net/bridge.c b/sys/net/bridge.c index 5eb86ce0e39..ec9aada88ec 100644 --- a/sys/net/bridge.c +++ b/sys/net/bridge.c @@ -118,11 +118,12 @@ #define DEB(x) static void bdginit(void *); -static void bdgtakeifaces(void); static void flush_table(void); static void bdg_promisc_on(void); static void parse_bdg_cfg(void); +static int bdg_initialized = 0; + static int bdg_ipfw = 0 ; int do_bridge = 0; bdg_hash_table *bdg_table = NULL ; @@ -434,6 +435,7 @@ static void bdginit(void *dummy) { + bdg_initialized++; if (bdg_table == NULL) bdg_table = (struct hash_table *) malloc(HASH_SIZE * sizeof(struct hash_table), @@ -459,6 +461,9 @@ bdgtakeifaces(void) u_char *eth_addr ; struct bdg_softc *bp; + if (!bdg_initialized) + return; + bdg_ports = 0 ; eth_addr = bdg_addresses ; *bridge_cfg = '\0'; diff --git a/sys/net/bridge.h b/sys/net/bridge.h index ea2db417059..246bb871789 100644 --- a/sys/net/bridge.h +++ b/sys/net/bridge.h @@ -41,6 +41,8 @@ extern bdg_hash_table *bdg_table ; extern unsigned char bdg_addresses[6*BDG_MAX_PORTS]; extern int bdg_ports ; +extern void bdgtakeifaces(void); + /* * out of the 6 bytes, the last ones are more "variable". Since * we are on a little endian machine, we have to do some gimmick... diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index d7c410b0c81..e8cfa0d6345 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -671,6 +671,9 @@ ether_ifattach(ifp, bpf) bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); if (ng_ether_attach_p != NULL) (*ng_ether_attach_p)(ifp); +#ifdef BRIDGE + bdgtakeifaces(); +#endif } /* @@ -686,6 +689,9 @@ ether_ifdetach(ifp, bpf) if (bpf) bpfdetach(ifp); if_detach(ifp); +#ifdef BRIDGE + bdgtakeifaces(); +#endif } SYSCTL_DECL(_net_link);