diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 4a9006703467..7014c057a570 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -143,15 +143,6 @@ static iffam_p get_iffam_from_hook(priv_p priv, hook_p hook); static iffam_p get_iffam_from_name(const char *name); static hook_p *get_hook_from_iffam(priv_p priv, iffam_p iffam); -/* Parse type for struct ng_iface_ifname */ -static const struct ng_parse_fixedstring_info ng_iface_ifname_info = { - NG_IFACE_IFACE_NAME_MAX + 1 -}; -static const struct ng_parse_type ng_iface_ifname_type = { - &ng_parse_fixedstring_type, - &ng_iface_ifname_info -}; - /* Parse type for struct ng_cisco_ipaddr */ static const struct ng_parse_struct_field ng_cisco_ipaddr_type_fields[] = NG_CISCO_IPADDR_TYPE_INFO; @@ -167,7 +158,7 @@ static const struct ng_cmdlist ng_iface_cmds[] = { NGM_IFACE_GET_IFNAME, "getifname", NULL, - &ng_iface_ifname_type + &ng_parse_string_type }, { NGM_IFACE_COOKIE, @@ -553,7 +544,6 @@ ng_iface_print_ioctl(struct ifnet *ifp, int command, caddr_t data) static int ng_iface_constructor(node_p node) { - char ifname[NG_IFACE_IFACE_NAME_MAX + 1]; struct ifnet *ifp; priv_p priv; int error = 0; @@ -599,10 +589,9 @@ ng_iface_constructor(node_p node) TAILQ_INIT(&ifp->if_addrhead); /* Give this node the same name as the interface (if possible) */ - bzero(ifname, sizeof(ifname)); - strlcpy(ifname, ifp->if_xname, sizeof(ifname)); - if (ng_name_node(node, ifname) != 0) - log(LOG_WARNING, "%s: can't acquire netgraph name\n", ifname); + if (ng_name_node(node, ifp->if_xname) != 0) + log(LOG_WARNING, "%s: can't acquire netgraph name\n", + ifp->if_xname); /* Attach the interface */ if_attach(ifp); @@ -647,19 +636,13 @@ ng_iface_rcvmsg(node_p node, item_p item, hook_p lasthook) case NGM_IFACE_COOKIE: switch (msg->header.cmd) { case NGM_IFACE_GET_IFNAME: - { - struct ng_iface_ifname *arg; - - NG_MKRESPONSE(resp, msg, sizeof(*arg), M_NOWAIT); + NG_MKRESPONSE(resp, msg, IFNAMSIZ, M_NOWAIT); if (resp == NULL) { error = ENOMEM; break; } - arg = (struct ng_iface_ifname *)resp->data; - strlcpy(arg->ngif_name, ifp->if_xname, - sizeof(arg->ngif_name)); + strlcpy(resp->data, ifp->if_xname, IFNAMSIZ); break; - } case NGM_IFACE_POINT2POINT: case NGM_IFACE_BROADCAST: diff --git a/sys/netgraph/ng_iface.h b/sys/netgraph/ng_iface.h index 721cc80e7ed4..bef1bcd3d6c6 100644 --- a/sys/netgraph/ng_iface.h +++ b/sys/netgraph/ng_iface.h @@ -50,7 +50,6 @@ /* Interface base name */ #define NG_IFACE_IFACE_NAME "ng" -#define NG_IFACE_IFACE_NAME_MAX 15 /* My hook names */ #define NG_IFACE_HOOK_INET "inet" @@ -73,8 +72,4 @@ enum { NGM_IFACE_GET_IFINDEX, }; -struct ng_iface_ifname { - char ngif_name[NG_IFACE_IFACE_NAME_MAX + 1]; -}; - #endif /* _NETGRAPH_NG_IFACE_H_ */ diff --git a/sys/netgraph/ng_sppp.c b/sys/netgraph/ng_sppp.c index 2cf86e9983d8..a53c956e16e7 100644 --- a/sys/netgraph/ng_sppp.c +++ b/sys/netgraph/ng_sppp.c @@ -70,16 +70,6 @@ static ng_newhook_t ng_sppp_newhook; static ng_rcvdata_t ng_sppp_rcvdata; static ng_disconnect_t ng_sppp_disconnect; -/* Parse type for struct ng_sppp_ifname */ -static const struct ng_parse_fixedstring_info ng_sppp_ifname_info = { - NG_SPPP_IFACE_NAME_MAX + 1 -}; - -static const struct ng_parse_type ng_sppp_ifname_type = { - &ng_parse_fixedstring_type, - &ng_sppp_ifname_info -}; - /* List of commands and how to convert arguments to/from ASCII */ static const struct ng_cmdlist ng_sppp_cmds[] = { { @@ -87,7 +77,7 @@ static const struct ng_cmdlist ng_sppp_cmds[] = { NGM_SPPP_GET_IFNAME, "getifname", NULL, - &ng_sppp_ifname_type + &ng_parse_string_type }, { 0 } }; @@ -252,7 +242,6 @@ ng_sppp_start (struct ifnet *ifp) static int ng_sppp_constructor (node_p node) { - char ifname[NG_SPPP_IFACE_NAME_MAX + 1]; struct sppp *pp; priv_p priv; int error = 0; @@ -291,10 +280,9 @@ ng_sppp_constructor (node_p node) pp->pp_if.if_flags = (IFF_POINTOPOINT|IFF_MULTICAST); /* Give this node the same name as the interface (if possible) */ - bzero (ifname, sizeof(ifname)); - snprintf (ifname, sizeof(ifname), "%s%d", NG_SPPP_IFACE_NAME, priv->unit); - if (ng_name_node(node, ifname) != 0) - log (LOG_WARNING, "%s: can't acquire netgraph name\n", ifname); + if (ng_name_node(node, pp->pp_if.if_xname) != 0) + log (LOG_WARNING, "%s: can't acquire netgraph name\n", + pp->pp_if.if_xname); /* Attach the interface */ sppp_attach (&pp->pp_if); @@ -342,19 +330,13 @@ ng_sppp_rcvmsg (node_p node, item_p item, hook_p lasthook) case NGM_SPPP_COOKIE: switch (msg->header.cmd) { case NGM_SPPP_GET_IFNAME: - { - struct ng_sppp_ifname *arg; - - NG_MKRESPONSE (resp, msg, sizeof (*arg), M_NOWAIT); + NG_MKRESPONSE (resp, msg, IFNAMSIZ, M_NOWAIT); if (!resp) { error = ENOMEM; break; } - arg = (struct ng_sppp_ifname *)resp->data; - snprintf (arg->ngif_name, sizeof (arg->ngif_name), - "%s", pp->pp_if.if_xname); + strlcpy(resp->data, pp->pp_if.if_xname, IFNAMSIZ); break; - } default: error = EINVAL; diff --git a/sys/netgraph/ng_sppp.h b/sys/netgraph/ng_sppp.h index e8353511ddfa..be1631e48f36 100644 --- a/sys/netgraph/ng_sppp.h +++ b/sys/netgraph/ng_sppp.h @@ -27,7 +27,6 @@ /* Interface base name */ #define NG_SPPP_IFACE_NAME "sppp" -#define NG_SPPP_IFACE_NAME_MAX 15 /* My hook names */ #define NG_SPPP_HOOK_DOWNSTREAM "downstream" @@ -37,8 +36,4 @@ enum { NGM_SPPP_GET_IFNAME = 1, /* returns struct ng_sppp_ifname */ }; -struct ng_sppp_ifname { - char ngif_name[NG_SPPP_IFACE_NAME_MAX + 1]; -}; - #endif /* _NETGRAPH_SPPP_H_ */