MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_bridge_constructor

Function ng_bridge_constructor

freebsd/netgraph/ng_bridge.c:292–328  ·  view source on GitHub ↗

* Node constructor */

Source from the content-addressed store, hash-verified

290 * Node constructor
291 */
292static int
293ng_bridge_constructor(node_p node)
294{
295 priv_p priv;
296
297 /* Allocate and initialize private info */
298 priv = malloc(sizeof(*priv), M_NETGRAPH_BRIDGE, M_WAITOK | M_ZERO);
299 ng_callout_init(&priv->timer);
300
301 /* Allocate and initialize hash table, etc. */
302 priv->tab = malloc(MIN_BUCKETS * sizeof(*priv->tab),
303 M_NETGRAPH_BRIDGE, M_WAITOK | M_ZERO);
304 priv->numBuckets = MIN_BUCKETS;
305 priv->hashMask = MIN_BUCKETS - 1;
306 priv->conf.debugLevel = 1;
307 priv->conf.loopTimeout = DEFAULT_LOOP_TIMEOUT;
308 priv->conf.maxStaleness = DEFAULT_MAX_STALENESS;
309 priv->conf.minStableAge = DEFAULT_MIN_STABLE_AGE;
310
311 /*
312 * This node has all kinds of stuff that could be screwed by SMP.
313 * Until it gets it's own internal protection, we go through in
314 * single file. This could hurt a machine bridging between two
315 * GB ethernets so it should be fixed.
316 * When it's fixed the process SHOULD NOT SLEEP, spinlocks please!
317 * (and atomic ops )
318 */
319 NG_NODE_FORCE_WRITER(node);
320 NG_NODE_SET_PRIVATE(node, priv);
321 priv->node = node;
322
323 /* Start timer; timer is always running while node is alive */
324 ng_callout(&priv->timer, node, NULL, hz, ng_bridge_timeout, NULL, 0);
325
326 /* Done */
327 return (0);
328}
329
330/*
331 * Method for attaching a new hook

Callers

nothing calls this directly

Calls 2

mallocFunction · 0.85
ng_calloutFunction · 0.70

Tested by

no test coverage detected