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

Function ng_gif_attach

freebsd/netgraph/ng_gif.c:224–255  ·  view source on GitHub ↗

* A new gif interface has been attached. * Create a new node for it, etc. */

Source from the content-addressed store, hash-verified

222 * Create a new node for it, etc.
223 */
224static void
225ng_gif_attach(struct ifnet *ifp)
226{
227 priv_p priv;
228 node_p node;
229
230 /* Create node */
231 KASSERT(!IFP2NG(ifp), ("%s: node already exists?", __func__));
232 if (ng_make_node_common(&ng_gif_typestruct, &node) != 0) {
233 log(LOG_ERR, "%s: can't %s for %s\n",
234 __func__, "create node", ifp->if_xname);
235 return;
236 }
237
238 /* Allocate private data */
239 priv = malloc(sizeof(*priv), M_NETGRAPH, M_NOWAIT | M_ZERO);
240 if (priv == NULL) {
241 log(LOG_ERR, "%s: can't %s for %s\n",
242 __func__, "allocate memory", ifp->if_xname);
243 NG_NODE_UNREF(node);
244 return;
245 }
246 NG_NODE_SET_PRIVATE(node, priv);
247 priv->ifp = ifp;
248 IFP2NG_SET(ifp, node);
249
250 /* Try to give the node the same name as the interface */
251 if (ng_name_node(node, ifp->if_xname) != 0) {
252 log(LOG_WARNING, "%s: can't name node %s\n",
253 __func__, ifp->if_xname);
254 }
255}
256
257/*
258 * An interface is being detached.

Callers 1

ng_gif_mod_eventFunction · 0.85

Calls 4

mallocFunction · 0.85
ng_make_node_commonFunction · 0.70
ng_name_nodeFunction · 0.70
logFunction · 0.50

Tested by

no test coverage detected