diff options
Diffstat (limited to 'sys/netgraph/ng_ether.c')
-rw-r--r-- | sys/netgraph/ng_ether.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c index 041999c..8cfd053 100644 --- a/sys/netgraph/ng_ether.c +++ b/sys/netgraph/ng_ether.c @@ -289,16 +289,14 @@ ng_ether_output(struct ifnet *ifp, struct mbuf **mp) static void ng_ether_attach(struct ifnet *ifp) { - char name[IFNAMSIZ + 1]; priv_p priv; node_p node; /* Create node */ KASSERT(!IFP2NG(ifp), ("%s: node already exists?", __func__)); - snprintf(name, sizeof(name), "%s%d", ifp->if_name, ifp->if_unit); if (ng_make_node_common(&ng_ether_typestruct, &node) != 0) { log(LOG_ERR, "%s: can't %s for %s\n", - __func__, "create node", name); + __func__, "create node", ifp->if_xname); return; } @@ -306,7 +304,7 @@ ng_ether_attach(struct ifnet *ifp) MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT | M_ZERO); if (priv == NULL) { log(LOG_ERR, "%s: can't %s for %s\n", - __func__, "allocate memory", name); + __func__, "allocate memory", ifp->if_xname); NG_NODE_UNREF(node); return; } @@ -317,9 +315,9 @@ ng_ether_attach(struct ifnet *ifp) priv->hwassist = ifp->if_hwassist; /* Try to give the node the same name as the interface */ - if (ng_name_node(node, name) != 0) { + if (ng_name_node(node, ifp->if_xname) != 0) { log(LOG_WARNING, "%s: can't name node %s\n", - __func__, name); + __func__, ifp->if_xname); } } @@ -434,8 +432,7 @@ ng_ether_rcvmsg(node_p node, item_p item, hook_p lasthook) error = ENOMEM; break; } - snprintf(resp->data, IFNAMSIZ + 1, - "%s%d", priv->ifp->if_name, priv->ifp->if_unit); + strlcpy(resp->data, priv->ifp->if_xname, IFNAMSIZ + 1); break; case NGM_ETHER_GET_IFINDEX: NG_MKRESPONSE(resp, msg, sizeof(u_int32_t), M_NOWAIT); |