* A new gif interface has been attached. * Create a new node for it, etc. */
| 222 | * Create a new node for it, etc. |
| 223 | */ |
| 224 | static void |
| 225 | ng_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. |
no test coverage detected