* Node constructor */
| 290 | * Node constructor |
| 291 | */ |
| 292 | static int |
| 293 | ng_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 |
nothing calls this directly
no test coverage detected