diff options
Diffstat (limited to 'sys/netgraph')
-rw-r--r-- | sys/netgraph/atm/ng_atm.c | 8 | ||||
-rw-r--r-- | sys/netgraph/ng_bridge.c | 3 | ||||
-rw-r--r-- | sys/netgraph/ng_eiface.c | 19 | ||||
-rw-r--r-- | sys/netgraph/ng_ether.c | 13 | ||||
-rw-r--r-- | sys/netgraph/ng_fec.c | 32 | ||||
-rw-r--r-- | sys/netgraph/ng_gif.c | 13 | ||||
-rw-r--r-- | sys/netgraph/ng_iface.c | 17 |
7 files changed, 43 insertions, 62 deletions
diff --git a/sys/netgraph/atm/ng_atm.c b/sys/netgraph/atm/ng_atm.c index 412f740..cb0c921 100644 --- a/sys/netgraph/atm/ng_atm.c +++ b/sys/netgraph/atm/ng_atm.c @@ -866,8 +866,7 @@ text_status(node_p node, char *arg, u_int len) mib = (const struct ifatm_mib *)(priv->ifp->if_linkmib); sbuf_new(&sbuf, arg, len, SBUF_FIXEDLEN); - sbuf_printf(&sbuf, "interface: %s%d\n", priv->ifp->if_name, - priv->ifp->if_unit); + sbuf_printf(&sbuf, "interface: %s\n", priv->ifp->if_xname); if (mib->device >= sizeof(devices) / sizeof(devices[0])) sbuf_printf(&sbuf, "device=unknown\nvendor=unknown\n"); @@ -940,8 +939,7 @@ ng_atm_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_ATM_GET_CONFIG: @@ -1265,7 +1263,7 @@ ng_atm_attach(struct ifnet *ifp) KASSERT(IFP2NG(ifp) == 0, ("%s: node alreay exists?", __FUNCTION__)); - snprintf(name, sizeof(name), "%s%d", ifp->if_name, ifp->if_unit); + strlcpy(name, ifp->if_xname, sizeof(name)); if (ng_make_node_common(&ng_atm_typestruct, &node) != 0) { log(LOG_ERR, "%s: can't create node for %s\n", diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 476e433..445f3e6 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -600,8 +600,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item) if (ifp != NULL) snprintf(suffix, sizeof(suffix), - " (%s%d)", ifp->if_name, - ifp->if_unit); + " (%s)", ifp->if_xname); else *suffix = '\0'; log(LOG_WARNING, "ng_bridge: %s:" diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c index 7588c92..460f8da 100644 --- a/sys/netgraph/ng_eiface.c +++ b/sys/netgraph/ng_eiface.c @@ -121,8 +121,6 @@ static struct ng_type typestruct = { }; NETGRAPH_INIT(eiface, &typestruct); -static char ng_eiface_ifname[] = NG_EIFACE_EIFACE_NAME; - /* We keep a bitmap indicating which unit numbers are free. One means the unit number is free, zero means it's taken. */ static int *ng_eiface_units = NULL; @@ -393,8 +391,8 @@ ng_eiface_print_ioctl(struct ifnet *ifp, int command, caddr_t data){ default: str = "IO??"; } - log(LOG_DEBUG, "%s%d: %s('%c', %d, char[%d])\n", - ifp->if_name, ifp->if_unit, + log(LOG_DEBUG, "%s: %s('%c', %d, char[%d])\n", + ifp->if_xname, str, IOCGROUP(command), command & 0xff, @@ -440,8 +438,7 @@ ng_eiface_constructor(node_p node) priv->node = node; /* Initialize interface structure */ - ifp->if_name = ng_eiface_ifname; - ifp->if_unit = priv->unit; + if_initname(ifp, NG_EIFACE_EIFACE_NAME, priv->unit); ifp->if_init = ng_eiface_init; ifp->if_output = ether_output; ifp->if_start = ng_eiface_start; @@ -452,7 +449,7 @@ ng_eiface_constructor(node_p node) /* * Give this node name * bzero(ifname, sizeof(ifname)); - * sprintf(ifname, "if%s%d", ifp->if_name, ifp->if_unit); (void) + * sprintf(ifname, "if%s", ifp->if_xname); (void) * ng_name_node(node, ifname); */ @@ -539,8 +536,8 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook) break; } arg = (struct ng_eiface_ifname *)resp->data; - sprintf(arg->ngif_name, - "%s%d", ifp->if_name, ifp->if_unit); + strlcpy(arg->ngif_name, ifp->if_xname, + sizeof(arg->ngif_name)); break; } @@ -567,8 +564,8 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook) const int len = SA_SIZE(ifa->ifa_addr); if (buflen < len) { - log(LOG_ERR, "%s%d: len changed?\n", - ifp->if_name, ifp->if_unit); + log(LOG_ERR, "%s: len changed?\n", + ifp->if_xname); break; } bcopy(ifa->ifa_addr, ptr, len); 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); diff --git a/sys/netgraph/ng_fec.c b/sys/netgraph/ng_fec.c index 82b740d..81e19f4 100644 --- a/sys/netgraph/ng_fec.c +++ b/sys/netgraph/ng_fec.c @@ -567,8 +567,7 @@ ng_fec_tick(void *arg) error = (*ifp->if_ioctl)(ifp, SIOCGIFMEDIA, (caddr_t)&ifmr); if (error) { printf("fec%d: failed to check status " - "of link %s%d\n", priv->unit, ifp->if_name, - ifp->if_unit); + "of link %s\n", priv->unit, ifp->if_xname); continue; } @@ -578,17 +577,17 @@ ng_fec_tick(void *arg) if (p->fec_ifstat == -1 || p->fec_ifstat == 0) { p->fec_ifstat = 1; - printf("fec%d: port %s%d in bundle " + printf("fec%d: port %s in bundle " "is up\n", priv->unit, - ifp->if_name, ifp->if_unit); + ifp->if_xname); } } else { if (p->fec_ifstat == -1 || p->fec_ifstat == 1) { p->fec_ifstat = 0; - printf("fec%d: port %s%d in bundle " + printf("fec%d: port %s in bundle " "is down\n", priv->unit, - ifp->if_name, ifp->if_unit); + ifp->if_xname); } } } @@ -817,15 +816,15 @@ ng_fec_output(struct ifnet *ifp, struct mbuf *m, #endif else { #ifdef DEBUG - printf("fec%d: can't do inet aggregation of non " - "inet packet\n", ifp->if_unit); + if_printf(ifp, "can't do inet aggregation of non " + "inet packet\n"); #endif m->m_flags |= M_FEC_MAC; } break; #endif default: - printf("fec%d: bogus hash type: %d\n", ifp->if_unit, + if_printf(ifp, "bogus hash type: %d\n", b->fec_btype); m_freem(m); return(EINVAL); @@ -1029,8 +1028,8 @@ ng_fec_print_ioctl(struct ifnet *ifp, int command, caddr_t data) default: str = "IO??"; } - log(LOG_DEBUG, "%s%d: %s('%c', %d, char[%d])\n", - ifp->if_name, ifp->if_unit, + log(LOG_DEBUG, "%s: %s('%c', %d, char[%d])\n", + ifp->if_xname, str, IOCGROUP(command), command & 0xff, @@ -1079,8 +1078,7 @@ ng_fec_constructor(node_p node) priv->arpcom.ac_netgraph = node; /* Initialize interface structure */ - ifp->if_name = NG_FEC_FEC_NAME; - ifp->if_unit = priv->unit; + if_initname(ifp, NG_FEC_FEC_NAME, priv->unit); ifp->if_start = ng_fec_start; ifp->if_ioctl = ng_fec_ioctl; ifp->if_init = ng_fec_init; @@ -1096,7 +1094,7 @@ ng_fec_constructor(node_p node) /* Give this node the same name as the interface (if possible) */ bzero(ifname, sizeof(ifname)); - snprintf(ifname, sizeof(ifname), "%s%d", ifp->if_name, ifp->if_unit); + 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); @@ -1182,17 +1180,13 @@ ng_fec_shutdown(node_p node) const priv_p priv = NG_NODE_PRIVATE(node); struct ng_fec_bundle *b; struct ng_fec_portlist *p; - char ifname[IFNAMSIZ]; b = &priv->fec_bundle; ng_fec_stop(&priv->arpcom.ac_if); while (!TAILQ_EMPTY(&b->ng_fec_ports)) { p = TAILQ_FIRST(&b->ng_fec_ports); - sprintf(ifname, "%s%d", - p->fec_if->if_name, - p->fec_if->if_unit); - ng_fec_delport(priv, ifname); + ng_fec_delport(priv, p->fec_if->if_xname); } ether_ifdetach(&priv->arpcom.ac_if); diff --git a/sys/netgraph/ng_gif.c b/sys/netgraph/ng_gif.c index 2d99959..794378b 100644 --- a/sys/netgraph/ng_gif.c +++ b/sys/netgraph/ng_gif.c @@ -227,16 +227,14 @@ ng_gif_input2(node_p node, struct mbuf **mp, int af) static void ng_gif_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_gif_typestruct, &node) != 0) { log(LOG_ERR, "%s: can't %s for %s\n", - __func__, "create node", name); + __func__, "create node", ifp->if_xname); return; } @@ -244,7 +242,7 @@ ng_gif_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; } @@ -253,9 +251,9 @@ ng_gif_attach(struct ifnet *ifp) IFP2NG(ifp) = node; /* 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); } } @@ -410,8 +408,7 @@ ng_gif_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_GIF_GET_IFINDEX: NG_MKRESPONSE(resp, msg, sizeof(u_int32_t), M_NOWAIT); diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 3aa34f2..ca637e7 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -449,8 +449,8 @@ ng_iface_output(struct ifnet *ifp, struct mbuf *m, /* Check address family to determine hook (if known) */ if (iffam == NULL) { m_freem(m); - log(LOG_WARNING, "%s%d: can't handle af%d\n", - ifp->if_name, ifp->if_unit, (int)dst->sa_family); + log(LOG_WARNING, "%s: can't handle af%d\n", + ifp->if_xname, (int)dst->sa_family); return (EAFNOSUPPORT); } @@ -524,8 +524,8 @@ ng_iface_print_ioctl(struct ifnet *ifp, int command, caddr_t data) default: str = "IO??"; } - log(LOG_DEBUG, "%s%d: %s('%c', %d, char[%d])\n", - ifp->if_name, ifp->if_unit, + log(LOG_DEBUG, "%s: %s('%c', %d, char[%d])\n", + ifp->if_xname, str, IOCGROUP(command), command & 0xff, @@ -574,8 +574,7 @@ ng_iface_constructor(node_p node) priv->node = node; /* Initialize interface structure */ - ifp->if_name = NG_IFACE_IFACE_NAME; - ifp->if_unit = priv->unit; + if_initname(ifp, NG_IFACE_IFACE_NAME, priv->unit); ifp->if_output = ng_iface_output; ifp->if_start = ng_iface_start; ifp->if_ioctl = ng_iface_ioctl; @@ -591,7 +590,7 @@ ng_iface_constructor(node_p node) /* Give this node the same name as the interface (if possible) */ bzero(ifname, sizeof(ifname)); - snprintf(ifname, sizeof(ifname), "%s%d", ifp->if_name, ifp->if_unit); + 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); @@ -647,8 +646,8 @@ ng_iface_rcvmsg(node_p node, item_p item, hook_p lasthook) break; } arg = (struct ng_iface_ifname *)resp->data; - snprintf(arg->ngif_name, sizeof(arg->ngif_name), - "%s%d", ifp->if_name, ifp->if_unit); + strlcpy(arg->ngif_name, ifp->if_xname, + sizeof(arg->ngif_name)); break; } |