Changeset View
Changeset View
Standalone View
Standalone View
sys/netgraph/ng_bridge.c
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | |||||
struct ng_bridge_private { | struct ng_bridge_private { | ||||
struct ng_bridge_bucket *tab; /* hash table bucket array */ | struct ng_bridge_bucket *tab; /* hash table bucket array */ | ||||
struct ng_bridge_config conf; /* node configuration */ | struct ng_bridge_config conf; /* node configuration */ | ||||
node_p node; /* netgraph node */ | node_p node; /* netgraph node */ | ||||
u_int numHosts; /* num entries in table */ | u_int numHosts; /* num entries in table */ | ||||
u_int numBuckets; /* num buckets in table */ | u_int numBuckets; /* num buckets in table */ | ||||
u_int hashMask; /* numBuckets - 1 */ | u_int hashMask; /* numBuckets - 1 */ | ||||
int numLinks; /* num connected links */ | int numLinks; /* num connected links */ | ||||
int persistent; /* can exist w/o hooks */ | unsigned int persistent : 1, /* can exist w/o hooks */ | ||||
sendUnknown : 1;/* links receive unknowns by default */ | |||||
struct callout timer; /* one second periodic timer */ | struct callout timer; /* one second periodic timer */ | ||||
}; | }; | ||||
typedef struct ng_bridge_private *priv_p; | typedef struct ng_bridge_private *priv_p; | ||||
/* Information about a host, stored in a hash table entry */ | /* Information about a host, stored in a hash table entry */ | ||||
struct ng_bridge_hent { | struct ng_bridge_hent { | ||||
struct ng_bridge_host host; /* actual host info */ | struct ng_bridge_host host; /* actual host info */ | ||||
SLIST_ENTRY(ng_bridge_hent) next; /* next entry in bucket */ | SLIST_ENTRY(ng_bridge_hent) next; /* next entry in bucket */ | ||||
▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | ng_bridge_constructor(node_p node) | ||||
priv->tab = malloc(MIN_BUCKETS * sizeof(*priv->tab), | priv->tab = malloc(MIN_BUCKETS * sizeof(*priv->tab), | ||||
M_NETGRAPH_BRIDGE, M_WAITOK | M_ZERO); | M_NETGRAPH_BRIDGE, M_WAITOK | M_ZERO); | ||||
priv->numBuckets = MIN_BUCKETS; | priv->numBuckets = MIN_BUCKETS; | ||||
priv->hashMask = MIN_BUCKETS - 1; | priv->hashMask = MIN_BUCKETS - 1; | ||||
priv->conf.debugLevel = 1; | priv->conf.debugLevel = 1; | ||||
priv->conf.loopTimeout = DEFAULT_LOOP_TIMEOUT; | priv->conf.loopTimeout = DEFAULT_LOOP_TIMEOUT; | ||||
priv->conf.maxStaleness = DEFAULT_MAX_STALENESS; | priv->conf.maxStaleness = DEFAULT_MAX_STALENESS; | ||||
priv->conf.minStableAge = DEFAULT_MIN_STABLE_AGE; | priv->conf.minStableAge = DEFAULT_MIN_STABLE_AGE; | ||||
priv->sendUnknown = 1; /* classic bridge */ | |||||
/* | /* | ||||
* This node has all kinds of stuff that could be screwed by SMP. | * This node has all kinds of stuff that could be screwed by SMP. | ||||
* Until it gets it's own internal protection, we go through in | * Until it gets it's own internal protection, we go through in | ||||
* single file. This could hurt a machine bridging between two | * single file. This could hurt a machine bridging between two | ||||
* GB ethernets so it should be fixed. | * GB ethernets so it should be fixed. | ||||
* When it's fixed the process SHOULD NOT SLEEP, spinlocks please! | * When it's fixed the process SHOULD NOT SLEEP, spinlocks please! | ||||
* (and atomic ops ) | * (and atomic ops ) | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | ng_bridge_newhook(node_p node, hook_p hook, const char *name) | ||||
link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, M_ZERO); | link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, M_ZERO); | ||||
if (link == NULL) | if (link == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
link->hook = hook; | link->hook = hook; | ||||
if (isUplink) { | if (isUplink) { | ||||
link->learnMac = 0; | link->learnMac = 0; | ||||
link->sendUnknown = 1; | link->sendUnknown = 1; | ||||
if (priv->numLinks == 0) /* if the first link is an uplink */ | |||||
priv->sendUnknown = 0; /* switch to restrictive mode */ | |||||
} else { | } else { | ||||
link->learnMac = 1; | link->learnMac = 1; | ||||
link->sendUnknown = 1; | link->sendUnknown = priv->sendUnknown; | ||||
} | } | ||||
NG_HOOK_SET_PRIVATE(hook, link); | NG_HOOK_SET_PRIVATE(hook, link); | ||||
priv->numLinks++; | priv->numLinks++; | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 741 Lines • Show Last 20 Lines |