summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2003-10-31 18:32:15 +0000
committerbrooks <brooks@FreeBSD.org>2003-10-31 18:32:15 +0000
commitf1e94c6f29b079e4ad9d9305ef3e90a719bcbbda (patch)
tree4d9e6671d486576767506230a4240131526fea49
parentbe546fdee455a96afdefee10d0bdba8547399f5b (diff)
downloadFreeBSD-src-f1e94c6f29b079e4ad9d9305ef3e90a719bcbbda.zip
FreeBSD-src-f1e94c6f29b079e4ad9d9305ef3e90a719bcbbda.tar.gz
Replace the if_name and if_unit members of struct ifnet with new members
if_xname, if_dname, and if_dunit. if_xname is the name of the interface and if_dname/unit are the driver name and instance. This change paves the way for interface renaming and enhanced pseudo device creation and configuration symantics. Approved By: re (in principle) Reviewed By: njl, imp Tested On: i386, amd64, sparc64 Obtained From: NetBSD (if_xname)
-rw-r--r--UPDATING8
-rw-r--r--sbin/ip6fw/ip6fw.c35
-rw-r--r--sbin/ipfw/ipfw2.c20
-rw-r--r--share/man/man9/ifnet.936
-rw-r--r--sys/alpha/osf1/osf1_ioctl.c2
-rw-r--r--sys/compat/linux/linux_ioctl.c11
-rw-r--r--sys/contrib/dev/oltr/if_oltr.c3
-rw-r--r--sys/contrib/ipfilter/netinet/ip_compat.h3
-rw-r--r--sys/contrib/ipfilter/netinet/ip_fil.c15
-rw-r--r--sys/contrib/ipfilter/netinet/ip_log.c3
-rw-r--r--sys/dev/an/if_an.c5
-rw-r--r--sys/dev/ar/if_ar.c4
-rw-r--r--sys/dev/ath/if_ath.c4
-rw-r--r--sys/dev/awi/if_awi_pccard.c7
-rw-r--r--sys/dev/bfe/if_bfe.c3
-rw-r--r--sys/dev/bge/if_bge.c3
-rw-r--r--sys/dev/cm/if_cm_isa.c2
-rw-r--r--sys/dev/cm/smc90cx6.c25
-rw-r--r--sys/dev/cm/smc90cx6var.h2
-rw-r--r--sys/dev/cnw/if_cnw.c3
-rw-r--r--sys/dev/cs/if_cs.c12
-rw-r--r--sys/dev/cs/if_cs_isa.c3
-rw-r--r--sys/dev/cs/if_cs_pccard.c3
-rw-r--r--sys/dev/cs/if_csvar.h2
-rw-r--r--sys/dev/dc/if_dc.c3
-rw-r--r--sys/dev/de/if_de.c153
-rw-r--r--sys/dev/de/if_devar.h6
-rw-r--r--sys/dev/ed/if_ed.c26
-rw-r--r--sys/dev/ed/if_ed_cbus.c2
-rw-r--r--sys/dev/ed/if_ed_isa.c3
-rw-r--r--sys/dev/ed/if_ed_pccard.c3
-rw-r--r--sys/dev/ed/if_ed_pci.c2
-rw-r--r--sys/dev/ed/if_edvar.h2
-rw-r--r--sys/dev/em/if_em.c3
-rw-r--r--sys/dev/en/if_en_pci.c7
-rw-r--r--sys/dev/en/midway.c5
-rw-r--r--sys/dev/ep/if_ep.c3
-rw-r--r--sys/dev/ex/if_ex.c16
-rw-r--r--sys/dev/fatm/if_fatm.c3
-rw-r--r--sys/dev/fe/if_fe.c57
-rw-r--r--sys/dev/fe/if_fevar.h3
-rw-r--r--sys/dev/firewire/if_fwe.c11
-rw-r--r--sys/dev/fxp/if_fxp.c3
-rw-r--r--sys/dev/gem/if_gem.c4
-rw-r--r--sys/dev/gx/if_gx.c3
-rw-r--r--sys/dev/harp/if_harp.c10
-rw-r--r--sys/dev/hatm/if_hatm.c5
-rw-r--r--sys/dev/hme/if_hme.c4
-rw-r--r--sys/dev/ie/if_ie.c3
-rw-r--r--sys/dev/iicbus/if_ic.c7
-rw-r--r--sys/dev/lge/if_lge.c3
-rw-r--r--sys/dev/lnc/if_lnc.c83
-rw-r--r--sys/dev/mii/brgphy.c4
-rw-r--r--sys/dev/my/if_my.c3
-rw-r--r--sys/dev/nge/if_nge.c3
-rw-r--r--sys/dev/patm/if_patm_attach.c3
-rw-r--r--sys/dev/pdq/if_fea.c5
-rw-r--r--sys/dev/pdq/if_fpa.c5
-rw-r--r--sys/dev/pdq/pdq_freebsd.h4
-rw-r--r--sys/dev/pdq/pdqvar.h2
-rw-r--r--sys/dev/ppbus/if_plip.c7
-rw-r--r--sys/dev/ray/if_ray.c3
-rw-r--r--sys/dev/re/if_re.c3
-rw-r--r--sys/dev/sbni/if_sbni.c5
-rw-r--r--sys/dev/sbni/if_sbni_isa.c4
-rw-r--r--sys/dev/sbsh/if_sbsh.c3
-rw-r--r--sys/dev/sf/if_sf.c3
-rw-r--r--sys/dev/sk/if_sk.c3
-rw-r--r--sys/dev/sn/if_sn.c3
-rw-r--r--sys/dev/sr/if_sr.c4
-rw-r--r--sys/dev/ti/if_ti.c5
-rw-r--r--sys/dev/tx/if_tx.c3
-rw-r--r--sys/dev/txp/if_txp.c3
-rw-r--r--sys/dev/usb/if_aue.c3
-rw-r--r--sys/dev/usb/if_axe.c3
-rw-r--r--sys/dev/usb/if_cue.c3
-rw-r--r--sys/dev/usb/if_kue.c3
-rw-r--r--sys/dev/usb/if_rue.c3
-rw-r--r--sys/dev/vr/if_vr.c3
-rw-r--r--sys/dev/vx/if_vx.c10
-rw-r--r--sys/dev/vx/if_vx_eisa.c2
-rw-r--r--sys/dev/vx/if_vx_pci.c2
-rw-r--r--sys/dev/vx/if_vxvar.h2
-rw-r--r--sys/dev/wi/if_wi.c3
-rw-r--r--sys/dev/wl/if_wl.c31
-rw-r--r--sys/dev/xe/if_xe.c3
-rw-r--r--sys/i386/isa/cx.c9
-rw-r--r--sys/i386/isa/if_cx.c3
-rw-r--r--sys/i386/isa/if_el.c5
-rw-r--r--sys/i386/isa/if_le.c10
-rw-r--r--sys/i386/isa/if_rdp.c5
-rw-r--r--sys/i4b/driver/i4b_ipr.c13
-rw-r--r--sys/i4b/driver/i4b_isppp.c7
-rw-r--r--sys/net/bpf.c7
-rw-r--r--sys/net/bridge.c38
-rw-r--r--sys/net/if.c50
-rw-r--r--sys/net/if.h2
-rw-r--r--sys/net/if_arcsubr.c8
-rw-r--r--sys/net/if_atmsubr.c6
-rw-r--r--sys/net/if_disc.c3
-rw-r--r--sys/net/if_ef.c26
-rw-r--r--sys/net/if_ethersubr.c5
-rw-r--r--sys/net/if_faith.c3
-rw-r--r--sys/net/if_gif.c3
-rw-r--r--sys/net/if_gre.c3
-rw-r--r--sys/net/if_loop.c3
-rw-r--r--sys/net/if_media.c4
-rw-r--r--sys/net/if_mib.c11
-rw-r--r--sys/net/if_ppp.c11
-rw-r--r--sys/net/if_sl.c13
-rw-r--r--sys/net/if_spppsubr.c2
-rw-r--r--sys/net/if_stf.c3
-rw-r--r--sys/net/if_tap.c71
-rw-r--r--sys/net/if_tun.c11
-rw-r--r--sys/net/if_var.h8
-rw-r--r--sys/net/if_vlan.c7
-rw-r--r--sys/net/net_osdep.c12
-rw-r--r--sys/net/net_osdep.h2
-rw-r--r--sys/net/ppp_tty.c2
-rw-r--r--sys/net/rtsock.c3
-rw-r--r--sys/net80211/ieee80211_node.c2
-rw-r--r--sys/net80211/ieee80211_proto.c2
-rw-r--r--sys/netatalk/ddp_output.c8
-rw-r--r--sys/netatm/atm_if.c13
-rw-r--r--sys/netatm/atm_if.h2
-rw-r--r--sys/netatm/atm_socket.c2
-rw-r--r--sys/netatm/atm_usrreq.c2
-rw-r--r--sys/netatm/atm_var.h2
-rw-r--r--sys/netatm/ipatm/ipatm_usrreq.c7
-rw-r--r--sys/netatm/spans/spans_arp.c8
-rw-r--r--sys/netatm/uni/uniarp.c16
-rw-r--r--sys/netgraph/atm/ng_atm.c8
-rw-r--r--sys/netgraph/ng_bridge.c3
-rw-r--r--sys/netgraph/ng_eiface.c19
-rw-r--r--sys/netgraph/ng_ether.c13
-rw-r--r--sys/netgraph/ng_fec.c32
-rw-r--r--sys/netgraph/ng_gif.c13
-rw-r--r--sys/netgraph/ng_iface.c17
-rw-r--r--sys/netinet/if_ether.c21
-rw-r--r--sys/netinet/ip_divert.c5
-rw-r--r--sys/netinet/ip_dummynet.c11
-rw-r--r--sys/netinet/ip_fw.h2
-rw-r--r--sys/netinet/ip_fw2.c17
-rw-r--r--sys/netinet/ip_mroute.c10
-rw-r--r--sys/netinet6/ip6_fw.c17
-rw-r--r--sys/netinet6/ip6_fw.h2
-rw-r--r--sys/netinet6/ip6_mroute.c7
-rw-r--r--sys/netipx/ipx_ip.c8
-rw-r--r--sys/netnatm/natm.c4
-rw-r--r--sys/nfsclient/bootp_subr.c12
-rw-r--r--sys/nfsclient/nfs_diskless.c2
-rw-r--r--sys/pci/if_dc.c3
-rw-r--r--sys/pci/if_de.c153
-rw-r--r--sys/pci/if_devar.h6
-rw-r--r--sys/pci/if_pcn.c3
-rw-r--r--sys/pci/if_rl.c3
-rw-r--r--sys/pci/if_sf.c3
-rw-r--r--sys/pci/if_sis.c3
-rw-r--r--sys/pci/if_sk.c3
-rw-r--r--sys/pci/if_ste.c3
-rw-r--r--sys/pci/if_ti.c5
-rw-r--r--sys/pci/if_tl.c3
-rw-r--r--sys/pci/if_vr.c3
-rw-r--r--sys/pci/if_wb.c3
-rw-r--r--sys/pci/if_xl.c3
-rw-r--r--sys/security/mac_biba/mac_biba.c6
-rw-r--r--sys/security/mac_lomac/mac_lomac.c6
-rw-r--r--sys/sys/param.h2
-rw-r--r--usr.bin/netstat/if.c18
-rw-r--r--usr.bin/netstat/route.c9
-rw-r--r--usr.sbin/ifmcstat/ifmcstat.c4
171 files changed, 773 insertions, 921 deletions
diff --git a/UPDATING b/UPDATING
index 3fe2db4..b0a18f7 100644
--- a/UPDATING
+++ b/UPDATING
@@ -17,6 +17,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 5.x IS SLOW:
developers choose to disable these features on build machines
to maximize performance.
+20031031:
+ The API and ABI of struct ifnet have been changed by removing
+ the if_name and if_unit members and replacing them with
+ if_xname, if_dname, and if_dunit. All network drivers and most
+ userland programs which include net/if_var.h must be updated
+ and recompiled. __FreeBSD_version has been bumped to 501113 to
+ reflect this change.
+
20030928:
Changes to the cdevsw default functions have been made to remove
the need to specify nullopen() and nullclose() explicitly.
diff --git a/sbin/ip6fw/ip6fw.c b/sbin/ip6fw/ip6fw.c
index be9e175..9f00b0c 100644
--- a/sbin/ip6fw/ip6fw.c
+++ b/sbin/ip6fw/ip6fw.c
@@ -187,15 +187,9 @@ print_port(prot, port, comma)
static void
print_iface(char *key, union ip6_fw_if *un, int byname)
{
- char ifnb[IP6FW_IFNLEN+1];
if (byname) {
- strncpy(ifnb, un->fu_via_if.name, IP6FW_IFNLEN);
- ifnb[IP6FW_IFNLEN]='\0';
- if (un->fu_via_if.unit == -1)
- printf(" %s %s*", key, ifnb);
- else
- printf(" %s %s%d", key, ifnb, un->fu_via_if.unit);
+ printf(" %s %s", key, un->fu_via_if.name);
} else if (!IN6_IS_ADDR_UNSPECIFIED(&un->fu_via_ip6)) {
printf(" %s %s", key, inet_ntop(AF_INET6,&un->fu_via_ip6,ntop_buf,sizeof(ntop_buf)));
} else
@@ -825,13 +819,7 @@ verify_interface(union ip6_fw_if *ifu)
{
struct ifreq ifr;
- /*
- * If a unit was specified, check for that exact interface.
- * If a wildcard was specified, check for unit 0.
- */
- snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d",
- ifu->fu_via_if.name,
- ifu->fu_via_if.unit == -1 ? 0 : ifu->fu_via_if.unit);
+ strlcpy(ifr.ifr_name, ifu->fu_via_if.name, sizeof(ifr.ifr_name));
if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
warnx("warning: interface ``%s'' does not exist", ifr.ifr_name);
@@ -851,14 +839,17 @@ fill_iface(char *which, union ip6_fw_if *ifu, int *byname, int ac, char *arg)
char *q;
*byname = 1;
- strncpy(ifu->fu_via_if.name, arg, sizeof(ifu->fu_via_if.name));
- ifu->fu_via_if.name[sizeof(ifu->fu_via_if.name) - 1] = '\0';
- for (q = ifu->fu_via_if.name;
- *q && !isdigit(*q) && *q != '*'; q++)
- continue;
- ifu->fu_via_if.unit = (*q == '*') ? -1 : atoi(q);
- *q = '\0';
- verify_interface(ifu);
+ strlcpy(ifu->fu_via_if.name, arg, sizeof(ifu->fu_via_if.name));
+ /*
+ * We assume that strings containing '*', '?', or '['
+ * are ment to be shell pattern.
+ */
+ if (strpbrk(arg, "*?[") != NULL) {
+ ifu->fu_via_if.glob = 1;
+ } else {
+ ifu->fu_via_if.glob = 0;
+ verify_interface(ifu);
+ }
} else if (inet_pton(AF_INET6, arg, &ifu->fu_via_ip6) != 1) {
show_usage("bad ip6 address ``%s''", arg);
} else
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index a7d9acc..7597ebd 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -1156,11 +1156,7 @@ show_ipfw(struct ip_fw *rule, int pcwidth, int bcwidth)
if (cmdif->name[0] == '\0')
printf(" %s %s", s,
inet_ntoa(cmdif->p.ip));
- else if (cmdif->p.unit == -1)
- printf(" %s %s*", s, cmdif->name);
- else
- printf(" %s %s%d", s, cmdif->name,
- cmdif->p.unit);
+ printf(" %s %s", s, cmdif->name);
}
break;
@@ -2144,7 +2140,8 @@ delete(int ac, char *av[])
* fill the interface structure. We do not check the name as we can
* create interfaces dynamically, so checking them at insert time
* makes relatively little sense.
- * A '*' following the name means any unit.
+ * Interface names containing '*', '?', or '[' are assumed to be shell
+ * patterns which match interfaces.
*/
static void
fill_iface(ipfw_insn_if *cmd, char *arg)
@@ -2156,15 +2153,8 @@ fill_iface(ipfw_insn_if *cmd, char *arg)
if (!strcmp(arg, "any"))
cmd->o.len = 0; /* effectively ignore this command */
else if (!isdigit(*arg)) {
- char *q;
-
- strncpy(cmd->name, arg, sizeof(cmd->name));
- cmd->name[sizeof(cmd->name) - 1] = '\0';
- /* find first digit or wildcard */
- for (q = cmd->name; *q && !isdigit(*q) && *q != '*'; q++)
- continue;
- cmd->p.unit = (*q == '*') ? -1 : atoi(q);
- *q = '\0';
+ strlcpy(cmd->name, arg, sizeof(cmd->name));
+ cmd->p.glob = strpbrk(arg, "*?[") != NULL ? 1 : 0;
} else if (!inet_aton(arg, &cmd->p.ip))
errx(EX_DATAERR, "bad ip address ``%s''", arg);
}
diff --git a/share/man/man9/ifnet.9 b/share/man/man9/ifnet.9
index e68e99a..fdc5d1b 100644
--- a/share/man/man9/ifnet.9
+++ b/share/man/man9/ifnet.9
@@ -216,18 +216,30 @@ are as follows:
.Pq Vt "void *"
A pointer to the driver's private state block.
(Initialized by driver.)
-.It Va if_name
-.Pq Vt "char *"
-The name of the interface, not including the unit number
-(e.g.,
-.Dq Li de
-or
-.Dq Li lo ) .
-(Initialized by driver.)
.It Va if_link
.Pq Fn TAILQ_ENTRY ifnet
.Xr queue 3
macro glue.
+.It Va if_xname
+.Pq Vt "char *"
+The name of the interface,
+(e.g.,
+.Dq Li fxp0
+or
+.Dq Li lo0) .
+(Initialized by driver.)
+.It Va if_dname
+.Pq Vt "const char *"
+The name of the driver.
+(Initialized by driver.)
+.It Va if_dunit
+.Pq Vt int
+A unique number assigned to each interface managed by a particular
+driver.
+Drivers may choose to set this to
+.Dv IF_DUNIT_NONE
+if a unit number is not associated with the device.
+(Initialized by driver.)
.It Va if_addrhead
.Pq Vt "struct ifaddrhead"
The head of the
@@ -255,14 +267,6 @@ This number can be used in a
to refer to a particular interface by index
(see
.Xr link_addr 3 ) .
-.It Va if_unit
-.Pq Vt short
-A unique number assigned to each interface managed by a particular
-driver, usually related to the unit number of a physical device in the
-kernel configuration file
-(see
-.Xr config 8 ) .
-(Initialized by driver.)
.It Va if_timer
.Pq Vt short
Number of seconds until the watchdog timer
diff --git a/sys/alpha/osf1/osf1_ioctl.c b/sys/alpha/osf1/osf1_ioctl.c
index 88892a4..1b4a6b1 100644
--- a/sys/alpha/osf1/osf1_ioctl.c
+++ b/sys/alpha/osf1/osf1_ioctl.c
@@ -207,7 +207,7 @@ osf1_ioctl_i(td, uap, cmd, dir, len)
* because osf/1 doesn't know about most of them.
*/
if (ifp->if_type == IFT_ETHER
- && strcmp(ifp->if_name, "ti") != 0) { /* looks good */
+ && strcmp(ifp->if_dname, "ti") != 0) { /* looks good */
/* walk the address list */
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) /* we have an address structure */
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index 3bb0a6d..bc6f0d8 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -1881,8 +1881,7 @@ linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen)
/* Short-circuit non ethernet interfaces */
if (!IFP_IS_ETH(ifp))
- return (snprintf(buffer, buflen, "%s%d", ifp->if_name,
- ifp->if_unit));
+ return (strlcpy(buffer, ifp->if_xname, buflen));
/* Determine the (relative) unit number for ethernet interfaces */
ethno = 0;
@@ -1932,15 +1931,14 @@ ifname_linux_to_bsd(const char *lxname, char *bsdname)
* we never have an interface named "eth", so don't make
* the test optional based on is_eth.
*/
- if (ifp->if_unit == unit && ifp->if_name[len] == '\0' &&
- strncmp(ifp->if_name, lxname, len) == 0)
+ if (strncmp(ifp->if_xname, lxname, LINUX_IFNAMSIZ) == 0)
break;
if (is_eth && IFP_IS_ETH(ifp) && unit == index++)
break;
}
IFNET_RUNLOCK();
if (ifp != NULL)
- snprintf(bsdname, IFNAMSIZ, "%s%d", ifp->if_name, ifp->if_unit);
+ strlcpy(bsdname, ifp->if_xname, IFNAMSIZ);
return (ifp);
}
@@ -1988,8 +1986,7 @@ linux_ifconf(struct thread *td, struct ifconf *uifc)
snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "eth%d",
ethno++);
else
- snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "%s%d",
- ifp->if_name, ifp->if_unit);
+ strlcpy(ifr.ifr_name, ifp->if_xname, LINUX_IFNAMSIZ);
/* Walk the address list */
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
diff --git a/sys/contrib/dev/oltr/if_oltr.c b/sys/contrib/dev/oltr/if_oltr.c
index 235d981..499580f 100644
--- a/sys/contrib/dev/oltr/if_oltr.c
+++ b/sys/contrib/dev/oltr/if_oltr.c
@@ -394,8 +394,7 @@ oltr_pci_attach(device_t dev)
* Do the ifnet initialization
*/
ifp->if_softc = sc;
- ifp->if_unit = device_get_unit(dev);
- ifp->if_name = "oltr";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_init = oltr_init;
ifp->if_start = oltr_start;
ifp->if_ioctl = oltr_ioctl;
diff --git a/sys/contrib/ipfilter/netinet/ip_compat.h b/sys/contrib/ipfilter/netinet/ip_compat.h
index 90fc988..d14ad2b 100644
--- a/sys/contrib/ipfilter/netinet/ip_compat.h
+++ b/sys/contrib/ipfilter/netinet/ip_compat.h
@@ -542,7 +542,8 @@ extern ill_t *get_unit __P((char *, int));
# ifndef linux
# define GETUNIT(n, v) ifunit(n)
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
- (defined(OpenBSD) && (OpenBSD >= 199603))
+ (defined(OpenBSD) && (OpenBSD >= 199603)) || \
+ (defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
# define IFNAME(x) ((struct ifnet *)x)->if_xname
# else
# define USE_GETIFNAME 1
diff --git a/sys/contrib/ipfilter/netinet/ip_fil.c b/sys/contrib/ipfilter/netinet/ip_fil.c
index 61c4ceb..6b9bafb 100644
--- a/sys/contrib/ipfilter/netinet/ip_fil.c
+++ b/sys/contrib/ipfilter/netinet/ip_fil.c
@@ -2075,7 +2075,8 @@ ip_t *ip;
int fd;
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
- (defined(OpenBSD) && (OpenBSD >= 199603))
+ (defined(OpenBSD) && (OpenBSD >= 199603)) || \
+ (defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
sprintf(fname, "%s", ifp->if_xname);
# else
sprintf(fname, "%s%d", ifp->if_name, ifp->if_unit);
@@ -2095,7 +2096,8 @@ char *get_ifname(ifp)
struct ifnet *ifp;
{
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
- (defined(OpenBSD) && (OpenBSD >= 199603))
+ (defined(OpenBSD) && (OpenBSD >= 199603)) || \
+ (defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
return ifp->if_xname;
# else
static char fullifname[LIFNAMSIZ];
@@ -2114,7 +2116,8 @@ int v;
for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) {
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
- (defined(OpenBSD) && (OpenBSD >= 199603))
+ (defined(OpenBSD) && (OpenBSD >= 199603)) || \
+ (defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
if (!strncmp(ifname, ifp->if_xname, sizeof(ifp->if_xname)))
# else
char fullname[LIFNAMSIZ];
@@ -2156,7 +2159,8 @@ int v;
ifp = ifneta[nifs - 1];
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
- (defined(OpenBSD) && (OpenBSD >= 199603))
+ (defined(OpenBSD) && (OpenBSD >= 199603)) || \
+ (defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
strncpy(ifp->if_xname, ifname, sizeof(ifp->if_xname));
# else
ifp->if_name = strdup(ifname);
@@ -2183,7 +2187,8 @@ void init_ifp()
int fd;
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
- (defined(OpenBSD) && (OpenBSD >= 199603))
+ (defined(OpenBSD) && (OpenBSD >= 199603)) || \
+ (defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) {
ifp->if_output = write_output;
sprintf(fname, "/tmp/%s", ifp->if_xname);
diff --git a/sys/contrib/ipfilter/netinet/ip_log.c b/sys/contrib/ipfilter/netinet/ip_log.c
index 7edba02..431b9fc 100644
--- a/sys/contrib/ipfilter/netinet/ip_log.c
+++ b/sys/contrib/ipfilter/netinet/ip_log.c
@@ -253,7 +253,8 @@ mb_t *m;
mlen = (flags & FR_LOGBODY) ? MIN(msgdsize(m) - hlen, 128) : 0;
# else
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \
- (defined(OpenBSD) && (OpenBSD >= 199603))
+ (defined(OpenBSD) && (OpenBSD >= 199603) || \
+ (defined(__FreeBSD__) && (__FreeBSD_version >= 501113)) )
strncpy(ipfl.fl_ifname, ifp->if_xname, IFNAMSIZ);
# else
ipfl.fl_unit = (u_char)ifp->if_unit;
diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c
index cdf85e9..15cd3e0 100644
--- a/sys/dev/an/if_an.c
+++ b/sys/dev/an/if_an.c
@@ -752,8 +752,9 @@ an_attach(sc, unit, flags)
sc->arpcom.ac_enaddr, ":");
ifp->if_softc = sc;
- ifp->if_unit = sc->an_unit = unit;
- ifp->if_name = "an";
+ sc->an_unit = unit;
+ if_initname(ifp, device_get_name(sc->an_dev),
+ device_get_unit(sc->an_dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = an_ioctl;
diff --git a/sys/dev/ar/if_ar.c b/sys/dev/ar/if_ar.c
index 17181f5..edba0ba 100644
--- a/sys/dev/ar/if_ar.c
+++ b/sys/dev/ar/if_ar.c
@@ -293,8 +293,8 @@ ar_attach(device_t device)
ifp = &sc->ifsppp.pp_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->unit;
- ifp->if_name = "ar";
+ if_initname(ifp, device_get_name(device),
+ device_get_unit(device));
ifp->if_mtu = PP_MTU;
ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
ifp->if_ioctl = arioctl;
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c
index c968179..f464f96 100644
--- a/sys/dev/ath/if_ath.c
+++ b/sys/dev/ath/if_ath.c
@@ -186,8 +186,8 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
DPRINTF(("ath_attach: devid 0x%x\n", devid));
/* set these up early for if_printf use */
- ifp->if_unit = device_get_unit(sc->sc_dev);
- ifp->if_name = "ath";
+ if_initname(ifp, device_get_name(sc->sc_dev),
+ device_get_unit(sc->sc_dev));
ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, &status);
if (ah == NULL) {
diff --git a/sys/dev/awi/if_awi_pccard.c b/sys/dev/awi/if_awi_pccard.c
index 346802e..4b0887c 100644
--- a/sys/dev/awi/if_awi_pccard.c
+++ b/sys/dev/awi/if_awi_pccard.c
@@ -141,10 +141,9 @@ awi_pccard_attach(device_t dev)
psc->sc_mem_res = 0;
psc->sc_intrhand = 0;
- ifp->if_name = "awi";
- ifp->if_unit = device_get_unit(dev);
- snprintf(sc->sc_dev.dv_xname, sizeof(sc->sc_dev.dv_xname),
- "%s%d", ifp->if_name, ifp->if_unit);
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
+ strlcpy(sc->sc_dev.dv_xname, ifp->if_xname,
+ sizeof(sc->sc_dev.dv_xname));
psc->sc_port_rid = 0;
psc->sc_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
diff --git a/sys/dev/bfe/if_bfe.c b/sys/dev/bfe/if_bfe.c
index b830c8c..3d5a7e7 100644
--- a/sys/dev/bfe/if_bfe.c
+++ b/sys/dev/bfe/if_bfe.c
@@ -368,8 +368,7 @@ bfe_attach(device_t dev)
/* Set up ifnet structure */
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->bfe_unit;
- ifp->if_name = "bfe";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = bfe_ioctl;
ifp->if_output = ether_output;
diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c
index 8d7850f..dcb289e 100644
--- a/sys/dev/bge/if_bge.c
+++ b/sys/dev/bge/if_bge.c
@@ -2365,8 +2365,7 @@ bge_attach(dev)
/* Set up ifnet structure */
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->bge_unit;
- ifp->if_name = "bge";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = bge_ioctl;
ifp->if_output = ether_output;
diff --git a/sys/dev/cm/if_cm_isa.c b/sys/dev/cm/if_cm_isa.c
index a478406..8f7732f 100644
--- a/sys/dev/cm/if_cm_isa.c
+++ b/sys/dev/cm/if_cm_isa.c
@@ -96,7 +96,7 @@ cm_isa_attach(dev)
return (error);
}
- return cm_attach(sc, device_get_unit(dev));
+ return cm_attach(dev);
}
static int
diff --git a/sys/dev/cm/smc90cx6.c b/sys/dev/cm/smc90cx6.c
index ff4bfe9..89a3415 100644
--- a/sys/dev/cm/smc90cx6.c
+++ b/sys/dev/cm/smc90cx6.c
@@ -274,10 +274,10 @@ cm_release_resources(dev)
}
int
-cm_attach(sc, unit)
- struct cm_softc *sc;
- int unit;
+cm_attach(dev)
+ device_t dev;
{
+ struct cm_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->sc_arccom.ac_if;
int s;
u_int8_t linkaddress;
@@ -313,8 +313,7 @@ cm_attach(sc, unit)
cm_stop(sc);
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "cm";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_output = arc_output;
ifp->if_start = cm_start;
ifp->if_ioctl = cm_ioctl;
@@ -841,8 +840,8 @@ cmintr(arg)
*/
PUTREG(CMCMD, CM_CLR(CLR_POR));
log(LOG_WARNING,
- "%s%d: intr: got spurious power on reset int\n",
- ifp->if_name, ifp->if_unit);
+ "%s: intr: got spurious power on reset int\n",
+ ifp->if_xname);
}
if (maskedisr & CM_RECON) {
@@ -872,9 +871,9 @@ cmintr(arg)
if ((newsec - sc->sc_recontime <= 2) &&
(++sc->sc_reconcount == ARC_EXCESSIVE_RECONS)) {
log(LOG_WARNING,
- "%s%d: excessive token losses, "
+ "%s: excessive token losses, "
"cable problem?\n",
- ifp->if_name, ifp->if_unit);
+ ifp->if_xname);
}
sc->sc_recontime = newsec;
callout_reset(&sc->sc_recon_ch, 15 * hz,
@@ -895,8 +894,8 @@ cmintr(arg)
* configured sender)
*/
log(LOG_WARNING,
- "%s%d: spurious RX interupt or sender 0 "
- " (ignored)\n", ifp->if_name, ifp->if_unit);
+ "%s: spurious RX interupt or sender 0 "
+ " (ignored)\n", ifp->if_xname);
/*
* restart receiver on same buffer.
* XXX maybe better reset interface?
@@ -958,8 +957,8 @@ cm_reconwatch(arg)
if (sc->sc_reconcount >= ARC_EXCESSIVE_RECONS) {
sc->sc_reconcount = 0;
- log(LOG_WARNING, "%s%d: token valid again.\n",
- ifp->if_name, ifp->if_unit);
+ log(LOG_WARNING, "%s: token valid again.\n",
+ ifp->if_xname);
}
sc->sc_reconcount = 0;
}
diff --git a/sys/dev/cm/smc90cx6var.h b/sys/dev/cm/smc90cx6var.h
index ad6d09a..1703145 100644
--- a/sys/dev/cm/smc90cx6var.h
+++ b/sys/dev/cm/smc90cx6var.h
@@ -87,7 +87,7 @@ struct cm_softc {
u_char sc_retransmits[2]; /* unused at the moment */
};
-int cm_attach(struct cm_softc *, int unit);
+int cm_attach(device_t dev);
void cmintr(void *);
int cm_probe(device_t dev);
diff --git a/sys/dev/cnw/if_cnw.c b/sys/dev/cnw/if_cnw.c
index bbf2a6b..6aedca3 100644
--- a/sys/dev/cnw/if_cnw.c
+++ b/sys/dev/cnw/if_cnw.c
@@ -1632,8 +1632,7 @@ static int cnw_pccard_attach(device_t dev)
sc->arpcom.ac_enaddr, ":");
ifp->if_softc = sc;
- ifp->if_name = "cnw";
- ifp->if_unit = device_get_unit(dev);
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_timer = 0;
ifp->if_mtu = ETHERMTU;
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c
index f09bb3d..c67b328 100644
--- a/sys/dev/cs/if_cs.c
+++ b/sys/dev/cs/if_cs.c
@@ -575,16 +575,16 @@ void cs_release_resources(device_t dev)
* Install the interface into kernel networking data structures
*/
int
-cs_attach(struct cs_softc *sc, int unit, int flags)
+cs_attach(device_t dev)
{
int media=0;
+ struct cs_softc *sc = device_get_softc(dev);;
struct ifnet *ifp = &(sc->arpcom.ac_if);
cs_stop( sc );
ifp->if_softc=sc;
- ifp->if_unit=unit;
- ifp->if_name="cs";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_output=ether_output;
ifp->if_start=cs_start;
ifp->if_ioctl=cs_ioctl;
@@ -607,8 +607,8 @@ cs_attach(struct cs_softc *sc, int unit, int flags)
sc->recv_ring=malloc(CS_DMA_BUFFER_SIZE<<1, M_DEVBUF, M_NOWAIT);
if (sc->recv_ring == NULL) {
- log(LOG_ERR,CS_NAME
- "%d: Couldn't allocate memory for NIC\n", unit);
+ log(LOG_ERR,
+ "%s: Couldn't allocate memory for NIC\n", ifp->if_xname);
return(0);
}
if ((sc->recv_ring-(sc->recv_ring & 0x1FFFF))
@@ -1137,7 +1137,7 @@ cs_watchdog(struct ifnet *ifp)
struct cs_softc *sc = ifp->if_softc;
ifp->if_oerrors++;
- log(LOG_ERR, CS_NAME"%d: device timeout\n", ifp->if_unit);
+ log(LOG_ERR, "%s: device timeout\n", ifp->if_xname);
/* Reset the interface */
if (ifp->if_flags & IFF_UP)
diff --git a/sys/dev/cs/if_cs_isa.c b/sys/dev/cs/if_cs_isa.c
index 7b93f07..dcbd02f 100644
--- a/sys/dev/cs/if_cs_isa.c
+++ b/sys/dev/cs/if_cs_isa.c
@@ -90,7 +90,6 @@ static int
cs_isa_attach(device_t dev)
{
struct cs_softc *sc = device_get_softc(dev);
- int flags = device_get_flags(dev);
int error;
cs_alloc_port(dev, 0, CS_89x0_IO_PORTS);
@@ -106,7 +105,7 @@ cs_isa_attach(device_t dev)
return (error);
}
- return (cs_attach(sc, device_get_unit(dev), flags));
+ return (cs_attach(dev));
}
static device_method_t cs_isa_methods[] = {
diff --git a/sys/dev/cs/if_cs_pccard.c b/sys/dev/cs/if_cs_pccard.c
index 2b1f3e8..499cf8f 100644
--- a/sys/dev/cs/if_cs_pccard.c
+++ b/sys/dev/cs/if_cs_pccard.c
@@ -81,7 +81,6 @@ static int
cs_pccard_attach(device_t dev)
{
struct cs_softc *sc = device_get_softc(dev);
- int flags = device_get_flags(dev);
int error;
error = cs_alloc_port(dev, sc->port_rid, CS_89x0_IO_PORTS);
@@ -95,7 +94,7 @@ cs_pccard_attach(device_t dev)
if (error != 0)
goto bad;
- return (cs_attach(sc, device_get_unit(dev), flags));
+ return (cs_attach(dev));
bad:
cs_release_resources(dev);
return (error);
diff --git a/sys/dev/cs/if_csvar.h b/sys/dev/cs/if_csvar.h
index 719a8db..0f62c62 100644
--- a/sys/dev/cs/if_csvar.h
+++ b/sys/dev/cs/if_csvar.h
@@ -70,7 +70,7 @@ struct cs_softc {
int cs_alloc_port(device_t dev, int rid, int size);
int cs_alloc_memory(device_t dev, int rid, int size);
int cs_alloc_irq(device_t dev, int rid, int flags);
-int cs_attach(struct cs_softc *, int, int);
+int cs_attach(device_t dev);
int cs_cs89x0_probe(device_t dev);
void cs_release_resources(device_t dev);
driver_intr_t csintr;
diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c
index f6ebbb3..f483505 100644
--- a/sys/dev/dc/if_dc.c
+++ b/sys/dev/dc/if_dc.c
@@ -2228,8 +2228,7 @@ dc_attach(device_t dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "dc";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
/* XXX: bleah, MTU gets overwritten in ether_ifattach() */
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c
index 3a3d242..248101e 100644
--- a/sys/dev/de/if_de.c
+++ b/sys/dev/de/if_de.c
@@ -383,12 +383,12 @@ tulip_media_print(
if ((sc->tulip_flags & TULIP_LINKUP) == 0)
return;
if (sc->tulip_flags & TULIP_PRINTMEDIA) {
- printf("%s%d: enabling %s port\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: enabling %s port\n",
+ sc->tulip_xname,
tulip_mediums[sc->tulip_media]);
sc->tulip_flags &= ~(TULIP_PRINTMEDIA|TULIP_PRINTLINKUP);
} else if (sc->tulip_flags & TULIP_PRINTLINKUP) {
- printf("%s%d: link up\n", sc->tulip_name, sc->tulip_unit);
+ printf("%s: link up\n", sc->tulip_xname);
sc->tulip_flags &= ~TULIP_PRINTLINKUP;
}
}
@@ -435,8 +435,8 @@ tulip_21140_gpr_media_sense(
continue;
#if defined(TULIP_DEBUG)
- printf("%s%d: gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n",
- sc->tulip_name, sc->tulip_unit, tulip_mediums[media],
+ printf("%s: gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n",
+ sc->tulip_xname, tulip_mediums[media],
TULIP_CSR_READ(sc, csr_gp) & 0xFF,
mi->mi_actmask, mi->mi_actdata);
#endif
@@ -499,8 +499,8 @@ tulip_media_link_monitor(
abilities = (abilities << 6) & status;
if (abilities != sc->tulip_abilities) {
#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation changed: 0x%04x -> 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, sc->tulip_phyaddr,
+ loudprintf("%s(phy%d): autonegotiation changed: 0x%04x -> 0x%04x\n",
+ sc->tulip_xname, sc->tulip_phyaddr,
sc->tulip_abilities, abilities);
#endif
if (tulip_mii_map_abilities(sc, abilities)) {
@@ -542,8 +542,8 @@ tulip_media_link_monitor(
linkup = TULIP_LINK_UP;
#if defined(TULIP_DEBUG)
if (sc->tulip_probe_timeout <= 0)
- printf("%s%d: sia status = 0x%08x\n", sc->tulip_name,
- sc->tulip_unit, TULIP_CSR_READ(sc, csr_sia_status));
+ printf("%s: sia status = 0x%08x\n", sc->tulip_xname,
+ TULIP_CSR_READ(sc, csr_sia_status));
#endif
} else if (mi->mi_type == TULIP_MEDIAINFO_SYM) {
return TULIP_LINK_UNKNOWN;
@@ -558,7 +558,7 @@ tulip_media_link_monitor(
return TULIP_LINK_UP;
sc->tulip_flags &= ~TULIP_LINKUP;
- printf("%s%d: link down: cable problem?\n", sc->tulip_name, sc->tulip_unit);
+ printf("%s: link down: cable problem?\n", sc->tulip_xname);
}
#if defined(TULIP_DEBUG)
sc->tulip_dbg.dbg_link_downed++;
@@ -689,8 +689,8 @@ tulip_media_poll(
if (sc->tulip_probe_timeout > 0) {
tulip_media_t new_probe_media = tulip_21140_gpr_media_sense(sc);
#if defined(TULIP_DEBUG)
- printf("%s%d: media_poll: gpr sensing = %s\n",
- sc->tulip_name, sc->tulip_unit, tulip_mediums[new_probe_media]);
+ printf("%s: media_poll: gpr sensing = %s\n",
+ sc->tulip_xname, tulip_mediums[new_probe_media]);
#endif
if (new_probe_media != TULIP_MEDIA_UNKNOWN) {
if (new_probe_media == sc->tulip_probe_media) {
@@ -776,8 +776,8 @@ tulip_media_poll(
if (/* event == TULIP_MEDIAPOLL_TXPROBE_FAILED || */ sc->tulip_probe_timeout <= 0) {
#if defined(TULIP_DEBUG)
if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) {
- printf("%s%d: poll media unknown!\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: poll media unknown!\n",
+ sc->tulip_xname);
sc->tulip_probe_media = TULIP_MEDIA_MAX;
}
#endif
@@ -789,8 +789,8 @@ tulip_media_poll(
sc->tulip_probe_media -= 1;
if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) {
if (++sc->tulip_probe_passes == 3) {
- printf("%s%d: autosense failed: cable problem?\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: autosense failed: cable problem?\n",
+ sc->tulip_xname);
if ((sc->tulip_if.if_flags & IFF_UP) == 0) {
sc->tulip_if.if_flags &= ~IFF_RUNNING;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
@@ -806,7 +806,7 @@ tulip_media_poll(
|| TULIP_IS_MEDIA_FD(sc->tulip_probe_media));
#if defined(TULIP_DEBUG)
- printf("%s%d: %s: probing %s\n", sc->tulip_name, sc->tulip_unit,
+ printf("%s: %s: probing %s\n", sc->tulip_xname,
event == TULIP_MEDIAPOLL_TXPROBE_FAILED ? "txprobe failed" : "timeout",
tulip_mediums[sc->tulip_probe_media]);
#endif
@@ -1135,8 +1135,8 @@ tulip_21041_media_poll(
sc->tulip_flags &= ~TULIP_WANTRXACT;
sc->tulip_probe_timeout = TULIP_21041_PROBE_AUIBNC_TIMEOUT;
} else {
- printf("%s%d: autosense failed: cable problem?\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: autosense failed: cable problem?\n",
+ sc->tulip_xname);
if ((sc->tulip_if.if_flags & IFF_UP) == 0) {
sc->tulip_if.if_flags &= ~IFF_RUNNING;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
@@ -1347,8 +1347,8 @@ tulip_mii_autonegotiate(
tulip_timeout(sc);
return;
}
- printf("%s%d(phy%d): error: reset of PHY never completed!\n",
- sc->tulip_name, sc->tulip_unit, phyaddr);
+ printf("%s(phy%d): error: reset of PHY never completed!\n",
+ sc->tulip_xname, phyaddr);
sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE;
sc->tulip_probe_state = TULIP_PROBE_FAILED;
sc->tulip_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
@@ -1357,8 +1357,8 @@ tulip_mii_autonegotiate(
status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
if ((status & PHYSTS_CAN_AUTONEG) == 0) {
#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation disabled\n",
- sc->tulip_name, sc->tulip_unit, phyaddr);
+ loudprintf("%s(phy%d): autonegotiation disabled\n",
+ sc->tulip_xname, phyaddr);
#endif
sc->tulip_flags &= ~TULIP_DIDNWAY;
sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
@@ -1370,11 +1370,11 @@ tulip_mii_autonegotiate(
data = tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL);
#if defined(TULIP_DEBUG)
if ((data & PHYCTL_AUTONEG_ENABLE) == 0)
- loudprintf("%s%d(phy%d): oops: enable autonegotiation failed: 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, data);
+ loudprintf("%s(phy%d): oops: enable autonegotiation failed: 0x%04x\n",
+ sc->tulip_xname, phyaddr, data);
else
- loudprintf("%s%d(phy%d): autonegotiation restarted: 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, data);
+ loudprintf("%s(phy%d): autonegotiation restarted: 0x%04x\n",
+ sc->tulip_xname, phyaddr, data);
sc->tulip_dbg.dbg_nway_starts++;
#endif
sc->tulip_probe_state = TULIP_PROBE_PHYAUTONEG;
@@ -1390,8 +1390,8 @@ tulip_mii_autonegotiate(
return;
}
#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation timeout: sts=0x%04x, ctl=0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, status,
+ loudprintf("%s(phy%d): autonegotiation timeout: sts=0x%04x, ctl=0x%04x\n",
+ sc->tulip_xname, phyaddr, status,
tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL));
#endif
sc->tulip_flags &= ~TULIP_DIDNWAY;
@@ -1400,8 +1400,8 @@ tulip_mii_autonegotiate(
}
data = tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ABILITIES);
#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation complete: 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, data);
+ loudprintf("%s(phy%d): autonegotiation complete: 0x%04x\n",
+ sc->tulip_xname, phyaddr, data);
#endif
data = (data << 6) & status;
if (!tulip_mii_map_abilities(sc, data))
@@ -1416,8 +1416,8 @@ tulip_mii_autonegotiate(
}
}
#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation failure: state = %d\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, sc->tulip_probe_state);
+ loudprintf("%s(phy%d): autonegotiation failure: state = %d\n",
+ sc->tulip_xname, phyaddr, sc->tulip_probe_state);
sc->tulip_dbg.dbg_nway_failures++;
#endif
}
@@ -1452,8 +1452,8 @@ tulip_2114x_media_preset(
}
#if defined(TULIP_DEBUG)
} else {
- printf("%s%d: preset: bad media %d!\n",
- sc->tulip_name, sc->tulip_unit, media);
+ printf("%s: preset: bad media %d!\n",
+ sc->tulip_xname, media);
}
#endif
}
@@ -1508,8 +1508,8 @@ tulip_null_media_poll(
sc->tulip_dbg.dbg_events[event]++;
#endif
#if defined(DIAGNOSTIC)
- printf("%s%d: botch(media_poll) at line %d\n",
- sc->tulip_name, sc->tulip_unit, __LINE__);
+ printf("%s: botch(media_poll) at line %d\n",
+ sc->tulip_xname, __LINE__);
#endif
}
@@ -2276,7 +2276,7 @@ tulip_identify_asante_nic(
mi->mi_phyaddr = tulip_mii_get_phyaddr(sc, 0);
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
- printf("%s%d: can't find phy 0\n", sc->tulip_name, sc->tulip_unit);
+ printf("%s: can't find phy 0\n", sc->tulip_xname);
return;
}
@@ -2326,8 +2326,8 @@ tulip_identify_compex_nic(
sc->tulip_slaves = root_sc->tulip_slaves;
root_sc->tulip_slaves = sc;
} else if(sc->tulip_features & TULIP_HAVE_SLAVEDINTR) {
- printf("\nCannot find master device for de%d interrupts",
- sc->tulip_unit);
+ printf("\nCannot find master device for %s interrupts",
+ sc->tulip_xname);
}
} else {
strcat(sc->tulip_boardid, "unknown ");
@@ -2529,8 +2529,8 @@ tulip_srom_decode(
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
#if defined(TULIP_DEBUG)
- printf("%s%d: can't find phy %d\n",
- sc->tulip_name, sc->tulip_unit, phyno);
+ printf("%s: can't find phy %d\n",
+ sc->tulip_xname, phyno);
#endif
break;
}
@@ -2630,8 +2630,8 @@ tulip_srom_decode(
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
#if defined(TULIP_DEBUG)
- printf("%s%d: can't find phy %d\n",
- sc->tulip_name, sc->tulip_unit, phyno);
+ printf("%s: can't find phy %d\n",
+ sc->tulip_xname, phyno);
#endif
break;
}
@@ -3274,8 +3274,8 @@ tulip_reset(
(*sc->tulip_boardsw->bd_media_select)(sc);
#if defined(TULIP_DEBUG)
if ((sc->tulip_flags & TULIP_NEEDRESET) == TULIP_NEEDRESET)
- printf("%s%d: tulip_reset: additional reset needed?!?\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: tulip_reset: additional reset needed?!?\n",
+ sc->tulip_xname);
#endif
tulip_media_print(sc);
if (sc->tulip_features & TULIP_HAVE_DUALSENSE)
@@ -3503,8 +3503,8 @@ tulip_rx_intr(
}
#if defined(TULIP_VERBOSE)
if (error != NULL && (sc->tulip_flags & TULIP_NOMESSAGES) == 0) {
- printf("%s%d: receive: %6D: %s\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: receive: %6D: %s\n",
+ sc->tulip_xname,
mtod(ms, u_char *) + 6, ":",
error);
sc->tulip_flags |= TULIP_NOMESSAGES;
@@ -3615,8 +3615,8 @@ tulip_rx_intr(
error = bus_dmamap_load(sc->tulip_dmatag, map, mtod(ms, void *),
TULIP_RX_BUFLEN, NULL, BUS_DMA_NOWAIT);
if (error) {
- printf("%s%d: unable to load rx map, "
- "error = %d\n", sc->tulip_name, sc->tulip_unit, error);
+ printf("%s: unable to load rx map, "
+ "error = %d\n", sc->tulip_xname, error);
panic("tulip_rx_intr"); /* XXX */
}
nextout->d_addr1 = map->dm_segs[0].ds_addr;
@@ -3707,8 +3707,8 @@ tulip_tx_intr(
m_freem(m);
#if defined(TULIP_DEBUG)
} else {
- printf("%s%d: tx_intr: failed to dequeue mbuf?!?\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: tx_intr: failed to dequeue mbuf?!?\n",
+ sc->tulip_xname);
#endif
}
if (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) {
@@ -3797,7 +3797,7 @@ tulip_print_abnormal_interrupt(
const char thrsh[] = "72|128\0\0\0" "96|256\0\0\0" "128|512\0\0" "160|1024";
csr &= (1 << (sizeof(tulip_status_bits)/sizeof(tulip_status_bits[0]))) - 1;
- printf("%s%d: abnormal interrupt:", sc->tulip_name, sc->tulip_unit);
+ printf("%s: abnormal interrupt:", sc->tulip_xname);
for (sep = " ", mask = 1; mask <= csr; mask <<= 1, msgp++) {
if ((csr & mask) && *msgp != NULL) {
printf("%s%s", sep, *msgp);
@@ -3833,8 +3833,8 @@ tulip_intr_handler(
if (sc->tulip_flags & TULIP_NOMESSAGES) {
sc->tulip_flags |= TULIP_SYSTEMERROR;
} else {
- printf("%s%d: system error: %s\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: system error: %s\n",
+ sc->tulip_xname,
tulip_system_errors[sc->tulip_last_system_error]);
}
sc->tulip_flags |= TULIP_NEEDRESET;
@@ -4130,8 +4130,8 @@ tulip_txput(
#if defined(TULIP_DEBUG)
if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) {
- printf("%s%d: txput%s: tx not running\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: txput%s: tx not running\n",
+ sc->tulip_xname,
(sc->tulip_flags & TULIP_TXPROBE_ACTIVE) ? "(probe)" : "");
sc->tulip_flags |= TULIP_WANTTXSTART;
sc->tulip_dbg.dbg_txput_finishes[0]++;
@@ -4202,8 +4202,8 @@ tulip_txput(
error = bus_dmamap_load_mbuf(sc->tulip_dmatag, map, m, BUS_DMA_NOWAIT);
}
if (error != 0) {
- printf("%s%d: unable to load tx map, "
- "error = %d\n", sc->tulip_name, sc->tulip_unit, error);
+ printf("%s: unable to load tx map, "
+ "error = %d\n", sc->tulip_xname, error);
#if defined(TULIP_DEBUG)
sc->tulip_dbg.dbg_txput_finishes[3]++;
#endif
@@ -4455,8 +4455,8 @@ tulip_txput_setup(
#if defined(TULIP_DEBUG)
if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) {
- printf("%s%d: txput_setup: tx not running\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: txput_setup: tx not running\n",
+ sc->tulip_xname);
sc->tulip_flags |= TULIP_WANTTXSTART;
sc->tulip_if.if_start = tulip_ifstart;
return;
@@ -4705,8 +4705,8 @@ tulip_ifwatchdog(
tulip_rx_intr(sc);
if (sc->tulip_flags & TULIP_SYSTEMERROR) {
- printf("%s%d: %d system errors: last was %s\n",
- sc->tulip_name, sc->tulip_unit, sc->tulip_system_errors,
+ printf("%s: %d system errors: last was %s\n",
+ sc->tulip_xname, sc->tulip_system_errors,
tulip_system_errors[sc->tulip_last_system_error]);
}
if (sc->tulip_statusbits) {
@@ -4720,7 +4720,7 @@ tulip_ifwatchdog(
if (sc->tulip_txtimer)
tulip_tx_intr(sc);
if (sc->tulip_txtimer && --sc->tulip_txtimer == 0) {
- printf("%s%d: transmission timeout\n", sc->tulip_name, sc->tulip_unit);
+ printf("%s: transmission timeout\n", sc->tulip_xname);
if (TULIP_DO_AUTOSENSE(sc)) {
sc->tulip_media = TULIP_MEDIA_UNKNOWN;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
@@ -4766,6 +4766,9 @@ tulip_attach(
{
struct ifnet * const ifp = &sc->tulip_if;
+ /* XXX: driver name/unit should be set some other way */
+ ifp->if_dname = "de";
+ ifp->if_dunit = sc->tulip_unit;
ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST;
ifp->if_ioctl = tulip_ifioctl;
ifp->if_start = tulip_ifstart;
@@ -4774,16 +4777,16 @@ tulip_attach(
ifp->if_output = ether_output;
ifp->if_init = tulip_ifinit;
- printf("%s%d: %s%s pass %d.%d%s\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: %s%s pass %d.%d%s\n",
+ sc->tulip_xname,
sc->tulip_boardid,
tulip_chipdescs[sc->tulip_chipid],
(sc->tulip_revinfo & 0xF0) >> 4,
sc->tulip_revinfo & 0x0F,
(sc->tulip_features & (TULIP_HAVE_ISVSROM|TULIP_HAVE_OKSROM))
== TULIP_HAVE_ISVSROM ? " (invalid EESPROM checksum)" : "");
- printf("%s%d: address %6D\n",
- sc->tulip_name, sc->tulip_unit, sc->tulip_enaddr, ":");
+ printf("%s: address %6D\n",
+ sc->tulip_xname, sc->tulip_enaddr, ":");
#if defined(__alpha__)
/*
@@ -5142,7 +5145,7 @@ tulip_pci_attach(device_t dev)
#endif
sc->tulip_unit = unit;
- sc->tulip_name = "de";
+ snprintf(sc->tulip_xname, IFNAMSIZ, "de%d", sc->tulip_unit);
sc->tulip_revinfo = revinfo;
sc->tulip_if.if_softc = sc;
#if defined(TULIP_IOMAPPED)
@@ -5194,16 +5197,16 @@ tulip_pci_attach(device_t dev)
bit longer anyways) */
if ((retval = tulip_read_macaddr(sc)) < 0) {
- printf("%s%d", sc->tulip_name, sc->tulip_unit);
+ printf("%s", sc->tulip_xname);
printf(": can't read ENET ROM (why=%d) (", retval);
for (idx = 0; idx < 32; idx++)
printf("%02x", sc->tulip_rombuf[idx]);
printf("\n");
- printf("%s%d: %s%s pass %d.%d\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: %s%s pass %d.%d\n",
+ sc->tulip_xname,
sc->tulip_boardid, tulip_chipdescs[sc->tulip_chipid],
(sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F);
- printf("%s%d: address unknown\n", sc->tulip_name, sc->tulip_unit);
+ printf("%s: address unknown\n", sc->tulip_xname);
} else {
int s;
void (*intr_rtn)(void *) = tulip_intr_normal;
@@ -5219,8 +5222,8 @@ tulip_pci_attach(device_t dev)
0, ~0, 1, RF_SHAREABLE | RF_ACTIVE);
if (res == 0 || bus_setup_intr(dev, res, INTR_TYPE_NET,
intr_rtn, sc, &ih)) {
- printf("%s%d: couldn't map interrupt\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: couldn't map interrupt\n",
+ sc->tulip_xname);
free((caddr_t) sc->tulip_rxdescs, M_DEVBUF);
free((caddr_t) sc->tulip_txdescs, M_DEVBUF);
return ENXIO;
diff --git a/sys/dev/de/if_devar.h b/sys/dev/de/if_devar.h
index 13d2357..9b47cca 100644
--- a/sys/dev/de/if_devar.h
+++ b/sys/dev/de/if_devar.h
@@ -431,6 +431,7 @@ typedef struct {
*/
struct _tulip_softc_t {
struct ifmedia tulip_ifmedia;
+ int tulip_unit;
#if defined(TULIP_BUS_DMA)
bus_dma_tag_t tulip_dmatag; /* bus DMA tag */
#if !defined(TULIP_BUS_DMA_NOTX)
@@ -850,10 +851,7 @@ NETISR_SET(NETISR_DE, tulip_softintr);
#ifndef tulip_if
#define tulip_if tulip_ac.ac_if
#endif
-#ifndef tulip_unit
-#define tulip_unit tulip_if.if_unit
-#endif
-#define tulip_name tulip_if.if_name
+#define tulip_xname tulip_if.if_xname
#ifndef tulip_enaddr
#define tulip_enaddr tulip_ac.ac_enaddr
#endif
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c
index 0c6a0f6..1ec954f 100644
--- a/sys/dev/ed/if_ed.c
+++ b/sys/dev/ed/if_ed.c
@@ -1700,11 +1700,10 @@ ed_release_resources(dev)
* Install interface into kernel networking data structures
*/
int
-ed_attach(sc, unit, flags)
- struct ed_softc *sc;
- int unit;
- int flags;
+ed_attach(dev)
+ device_t dev;
{
+ struct ed_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->arpcom.ac_if;
callout_handle_init(&sc->tick_ch);
@@ -1717,8 +1716,7 @@ ed_attach(sc, unit, flags)
* Initialize ifnet structure
*/
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "ed";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_output = ether_output;
ifp->if_start = ed_start;
ifp->if_ioctl = ed_ioctl;
@@ -1745,7 +1743,7 @@ ed_attach(sc, unit, flags)
* tranceiver for AUI operation), based on compile-time
* config option.
*/
- if (flags & ED_FLAGS_DISABLE_TRANCEIVER)
+ if (device_get_flags(dev) & ED_FLAGS_DISABLE_TRANCEIVER)
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
IFF_MULTICAST | IFF_ALTPHYS);
else
@@ -1846,7 +1844,7 @@ ed_watchdog(ifp)
if (sc->gone)
return;
- log(LOG_ERR, "ed%d: device timeout\n", ifp->if_unit);
+ log(LOG_ERR, "%s: device timeout\n", ifp->if_xname);
ifp->if_oerrors++;
ed_reset(ifp);
@@ -2349,8 +2347,8 @@ ed_rint(sc)
* Really BAD. The ring pointers are corrupted.
*/
log(LOG_ERR,
- "ed%d: NIC memory corrupt - invalid packet length %d\n",
- ifp->if_unit, len);
+ "%s: NIC memory corrupt - invalid packet length %d\n",
+ ifp->if_xname, len);
ifp->if_ierrors++;
ed_reset(ifp);
return;
@@ -2554,8 +2552,8 @@ edintr(arg)
ifp->if_ierrors++;
#ifdef DIAGNOSTIC
log(LOG_WARNING,
- "ed%d: warning - receiver ring buffer overrun\n",
- ifp->if_unit);
+ "%s: warning - receiver ring buffer overrun\n",
+ ifp->if_xname);
#endif
/*
@@ -3057,8 +3055,8 @@ ed_pio_write_mbufs(sc, m, dst)
while (((ed_nic_inb(sc, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
if (!maxwait) {
- log(LOG_WARNING, "ed%d: remote transmit DMA failed to complete\n",
- ifp->if_unit);
+ log(LOG_WARNING, "%s: remote transmit DMA failed to complete\n",
+ ifp->if_xname);
ed_reset(ifp);
return(0);
}
diff --git a/sys/dev/ed/if_ed_cbus.c b/sys/dev/ed/if_ed_cbus.c
index d6c37f2..40f114b 100644
--- a/sys/dev/ed/if_ed_cbus.c
+++ b/sys/dev/ed/if_ed_cbus.c
@@ -277,7 +277,7 @@ ed_isa_attach(dev)
return (error);
}
- return ed_attach(sc, device_get_unit(dev), flags);
+ return ed_attach(dev);
}
#ifdef PC98
diff --git a/sys/dev/ed/if_ed_isa.c b/sys/dev/ed/if_ed_isa.c
index bc5e397..69da715 100644
--- a/sys/dev/ed/if_ed_isa.c
+++ b/sys/dev/ed/if_ed_isa.c
@@ -125,7 +125,6 @@ ed_isa_attach(dev)
device_t dev;
{
struct ed_softc *sc = device_get_softc(dev);
- int flags = device_get_flags(dev);
int error;
if (sc->port_used > 0)
@@ -142,7 +141,7 @@ ed_isa_attach(dev)
return (error);
}
- return ed_attach(sc, device_get_unit(dev), flags);
+ return ed_attach(dev);
}
static device_method_t ed_isa_methods[] = {
diff --git a/sys/dev/ed/if_ed_pccard.c b/sys/dev/ed/if_ed_pccard.c
index 1930b1f..8b9f52d 100644
--- a/sys/dev/ed/if_ed_pccard.c
+++ b/sys/dev/ed/if_ed_pccard.c
@@ -246,7 +246,6 @@ static int
ed_pccard_attach(device_t dev)
{
int error;
- int flags = device_get_flags(dev);
int i;
struct ed_softc *sc = device_get_softc(dev);
u_char sum;
@@ -274,7 +273,7 @@ ed_pccard_attach(device_t dev)
bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
}
- error = ed_attach(sc, device_get_unit(dev), flags);
+ error = ed_attach(dev);
#ifndef ED_NO_MIIBUS
if (error == 0 && sc->vendor == ED_VENDOR_LINKSYS) {
/* Probe for an MII bus, but ignore errors. */
diff --git a/sys/dev/ed/if_ed_pci.c b/sys/dev/ed/if_ed_pci.c
index 87ac950..3d775be 100644
--- a/sys/dev/ed/if_ed_pci.c
+++ b/sys/dev/ed/if_ed_pci.c
@@ -101,7 +101,7 @@ ed_pci_attach(device_t dev)
return (error);
}
- error = ed_attach(sc, device_get_unit(dev), flags);
+ error = ed_attach(dev);
return (error);
}
diff --git a/sys/dev/ed/if_edvar.h b/sys/dev/ed/if_edvar.h
index 3b71c8c..d1f903d 100644
--- a/sys/dev/ed/if_edvar.h
+++ b/sys/dev/ed/if_edvar.h
@@ -204,7 +204,7 @@ int ed_probe_Novell (device_t, int, int);
int ed_probe_Novell_generic (device_t, int);
int ed_probe_HP_pclanp (device_t, int, int);
-int ed_attach (struct ed_softc *, int, int);
+int ed_attach (device_t);
void ed_stop (struct ed_softc *);
void ed_pio_readmem (struct ed_softc *, int, unsigned char *,
unsigned short);
diff --git a/sys/dev/em/if_em.c b/sys/dev/em/if_em.c
index 27b9d6c..295fdb6 100644
--- a/sys/dev/em/if_em.c
+++ b/sys/dev/em/if_em.c
@@ -1816,8 +1816,7 @@ em_setup_interface(device_t dev, struct adapter * adapter)
INIT_DEBUGOUT("em_setup_interface: begin");
ifp = &adapter->interface_data.ac_if;
- ifp->if_unit = adapter->unit;
- ifp->if_name = "em";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_output = ether_output;
ifp->if_baudrate = 1000000000;
diff --git a/sys/dev/en/if_en_pci.c b/sys/dev/en/if_en_pci.c
index b535d58..dac053e 100644
--- a/sys/dev/en/if_en_pci.c
+++ b/sys/dev/en/if_en_pci.c
@@ -193,14 +193,13 @@ en_pci_attach(device_t dev)
struct en_softc *sc;
struct en_pci_softc *scp;
u_long val;
- int rid, unit, error = 0;
+ int rid, error = 0;
sc = device_get_softc(dev);
scp = (struct en_pci_softc *)sc;
- unit = device_get_unit(dev);
- sc->ifatm.ifnet.if_unit = unit;
- sc->ifatm.ifnet.if_name = "en";
+ if_initname(&(sc->ifatm.ifnet), device_get_name(dev),
+ device_get_unit(dev));
/*
* Enable bus mastering.
diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c
index bfb503d..48df206 100644
--- a/sys/dev/en/midway.c
+++ b/sys/dev/en/midway.c
@@ -1827,9 +1827,8 @@ en_rx_drain(struct en_softc *sc, u_int drq)
m = NULL; /* assume "JK" trash DMA */
if (EN_DQ_LEN(drq) != 0) {
_IF_DEQUEUE(&slot->indma, m);
- KASSERT(m != NULL, ("drqsync: %s%d: lost mbuf in slot %zu!",
- sc->ifatm.ifnet.if_name, sc->ifatm.ifnet.if_unit,
- slot - sc->rxslot));
+ KASSERT(m != NULL, ("drqsync: %s: lost mbuf in slot %zu!",
+ sc->ifatm.ifnet.if_xname, slot - sc->rxslot));
uma_zfree(sc->map_zone, (struct en_map *)m->m_pkthdr.rcvif);
}
if ((vc = slot->vcc) == NULL) {
diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c
index 32683c3..4fd8e33 100644
--- a/sys/dev/ep/if_ep.c
+++ b/sys/dev/ep/if_ep.c
@@ -292,8 +292,7 @@ ep_attach(struct ep_softc *sc)
attached = (ifp->if_softc != 0);
ifp->if_softc = sc;
- ifp->if_unit = sc->unit;
- ifp->if_name = "ep";
+ if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_output = ether_output;
diff --git a/sys/dev/ex/if_ex.c b/sys/dev/ex/if_ex.c
index 1a5e25d..b4b1bc3 100644
--- a/sys/dev/ex/if_ex.c
+++ b/sys/dev/ex/if_ex.c
@@ -221,7 +221,6 @@ ex_attach(device_t dev)
struct ex_softc * sc = device_get_softc(dev);
struct ifnet * ifp = &sc->arpcom.ac_if;
struct ifmedia * ifm;
- int unit = device_get_unit(dev);
u_int16_t temp;
/* work out which set of irq <-> internal tables to use */
@@ -239,8 +238,7 @@ ex_attach(device_t dev)
* Initialize the ifnet structure.
*/
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "ex";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
ifp->if_output = ether_output;
@@ -308,7 +306,7 @@ ex_init(void *xsc)
register int iobase = sc->iobase;
unsigned short temp_reg;
- DODEBUG(Start_End, printf("ex_init%d: start\n", ifp->if_unit););
+ DODEBUG(Start_End, printf("%s: ex_init: start\n", ifp->if_xname););
if (TAILQ_FIRST(&ifp->if_addrhead) == NULL) {
return;
@@ -389,7 +387,7 @@ ex_init(void *xsc)
ex_start(ifp);
splx(s);
- DODEBUG(Start_End, printf("ex_init%d: finish\n", ifp->if_unit););
+ DODEBUG(Start_End, printf("%s: ex_init: finish\n", ifp->if_xname););
}
@@ -809,7 +807,7 @@ ex_ioctl(register struct ifnet *ifp, u_long cmd, caddr_t data)
int s;
int error = 0;
- DODEBUG(Start_End, printf("ex_ioctl%d: start ", ifp->if_unit););
+ DODEBUG(Start_End, printf("%s: ex_ioctl: start ", ifp->if_xname););
s = splimp();
@@ -854,7 +852,7 @@ ex_ioctl(register struct ifnet *ifp, u_long cmd, caddr_t data)
splx(s);
- DODEBUG(Start_End, printf("\nex_ioctl%d: finish\n", ifp->if_unit););
+ DODEBUG(Start_End, printf("\n%s: ex_ioctl: finish\n", ifp->if_xname););
return(error);
}
@@ -977,7 +975,7 @@ ex_watchdog(struct ifnet *ifp)
{
struct ex_softc * sc = ifp->if_softc;
- DODEBUG(Start_End, printf("ex_watchdog%d: start\n", ifp->if_unit););
+ DODEBUG(Start_End, printf("%s: ex_watchdog: start\n", ifp->if_xname););
ifp->if_flags &= ~IFF_OACTIVE;
@@ -987,7 +985,7 @@ ex_watchdog(struct ifnet *ifp)
ex_reset(sc);
ex_start(ifp);
- DODEBUG(Start_End, printf("ex_watchdog%d: finish\n", ifp->if_unit););
+ DODEBUG(Start_End, printf("%s: ex_watchdog: finish\n", ifp->if_xname););
return;
}
diff --git a/sys/dev/fatm/if_fatm.c b/sys/dev/fatm/if_fatm.c
index cdba704..258e8a7 100644
--- a/sys/dev/fatm/if_fatm.c
+++ b/sys/dev/fatm/if_fatm.c
@@ -2805,8 +2805,7 @@ fatm_attach(device_t dev)
*/
ifp = &sc->ifatm.ifnet;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "fatm";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_SIMPLEX;
ifp->if_ioctl = fatm_ioctl;
ifp->if_start = fatm_start;
diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c
index 0a21324..8e9c69e 100644
--- a/sys/dev/fe/if_fe.c
+++ b/sys/dev/fe/if_fe.c
@@ -423,8 +423,8 @@ fe_read_eeprom_jli (struct fe_softc * sc, u_char * data)
int i;
data -= JLI_EEPROM_SIZE;
for (i = 0; i < JLI_EEPROM_SIZE; i += 16) {
- printf("fe%d: EEPROM(JLI):%3x: %16D\n",
- sc->sc_unit, i, data + i, " ");
+ printf("%s: EEPROM(JLI):%3x: %16D\n",
+ sc->sc_xname, i, data + i, " ");
}
}
#endif
@@ -539,8 +539,8 @@ fe_read_eeprom_ssi (struct fe_softc *sc, u_char *data)
int i;
data -= SSI_EEPROM_SIZE;
for (i = 0; i < SSI_EEPROM_SIZE; i += 16) {
- printf("fe%d: EEPROM(SSI):%3x: %16D\n",
- sc->sc_unit, i, data + i, " ");
+ printf("%s: EEPROM(SSI):%3x: %16D\n",
+ sc->sc_xname, i, data + i, " ");
}
}
#endif
@@ -641,8 +641,8 @@ fe_read_eeprom_lnx (struct fe_softc *sc, u_char *data)
this board was not a TDK/LANX) or not working
properly. */
if (bootverbose) {
- printf("fe%d: no ACK received from EEPROM(LNX)\n",
- sc->sc_unit);
+ printf("%s: no ACK received from EEPROM(LNX)\n",
+ sc->sc_xname);
}
/* Clear the given buffer to indicate we could not get
any info. and return. */
@@ -680,8 +680,8 @@ fe_read_eeprom_lnx (struct fe_softc *sc, u_char *data)
if (bootverbose) {
data -= LNX_EEPROM_SIZE;
for (i = 0; i < LNX_EEPROM_SIZE; i += 16) {
- printf("fe%d: EEPROM(LNX):%3x: %16D\n",
- sc->sc_unit, i, data + i, " ");
+ printf("%s: EEPROM(LNX):%3x: %16D\n",
+ sc->sc_xname, i, data + i, " ");
}
}
#endif
@@ -739,8 +739,7 @@ fe_attach (device_t dev)
* Initialize ifnet structure
*/
sc->sc_if.if_softc = sc;
- sc->sc_if.if_unit = sc->sc_unit;
- sc->sc_if.if_name = "fe";
+ if_initname(&sc->sc_if, device_get_name(dev), device_get_unit(dev));
sc->sc_if.if_output = ether_output;
sc->sc_if.if_start = fe_start;
sc->sc_if.if_ioctl = fe_ioctl;
@@ -791,8 +790,8 @@ fe_attach (device_t dev)
default:
/* Oops, we can't work with single buffer configuration. */
if (bootverbose) {
- printf("fe%d: strange TXBSIZ config; fixing\n",
- sc->sc_unit);
+ printf("%s: strange TXBSIZ config; fixing\n",
+ sc->sc_xname);
}
sc->proto_dlcr6 &= ~FE_D6_TXBSIZ;
sc->proto_dlcr6 |= FE_D6_TXBSIZ_2x2KB;
@@ -1013,7 +1012,7 @@ fe_init (void * xsc)
/* We need an address. */
if (TAILQ_EMPTY(&sc->sc_if.if_addrhead)) { /* XXX unlikely */
#ifdef DIAGNOSTIC
- printf("fe%d: init() without any address\n", sc->sc_unit);
+ printf("%s: init() without any address\n", sc->sc_xname);
#endif
return;
}
@@ -1098,8 +1097,8 @@ fe_init (void * xsc)
* The following message helps discovering the fact. FIXME.
*/
if (!(fe_inb(sc, FE_DLCR5) & FE_D5_BUFEMP)) {
- printf("fe%d: receive buffer has some data after reset\n",
- sc->sc_unit);
+ printf("%s: receive buffer has some data after reset\n",
+ sc->sc_xname);
fe_emptybuffer(sc);
}
@@ -1366,7 +1365,7 @@ fe_emptybuffer (struct fe_softc * sc)
u_char saved_dlcr5;
#ifdef FE_DEBUG
- printf("fe%d: emptying receive buffer\n", sc->sc_unit);
+ printf("%s: emptying receive buffer\n", sc->sc_xname);
#endif
/*
@@ -1402,7 +1401,7 @@ fe_emptybuffer (struct fe_softc * sc)
* Double check.
*/
if (fe_inb(sc, FE_DLCR5) & FE_D5_BUFEMP) {
- printf("fe%d: could not empty receive buffer\n", sc->sc_unit);
+ printf("%s: could not empty receive buffer\n", sc->sc_xname);
/* Hmm. What should I do if this happens? FIXME. */
}
@@ -1433,8 +1432,8 @@ fe_tint (struct fe_softc * sc, u_char tstat)
* are left unsent in transmission buffer.
*/
left = fe_inb(sc, FE_BMPR10);
- printf("fe%d: excessive collision (%d/%d)\n",
- sc->sc_unit, left, sc->txb_sched);
+ printf("%s: excessive collision (%d/%d)\n",
+ sc->sc_xname, left, sc->txb_sched);
/*
* Clear the collision flag (in 86960) here
@@ -1636,7 +1635,7 @@ fe_rint (struct fe_softc * sc, u_char rstat)
if ((status & 0xF0) != 0x20 ||
len > ETHER_MAX_LEN - ETHER_CRC_LEN ||
len < ETHER_MIN_LEN - ETHER_CRC_LEN) {
- printf("fe%d: RX buffer out-of-sync\n", sc->sc_unit);
+ printf("%s: RX buffer out-of-sync\n", sc->sc_xname);
sc->sc_if.if_ierrors++;
sc->mibdata.dot3StatsInternalMacReceiveErrors++;
fe_reset(sc);
@@ -1666,7 +1665,7 @@ fe_rint (struct fe_softc * sc, u_char rstat)
/* Maximum number of frames has been received. Something
strange is happening here... */
- printf("fe%d: unusual receive flood\n", sc->sc_unit);
+ printf("%s: unusual receive flood\n", sc->sc_xname);
sc->mibdata.dot3StatsInternalMacReceiveErrors++;
fe_reset(sc);
}
@@ -1740,7 +1739,7 @@ fe_intr (void *arg)
fe_start(&sc->sc_if);
}
- printf("fe%d: too many loops\n", sc->sc_unit);
+ printf("%s: too many loops\n", sc->sc_xname);
}
/*
@@ -1918,7 +1917,7 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m)
/* Check if this matches the one in the packet header. */
if (length != m->m_pkthdr.len) {
- printf("fe%d: packet length mismatch? (%d/%d)\n", sc->sc_unit,
+ printf("%s: packet length mismatch? (%d/%d)\n", sc->sc_xname,
length, m->m_pkthdr.len);
}
#else
@@ -1934,8 +1933,8 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m)
*/
if (length < ETHER_HDR_LEN ||
length > ETHER_MAX_LEN - ETHER_CRC_LEN) {
- printf("fe%d: got an out-of-spec packet (%u bytes) to send\n",
- sc->sc_unit, length);
+ printf("%s: got an out-of-spec packet (%u bytes) to send\n",
+ sc->sc_xname, length);
sc->sc_if.if_oerrors++;
sc->mibdata.dot3StatsInternalMacTransmitErrors++;
return;
@@ -2086,8 +2085,8 @@ fe_mcaf ( struct fe_softc *sc )
continue;
index = fe_hash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
#ifdef FE_DEBUG
- printf("fe%d: hash(%6D) == %d\n",
- sc->sc_unit, enm->enm_addrlo , ":", index);
+ printf("%s: hash(%6D) == %d\n",
+ sc->sc_xname, enm->enm_addrlo , ":", index);
#endif
filter.data[index >> 3] |= 1 << (index & 7);
@@ -2229,8 +2228,8 @@ fe_medchange (struct ifnet *ifp)
if (bit2media[b] == sc->media.ifm_media) break;
}
if (((1 << b) & sc->mbitmap) == 0) {
- printf("fe%d: got an unsupported media request (0x%x)\n",
- sc->sc_unit, sc->media.ifm_media);
+ printf("%s: got an unsupported media request (0x%x)\n",
+ sc->sc_xname, sc->media.ifm_media);
return EINVAL;
}
#endif
diff --git a/sys/dev/fe/if_fevar.h b/sys/dev/fe/if_fevar.h
index 37842b2..c8fd355 100644
--- a/sys/dev/fe/if_fevar.h
+++ b/sys/dev/fe/if_fevar.h
@@ -69,6 +69,7 @@ struct fe_softc {
/* Used by "common" codes. */
struct arpcom arpcom; /* Ethernet common */
+ int sc_unit;
/* Used by config codes. */
int type;
@@ -118,7 +119,7 @@ struct fe_softc {
};
#define sc_if arpcom.ac_if
-#define sc_unit arpcom.ac_if.if_unit
+#define sc_xname arpcom.ac_if.if_xname
#define sc_enaddr arpcom.ac_enaddr
diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c
index b076497..92c0314 100644
--- a/sys/dev/firewire/if_fwe.c
+++ b/sys/dev/firewire/if_fwe.c
@@ -186,8 +186,7 @@ fwe_attach(device_t dev)
ifp = &fwe->fwe_if;
ifp->if_softc = &fwe->eth_softc;
- ifp->if_unit = unit;
- ifp->if_name = "fwe";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_init = fwe_init;
ifp->if_output = ether_output;
ifp->if_start = fwe_start;
@@ -211,7 +210,7 @@ fwe_attach(device_t dev)
#endif
- FWEDEBUG("interface %s%d created.\n", ifp->if_name, ifp->if_unit);
+ FWEDEBUG("interface %s created.\n", ifp->if_xname);
return 0;
}
@@ -287,7 +286,7 @@ fwe_init(void *arg)
struct mbuf *m;
int i;
- FWEDEBUG("initializing %s%d\n", ifp->if_name, ifp->if_unit);
+ FWEDEBUG("initializing %s\n", ifp->if_xname);
/* XXX keep promiscoud mode */
ifp->if_flags |= IFF_PROMISC;
@@ -464,12 +463,12 @@ fwe_start(struct ifnet *ifp)
struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe;
int s;
- FWEDEBUG("%s%d starting\n", ifp->if_name, ifp->if_unit);
+ FWEDEBUG("%s starting\n", ifp->if_xname);
if (fwe->dma_ch < 0) {
struct mbuf *m = NULL;
- FWEDEBUG("%s%d not ready.\n", ifp->if_name, ifp->if_unit);
+ FWEDEBUG("%s not ready.\n", ifp->if_xname);
s = splimp();
do {
diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c
index 7fa3e88..39a42d0 100644
--- a/sys/dev/fxp/if_fxp.c
+++ b/sys/dev/fxp/if_fxp.c
@@ -793,8 +793,7 @@ fxp_attach(device_t dev)
}
ifp = &sc->arpcom.ac_if;
- ifp->if_unit = device_get_unit(dev);
- ifp->if_name = "fxp";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_output = ether_output;
ifp->if_baudrate = 100000000;
ifp->if_init = fxp_init;
diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c
index 3ae3c3e..5809e7b 100644
--- a/sys/dev/gem/if_gem.c
+++ b/sys/dev/gem/if_gem.c
@@ -250,8 +250,8 @@ gem_attach(sc)
/* Initialize ifnet structure. */
ifp->if_softc = sc;
- ifp->if_unit = device_get_unit(sc->sc_dev);
- ifp->if_name = "gem";
+ if_initname(ifp, device_get_name(sc->sc_dev),
+ device_get_unit(sc->sc_dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_start = gem_start;
diff --git a/sys/dev/gx/if_gx.c b/sys/dev/gx/if_gx.c
index 3573a78..4b5955f 100644
--- a/sys/dev/gx/if_gx.c
+++ b/sys/dev/gx/if_gx.c
@@ -341,8 +341,7 @@ gx_attach(device_t dev)
/* Set up ifnet structure */
ifp = &gx->arpcom.ac_if;
ifp->if_softc = gx;
- ifp->if_unit = device_get_unit(dev);
- ifp->if_name = "gx";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = gx_ioctl;
ifp->if_output = ether_output;
diff --git a/sys/dev/harp/if_harp.c b/sys/dev/harp/if_harp.c
index 02e1aa7..ac38b02 100644
--- a/sys/dev/harp/if_harp.c
+++ b/sys/dev/harp/if_harp.c
@@ -160,7 +160,7 @@ static const struct {
static int
harp_check_if(const struct ifnet *ifp)
{
- if (ifp->if_type == IFT_ATM && strcmp(ifp->if_name, "en"))
+ if (ifp->if_type == IFT_ATM && strcmp(ifp->if_dname, "en"))
return (0);
else
return (-1);
@@ -386,7 +386,7 @@ harp_attach(struct ifnet *parent)
sc = malloc(sizeof(*sc), M_HARP, M_WAITOK | M_ZERO);
sc->parent = parent;
- sc->cmn.cu_unit = parent->if_unit;
+ sc->cmn.cu_unit = parent->if_dunit;
sc->cmn.cu_mtu = HARP_MTU;
sc->cmn.cu_ioctl = harp_ioctl;
sc->cmn.cu_instvcc = harp_instvcc;
@@ -469,10 +469,10 @@ harp_attach(struct ifnet *parent)
sc->cmn.cu_config.ac_macaddr.ma_data[5] =
sc->cmn.cu_pif.pif_macaddr.ma_data[5] = mib->esi[5];
- error = atm_physif_register(&sc->cmn, parent->if_name, harp_services);
+ error = atm_physif_register(&sc->cmn, parent->if_dname, harp_services);
if (error) {
log(LOG_ERR, "%s: pif registration failed %d\n",
- parent->if_name, error);
+ parent->if_dname, error);
free(sc, M_HARP);
return;
}
@@ -498,7 +498,7 @@ harp_detach(struct ifnet *ifp)
error = atm_physif_deregister(&sc->cmn);
if (error)
- log(LOG_ERR, "%s: de-registration failed %d\n", ifp->if_name,
+ log(LOG_ERR, "%s: de-registration failed %d\n", ifp->if_dname,
error);
LIST_REMOVE(sc, link);
diff --git a/sys/dev/hatm/if_hatm.c b/sys/dev/hatm/if_hatm.c
index 5295ee0..cb1b23b 100644
--- a/sys/dev/hatm/if_hatm.c
+++ b/sys/dev/hatm/if_hatm.c
@@ -1639,13 +1639,11 @@ static int
hatm_attach(device_t dev)
{
struct hatm_softc *sc;
- int unit;
int error;
uint32_t v;
struct ifnet *ifp;
sc = device_get_softc(dev);
- unit = device_get_unit(dev);
sc->dev = dev;
sc->ifatm.mib.device = ATM_DEVICE_HE155;
@@ -1760,8 +1758,7 @@ hatm_attach(device_t dev)
ifp = &sc->ifatm.ifnet;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "hatm";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
/*
* Make the sysctl tree
diff --git a/sys/dev/hme/if_hme.c b/sys/dev/hme/if_hme.c
index 718a921..bbb428b 100644
--- a/sys/dev/hme/if_hme.c
+++ b/sys/dev/hme/if_hme.c
@@ -268,8 +268,8 @@ hme_config(struct hme_softc *sc)
/* Initialize ifnet structure. */
ifp->if_softc = sc;
- ifp->if_unit = device_get_unit(sc->sc_dev);
- ifp->if_name = "hme";
+ if_initname(ifp, device_get_name(sc->sc_dev),
+ device_get_unit(sc->sc_dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX |IFF_MULTICAST;
ifp->if_start = hme_start;
diff --git a/sys/dev/ie/if_ie.c b/sys/dev/ie/if_ie.c
index 2ebc298..4251738 100644
--- a/sys/dev/ie/if_ie.c
+++ b/sys/dev/ie/if_ie.c
@@ -307,8 +307,7 @@ ie_attach(device_t dev)
ie_hardware_names[sc->hard_type], sc->hard_vers + 1);
ifp->if_softc = sc;
- ifp->if_unit = sc->unit;
- ifp->if_name = "ie";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_start = iestart;
diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c
index d09973a..a98720f 100644
--- a/sys/dev/iicbus/if_ic.c
+++ b/sys/dev/iicbus/if_ic.c
@@ -134,8 +134,7 @@ icattach(device_t dev)
sc->ic_addr = PCF_MASTER_ADDRESS; /* XXX only PCF masters */
ifp->if_softc = sc;
- ifp->if_name = "ic";
- ifp->if_unit = device_get_unit(dev);
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ICMTU;
ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST;
ifp->if_ioctl = icioctl;
@@ -158,7 +157,7 @@ icattach(device_t dev)
static int
icioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
- device_t icdev = devclass_get_device(ic_devclass, ifp->if_unit);
+ device_t icdev = devclass_get_device(ic_devclass, ifp->if_dunit);
device_t parent = device_get_parent(icdev);
struct ic_softc *sc = (struct ic_softc *)device_get_softc(icdev);
@@ -363,7 +362,7 @@ static int
icoutput(struct ifnet *ifp, struct mbuf *m,
struct sockaddr *dst, struct rtentry *rt)
{
- device_t icdev = devclass_get_device(ic_devclass, ifp->if_unit);
+ device_t icdev = devclass_get_device(ic_devclass, ifp->if_dunit);
device_t parent = device_get_parent(icdev);
struct ic_softc *sc = (struct ic_softc *)device_get_softc(icdev);
diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c
index 1af3725..bd545e3 100644
--- a/sys/dev/lge/if_lge.c
+++ b/sys/dev/lge/if_lge.c
@@ -615,8 +615,7 @@ lge_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "lge";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = lge_ioctl;
diff --git a/sys/dev/lnc/if_lnc.c b/sys/dev/lnc/if_lnc.c
index e8b526b..3173b0c 100644
--- a/sys/dev/lnc/if_lnc.c
+++ b/sys/dev/lnc/if_lnc.c
@@ -468,14 +468,12 @@ lnc_rint(struct lnc_softc *sc)
#ifdef DIAGNOSTIC
if ((sc->recv_ring + sc->recv_next)->md->md1 & OWN) {
- int unit = ifp->if_unit;
- log(LOG_ERR, "lnc%d: Receive interrupt with buffer still owned by controller -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Receive interrupt with buffer still owned by controller -- Resetting\n", ifp->if_xname);
lnc_reset(sc);
return;
}
if (!((sc->recv_ring + sc->recv_next)->md->md1 & STP)) {
- int unit = ifp->if_unit;
- log(LOG_ERR, "lnc%d: Receive interrupt but not start of packet -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Receive interrupt but not start of packet -- Resetting\n", ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -506,8 +504,7 @@ lnc_rint(struct lnc_softc *sc)
} while (!(flags & (STP | OWN | ENP | MDERR)));
if (flags & STP) {
- int unit = ifp->if_unit;
- log(LOG_ERR, "lnc%d: Start of packet found before end of previous in receive ring -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Start of packet found before end of previous in receive ring -- Resetting\n", ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -520,8 +517,7 @@ lnc_rint(struct lnc_softc *sc)
sc->recv_next = start_of_packet;
break;
} else {
- int unit = ifp->if_unit;
- log(LOG_ERR, "lnc%d: End of received packet not found-- Resetting\n", unit);
+ log(LOG_ERR, "%s: End of received packet not found-- Resetting\n", ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -535,16 +531,16 @@ lnc_rint(struct lnc_softc *sc)
next = sc->recv_ring + sc->recv_next;
if (flags & MDERR) {
- int unit = ifp->if_unit;
+ const char *if_xname = ifp->if_xname;
if (flags & RBUFF) {
LNCSTATS(rbuff)
- log(LOG_ERR, "lnc%d: Receive buffer error\n", unit);
+ log(LOG_ERR, "%s: Receive buffer error\n", if_xname);
}
if (flags & OFLO) {
/* OFLO only valid if ENP is not set */
if (!(flags & ENP)) {
LNCSTATS(oflo)
- log(LOG_ERR, "lnc%d: Receive overflow error \n", unit);
+ log(LOG_ERR, "%s: Receive overflow error \n", if_xname);
}
} else if (flags & ENP) {
if ((ifp->if_flags & IFF_PROMISC)==0) {
@@ -554,14 +550,14 @@ lnc_rint(struct lnc_softc *sc)
*/
if (flags & FRAM) {
LNCSTATS(fram)
- log(LOG_ERR, "lnc%d: Framing error\n", unit);
+ log(LOG_ERR, "%s: Framing error\n", if_xname);
/*
* FRAM is only set if there's a CRC
* error so avoid multiple messages
*/
} else if (flags & CRC) {
LNCSTATS(crc)
- log(LOG_ERR, "lnc%d: Receive CRC error\n", unit);
+ log(LOG_ERR, "%s: Receive CRC error\n", if_xname);
}
}
}
@@ -607,8 +603,7 @@ lnc_rint(struct lnc_softc *sc)
(*ifp->if_input)(ifp, head);
}
} else {
- int unit = ifp->if_unit;
- log(LOG_ERR,"lnc%d: Packet dropped, no mbufs\n",unit);
+ log(LOG_ERR,"%s: Packet dropped, no mbufs\n",ifp->if_xname);
LNCSTATS(drop_packet)
}
}
@@ -649,8 +644,7 @@ lnc_tint(struct lnc_softc *sc)
#ifdef DIAGNOSTIC
if ((sc->trans_ring + sc->trans_next)->md->md1 & OWN) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Transmit interrupt with buffer still owned by controller -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Transmit interrupt with buffer still owned by controller -- Resetting\n", sc->arpcom.ac_if.if_xname);
lnc_reset(sc);
return;
}
@@ -678,12 +672,11 @@ lnc_tint(struct lnc_softc *sc)
next = sc->trans_ring + sc->trans_next;
#ifdef DIAGNOSTIC
- if (!(next->md->md1 & STP)) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Transmit interrupt but not start of packet -- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
+ if (!(next->md->md1 & STP)) {
+ log(LOG_ERR, "%s: Transmit interrupt but not start of packet -- Resetting\n", sc->arpcom.ac_if.if_xname);
+ lnc_reset(sc);
+ return;
+ }
#endif
/*
@@ -697,8 +690,7 @@ lnc_tint(struct lnc_softc *sc)
} while (!(next->md->md1 & (STP | OWN | ENP | MDERR)));
if (next->md->md1 & STP) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Start of packet found before end of previous in transmit ring -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Start of packet found before end of previous in transmit ring -- Resetting\n", sc->arpcom.ac_if.if_xname);
lnc_reset(sc);
return;
}
@@ -711,8 +703,7 @@ lnc_tint(struct lnc_softc *sc)
sc->trans_next = start_of_packet;
break;
} else {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: End of transmitted packet not found -- Resetting\n", unit);
+ log(LOG_ERR, "%s: End of transmitted packet not found -- Resetting\n", sc->arpcom.ac_if.if_xname);
lnc_reset(sc);
return;
}
@@ -724,14 +715,12 @@ lnc_tint(struct lnc_softc *sc)
*/
if (next->md->md1 & MDERR) {
- int unit = sc->arpcom.ac_if.if_unit;
-
LNCSTATS(terr)
sc->arpcom.ac_if.if_oerrors++;
if (next->md->md3 & LCOL) {
LNCSTATS(lcol)
- log(LOG_ERR, "lnc%d: Transmit late collision -- Net error?\n", unit);
+ log(LOG_ERR, "%s: Transmit late collision -- Net error?\n", sc->arpcom.ac_if.if_xname);
sc->arpcom.ac_if.if_collisions++;
/*
* Clear TBUFF since it's not valid when LCOL
@@ -741,11 +730,11 @@ lnc_tint(struct lnc_softc *sc)
}
if (next->md->md3 & LCAR) {
LNCSTATS(lcar)
- log(LOG_ERR, "lnc%d: Loss of carrier during transmit -- Net error?\n", unit);
+ log(LOG_ERR, "%s: Loss of carrier during transmit -- Net error?\n", sc->arpcom.ac_if.if_xname);
}
if (next->md->md3 & RTRY) {
LNCSTATS(rtry)
- log(LOG_ERR, "lnc%d: Transmit of packet failed after 16 attempts -- TDR = %d\n", unit, ((sc->trans_ring + sc->trans_next)->md->md3 & TDR));
+ log(LOG_ERR, "%s: Transmit of packet failed after 16 attempts -- TDR = %d\n", sc->arpcom.ac_if.if_xname, ((sc->trans_ring + sc->trans_next)->md->md3 & TDR));
sc->arpcom.ac_if.if_collisions += 16;
/*
* Clear TBUFF since it's not valid when RTRY
@@ -771,9 +760,9 @@ lnc_tint(struct lnc_softc *sc)
*/
if (next->md->md3 & TBUFF) {
LNCSTATS(tbuff)
- log(LOG_ERR, "lnc%d: Transmit buffer error -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Transmit buffer error -- Resetting\n", sc->arpcom.ac_if.if_xname);
} else
- log(LOG_ERR, "lnc%d: Transmit underflow error -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Transmit underflow error -- Resetting\n", sc->arpcom.ac_if.if_xname);
lnc_reset(sc);
return;
}
@@ -865,7 +854,6 @@ lnc_tint(struct lnc_softc *sc)
int
lnc_attach_common(device_t dev)
{
- int unit = device_get_unit(dev);
lnc_softc_t *sc = device_get_softc(dev);
int i;
int skip;
@@ -886,8 +874,8 @@ lnc_attach_common(device_t dev)
/* Fill in arpcom structure entries */
sc->arpcom.ac_if.if_softc = sc;
- sc->arpcom.ac_if.if_name = "lnc";
- sc->arpcom.ac_if.if_unit = unit;
+ if_initname(&sc->arpcom.ac_if, device_get_name(dev),
+ device_get_unit(dev));
sc->arpcom.ac_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
sc->arpcom.ac_if.if_timer = 0;
sc->arpcom.ac_if.if_output = ether_output;
@@ -907,7 +895,7 @@ lnc_attach_common(device_t dev)
ether_ifattach(&sc->arpcom.ac_if, sc->arpcom.ac_enaddr);
- printf("lnc%d: ", unit);
+ printf("%s: ", sc->arpcom.ac_if.if_xname);
if (sc->nic.ic == LANCE || sc->nic.ic == C_LANCE)
printf("%s (%s)",
nic_ident[sc->nic.ident], ic_ident[sc->nic.ic]);
@@ -1094,8 +1082,8 @@ printf("Enabling lnc interrupts\n");
sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
lnc_start(&sc->arpcom.ac_if);
} else
- log(LOG_ERR, "lnc%d: Initialisation failed\n",
- sc->arpcom.ac_if.if_unit);
+ log(LOG_ERR, "%s: Initialisation failed\n",
+ sc->arpcom.ac_if.if_xname);
splx(s);
}
@@ -1125,7 +1113,6 @@ void
lncintr(void *arg)
{
lnc_softc_t *sc = arg;
- int unit = sc->arpcom.ac_if.if_unit;
u_short csr0;
/*
@@ -1160,21 +1147,21 @@ printf("IDON\n");
if (csr0 & ERR) {
if (csr0 & CERR) {
- log(LOG_ERR, "lnc%d: Heartbeat error -- SQE test failed\n", unit);
+ log(LOG_ERR, "%s: Heartbeat error -- SQE test failed\n", sc->arpcom.ac_if.if_xname);
LNCSTATS(cerr)
}
if (csr0 & BABL) {
- log(LOG_ERR, "lnc%d: Babble error - more than 1519 bytes transmitted\n", unit);
+ log(LOG_ERR, "%s: Babble error - more than 1519 bytes transmitted\n", sc->arpcom.ac_if.if_xname);
LNCSTATS(babl)
sc->arpcom.ac_if.if_oerrors++;
}
if (csr0 & MISS) {
- log(LOG_ERR, "lnc%d: Missed packet -- no receive buffer\n", unit);
+ log(LOG_ERR, "%s: Missed packet -- no receive buffer\n", sc->arpcom.ac_if.if_xname);
LNCSTATS(miss)
sc->arpcom.ac_if.if_ierrors++;
}
if (csr0 & MERR) {
- log(LOG_ERR, "lnc%d: Memory error -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Memory error -- Resetting\n", sc->arpcom.ac_if.if_xname);
LNCSTATS(merr)
lnc_reset(sc);
continue;
@@ -1282,7 +1269,7 @@ lnc_start(struct ifnet *ifp)
if (no_entries_needed > (NDESC(sc->ntdre) - sc->pending_transmits)) {
if (!(head = chain_to_cluster(head))) {
- log(LOG_ERR, "lnc%d: Couldn't get mbuf for transmit packet -- Resetting \n ",ifp->if_unit);
+ log(LOG_ERR, "%s: Couldn't get mbuf for transmit packet -- Resetting \n ",ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -1465,7 +1452,7 @@ lnc_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
static void
lnc_watchdog(struct ifnet *ifp)
{
- log(LOG_ERR, "lnc%d: Device timeout -- Resetting\n", ifp->if_unit);
+ log(LOG_ERR, "%s: Device timeout -- Resetting\n", ifp->if_xname);
ifp->if_oerrors++;
lnc_reset(ifp->if_softc);
}
@@ -1476,7 +1463,7 @@ lnc_dump_state(struct lnc_softc *sc)
{
int i;
- printf("\nDriver/NIC [%d] state dump\n", sc->arpcom.ac_if.if_unit);
+ printf("\nDriver/NIC [%s] state dump\n", sc->arpcom.ac_if.if_xname);
printf("Memory access mode: %b\n", sc->nic.mem_mode, MEM_MODES);
printf("Host memory\n");
printf("-----------\n");
diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c
index 29e1f72..6b4d38f 100644
--- a/sys/dev/mii/brgphy.c
+++ b/sys/dev/mii/brgphy.c
@@ -199,7 +199,7 @@ brgphy_attach(dev)
bge_sc = mii->mii_ifp->if_softc;
- if (strcmp(mii->mii_ifp->if_name, "bge") == 0 &&
+ if (strcmp(mii->mii_ifp->if_dname, "bge") == 0 &&
pci_get_vendor(bge_sc->bge_dev) == BCOM_VENDORID &&
(pci_get_device(bge_sc->bge_dev) == BCOM_DEVICEID_BCM5901 ||
pci_get_device(bge_sc->bge_dev) == BCOM_DEVICEID_BCM5901A2))
@@ -613,7 +613,7 @@ brgphy_reset(struct mii_softc *sc)
* on "bge" NICs, since other drivers may use this same
* PHY subdriver.
*/
- if (strcmp(ifp->if_name, "bge") == 0 &&
+ if (strcmp(ifp->if_dname, "bge") == 0 &&
(bge_sc->bge_asicrev == BGE_ASICREV_BCM5700 ||
bge_sc->bge_chipid == BGE_CHIPID_BCM5705_A1 ||
bge_sc->bge_chipid == BGE_CHIPID_BCM5705_A2))
diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c
index 2f87fa8..d580e9c 100644
--- a/sys/dev/my/if_my.c
+++ b/sys/dev/my/if_my.c
@@ -994,8 +994,7 @@ my_attach(device_t dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "my";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = my_ioctl;
diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c
index fb154a6..0fca198 100644
--- a/sys/dev/nge/if_nge.c
+++ b/sys/dev/nge/if_nge.c
@@ -948,8 +948,7 @@ nge_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "nge";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = nge_ioctl;
diff --git a/sys/dev/patm/if_patm_attach.c b/sys/dev/patm/if_patm_attach.c
index f0730ba..37814bc 100644
--- a/sys/dev/patm/if_patm_attach.c
+++ b/sys/dev/patm/if_patm_attach.c
@@ -192,8 +192,7 @@ patm_attach(device_t dev)
ifp = &sc->ifatm.ifnet;
ifp->if_softc = sc;
- ifp->if_unit = device_get_unit(dev);
- ifp->if_name = "patm";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_SIMPLEX;
ifp->if_watchdog = NULL;
ifp->if_init = patm_init;
diff --git a/sys/dev/pdq/if_fea.c b/sys/dev/pdq/if_fea.c
index 95200f7..2c1dc43 100644
--- a/sys/dev/pdq/if_fea.c
+++ b/sys/dev/pdq/if_fea.c
@@ -223,12 +223,11 @@ pdq_eisa_attach (dev)
goto bad;
}
- ifp->if_name = "fea";
- ifp->if_unit = device_get_unit(dev);
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
pdq_eisa_devinit(sc);
sc->sc_pdq = pdq_initialize(sc->mem_bst, sc->mem_bsh,
- ifp->if_name, ifp->if_unit,
+ ifp->if_xname, -1,
(void *)sc, PDQ_DEFEA);
if (sc->sc_pdq == NULL) {
device_printf(dev, "Initialization failed.\n");
diff --git a/sys/dev/pdq/if_fpa.c b/sys/dev/pdq/if_fpa.c
index 8aeccbf..997f0cc 100644
--- a/sys/dev/pdq/if_fpa.c
+++ b/sys/dev/pdq/if_fpa.c
@@ -149,11 +149,10 @@ pdq_pci_attach(device_t dev)
goto bad;
}
- ifp->if_name = "fpa";
- ifp->if_unit = device_get_unit(dev);
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
sc->sc_pdq = pdq_initialize(sc->mem_bst, sc->mem_bsh,
- ifp->if_name, ifp->if_unit,
+ ifp->if_xname, -1,
(void *)sc, PDQ_DEFPA);
if (sc->sc_pdq == NULL) {
device_printf(dev, "Initialization failed.\n");
diff --git a/sys/dev/pdq/pdq_freebsd.h b/sys/dev/pdq/pdq_freebsd.h
index f43f3e3..c86b14b 100644
--- a/sys/dev/pdq/pdq_freebsd.h
+++ b/sys/dev/pdq/pdq_freebsd.h
@@ -158,8 +158,8 @@ typedef struct _pdq_os_ctx_t {
#if defined(PDQ_HWSUPPORT)
-#define PDQ_OS_PREFIX "%s%d: "
-#define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name, pdq->pdq_unit
+#define PDQ_OS_PREFIX "%s: "
+#define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name
#define PDQ_OS_PTR_FMT "%p"
#define PDQ_OS_CSR_FMT "0x%x"
diff --git a/sys/dev/pdq/pdqvar.h b/sys/dev/pdq/pdqvar.h
index 09358d8..1ac3d85 100644
--- a/sys/dev/pdq/pdqvar.h
+++ b/sys/dev/pdq/pdqvar.h
@@ -73,7 +73,7 @@ enum _pdq_type_t {
#include <vm/vm_kern.h>
#define PDQ_USE_MBUFS
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(__FreeBSD__)
#define PDQ_OS_PREFIX "%s: "
#define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name
#else
diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c
index ad2c3be..ab02841 100644
--- a/sys/dev/ppbus/if_plip.c
+++ b/sys/dev/ppbus/if_plip.c
@@ -233,8 +233,7 @@ lp_attach (device_t dev)
struct ifnet *ifp = &lp->sc_if;
ifp->if_softc = lp;
- ifp->if_name = "lp";
- ifp->if_unit = device_get_unit(dev);
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = LPMTU;
ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST;
ifp->if_ioctl = lpioctl;
@@ -295,7 +294,7 @@ lpinittables (void)
static int
lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
{
- device_t dev = UNITODEVICE(ifp->if_unit);
+ device_t dev = UNITODEVICE(ifp->if_dunit);
device_t ppbus = device_get_parent(dev);
struct lp_data *sc = DEVTOSOFTC(dev);
struct ifaddr *ifa = (struct ifaddr *)data;
@@ -609,7 +608,7 @@ static int
lpoutput (struct ifnet *ifp, struct mbuf *m,
struct sockaddr *dst, struct rtentry *rt)
{
- device_t dev = UNITODEVICE(ifp->if_unit);
+ device_t dev = UNITODEVICE(ifp->if_dunit);
device_t ppbus = device_get_parent(dev);
int s, err;
struct mbuf *mm;
diff --git a/sys/dev/ray/if_ray.c b/sys/dev/ray/if_ray.c
index b37f9c3..3319396 100644
--- a/sys/dev/ray/if_ray.c
+++ b/sys/dev/ray/if_ray.c
@@ -503,8 +503,7 @@ ray_attach(device_t dev)
bcopy((char *)&ep->e_station_addr,
(char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
ifp->if_softc = sc;
- ifp->if_name = "ray";
- ifp->if_unit = device_get_unit(dev);
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_timer = 0;
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
ifp->if_hdrlen = sizeof(struct ieee80211_frame) +
diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c
index 004c4c6..549d3ae 100644
--- a/sys/dev/re/if_re.c
+++ b/sys/dev/re/if_re.c
@@ -1254,8 +1254,7 @@ re_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "re";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = re_ioctl;
diff --git a/sys/dev/sbni/if_sbni.c b/sys/dev/sbni/if_sbni.c
index 1697a41..dad1dce 100644
--- a/sys/dev/sbni/if_sbni.c
+++ b/sys/dev/sbni/if_sbni.c
@@ -228,8 +228,7 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
callout_handle_init(&sc->wch);
/* Initialize ifnet structure */
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "sbni";
+ if_initname(ifp, "sbni", unit);
ifp->if_init = sbni_init;
ifp->if_start = sbni_start;
ifp->if_output = ether_output;
@@ -926,7 +925,7 @@ card_start(struct sbni_softc *sc)
static void
sbni_watchdog(struct ifnet *ifp)
{
- log(LOG_ERR, "sbni%d: device timeout\n", ifp->if_unit);
+ log(LOG_ERR, "%s: device timeout\n", ifp->if_xname);
ifp->if_oerrors++;
}
diff --git a/sys/dev/sbni/if_sbni_isa.c b/sys/dev/sbni/if_sbni_isa.c
index 6da8b32..cb7b02c 100644
--- a/sys/dev/sbni/if_sbni_isa.c
+++ b/sys/dev/sbni/if_sbni_isa.c
@@ -156,8 +156,8 @@ sbni_attach_isa(device_t dev)
dev, SYS_RES_IOPORT, sc->io_rid, sc->io_res);
return (ENXIO);
} else {
- printf(" shared irq with sbni%d\n",
- master->arpcom.ac_if.if_unit);
+ printf(" shared irq with %s\n",
+ master->arpcom.ac_if.if_xname);
}
}
#endif /* SBNI_DUAL_COMPOUND */
diff --git a/sys/dev/sbsh/if_sbsh.c b/sys/dev/sbsh/if_sbsh.c
index 9678e10..0360e20 100644
--- a/sys/dev/sbsh/if_sbsh.c
+++ b/sys/dev/sbsh/if_sbsh.c
@@ -268,8 +268,7 @@ sbsh_attach(device_t dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "sbsh";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = sbsh_ioctl;
diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c
index fcd05ff..6642809 100644
--- a/sys/dev/sf/if_sf.c
+++ b/sys/dev/sf/if_sf.c
@@ -770,8 +770,7 @@ sf_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "sf";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = sf_ioctl;
diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c
index 813c94d..2773236 100644
--- a/sys/dev/sk/if_sk.c
+++ b/sys/dev/sk/if_sk.c
@@ -1394,8 +1394,7 @@ sk_attach(dev)
ifp = &sc_if->arpcom.ac_if;
ifp->if_softc = sc_if;
- ifp->if_unit = sc_if->sk_unit;
- ifp->if_name = "sk";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = sk_ioctl;
diff --git a/sys/dev/sn/if_sn.c b/sys/dev/sn/if_sn.c
index 5cb968a..49cd843 100644
--- a/sys/dev/sn/if_sn.c
+++ b/sys/dev/sn/if_sn.c
@@ -203,8 +203,7 @@ sn_attach(device_t dev)
}
printf(" MAC address %6D\n", sc->arpcom.ac_enaddr, ":");
ifp->if_softc = sc;
- ifp->if_unit = device_get_unit(dev);
- ifp->if_name = "sn";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_output = ether_output;
diff --git a/sys/dev/sr/if_sr.c b/sys/dev/sr/if_sr.c
index d315a4f..745dada 100644
--- a/sys/dev/sr/if_sr.c
+++ b/sys/dev/sr/if_sr.c
@@ -419,8 +419,8 @@ sr_attach(device_t device)
#ifndef NETGRAPH
ifp = &sc->ifsppp.pp_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->unit;
- ifp->if_name = "sr";
+ if_initname(ifp, device_get_name(device),
+ device_get_unit(device));
ifp->if_mtu = PP_MTU;
ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
ifp->if_ioctl = srioctl;
diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c
index 95bbfc4..4cbea9b 100644
--- a/sys/dev/ti/if_ti.c
+++ b/sys/dev/ti/if_ti.c
@@ -2187,8 +2187,7 @@ ti_attach(dev)
/* Set up ifnet structure */
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->ti_unit;
- ifp->if_name = "ti";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
tis[unit] = sc;
ifp->if_ioctl = ti_ioctl;
@@ -2810,7 +2809,7 @@ static void ti_init2(sc)
ifp = &sc->arpcom.ac_if;
/* Specify MTU and interface index. */
- CSR_WRITE_4(sc, TI_GCR_IFINDEX, ifp->if_unit);
+ CSR_WRITE_4(sc, TI_GCR_IFINDEX, sc->ti_unit);
CSR_WRITE_4(sc, TI_GCR_IFMTU, ifp->if_mtu +
ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN);
TI_DO_CMD(TI_CMD_UPDATE_GENCOM, 0, 0);
diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c
index 4afcd0a..634e971 100644
--- a/sys/dev/tx/if_tx.c
+++ b/sys/dev/tx/if_tx.c
@@ -242,8 +242,7 @@ epic_attach(dev)
/* Fill ifnet structure. */
ifp = &sc->sc_if;
- ifp->if_unit = unit;
- ifp->if_name = "tx";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST;
ifp->if_ioctl = epic_ifioctl;
diff --git a/sys/dev/txp/if_txp.c b/sys/dev/txp/if_txp.c
index dfc81b5..d5161ea 100644
--- a/sys/dev/txp/if_txp.c
+++ b/sys/dev/txp/if_txp.c
@@ -355,8 +355,7 @@ txp_attach(dev)
ifp = &sc->sc_arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "txp";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = txp_ioctl;
diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c
index b584b6f..bbb5669 100644
--- a/sys/dev/usb/if_aue.c
+++ b/sys/dev/usb/if_aue.c
@@ -739,8 +739,7 @@ USB_ATTACH(aue)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->aue_unit;
- ifp->if_name = "aue";
+ if_initname(ifp, "aue", sc->aue_unit);
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = aue_ioctl;
diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c
index a808754..b4df6e6 100644
--- a/sys/dev/usb/if_axe.c
+++ b/sys/dev/usb/if_axe.c
@@ -509,8 +509,7 @@ USB_ATTACH(axe)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->axe_unit;
- ifp->if_name = "axe";
+ if_initname(ifp, "axe", sc->axe_unit);
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = axe_ioctl;
diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c
index 9497aab..54d887e 100644
--- a/sys/dev/usb/if_cue.c
+++ b/sys/dev/usb/if_cue.c
@@ -520,8 +520,7 @@ USB_ATTACH(cue)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->cue_unit;
- ifp->if_name = "cue";
+ if_initname(ifp, "cue", sc->cue_unit);
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = cue_ioctl;
diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c
index 28140d8..2be9b50 100644
--- a/sys/dev/usb/if_kue.c
+++ b/sys/dev/usb/if_kue.c
@@ -489,8 +489,7 @@ USB_ATTACH(kue)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->kue_unit;
- ifp->if_name = "kue";
+ if_initname(ifp, "kue", sc->kue_unit);
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = kue_ioctl;
diff --git a/sys/dev/usb/if_rue.c b/sys/dev/usb/if_rue.c
index 53b3b77..b23184c 100644
--- a/sys/dev/usb/if_rue.c
+++ b/sys/dev/usb/if_rue.c
@@ -661,8 +661,7 @@ USB_ATTACH(rue)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->rue_unit;
- ifp->if_name = "rue";
+ if_initname(ifp, "rue", sc->rue_unit);
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = rue_ioctl;
diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c
index 35343da..ffd2c3e 100644
--- a/sys/dev/vr/if_vr.c
+++ b/sys/dev/vr/if_vr.c
@@ -849,8 +849,7 @@ vr_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "vr";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = vr_ioctl;
diff --git a/sys/dev/vx/if_vx.c b/sys/dev/vx/if_vx.c
index 7c6e8a9..5f17e22 100644
--- a/sys/dev/vx/if_vx.c
+++ b/sys/dev/vx/if_vx.c
@@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$");
#include <machine/bus_pio.h>
#include <machine/bus.h>
+#include <sys/bus.h>
+
#include <net/bpf.h>
#include <dev/vx/if_vxreg.h>
@@ -122,9 +124,10 @@ static void vxsetlink(struct vx_softc *);
int
-vxattach(sc)
- struct vx_softc *sc;
+vxattach(dev)
+ device_t dev;
{
+ struct vx_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->arpcom.ac_if;
int i;
@@ -154,8 +157,7 @@ vxattach(sc)
printf(" address %6D\n", sc->arpcom.ac_enaddr, ":");
- ifp->if_unit = sc->unit;
- ifp->if_name = "vx";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
diff --git a/sys/dev/vx/if_vx_eisa.c b/sys/dev/vx/if_vx_eisa.c
index 95e5554..4c8931d 100644
--- a/sys/dev/vx/if_vx_eisa.c
+++ b/sys/dev/vx/if_vx_eisa.c
@@ -155,7 +155,7 @@ vx_eisa_attach(device_t dev)
/* Now the registers are availible through the lower ioport */
- vxattach(sc);
+ vxattach(dev);
if (bus_setup_intr(dev, irq, INTR_TYPE_NET, vxintr, sc, &ih)) {
goto bad;
diff --git a/sys/dev/vx/if_vx_pci.c b/sys/dev/vx/if_vx_pci.c
index 201b4ea..ff4f1fb 100644
--- a/sys/dev/vx/if_vx_pci.c
+++ b/sys/dev/vx/if_vx_pci.c
@@ -151,7 +151,7 @@ vx_pci_attach(
vxintr, sc, &sc->vx_intrhand))
goto bad;
- if (vxattach(sc) == 0) {
+ if (vxattach(dev) == 0) {
goto bad;
}
diff --git a/sys/dev/vx/if_vxvar.h b/sys/dev/vx/if_vxvar.h
index 712e9f5..e8a7a32 100644
--- a/sys/dev/vx/if_vxvar.h
+++ b/sys/dev/vx/if_vxvar.h
@@ -70,7 +70,7 @@ struct vx_softc {
bus_space_read_1(sc->bst, sc->bsh, reg)
extern void vxfree(struct vx_softc *);
-extern int vxattach(struct vx_softc *);
+extern int vxattach(device_t);
extern void vxstop(struct vx_softc *);
extern void vxintr(void *);
extern int vxbusyeeprom(struct vx_softc *);
diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c
index e70698d..770353b 100644
--- a/sys/dev/wi/if_wi.c
+++ b/sys/dev/wi/if_wi.c
@@ -300,8 +300,7 @@ wi_attach(device_t dev)
wi_read_nicid(sc);
ifp->if_softc = sc;
- ifp->if_unit = sc->sc_unit;
- ifp->if_name = "wi";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = wi_ioctl;
ifp->if_start = wi_start;
diff --git a/sys/dev/wl/if_wl.c b/sys/dev/wl/if_wl.c
index f1f4027..e25f965 100644
--- a/sys/dev/wl/if_wl.c
+++ b/sys/dev/wl/if_wl.c
@@ -554,8 +554,7 @@ wlattach(device_t device)
#if MULTICAST
ifp->if_flags |= IFF_MULTICAST;
#endif /* MULTICAST */
- ifp->if_name = "wl";
- ifp->if_unit = unit;
+ if_initname(ifp, device_get_name(device), device_get_unit(device));
ifp->if_init = wlinit;
ifp->if_output = ether_output;
ifp->if_start = wlstart;
@@ -570,7 +569,7 @@ wlattach(device_t device)
ether_ifattach(ifp, &sc->wl_addr[0]);
bcopy(&sc->wl_addr[0], sc->wl_ac.ac_enaddr, WAVELAN_ADDR_SIZE);
- printf("%s%d: address %6D, NWID 0x%02x%02x", ifp->if_name, ifp->if_unit,
+ printf("%s: address %6D, NWID 0x%02x%02x", ifp->if_xname,
sc->wl_ac.ac_enaddr, ":", sc->nwid[0], sc->nwid[1]);
if (sc->freq24)
printf(", Freq %d MHz",sc->freq24); /* 2.4 Gz */
@@ -966,7 +965,6 @@ wlbldcu(struct wl_softc *sc)
static void
wlstart(struct ifnet *ifp)
{
- int unit = ifp->if_unit;
struct mbuf *m;
struct wl_softc *sc = ifp->if_softc;
short base = sc->base;
@@ -975,7 +973,7 @@ wlstart(struct ifnet *ifp)
WL_LOCK(sc);
#ifdef WLDEBUG
if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlstart()\n",unit);
+ printf("%s: entered wlstart()\n", ifp->if_xname);
#endif
outw(PIOR1(base), OFFSET_CU);
@@ -1000,8 +998,8 @@ wlstart(struct ifnet *ifp)
* became idle but WE have masked interrupts so ...
*/
#ifdef WLDEBUG
- printf("wl%d: CU idle, scb %04x %04x cu %04x\n",
- unit, scb_status, scb_command, cu_status);
+ printf("%s: CU idle, scb %04x %04x cu %04x\n",
+ ifp->if_xname, scb_status, scb_command, cu_status);
#endif
if (xmt_watch) printf("!!");
} else {
@@ -1011,10 +1009,10 @@ wlstart(struct ifnet *ifp)
} else if ((scb_status & 0x0700) == SCB_CUS_ACTV ||
(cu_status & AC_SW_B)){
#ifdef WLDEBUG
- printf("wl%d: CU unexpectedly busy; scb %04x cu %04x\n",
- unit, scb_status, cu_status);
+ printf("%s: CU unexpectedly busy; scb %04x cu %04x\n",
+ ifp->if_xname, scb_status, cu_status);
#endif
- if (xmt_watch) printf("wl%d: busy?!",unit);
+ if (xmt_watch) printf("%s: busy?!",ifp->if_xname);
WL_UNLOCK(sc);
return; /* hey, why are we busy? */
}
@@ -1078,7 +1076,7 @@ wlread(struct wl_softc *sc, u_short fd_p)
printf("wl%d: entered wlread()\n", sc->unit);
#endif
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) {
- printf("wl%d read(): board is not running.\n", sc->unit);
+ printf("%s read(): board is not running.\n", ifp->if_xname);
sc->hacr &= ~HACR_INTRON;
CMD(sc); /* turn off interrupts */
}
@@ -1235,7 +1233,6 @@ static int
wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
struct ifreq *ifr = (struct ifreq *)data;
- int unit = ifp->if_unit;
struct wl_softc *sc = ifp->if_softc;
short base = sc->base;
short mode = 0;
@@ -1251,7 +1248,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
WL_LOCK(sc);
#ifdef WLDEBUG
if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlioctl()\n",unit);
+ printf("%s: entered wlioctl()\n", ifp->if_xname);
#endif
opri = splimp();
switch (cmd) {
@@ -1282,7 +1279,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
* stop it.
*/
if ((ifp->if_flags & IFF_UP) == 0 && sc->flags & DSF_RUNNING) {
- printf("wl%d ioctl(): board is not running\n", unit);
+ printf("%s ioctl(): board is not running\n", ifp->if_xname);
sc->flags &= ~DSF_RUNNING;
sc->hacr &= ~HACR_INTRON;
CMD(sc); /* turn off interrupts */
@@ -1768,7 +1765,7 @@ static int xmt_debug = 0;
* locations on the WaveLAN board and starts the board off on
* the transmit.
*
- * input : board number of interest, and a pointer to the mbuf
+ * input : pointers to board of interest's softc and the mbuf
* output : board memory and registers are set for xfer and attention
*
*/
@@ -1789,7 +1786,7 @@ wlxmt(struct wl_softc *sc, struct mbuf *m)
#ifdef WLDEBUG
if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlxmt()\n", sc->unit);
+ printf("%s: entered wlxmt()\n", sc->wl_if.if_xname);
#endif
cb.ac_status = 0;
@@ -1899,7 +1896,7 @@ wlxmt(struct wl_softc *sc, struct mbuf *m)
break;
}
if ((spin == 0) && xmt_watch) { /* not waking up, and we care */
- printf("wl%d: slow accepting xmit\n", sc->unit);
+ printf("%s: slow accepting xmit\n", sc->wl_if.if_xname);
}
}
outw(PIOP0(base), SCB_CU_STRT); /* new command */
diff --git a/sys/dev/xe/if_xe.c b/sys/dev/xe/if_xe.c
index 6158e7d..e4fc724 100644
--- a/sys/dev/xe/if_xe.c
+++ b/sys/dev/xe/if_xe.c
@@ -219,8 +219,7 @@ xe_attach (device_t dev)
/* Initialise the ifnet structure */
scp->ifp->if_softc = scp;
- scp->ifp->if_name = "xe";
- scp->ifp->if_unit = device_get_unit(dev);
+ if_initname(scp->ifp, device_get_name(dev), device_get_unit(dev));
scp->ifp->if_timer = 0;
scp->ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
scp->ifp->if_linkmib = &scp->mibdata;
diff --git a/sys/i386/isa/cx.c b/sys/i386/isa/cx.c
index c0fc028..fd5b686 100644
--- a/sys/i386/isa/cx.c
+++ b/sys/i386/isa/cx.c
@@ -285,11 +285,11 @@ cxioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
master = *o->master ? ifunit (o->master) : c->ifp;
if (! master)
return (EINVAL);
- m = cxchan[master->if_unit];
+ m = cxchan[master->if_dunit];
/* Leave the previous master queue. */
if (c->master != c->ifp) {
- cx_chan_t *p = cxchan[c->master->if_unit];
+ cx_chan_t *p = cxchan[c->master->if_dunit];
for (; p; p=p->slaveq)
if (p->slaveq == c)
@@ -355,9 +355,8 @@ cxioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
case 8: o->iftype = c->board->if8type; break;
}
if (c->master != c->ifp)
- snprintf (o->master, sizeof(o->master),
- "%s%d", c->master->if_name,
- c->master->if_unit);
+ strlcpy(o->master, c->master->if_xname,
+ sizeof(o->master));
else
*o->master = 0;
break;
diff --git a/sys/i386/isa/if_cx.c b/sys/i386/isa/if_cx.c
index 192ab64..1fe8b2f 100644
--- a/sys/i386/isa/if_cx.c
+++ b/sys/i386/isa/if_cx.c
@@ -269,8 +269,7 @@ cxattach (struct isa_device *id)
bzero (c->ifp, IFSTRUCTSZ);
c->master = c->ifp;
c->ifp->if_softc = c;
- c->ifp->if_unit = u;
- c->ifp->if_name = "cx";
+ if_initname(c->ifp, "cx", u);
c->ifp->if_mtu = PP_MTU;
c->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
c->ifp->if_ioctl = cxsioctl;
diff --git a/sys/i386/isa/if_el.c b/sys/i386/isa/if_el.c
index de28c81..62dd35d 100644
--- a/sys/i386/isa/if_el.c
+++ b/sys/i386/isa/if_el.c
@@ -264,8 +264,7 @@ el_attach(device_t dev)
/* Initialize ifnet structure */
ifp->if_softc = sc;
- ifp->if_unit = device_get_unit(dev);;
- ifp->if_name = "el";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_start = el_start;
ifp->if_ioctl = el_ioctl;
@@ -765,7 +764,7 @@ el_ioctl(ifp, command, data)
static void
el_watchdog(struct ifnet *ifp)
{
- log(LOG_ERR,"el%d: device timeout\n", ifp->if_unit);
+ log(LOG_ERR,"%s: device timeout\n", ifp->if_xname);
ifp->if_oerrors++;
el_reset(ifp->if_softc);
}
diff --git a/sys/i386/isa/if_le.c b/sys/i386/isa/if_le.c
index e55fe96..165ecac 100644
--- a/sys/i386/isa/if_le.c
+++ b/sys/i386/isa/if_le.c
@@ -196,6 +196,7 @@ static void (*le_intrvec[NLE])(le_softc_t *sc);
*/
struct le_softc {
struct arpcom le_ac; /* Common Ethernet/ARP Structure */
+ int le_unit; /* Unit number */
void (*if_init)(void *);/* Interface init routine */
void (*if_reset)(le_softc_t *);/* Interface reset routine */
caddr_t le_membase; /* Starting memory address (virtual) */
@@ -319,8 +320,7 @@ le_probe(
sc->le_iobase = dvp->id_iobase;
sc->le_membase = (u_char *) dvp->id_maddr;
sc->le_irq = dvp->id_irq;
- sc->le_if.if_name = (char *)(uintptr_t)(const void *)ledriver.name;
- sc->le_if.if_unit = dvp->id_unit;
+ sc->le_unit = dvp->id_unit;
/*
* Find and Initialize board..
@@ -346,7 +346,7 @@ le_attach(
dvp->id_ointr = le_intr;
ifp->if_softc = sc;
- ifp->if_unit = dvp->id_unit;
+ if_initname(ifp, ledriver.name, dvp->id_unit);
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = le_ioctl;
ifp->if_init = sc->if_init;
@@ -704,7 +704,7 @@ lemac_probe(
sc->le_mcmask = (1 << LEMAC_MCTBL_BITS) - 1;
sc->lemac_txmax = lemac_deftxmax;
*msize = 2048;
- le_intrvec[sc->le_if.if_unit] = lemac_intr;
+ le_intrvec[sc->le_unit] = lemac_intr;
return LEMAC_IOSPACE;
}
@@ -1346,7 +1346,7 @@ depca_probe(
*/
DEPCA_WRNICSR(sc, DEPCA_RDNICSR(sc) | DEPCA_NICSR_SHE);
- le_intrvec[sc->le_if.if_unit] = depca_intr;
+ le_intrvec[sc->le_unit] = depca_intr;
if (!lance_init_adapmem(sc))
return 0;
diff --git a/sys/i386/isa/if_rdp.c b/sys/i386/isa/if_rdp.c
index e9ba78a..23fb4c0 100644
--- a/sys/i386/isa/if_rdp.c
+++ b/sys/i386/isa/if_rdp.c
@@ -595,8 +595,7 @@ rdp_attach(struct isa_device *isa_dev)
* Initialize ifnet structure
*/
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "rdp";
+ if_initname(ifp, "rdp", unit);
ifp->if_start = rdp_start;
ifp->if_ioctl = rdp_ioctl;
ifp->if_watchdog = rdp_watchdog;
@@ -668,7 +667,7 @@ static void
rdp_watchdog(struct ifnet *ifp)
{
- log(LOG_ERR, "rdp%d: device timeout\n", ifp->if_unit);
+ log(LOG_ERR, "%s: device timeout\n", ifp->if_xname);
ifp->if_oerrors++;
rdp_reset(ifp);
diff --git a/sys/i4b/driver/i4b_ipr.c b/sys/i4b/driver/i4b_ipr.c
index f2ea70e..6a30908 100644
--- a/sys/i4b/driver/i4b_ipr.c
+++ b/sys/i4b/driver/i4b_ipr.c
@@ -203,8 +203,8 @@ i4biprattach(void *dummy)
sc->sc_if.if_softc = sc;
sc->sc_state = ST_IDLE;
- sc->sc_if.if_name = "ipr";
- sc->sc_if.if_unit = i;
+ if_initname(&sc->sc_if, "ipr", i);
+
#ifdef IPR_VJ
sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_SIMPLEX | IPR_AUTOCOMP;
@@ -287,8 +287,8 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
s = SPLI4B();
- unit = ifp->if_unit;
sc = ifp->if_softc;
+ unit = ifp->if_dunit;
/* check for IP */
@@ -435,7 +435,8 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if(sc->sc_if.if_flags & IFF_RUNNING)
{
/* disconnect ISDN line */
- i4b_l4_drvrdisc(BDRV_IPR, ifp->if_unit);
+ i4b_l4_drvrdisc(BDRV_IPR,
+ ifp->if_dunit);
sc->sc_if.if_flags &= ~IFF_RUNNING;
}
@@ -513,7 +514,7 @@ iprclearqueues(struct ipr_softc *sc)
static void
iprwatchdog(struct ifnet *ifp)
{
- int unit = ifp->if_unit;
+ int unit = ifp->if_dunit;
struct ipr_softc *sc = ifp->if_softc;
bchan_statistics_t bs;
@@ -560,7 +561,7 @@ i4bipr_connect_startio(struct ipr_softc *sc)
if(sc->sc_state == ST_CONNECTED_W)
{
sc->sc_state = ST_CONNECTED_A;
- ipr_tx_queue_empty(sc->sc_if.if_unit);
+ ipr_tx_queue_empty(sc->sc_if.if_dunit);
}
splx(s);
diff --git a/sys/i4b/driver/i4b_isppp.c b/sys/i4b/driver/i4b_isppp.c
index dc60fad..3f374dc 100644
--- a/sys/i4b/driver/i4b_isppp.c
+++ b/sys/i4b/driver/i4b_isppp.c
@@ -68,9 +68,9 @@ __FBSDID("$FreeBSD$");
#include <i4b/layer4/i4b_l4.h>
#define ISPPP_FMT "isp%d: "
-#define ISPPP_ARG(sc) ((sc)->sc_if.if_unit)
+#define ISPPP_ARG(sc) ((sc)->sc_if.if_dunit)
#define PDEVSTATIC static
-#define IFP2UNIT(ifp) (ifp)->if_unit
+#define IFP2UNIT(ifp) (ifp)->if_dunit
# define CALLOUT_INIT(chan) callout_handle_init(chan)
# define TIMEOUT(fun, arg, chan, tick) chan = timeout(fun, arg, tick)
@@ -170,8 +170,7 @@ i4bispppattach(void *dummy)
i4bisppp_init_linktab(i);
sc->sc_if.if_softc = sc;
- sc->sc_if.if_name = "isp";
- sc->sc_if.if_unit = i;
+ if_initname(&sc->sc_if, "isp", i);
sc->sc_if.if_mtu = PP_MTU;
sc->sc_if.if_flags = IFF_SIMPLEX | IFF_POINTOPOINT;
sc->sc_if.if_type = IFT_ISDNBASIC;
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 535d268..1dc40c1 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -785,8 +785,8 @@ bpfioctl(dev, cmd, addr, flags, td)
struct ifnet *const ifp = d->bd_bif->bif_ifp;
struct ifreq *const ifr = (struct ifreq *)addr;
- snprintf(ifr->ifr_name, sizeof(ifr->ifr_name),
- "%s%d", ifp->if_name, ifp->if_unit);
+ strlcpy(ifr->ifr_name, ifp->if_xname,
+ sizeof(ifr->ifr_name));
}
break;
@@ -1425,8 +1425,7 @@ bpfdetach(ifp)
/* Interface wasn't attached */
if ((bp == NULL) || (bp->bif_ifp == NULL)) {
mtx_unlock(&bpf_mtx);
- printf("bpfdetach: %s%d was not attached\n", ifp->if_name,
- ifp->if_unit);
+ printf("bpfdetach: %s was not attached\n", ifp->if_xname);
return;
}
diff --git a/sys/net/bridge.c b/sys/net/bridge.c
index 5864a6f..c34d6e2 100644
--- a/sys/net/bridge.c
+++ b/sys/net/bridge.c
@@ -390,8 +390,8 @@ bridge_off(void)
if ( b->flags & IFF_BDG_PROMISC ) {
ifpromisc(ifp, 0);
b->flags &= ~(IFF_BDG_PROMISC|IFF_MUTE) ;
- DPRINTF(("%s: %s%d promisc OFF if_flags 0x%x "
- "bdg_flags 0x%x\n", __func__, ifp->if_name, ifp->if_unit,
+ DPRINTF(("%s: %s promisc OFF if_flags 0x%x "
+ "bdg_flags 0x%x\n", __func__, ifp->if_xname,
ifp->if_flags, b->flags));
}
b->flags &= ~(IFF_USED) ;
@@ -433,12 +433,11 @@ bridge_on(void)
if ( !(b->flags & IFF_BDG_PROMISC) ) {
(void) ifpromisc(ifp, 1);
b->flags |= IFF_BDG_PROMISC ;
- DPRINTF(("%s: %s%d promisc ON if_flags 0x%x bdg_flags 0x%x\n",
- __func__, ifp->if_name, ifp->if_unit, ifp->if_flags, b->flags));
+ DPRINTF(("%s: %s promisc ON if_flags 0x%x bdg_flags 0x%x\n",
+ __func__, ifp->if_xname, ifp->if_flags, b->flags));
}
if (b->flags & IFF_MUTE) {
- DPRINTF(("%s: unmuting %s%d\n", __func__,
- ifp->if_name, ifp->if_unit));
+ DPRINTF(("%s: unmuting %s\n", __func__, ifp->if_xname));
b->flags &= ~IFF_MUTE;
}
}
@@ -522,23 +521,22 @@ parse_bdg_cfg(void)
*/
IFNET_RLOCK(); /* could sleep XXX */
TAILQ_FOREACH(ifp, &ifnet, if_link) {
- char buf[IFNAMSIZ];
- snprintf(buf, sizeof(buf), "%s%d", ifp->if_name, ifp->if_unit);
- if (!strncmp(beg, buf, max(l, strlen(buf)))) {
+ if (!strncmp(beg, ifp->if_xname, max(l, strlen(ifp->if_xname)))) {
struct bdg_softc *b = &ifp2sc[ifp->if_index];
if (ifp->if_type != IFT_ETHER && ifp->if_type != IFT_L2VLAN) {
- printf("%s is not an ethernet, continue\n", buf);
+ printf("%s is not an ethernet, continue\n", ifp->if_xname);
continue;
}
if (b->flags & IFF_USED) {
- printf("%s already used, skipping\n", buf);
+ printf("%s already used, skipping\n", ifp->if_xname);
break;
}
b->cluster = add_cluster(htons(cluster), (struct arpcom *)ifp);
b->flags |= IFF_USED ;
- sprintf(bdg_stats.s[ifp->if_index].name,
- "%s%d:%d", ifp->if_name, ifp->if_unit, cluster);
+ snprintf(bdg_stats.s[ifp->if_index].name,
+ sizeof(bdg_stats.s[ifp->if_index].name),
+ "%s:%d", ifp->if_xname, cluster);
DPRINTF(("%s: found %s next c %d\n", __func__,
bdg_stats.s[ifp->if_index].name, c));
@@ -793,10 +791,9 @@ bridge_in(struct ifnet *ifp, struct ether_header *eh)
* from the old interface.
*/
bt->name = ifp; /* relocate address */
- printf("-- loop (%d) %6D to %s%d from %s%d (%s)\n",
+ printf("-- loop (%d) %6D to %s from %s (%s)\n",
bdg_loops, eh->ether_shost, ".",
- ifp->if_name, ifp->if_unit,
- old->if_name, old->if_unit,
+ ifp->if_xname, old->if_xname,
BDG_MUTED(old) ? "muted":"active");
dropit = 1;
if (!BDG_MUTED(old)) {
@@ -810,8 +807,8 @@ bridge_in(struct ifnet *ifp, struct ether_header *eh)
* now write the source address into the table
*/
if (bt->name == NULL) {
- DPRINTF(("%s: new addr %6D at %d for %s%d\n",
- __func__, eh->ether_shost, ".", index, ifp->if_name, ifp->if_unit));
+ DPRINTF(("%s: new addr %6D at %d for %s\n",
+ __func__, eh->ether_shost, ".", index, ifp->if_xname));
ETHER_ADDR_COPY(bt->etheraddr, eh->ether_shost);
bt->name = ifp;
}
@@ -853,13 +850,12 @@ bridge_in(struct ifnet *ifp, struct ether_header *eh)
if (dst == ifp)
dst = BDG_DROP;
}
- DPRINTF(("%s: %6D ->%6D ty 0x%04x dst %s%d\n", __func__,
+ DPRINTF(("%s: %6D ->%6D ty 0x%04x dst %s\n", __func__,
eh->ether_shost, ".",
eh->ether_dhost, ".",
ntohs(eh->ether_type),
(dst <= BDG_FORWARD) ? bdg_dst_names[(uintptr_t)dst] :
- dst->if_name,
- (dst <= BDG_FORWARD) ? 0 : dst->if_unit));
+ dst->if_xname));
return dst;
}
diff --git a/sys/net/if.c b/sys/net/if.c
index 97ea658..447e4a1 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -325,7 +325,7 @@ if_findindex(struct ifnet *ifp)
eaddr[0] = '\0';
break;
}
- snprintf(devname, 32, "%s%d", ifp->if_name, ifp->if_unit);
+ strlcpy(devname, ifp->if_xname, sizeof(devname));
name = net_cdevsw.d_name;
i = 0;
while ((resource_find_dev(&i, name, &unit, NULL, NULL)) == 0) {
@@ -364,7 +364,6 @@ if_attach(struct ifnet *ifp)
{
unsigned socksize, ifasize;
int namelen, masklen;
- char workbuf[64];
struct sockaddr_dl *sdl;
struct ifaddr *ifa;
@@ -399,18 +398,17 @@ if_attach(struct ifnet *ifp)
ifnet_byindex(ifp->if_index) = ifp;
ifdev_byindex(ifp->if_index) = make_dev(&net_cdevsw, ifp->if_index,
- UID_ROOT, GID_WHEEL, 0600, "%s/%s%d",
- net_cdevsw.d_name, ifp->if_name, ifp->if_unit);
+ UID_ROOT, GID_WHEEL, 0600, "%s/%s",
+ net_cdevsw.d_name, ifp->if_xname);
make_dev_alias(ifdev_byindex(ifp->if_index), "%s%d",
net_cdevsw.d_name, ifp->if_index);
- mtx_init(&ifp->if_snd.ifq_mtx, ifp->if_name, "if send queue", MTX_DEF);
+ mtx_init(&ifp->if_snd.ifq_mtx, ifp->if_xname, "if send queue", MTX_DEF);
/*
* create a Link Level name for this device
*/
- namelen = snprintf(workbuf, sizeof(workbuf),
- "%s%d", ifp->if_name, ifp->if_unit);
+ namelen = strlen(ifp->if_xname);
#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
masklen = _offsetof(struct sockaddr_dl, sdl_data[0]) + namelen;
socksize = masklen + ifp->if_addrlen;
@@ -425,7 +423,7 @@ if_attach(struct ifnet *ifp)
sdl = (struct sockaddr_dl *)(ifa + 1);
sdl->sdl_len = socksize;
sdl->sdl_family = AF_LINK;
- bcopy(workbuf, sdl->sdl_data, namelen);
+ bcopy(ifp->if_xname, sdl->sdl_data, namelen);
sdl->sdl_nlen = namelen;
sdl->sdl_index = ifp->if_index;
sdl->sdl_type = ifp->if_type;
@@ -881,8 +879,7 @@ if_clone_list(struct if_clonereq *ifcr)
for (ifc = LIST_FIRST(&if_cloners); ifc != NULL && count != 0;
ifc = LIST_NEXT(ifc, ifc_list), count--, dst += IFNAMSIZ) {
- strncpy(outbuf, ifc->ifc_name, IFNAMSIZ);
- outbuf[IFNAMSIZ - 1] = '\0'; /* sanity */
+ strlcpy(outbuf, ifc->ifc_name, IFNAMSIZ);
error = copyout(outbuf, dst, IFNAMSIZ);
if (error)
break;
@@ -1643,8 +1640,8 @@ ifpromisc(struct ifnet *ifp, int pswitch)
ifr.ifr_flagshigh = ifp->if_flags >> 16;
error = (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
if (error == 0) {
- log(LOG_INFO, "%s%d: promiscuous mode %s\n",
- ifp->if_name, ifp->if_unit,
+ log(LOG_INFO, "%s: promiscuous mode %s\n",
+ ifp->if_xname,
(ifp->if_flags & IFF_PROMISC) ? "enabled" : "disabled");
rt_ifmsg(ifp);
} else {
@@ -1673,18 +1670,14 @@ ifconf(u_long cmd, caddr_t data)
ifrp = ifc->ifc_req;
IFNET_RLOCK(); /* could sleep XXX */
TAILQ_FOREACH(ifp, &ifnet, if_link) {
- char workbuf[64];
- int ifnlen, addrs;
+ int addrs;
if (space < sizeof(ifr))
break;
- ifnlen = snprintf(workbuf, sizeof(workbuf),
- "%s%d", ifp->if_name, ifp->if_unit);
- if(ifnlen + 1 > sizeof ifr.ifr_name) {
+ if (strlcpy(ifr.ifr_name, ifp->if_xname, sizeof(ifr.ifr_name))
+ >= sizeof(ifr.ifr_name)) {
error = ENAMETOOLONG;
break;
- } else {
- strcpy(ifr.ifr_name, workbuf);
}
addrs = 0;
@@ -2019,13 +2012,30 @@ ifmaof_ifpforaddr(struct sockaddr *sa, struct ifnet *ifp)
return ifma;
}
+/*
+ * The name argument must be a pointer to storage which will last as
+ * long as the interface does. For physical devices, the result of
+ * device_get_name(dev) is a good choice and for pseudo-devices a
+ * static string works well.
+ */
+void
+if_initname(struct ifnet *ifp, const char *name, int unit)
+{
+ ifp->if_dname = name;
+ ifp->if_dunit = unit;
+ if (unit != IF_DUNIT_NONE)
+ snprintf(ifp->if_xname, IFNAMSIZ, "%s%d", name, unit);
+ else
+ strlcpy(ifp->if_xname, name, IFNAMSIZ);
+}
+
int
if_printf(struct ifnet *ifp, const char * fmt, ...)
{
va_list ap;
int retval;
- retval = printf("%s%d: ", ifp->if_name, ifp->if_unit);
+ retval = printf("%s: ", ifp->if_xname);
va_start(ap, fmt);
retval += vprintf(fmt, ap);
va_end(ap);
diff --git a/sys/net/if.h b/sys/net/if.h
index 44531d2..3d21acb 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -62,7 +62,7 @@ struct ifnet;
#define IF_NAMESIZE 16
#if __BSD_VISIBLE
#define IFNAMSIZ IF_NAMESIZE
-#define IF_MAXUNIT 0x7fff /* ifp->if_unit is only 15 bits */
+#define IF_MAXUNIT 0x7fff /* historical value */
#endif
#ifdef _KERNEL
diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c
index a2d8a4d..24c3a86 100644
--- a/sys/net/if_arcsubr.c
+++ b/sys/net/if_arcsubr.c
@@ -474,8 +474,8 @@ outofseq:
if (m)
m_freem(m);
- log(LOG_INFO,"%s%d: got out of seq. packet: %s\n",
- ifp->if_name, ifp->if_unit, s);
+ log(LOG_INFO,"%s: got out of seq. packet: %s\n",
+ ifp->if_xname, s);
return NULL;
}
@@ -648,8 +648,8 @@ arc_ifattach(ifp, lla)
ac->ac_seqid = (time_second) & 0xFFFF; /* try to make seqid unique */
if (lla == 0) {
/* XXX this message isn't entirely clear, to me -- cgd */
- log(LOG_ERR,"%s%d: link address 0 reserved for broadcasts. Please change it and ifconfig %s%d down up\n",
- ifp->if_name, ifp->if_unit, ifp->if_name, ifp->if_unit);
+ log(LOG_ERR,"%s: link address 0 reserved for broadcasts. Please change it and ifconfig %s down up\n",
+ ifp->if_xname, ifp->if_xname);
}
arc_storelladdr(ifp, lla);
diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c
index 02a463f..4c8856e 100644
--- a/sys/net/if_atmsubr.c
+++ b/sys/net/if_atmsubr.c
@@ -181,7 +181,8 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
break;
default:
-#if defined(__NetBSD__) || defined(__OpenBSD__)
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 501113) || \
+ defined(__NetBSD__) || defined(__OpenBSD__)
printf("%s: can't handle af%d\n", ifp->if_xname,
dst->sa_family);
#elif defined(__FreeBSD__) || defined(__bsdi__)
@@ -301,7 +302,8 @@ atm_input(struct ifnet *ifp, struct atm_pseudohdr *ah, struct mbuf *m,
return; /* failed */
alc = mtod(m, struct atmllc *);
if (bcmp(alc, ATMLLC_HDR, 6)) {
-#if defined(__NetBSD__) || defined(__OpenBSD__)
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 501113) || \
+ defined(__NetBSD__) || defined(__OpenBSD__)
printf("%s: recv'd invalid LLC/SNAP frame "
"[vp=%d,vc=%d]\n", ifp->if_xname,
ATM_PH_VPI(ah), ATM_PH_VCI(ah));
diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c
index a392d5f..48935b3 100644
--- a/sys/net/if_disc.c
+++ b/sys/net/if_disc.c
@@ -93,8 +93,7 @@ disc_clone_create(struct if_clone *ifc, int unit)
ifp = &sc->sc_if;
ifp->if_softc = sc;
- ifp->if_name = DISCNAME;
- ifp->if_unit = unit;
+ if_initname(ifp, ifc->ifc_name, unit);
ifp->if_mtu = DSMTU;
ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
ifp->if_ioctl = discioctl;
diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c
index cb7bc64..8b5aee0 100644
--- a/sys/net/if_ef.c
+++ b/sys/net/if_ef.c
@@ -79,6 +79,7 @@
struct efnet {
struct arpcom ef_ac;
struct ifnet * ef_ifp;
+ int ef_frametype;
};
struct ef_link {
@@ -138,7 +139,7 @@ ef_attach(struct efnet *sc)
bcopy(LLADDR(sdl2), sc->ef_ac.ac_enaddr, ETHER_ADDR_LEN);
- EFDEBUG("%s%d: attached\n", ifp->if_name, ifp->if_unit);
+ EFDEBUG("%s: attached\n", ifp->if_xname);
return 1;
}
@@ -178,11 +179,11 @@ ef_init(void *foo) {
static int
ef_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
-/* struct ef_link *sc = (struct ef_link*)ifp->if_softc;*/
+ struct efnet *sc = ifp->if_softc;
struct ifaddr *ifa = (struct ifaddr*)data;
int s, error;
- EFDEBUG("IOCTL %ld for %s%d\n", cmd, ifp->if_name, ifp->if_unit);
+ EFDEBUG("IOCTL %ld for %s\n", cmd, ifp->if_xname);
error = 0;
s = splimp();
switch (cmd) {
@@ -190,7 +191,7 @@ ef_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
error = 0;
break;
case SIOCSIFADDR:
- if (ifp->if_unit == ETHER_FT_8023 &&
+ if (sc->ef_frametype == ETHER_FT_8023 &&
ifa->ifa_addr->sa_family != AF_IPX) {
error = EAFNOSUPPORT;
break;
@@ -406,13 +407,14 @@ static int
ef_output(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst, short *tp,
int *hlen)
{
+ struct efnet *sc = (struct efnet*)ifp->if_softc;
struct mbuf *m = *mp;
u_char *cp;
short type;
if (ifp->if_type != IFT_XETHER)
return ENETDOWN;
- switch (ifp->if_unit) {
+ switch (sc->ef_frametype) {
case ETHER_FT_EII:
#ifdef IPX
type = htons(ETHERTYPE_IPX);
@@ -474,20 +476,18 @@ ef_clone(struct ef_link *efl, int ft)
struct efnet *efp;
struct ifnet *eifp;
struct ifnet *ifp = efl->el_ifp;
- char cbuf[IFNAMSIZ], *ifname;
- int ifnlen;
efp = (struct efnet*)malloc(sizeof(struct efnet), M_IFADDR,
M_WAITOK | M_ZERO);
if (efp == NULL)
return ENOMEM;
efp->ef_ifp = ifp;
+ efp->ef_frametype = ft;
eifp = &efp->ef_ac.ac_if;
- ifnlen = 1 + snprintf(cbuf, sizeof(cbuf), "%s%df", ifp->if_name,
- ifp->if_unit);
- ifname = (char*)malloc(ifnlen, M_IFADDR, M_WAITOK);
- eifp->if_name = strcpy(ifname, cbuf);
- eifp->if_unit = ft;
+ snprintf(eifp->if_xname, IFNAMSIZ,
+ "%sf%d", ifp->if_xname, efp->ef_frametype);
+ eifp->if_dname = "ef";
+ eifp->if_dunit = IF_DUNIT_NONE;
eifp->if_softc = efp;
if (ifp->if_ioctl)
eifp->if_ioctl = ef_ioctl;
@@ -506,7 +506,7 @@ ef_load(void)
IFNET_RLOCK();
TAILQ_FOREACH(ifp, &ifnet, if_link) {
if (ifp->if_type != IFT_ETHER) continue;
- EFDEBUG("Found interface %s%d\n", ifp->if_name, ifp->if_unit);
+ EFDEBUG("Found interface %s\n", ifp->if_xname);
efl = (struct ef_link*)malloc(sizeof(struct ef_link),
M_IFADDR, M_WAITOK | M_ZERO);
if (efl == NULL) {
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 4e0e5cb..8ceb8e3 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -503,9 +503,8 @@ ether_input(struct ifnet *ifp, struct mbuf *m)
}
#ifdef DIAGNOSTIC
if (m->m_pkthdr.rcvif != ifp) {
- if_printf(ifp, "Warning, frame marked as received on %s%u\n",
- m->m_pkthdr.rcvif->if_name,
- m->m_pkthdr.rcvif->if_unit);
+ if_printf(ifp, "Warning, frame marked as received on %s\n",
+ m->m_pkthdr.rcvif->if_xname);
}
#endif
diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c
index 8a9cb7c..07216b5 100644
--- a/sys/net/if_faith.c
+++ b/sys/net/if_faith.c
@@ -163,8 +163,7 @@ faith_clone_create(ifc, unit)
bzero(sc, sizeof(struct faith_softc));
sc->sc_if.if_softc = sc;
- sc->sc_if.if_name = FAITHNAME;
- sc->sc_if.if_unit = unit;
+ if_initname(&sc->sc_if, ifc->ifc_name, unit);
sc->sc_if.if_mtu = FAITHMTU;
/* Change to BROADCAST experimentaly to announce its prefix. */
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index ae761e8..d77a5a5 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -141,8 +141,7 @@ gif_clone_create(ifc, unit)
bzero(sc, sizeof(struct gif_softc));
sc->gif_if.if_softc = sc;
- sc->gif_if.if_name = GIFNAME;
- sc->gif_if.if_unit = unit;
+ if_initname(&sc->gif_if, ifc->ifc_name, unit);
gifattach0(sc);
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index bc8f1f7..3541410 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -162,9 +162,8 @@ gre_clone_create(ifc, unit)
sc = malloc(sizeof(struct gre_softc), M_GRE, M_WAITOK);
memset(sc, 0, sizeof(struct gre_softc));
- sc->sc_if.if_name = GRENAME;
+ if_initname(&sc->sc_if, ifc->ifc_name, unit);
sc->sc_if.if_softc = sc;
- sc->sc_if.if_unit = unit;
sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
sc->sc_if.if_type = IFT_OTHER;
sc->sc_if.if_addrlen = 0;
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index b0ec6ea..357862d 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -144,8 +144,7 @@ lo_clone_create(ifc, unit)
MALLOC(sc, struct lo_softc *, sizeof(*sc), M_LO, M_WAITOK | M_ZERO);
- sc->sc_if.if_name = LONAME;
- sc->sc_if.if_unit = unit;
+ if_initname(&sc->sc_if, ifc->ifc_name, unit);
sc->sc_if.if_mtu = LOMTU;
sc->sc_if.if_flags = IFF_LOOPBACK | IFF_MULTICAST;
sc->sc_if.if_ioctl = loioctl;
diff --git a/sys/net/if_media.c b/sys/net/if_media.c
index a584419..5351157 100644
--- a/sys/net/if_media.c
+++ b/sys/net/if_media.c
@@ -246,8 +246,8 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
*/
#ifdef IFMEDIA_DEBUG
if (ifmedia_debug) {
- printf("ifmedia_ioctl: switching %s%d to ",
- ifp->if_name, ifp->if_unit);
+ printf("ifmedia_ioctl: switching %s to ",
+ ifp->if_xname);
ifmedia_printword(match->ifm_media);
}
#endif
diff --git a/sys/net/if_mib.c b/sys/net/if_mib.c
index b8e7ed6..f104b77 100644
--- a/sys/net/if_mib.c
+++ b/sys/net/if_mib.c
@@ -71,10 +71,9 @@ static int
sysctl_ifdata(SYSCTL_HANDLER_ARGS) /* XXX bad syntax! */
{
int *name = (int *)arg1;
- int error, ifnlen;
+ int error;
u_int namelen = arg2;
struct ifnet *ifp;
- char workbuf[64];
struct ifmibdata ifmd;
if (namelen != 2)
@@ -91,13 +90,7 @@ sysctl_ifdata(SYSCTL_HANDLER_ARGS) /* XXX bad syntax! */
return ENOENT;
case IFDATA_GENERAL:
- ifnlen = snprintf(workbuf, sizeof(workbuf),
- "%s%d", ifp->if_name, ifp->if_unit);
- if(ifnlen + 1 > sizeof ifmd.ifmd_name) {
- return ENAMETOOLONG;
- } else {
- strcpy(ifmd.ifmd_name, workbuf);
- }
+ strlcpy(ifmd.ifmd_name, ifp->if_xname, sizeof(ifmd.ifmd_name));
#define COPY(fld) ifmd.ifmd_##fld = ifp->if_##fld
COPY(pcount);
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index b3dfccb..9480d92 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -201,8 +201,7 @@ ppp_clone_create(struct if_clone *ifc, int unit)
sc = malloc(sizeof(struct ppp_softc), M_PPP, M_WAITOK | M_ZERO);
sc->sc_if.if_softc = sc;
- sc->sc_if.if_name = PPPNAME;
- sc->sc_if.if_unit = unit;
+ if_initname(&sc->sc_if, ifc->ifc_name, unit);
sc->sc_if.if_mtu = PPP_MTU;
sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
sc->sc_if.if_type = IFT_PPP;
@@ -414,7 +413,7 @@ pppioctl(sc, cmd, data, flag, td)
break;
case PPPIOCGUNIT:
- *(int *)data = sc->sc_if.if_unit;
+ *(int *)data = sc->sc_if.if_dunit;
break;
case PPPIOCGFLAGS:
@@ -850,7 +849,7 @@ pppoutput(ifp, m0, dst, rtp)
len = m_length(m0, NULL);
if (sc->sc_flags & SC_LOG_OUTPKT) {
- printf("ppp%d output: ", ifp->if_unit);
+ printf("%s output: ", ifp->if_xname);
pppdumpm(m0);
}
@@ -1214,7 +1213,7 @@ ppp_ccp(sc, m, rcvd)
if (sc->sc_xc_state != NULL
&& (*sc->sc_xcomp->comp_init)
(sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
- sc->sc_if.if_unit, 0, sc->sc_flags & SC_DEBUG)) {
+ sc->sc_if.if_dunit, 0, sc->sc_flags & SC_DEBUG)) {
s = splimp();
sc->sc_flags |= SC_COMP_RUN;
splx(s);
@@ -1224,7 +1223,7 @@ ppp_ccp(sc, m, rcvd)
if (sc->sc_rc_state != NULL
&& (*sc->sc_rcomp->decomp_init)
(sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
- sc->sc_if.if_unit, 0, sc->sc_mru,
+ sc->sc_if.if_dunit, 0, sc->sc_mru,
sc->sc_flags & SC_DEBUG)) {
s = splimp();
sc->sc_flags |= SC_DECOMP_RUN;
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 1d3fa0b..39fce74 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -288,7 +288,6 @@ slcreate()
sl_compress_init(&sc->sc_comp, -1);
sc->sc_if.if_softc = sc;
- sc->sc_if.if_name = "sl";
sc->sc_if.if_mtu = SLMTU;
sc->sc_if.if_flags =
#ifdef SLIP_IFF_OPTS
@@ -312,12 +311,12 @@ slcreate()
if (slisstatic(unit))
continue;
LIST_FOREACH(nc, &sl_list, sl_next) {
- if (nc->sc_if.if_unit == unit)
+ if (nc->sc_if.if_dunit == unit)
continue;
}
break;
}
- sc->sc_if.if_unit = unit;
+ if_initname(&sc->sc_if, "sl", unit);
LIST_INSERT_HEAD(&sl_list, sc, sl_next);
if_attach(&sc->sc_if);
@@ -450,7 +449,7 @@ sltioctl(tp, cmd, data, flag, td)
s = splimp();
switch (cmd) {
case SLIOCGUNIT:
- *(int *)data = sc->sc_if.if_unit;
+ *(int *)data = sc->sc_if.if_dunit;
break;
case SLIOCSUNIT:
@@ -459,9 +458,9 @@ sltioctl(tp, cmd, data, flag, td)
splx(s);
return (ENXIO);
}
- if (sc->sc_if.if_unit != unit) {
+ if (sc->sc_if.if_dunit != unit) {
LIST_FOREACH(nc, &sl_list, sl_next) {
- if (nc->sc_if.if_unit == *(u_int *)data) {
+ if (nc->sc_if.if_dunit == *(u_int *)data) {
splx(s);
return (ENXIO);
}
@@ -471,7 +470,7 @@ sltioctl(tp, cmd, data, flag, td)
bpfdetach(&sc->sc_if);
if_detach(&sc->sc_if);
LIST_REMOVE(sc, sl_next);
- sc->sc_if.if_unit = unit;
+ if_initname(&sc->sc_if, "sl", unit);
LIST_INSERT_HEAD(&sl_list, sc, sl_next);
if_attach(&sc->sc_if);
bpfattach(&sc->sc_if, DLT_SLIP, SLIP_HDRLEN);
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index c21d922..27e7638 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -264,7 +264,7 @@ static struct sppp *spppq;
static struct callout_handle keepalive_ch;
#endif
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if defined(__FreeBSD__) && __FreeBSD__ >= 3 && __FreeBSD_version < 501113
#define SPP_FMT "%s%d: "
#define SPP_ARGS(ifp) (ifp)->if_name, (ifp)->if_unit
#else
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index 93fa212..76b92ec 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -180,8 +180,7 @@ stf_clone_create(ifc, unit)
struct stf_softc *sc;
sc = malloc(sizeof(struct stf_softc), M_STF, M_WAITOK | M_ZERO);
- sc->sc_if.if_name = STFNAME;
- sc->sc_if.if_unit = unit;
+ if_initname(&sc->sc_if, ifc->ifc_name, unit);
sc->encap_cookie = encap_attach_func(AF_INET, IPPROTO_IPV6,
stf_encapcheck, &in_stf_protosw, sc);
diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c
index 3ac2be8..80d54e6 100644
--- a/sys/net/if_tap.c
+++ b/sys/net/if_tap.c
@@ -199,11 +199,10 @@ bail:
ifp = &tp->tap_if;
- TAPDEBUG("detaching %s%d\n", ifp->if_name,ifp->if_unit);
+ TAPDEBUG("detaching %s\n", ifp->if_xname);
- KASSERT(!(tp->tap_flags & TAP_OPEN),
- ("%s%d flags is out of sync", ifp->if_name,
- ifp->if_unit));
+ KASSERT(!(tp->tap_flags & TAP_OPEN),
+ ("%s flags is out of sync", ifp->if_xname));
/* XXX makedev check? nah.. not right now :) */
@@ -346,8 +345,7 @@ tapcreate(dev)
/* fill the rest and attach interface */
ifp = &tp->tap_if;
ifp->if_softc = tp;
- ifp->if_unit = unit;
- ifp->if_name = name;
+ if_initname(ifp, name, unit);
ifp->if_init = tapifinit;
ifp->if_start = tapifstart;
ifp->if_ioctl = tapifioctl;
@@ -363,8 +361,8 @@ tapcreate(dev)
tp->tap_flags |= TAP_INITED;
- TAPDEBUG("interface %s%d is created. minor = %#x\n",
- ifp->if_name, ifp->if_unit, minor(dev));
+ TAPDEBUG("interface %s is created. minor = %#x\n",
+ ifp->if_xname, minor(dev));
} /* tapcreate */
@@ -407,8 +405,8 @@ tapopen(dev, flag, mode, td)
tp = dev->si_drv1;
}
- KASSERT(!(tp->tap_flags & TAP_OPEN),
- ("%s%d flags is out of sync", tp->tap_if.if_name, unit));
+ KASSERT(!(tp->tap_flags & TAP_OPEN),
+ ("%s flags is out of sync", tp->tap_if.if_xname));
bcopy(tp->arpcom.ac_enaddr, tp->ether_addr, sizeof(tp->ether_addr));
@@ -416,8 +414,8 @@ tapopen(dev, flag, mode, td)
tp->tap_pid = td->td_proc->p_pid;
tp->tap_flags |= TAP_OPEN;
- TAPDEBUG("%s%d is open. minor = %#x\n",
- tp->tap_if.if_name, unit, minor(dev));
+ TAPDEBUG("%s is open. minor = %#x\n",
+ tp->tap_if.if_xname, minor(dev));
return (0);
} /* tapopen */
@@ -440,7 +438,7 @@ tapclose(dev, foo, bar, td)
struct ifnet *ifp = &tp->tap_if;
KASSERT((tp->tap_unit != NULL),
- ("%s%d is not open", ifp->if_name, ifp->if_unit));
+ ("%s is not open", ifp->if_xname));
/* junk all pending output */
IF_DRAIN(&ifp->if_snd);
@@ -482,12 +480,12 @@ tapclose(dev, foo, bar, td)
tp->tap_flags &= ~TAP_OPEN;
tp->tap_pid = 0;
error = rman_release_resource(tp->tap_unit);
- KASSERT((error == 0),
- ("%s%d could not release unit", ifp->if_name, ifp->if_unit));
+ KASSERT((error == 0),
+ ("%s could not release unit", ifp->if_xname));
tp->tap_unit = NULL;
- TAPDEBUG("%s%d is closed. minor = %#x\n",
- ifp->if_name, ifp->if_unit, minor(dev));
+ TAPDEBUG("%s is closed. minor = %#x\n",
+ ifp->if_xname, minor(dev));
return (0);
} /* tapclose */
@@ -505,7 +503,7 @@ tapifinit(xtp)
struct tap_softc *tp = (struct tap_softc *)xtp;
struct ifnet *ifp = &tp->tap_if;
- TAPDEBUG("initializing %s%d\n", ifp->if_name, ifp->if_unit);
+ TAPDEBUG("initializing %s\n", ifp->if_xname);
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
@@ -570,7 +568,7 @@ tapifstart(ifp)
struct tap_softc *tp = ifp->if_softc;
int s;
- TAPDEBUG("%s%d starting\n", ifp->if_name, ifp->if_unit);
+ TAPDEBUG("%s starting\n", ifp->if_xname);
/*
* do not junk pending output if we are in VMnet mode.
@@ -581,8 +579,8 @@ tapifstart(ifp)
((tp->tap_flags & TAP_READY) != TAP_READY)) {
struct mbuf *m = NULL;
- TAPDEBUG("%s%d not ready, tap_flags = 0x%x\n", ifp->if_name,
- ifp->if_unit, tp->tap_flags);
+ TAPDEBUG("%s not ready, tap_flags = 0x%x\n", ifp->if_xname,
+ tp->tap_flags);
s = splimp();
do {
@@ -751,12 +749,11 @@ tapread(dev, uio, flag)
struct mbuf *m = NULL;
int error = 0, len, s;
- TAPDEBUG("%s%d reading, minor = %#x\n",
- ifp->if_name, ifp->if_unit, minor(dev));
+ TAPDEBUG("%s reading, minor = %#x\n", ifp->if_xname, minor(dev));
if ((tp->tap_flags & TAP_READY) != TAP_READY) {
- TAPDEBUG("%s%d not ready. minor = %#x, tap_flags = 0x%x\n",
- ifp->if_name, ifp->if_unit, minor(dev), tp->tap_flags);
+ TAPDEBUG("%s not ready. minor = %#x, tap_flags = 0x%x\n",
+ ifp->if_xname, minor(dev), tp->tap_flags);
return (EHOSTDOWN);
}
@@ -794,8 +791,8 @@ tapread(dev, uio, flag)
}
if (m != NULL) {
- TAPDEBUG("%s%d dropping mbuf, minor = %#x\n", ifp->if_name,
- ifp->if_unit, minor(dev));
+ TAPDEBUG("%s dropping mbuf, minor = %#x\n", ifp->if_xname,
+ minor(dev));
m_freem(m);
}
@@ -819,15 +816,15 @@ tapwrite(dev, uio, flag)
struct mbuf *top = NULL, **mp = NULL, *m = NULL;
int error = 0, tlen, mlen;
- TAPDEBUG("%s%d writting, minor = %#x\n",
- ifp->if_name, ifp->if_unit, minor(dev));
+ TAPDEBUG("%s writting, minor = %#x\n",
+ ifp->if_xname, minor(dev));
if (uio->uio_resid == 0)
return (0);
if ((uio->uio_resid < 0) || (uio->uio_resid > TAPMRU)) {
- TAPDEBUG("%s%d invalid packet len = %d, minor = %#x\n",
- ifp->if_name, ifp->if_unit, uio->uio_resid, minor(dev));
+ TAPDEBUG("%s invalid packet len = %d, minor = %#x\n",
+ ifp->if_xname, uio->uio_resid, minor(dev));
return (EIO);
}
@@ -890,20 +887,20 @@ tappoll(dev, events, td)
struct ifnet *ifp = &tp->tap_if;
int s, revents = 0;
- TAPDEBUG("%s%d polling, minor = %#x\n",
- ifp->if_name, ifp->if_unit, minor(dev));
+ TAPDEBUG("%s polling, minor = %#x\n",
+ ifp->if_xname, minor(dev));
s = splimp();
if (events & (POLLIN | POLLRDNORM)) {
if (ifp->if_snd.ifq_len > 0) {
- TAPDEBUG("%s%d have data in queue. len = %d, " \
- "minor = %#x\n", ifp->if_name, ifp->if_unit,
+ TAPDEBUG("%s have data in queue. len = %d, " \
+ "minor = %#x\n", ifp->if_xname,
ifp->if_snd.ifq_len, minor(dev));
revents |= (events & (POLLIN | POLLRDNORM));
} else {
- TAPDEBUG("%s%d waiting for data, minor = %#x\n",
- ifp->if_name, ifp->if_unit, minor(dev));
+ TAPDEBUG("%s waiting for data, minor = %#x\n",
+ ifp->if_xname, minor(dev));
selrecord(td, &tp->tap_rsel);
}
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 9e1e180..b46cef6 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -170,10 +170,10 @@ tunmodevent(module_t mod, int type, void *data)
while (tunhead != NULL) {
KASSERT((tunhead->tun_flags & TUN_OPEN) == 0,
("tununits is out of sync - unit %d",
- tunhead->tun_if.if_unit));
+ tunhead->tun_if.if_dunit));
tp = tunhead;
dev = makedev(tun_cdevsw.d_maj,
- unit2minor(tp->tun_if.if_unit));
+ unit2minor(tp->tun_if.if_dunit));
KASSERT(dev->si_drv1 == tp, ("Bad makedev result"));
tunhead = tp->next;
bpfdetach(&tp->tun_if);
@@ -232,8 +232,7 @@ tuncreate(dev_t dev)
tunhead = sc;
ifp = &sc->tun_if;
- ifp->if_unit = dev2unit(dev);
- ifp->if_name = TUNNAME;
+ if_initname(ifp, TUNNAME, dev2unit(dev));
ifp->if_mtu = TUNMTU;
ifp->if_ioctl = tunifioctl;
ifp->if_output = tunoutput;
@@ -296,7 +295,7 @@ tunclose(dev_t dev, int foo, int bar, struct thread *td)
tp = dev->si_drv1;
ifp = &tp->tun_if;
- KASSERT(tp->tun_unit, ("Unit %d not marked open", ifp->if_unit));
+ KASSERT(tp->tun_unit, ("Unit %d not marked open", tp->tun_if.if_dunit));
tp->tun_flags &= ~TUN_OPEN;
tp->tun_pid = 0;
@@ -329,7 +328,7 @@ tunclose(dev_t dev, int foo, int bar, struct thread *td)
TUNDEBUG (ifp, "closed\n");
err = rman_release_resource(tp->tun_unit);
- KASSERT(err == 0, ("Unit %d failed to release", ifp->if_unit));
+ KASSERT(err == 0, ("Unit %d failed to release", tp->tun_if.if_dunit));
return (0);
}
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index b97a48d..52cee55 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -84,6 +84,8 @@ struct ether_header;
#include <sys/mutex.h> /* XXX */
#include <sys/event.h> /* XXX */
+#define IF_DUNIT_NONE -1
+
TAILQ_HEAD(ifnethead, ifnet); /* we use TAILQs so that the order of */
TAILQ_HEAD(ifaddrhead, ifaddr); /* instantiation is preserved in the list */
TAILQ_HEAD(ifprefixhead, ifprefix);
@@ -128,14 +130,15 @@ struct ifqueue {
*/
struct ifnet {
void *if_softc; /* pointer to driver state */
- char *if_name; /* name, e.g. ``en'' or ``lo'' */
TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */
+ char if_xname[IFNAMSIZ]; /* external name (name + unit) */
+ const char *if_dname; /* driver name */
+ int if_dunit; /* unit or IF_DUNIT_NONE */
struct ifaddrhead if_addrhead; /* linked list of addresses per if */
struct klist if_klist; /* events attached to this if */
int if_pcount; /* number of promiscuous listeners */
struct bpf_if *if_bpf; /* packet filter structure */
u_short if_index; /* numeric abbreviation for this if */
- short if_unit; /* sub-unit for lower level driver */
short if_timer; /* time 'til if_watchdog called */
u_short if_nvlans; /* number of active vlans */
int if_flags; /* up/down, broadcast, etc. */
@@ -451,6 +454,7 @@ void if_attach(struct ifnet *);
int if_delmulti(struct ifnet *, struct sockaddr *);
void if_detach(struct ifnet *);
void if_down(struct ifnet *);
+void if_initname(struct ifnet *, const char *, int);
int if_printf(struct ifnet *, const char *, ...) __printflike(2, 3);
void if_route(struct ifnet *, int flag, int fam);
int if_setlladdr(struct ifnet *, const u_char *, int);
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index c2e7402..75f25ed 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -250,8 +250,7 @@ vlan_clone_create(struct if_clone *ifc, int unit)
SLIST_INIT(&ifv->vlan_mc_listhead);
ifp->if_softc = ifv;
- ifp->if_name = VLANNAME;
- ifp->if_unit = unit;
+ if_initname(ifp, ifc->ifc_name, unit);
/* NB: flags are not set here */
ifp->if_linkmib = &ifv->ifv_mib;
ifp->if_linkmiblen = sizeof ifv->ifv_mib;
@@ -787,8 +786,8 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
bzero(&vlr, sizeof vlr);
VLAN_LOCK();
if (ifv->ifv_p) {
- snprintf(vlr.vlr_parent, sizeof(vlr.vlr_parent),
- "%s%d", ifv->ifv_p->if_name, ifv->ifv_p->if_unit);
+ strlcpy(vlr.vlr_parent, ifv->ifv_p->if_xname,
+ sizeof(vlr.vlr_parent));
vlr.vlr_tag = ifv->ifv_tag;
}
VLAN_UNLOCK();
diff --git a/sys/net/net_osdep.c b/sys/net/net_osdep.c
index 7cfb142..90601e2 100644
--- a/sys/net/net_osdep.c
+++ b/sys/net/net_osdep.c
@@ -53,15 +53,5 @@ const char *
if_name(ifp)
struct ifnet *ifp;
{
-#define MAXNUMBUF 8
- static char nam[MAXNUMBUF][IFNAMSIZ + 10]; /*enough?*/
- static int ifbufround = 0;
- char *cp;
-
- ifbufround = (ifbufround + 1) % MAXNUMBUF;
- cp = nam[ifbufround];
-
- snprintf(cp, IFNAMSIZ + 10, "%s%d", ifp->if_name, ifp->if_unit);
- return ((const char *)cp);
-#undef MAXNUMBUF
+ return ifp->if_xname;
}
diff --git a/sys/net/net_osdep.h b/sys/net/net_osdep.h
index 01a7199..3893496 100644
--- a/sys/net/net_osdep.h
+++ b/sys/net/net_osdep.h
@@ -116,6 +116,8 @@
* --- --- ---
* FreeBSD 2 no old standard if_name+unit
* FreeBSD 3 yes strange if_name+unit
+ * FreeBSD 4 yes strange if_name+unit
+ * FreeBSD 5 yes strange if_xname
* OpenBSD yes standard if_xname
* NetBSD yes standard if_xname
* BSDI [34] no old standard if_name+unit
diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c
index f50c4d6..135ddeb 100644
--- a/sys/net/ppp_tty.c
+++ b/sys/net/ppp_tty.c
@@ -1092,7 +1092,7 @@ ppplogchar(sc, c)
sc->sc_rawin[sc->sc_rawin_count++] = c;
if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
|| (c < 0 && sc->sc_rawin_count > 0)) {
- printf("ppp%d input: %*D", sc->sc_if.if_unit,
+ printf("%s input: %*D", sc->sc_if.if_xname,
sc->sc_rawin_count, sc->sc_rawin, " ");
sc->sc_rawin_count = 0;
}
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 201e4a9..484bfe8 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -898,8 +898,7 @@ rt_ifannouncemsg(struct ifnet *ifp, int what)
return;
ifan = mtod(m, struct if_announcemsghdr *);
ifan->ifan_index = ifp->if_index;
- snprintf(ifan->ifan_name, sizeof(ifan->ifan_name),
- "%s%d", ifp->if_name, ifp->if_unit);
+ strlcpy(ifan->ifan_name, ifp->if_xname, sizeof(ifan->ifan_name));
ifan->ifan_what = what;
rt_dispatch(m, NULL);
}
diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c
index 6ef241a..9c902ed 100644
--- a/sys/net80211/ieee80211_node.c
+++ b/sys/net80211/ieee80211_node.c
@@ -86,7 +86,7 @@ ieee80211_node_attach(struct ifnet *ifp)
struct ieee80211com *ic = (void *)ifp;
/* XXX need unit */
- IEEE80211_NODE_LOCK_INIT(ic, ifp->if_name);
+ IEEE80211_NODE_LOCK_INIT(ic, ifp->if_xname);
TAILQ_INIT(&ic->ic_node);
ic->ic_node_alloc = ieee80211_node_alloc;
ic->ic_node_free = ieee80211_node_free;
diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c
index 143f135..a2b0295 100644
--- a/sys/net80211/ieee80211_proto.c
+++ b/sys/net80211/ieee80211_proto.c
@@ -103,7 +103,7 @@ ieee80211_proto_attach(struct ifnet *ifp)
ic->ic_fragthreshold = 2346; /* XXX not used yet */
ic->ic_fixed_rate = -1; /* no fixed rate */
- mtx_init(&ic->ic_mgtq.ifq_mtx, ifp->if_name, "mgmt send q", MTX_DEF);
+ mtx_init(&ic->ic_mgtq.ifq_mtx, ifp->if_xname, "mgmt send q", MTX_DEF);
/* protocol state change handler */
ic->ic_newstate = ieee80211_newstate;
diff --git a/sys/netatalk/ddp_output.c b/sys/netatalk/ddp_output.c
index 5f7874d..b46551d 100644
--- a/sys/netatalk/ddp_output.c
+++ b/sys/netatalk/ddp_output.c
@@ -171,8 +171,8 @@ ddp_route( struct mbuf *m, struct route *ro)
if ( aa == NULL ) {
#ifdef NETATALK_DEBUG
- printf( "ddp_route: no atalk address found for %s%d\n",
- ifp->if_name, ifp->if_unit);
+ printf( "ddp_route: no atalk address found for %s\n",
+ ifp->if_xname);
#endif
m_freem( m );
return( ENETUNREACH );
@@ -220,14 +220,14 @@ ddp_route( struct mbuf *m, struct route *ro)
ro->ro_rt->rt_use++;
#ifdef NETATALK_DEBUG
- printf ("ddp_route: from %d.%d to %d.%d, via %d.%d (%s%d)\n",
+ printf ("ddp_route: from %d.%d to %d.%d, via %d.%d (%s)\n",
ntohs(satosat(&aa->aa_addr)->sat_addr.s_net),
satosat(&aa->aa_addr)->sat_addr.s_node,
ntohs(satosat(&ro->ro_dst)->sat_addr.s_net),
satosat(&ro->ro_dst)->sat_addr.s_node,
ntohs(gate.sat_addr.s_net),
gate.sat_addr.s_node,
- ifp->if_name, ifp->if_unit);
+ ifp->if_xname);
#endif
/* short-circuit the output if we're sending this to ourself */
diff --git a/sys/netatm/atm_if.c b/sys/netatm/atm_if.c
index ea2d2ce..81edae1 100644
--- a/sys/netatm/atm_if.c
+++ b/sys/netatm/atm_if.c
@@ -96,7 +96,7 @@ static int (*atm_ifouttbl[AF_MAX+1])
int
atm_physif_register(cup, name, sdp)
Cmn_unit *cup;
- char *name;
+ const char *name;
struct stack_defn *sdp;
{
struct atm_pif *pip;
@@ -341,7 +341,7 @@ atm_physif_ioctl(code, data, arg)
"%s%d", pip->pif_name, pip->pif_unit );
if ( pip->pif_nif )
{
- strcpy(apr.anp_nif_pref, pip->pif_nif->nif_if.if_name);
+ strcpy(apr.anp_nif_pref, pip->pif_nif->nif_if.if_dname);
nip = pip->pif_nif;
while ( nip ) {
@@ -392,7 +392,7 @@ atm_physif_ioctl(code, data, arg)
*/
bzero((caddr_t)&anr, sizeof(anr));
(void) snprintf(anr.anp_intf, sizeof(anr.anp_intf),
- "%s%d", ifp->if_name, ifp->if_unit);
+ "%s%d", ifp->if_dname, ifp->if_dunit);
IFP_TO_IA(ifp, ia);
if (ia) {
anr.anp_proto_addr = *ia->ia_ifa.ifa_addr;
@@ -508,8 +508,7 @@ atm_physif_ioctl(code, data, arg)
strcpy ( nip->nif_name, asr->asr_nif_pref );
nip->nif_sel = count;
- ifp->if_name = nip->nif_name;
- ifp->if_unit = count;
+ if_initname(ifp, nip->nif_name, count);
ifp->if_mtu = ATM_NIF_MTU;
ifp->if_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING;
ifp->if_output = atm_ifoutput;
@@ -1128,8 +1127,8 @@ atm_nifname(name)
*/
for (nip = pip->pif_nif; nip; nip = nip->nif_pnext) {
struct ifnet *ifp = (struct ifnet *)nip;
- if ((ifp->if_unit == unit) &&
- (strcmp(ifp->if_name, n) == 0))
+ if ((ifp->if_dunit == unit) &&
+ (strcmp(ifp->if_dname, n) == 0))
return (nip);
}
}
diff --git a/sys/netatm/atm_if.h b/sys/netatm/atm_if.h
index d1ea8e1..73c40d2 100644
--- a/sys/netatm/atm_if.h
+++ b/sys/netatm/atm_if.h
@@ -180,7 +180,7 @@ typedef struct atm_config Atm_config;
*/
struct atm_pif {
struct atm_pif *pif_next; /* Next registered atm interface */
- char *pif_name; /* Device name */
+ const char *pif_name; /* Device name */
short pif_unit; /* Device unit number */
u_char pif_flags; /* Interface flags (see below) */
struct sigmgr *pif_sigmgr; /* Signalling Manager for interface */
diff --git a/sys/netatm/atm_socket.c b/sys/netatm/atm_socket.c
index c0f5435..1c98961 100644
--- a/sys/netatm/atm_socket.c
+++ b/sys/netatm/atm_socket.c
@@ -1218,7 +1218,7 @@ atm_sock_getopt(so, sopt, atp)
ifp = &ap->nif->nif_if;
(void) snprintf(netif.net_intf, sizeof(netif.net_intf),
- "%s%d", ifp->if_name, ifp->if_unit);
+ "%s", ifp->if_xname);
return (sooptcopyout(sopt, &netif,
sizeof netif));
} else {
diff --git a/sys/netatm/atm_usrreq.c b/sys/netatm/atm_usrreq.c
index ffb9a94..4cc78b7 100644
--- a/sys/netatm/atm_usrreq.c
+++ b/sys/netatm/atm_usrreq.c
@@ -390,7 +390,7 @@ atm_dgram_control(so, cmd, data, ifp, td)
*/
IFNET_RLOCK();
TAILQ_FOREACH(ifp2, &ifnet, if_link) {
- if (!strcmp(ifp2->if_name, asp->asr_nif_pref)) {
+ if (!strcmp(ifp2->if_dname, asp->asr_nif_pref)) {
/*
* If this is for the interface we're
* (re-)defining, let it through
diff --git a/sys/netatm/atm_var.h b/sys/netatm/atm_var.h
index 6085275..141a737 100644
--- a/sys/netatm/atm_var.h
+++ b/sys/netatm/atm_var.h
@@ -113,7 +113,7 @@ void atm_dev_pdu_print(const Cmn_unit *, const Cmn_vcc *,
const KBuffer *, const char *);
/* atm_if.c */
-int atm_physif_register(Cmn_unit *, char *,
+int atm_physif_register(Cmn_unit *, const char *,
struct stack_defn *);
int atm_physif_deregister(Cmn_unit *);
void atm_physif_freenifs(struct atm_pif *, uma_zone_t);
diff --git a/sys/netatm/ipatm/ipatm_usrreq.c b/sys/netatm/ipatm/ipatm_usrreq.c
index b22c2b6..99d1575 100644
--- a/sys/netatm/ipatm/ipatm_usrreq.c
+++ b/sys/netatm/ipatm/ipatm_usrreq.c
@@ -446,10 +446,9 @@ ipatm_ioctl(code, data, arg1)
AF_INET;
SATOSIN(&aivr.aip_dst_addr)->sin_addr.s_addr =
ivp->iv_dst.s_addr;
- (void) snprintf(aivr.aip_intf,
- sizeof(aivr.aip_intf), "%s%d",
- inp->inf_nif->nif_if.if_name,
- inp->inf_nif->nif_if.if_unit);
+ strlcpy(aivr.aip_intf,
+ inp->inf_nif->nif_if.if_xname,
+ sizeof(aivr.aip_intf));
if ((ivp->iv_conn) &&
(ivp->iv_conn->co_connvc) &&
(vcp = ivp->iv_conn->co_connvc->cvc_vcc)) {
diff --git a/sys/netatm/spans/spans_arp.c b/sys/netatm/spans/spans_arp.c
index 06b73fe..63f7245 100644
--- a/sys/netatm/spans/spans_arp.c
+++ b/sys/netatm/spans/spans_arp.c
@@ -1117,11 +1117,9 @@ spansarp_ioctl(code, data, arg1)
AF_INET;
SATOSIN(&aar.aap_arp_addr)->sin_addr.s_addr =
sap->sa_dstip.s_addr;
- (void) snprintf(aar.aap_intf,
- sizeof(aar.aap_intf), "%s%d",
- clp->cls_ipnif->inf_nif->nif_if.if_name,
- clp->cls_ipnif->inf_nif->nif_if.if_unit
- );
+ strlcpy(aar.aap_intf,
+ clp->cls_ipnif->inf_nif->nif_if.if_xname,
+ sizeof(aar.aap_intf));
aar.aap_flags = sap->sa_flags;
aar.aap_origin = sap->sa_origin;
if (sap->sa_flags & SAF_VALID)
diff --git a/sys/netatm/uni/uniarp.c b/sys/netatm/uni/uniarp.c
index b593199..ff6819f 100644
--- a/sys/netatm/uni/uniarp.c
+++ b/sys/netatm/uni/uniarp.c
@@ -1054,10 +1054,8 @@ uniarp_ioctl(code, data, arg1)
AF_INET;
SATOSIN(&aar.aap_arp_addr)->sin_addr.s_addr =
uap->ua_dstip.s_addr;
- (void) snprintf(aar.aap_intf,
- sizeof(aar.aap_intf), "%s%d",
- nip->nif_if.if_name,
- nip->nif_if.if_unit);
+ strlcpy(aar.aap_intf, nip->nif_if.if_xname,
+ sizeof(aar.aap_intf));
aar.aap_flags = uap->ua_flags;
aar.aap_origin = uap->ua_origin;
if (uap->ua_flags & UAF_VALID)
@@ -1109,9 +1107,8 @@ uniarp_ioctl(code, data, arg1)
*/
SATOSIN(&aar.aap_arp_addr)->sin_family = AF_INET;
SATOSIN(&aar.aap_arp_addr)->sin_addr.s_addr = 0;
- (void) snprintf(aar.aap_intf,
- sizeof(aar.aap_intf), "%s%d",
- nip->nif_if.if_name, nip->nif_if.if_unit);
+ strlcpy(aar.aap_intf, nip->nif_if.if_xname,
+ sizeof(aar.aap_intf));
aar.aap_flags = 0;
aar.aap_origin = uap->ua_origin;
aar.aap_age = 0;
@@ -1190,9 +1187,8 @@ updbuf:
/*
* Fill in info to be returned
*/
- (void) snprintf(asr.asp_intf,
- sizeof(asr.asp_intf), "%s%d",
- nip->nif_if.if_name, nip->nif_if.if_unit);
+ strlcpy(asr.asp_intf, nip->nif_if.if_xname,
+ sizeof(asr.asp_intf));
asr.asp_state = uip->uip_arpstate;
if (uip->uip_arpstate == UIAS_SERVER_ACTIVE) {
asr.asp_addr.address_format = T_ATM_ABSENT;
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;
}
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index d5916ba..c2fefd6 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -666,27 +666,27 @@ match:
/* the following is not an error when doing bridging */
if (!BRIDGE_TEST && rt->rt_ifp != ifp) {
if (log_arp_wrong_iface)
- log(LOG_ERR, "arp: %s is on %s%d but got reply from %*D on %s%d\n",
+ log(LOG_ERR, "arp: %s is on %s but got reply from %*D on %s\n",
inet_ntoa(isaddr),
- rt->rt_ifp->if_name, rt->rt_ifp->if_unit,
+ rt->rt_ifp->if_xname,
ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
- ifp->if_name, ifp->if_unit);
+ ifp->if_xname);
goto reply;
}
if (sdl->sdl_alen &&
bcmp(ar_sha(ah), LLADDR(sdl), sdl->sdl_alen)) {
if (rt->rt_expire) {
if (log_arp_movements)
- log(LOG_INFO, "arp: %s moved from %*D to %*D on %s%d\n",
+ log(LOG_INFO, "arp: %s moved from %*D to %*D on %s\n",
inet_ntoa(isaddr),
ifp->if_addrlen, (u_char *)LLADDR(sdl), ":",
ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
- ifp->if_name, ifp->if_unit);
+ ifp->if_xname);
} else {
log(LOG_ERR,
- "arp: %*D attempts to modify permanent entry for %s on %s%d\n",
+ "arp: %*D attempts to modify permanent entry for %s on %s\n",
ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
- inet_ntoa(isaddr), ifp->if_name, ifp->if_unit);
+ inet_ntoa(isaddr), ifp->if_xname);
goto reply;
}
}
@@ -813,10 +813,9 @@ reply:
}
if (rt->rt_ifp != ifp) {
log(LOG_INFO, "arp_proxy: ignoring request"
- " from %s via %s%d, expecting %s%d\n",
- inet_ntoa(isaddr), ifp->if_name,
- ifp->if_unit, rt->rt_ifp->if_name,
- rt->rt_ifp->if_unit);
+ " from %s via %s, expecting %s\n",
+ inet_ntoa(isaddr), ifp->if_xname,
+ rt->rt_ifp->if_xname);
rtfree(rt);
m_freem(m);
return;
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index bb4a25c..571abb8 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -214,9 +214,8 @@ divert_packet(struct mbuf *m, int incoming, int port, int rule)
* this iface name will come along for the ride.
* (see div_output for the other half of this.)
*/
- snprintf(divsrc.sin_zero, sizeof(divsrc.sin_zero),
- "%s%d", m->m_pkthdr.rcvif->if_name,
- m->m_pkthdr.rcvif->if_unit);
+ strlcpy(divsrc.sin_zero, m->m_pkthdr.rcvif->if_xname,
+ sizeof(divsrc.sin_zero));
}
/* Put packet on socket queue, if any */
diff --git a/sys/netinet/ip_dummynet.c b/sys/netinet/ip_dummynet.c
index 93a4899..3a9c99c 100644
--- a/sys/netinet/ip_dummynet.c
+++ b/sys/netinet/ip_dummynet.c
@@ -796,18 +796,17 @@ if_tx_rdy(struct ifnet *ifp)
if (p->ifp == ifp)
break ;
if (p == NULL) {
- char buf[32];
- sprintf(buf, "%s%d",ifp->if_name, ifp->if_unit);
for (p = all_pipes; p ; p = p->next )
- if (!strcmp(p->if_name, buf) ) {
+ if (!strcmp(p->if_name, ifp->if_xname) ) {
p->ifp = ifp ;
- DPRINTF(("dummynet: ++ tx rdy from %s (now found)\n", buf));
+ DPRINTF(("dummynet: ++ tx rdy from %s (now found)\n",
+ ifp->if_xname));
break ;
}
}
if (p != NULL) {
- DPRINTF(("dummynet: ++ tx rdy from %s%d - qlen %d\n", ifp->if_name,
- ifp->if_unit, ifp->if_snd.ifq_len));
+ DPRINTF(("dummynet: ++ tx rdy from %s - qlen %d\n", ifp->if_xname,
+ ifp->if_snd.ifq_len));
p->numbytes = 0 ; /* mark ready for I/O */
ready_event_wfq(p);
}
diff --git a/sys/netinet/ip_fw.h b/sys/netinet/ip_fw.h
index b0d9e33..e6eae2d 100644
--- a/sys/netinet/ip_fw.h
+++ b/sys/netinet/ip_fw.h
@@ -223,7 +223,7 @@ typedef struct _ipfw_insn_if {
ipfw_insn o;
union {
struct in_addr ip;
- int32_t unit;
+ int glob;
} p;
char name[IFNAMSIZ];
} ipfw_insn_if;
diff --git a/sys/netinet/ip_fw2.c b/sys/netinet/ip_fw2.c
index 10a2bc0..4d54014 100644
--- a/sys/netinet/ip_fw2.c
+++ b/sys/netinet/ip_fw2.c
@@ -407,12 +407,14 @@ iface_match(struct ifnet *ifp, ipfw_insn_if *cmd)
return 0;
/* Check by name or by IP address */
if (cmd->name[0] != '\0') { /* match by name */
- /* Check unit number (-1 is wildcard) */
- if (cmd->p.unit != -1 && cmd->p.unit != ifp->if_unit)
- return(0);
/* Check name */
- if (!strncmp(ifp->if_name, cmd->name, IFNAMSIZ))
- return(1);
+ if (cmd->p.glob) {
+ if (fnmatch(cmd->name, ifp->if_xname, 0) == 0)
+ return(1);
+ } else {
+ if (strncmp(ifp->if_xname, cmd->name, IFNAMSIZ) == 0)
+ return(1);
+ }
} else {
struct ifaddr *ia;
@@ -648,11 +650,10 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ether_header *eh,
}
if (oif || m->m_pkthdr.rcvif)
log(LOG_SECURITY | LOG_INFO,
- "ipfw: %d %s %s %s via %s%d%s\n",
+ "ipfw: %d %s %s %s via %s%s\n",
f ? f->rulenum : -1,
action, proto, oif ? "out" : "in",
- oif ? oif->if_name : m->m_pkthdr.rcvif->if_name,
- oif ? oif->if_unit : m->m_pkthdr.rcvif->if_unit,
+ oif ? oif->if_xname : m->m_pkthdr.rcvif->if_xname,
fragment);
else
log(LOG_SECURITY | LOG_INFO,
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 7764c9b..a7265ac 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -935,8 +935,7 @@ add_vif(struct vifctl *vifcp)
return EIO; /* XXX */
}
for (i = 0; i < MAXVIFS; ++i) {
- multicast_decap_if[i].if_name = "mdecap";
- multicast_decap_if[i].if_unit = i;
+ if_initname(&multicast_decap_if[i], "mdecap", i);
}
}
/*
@@ -959,8 +958,7 @@ add_vif(struct vifctl *vifcp)
log(LOG_DEBUG, "Adding a register vif, ifp: %p\n",
(void *)&multicast_register_if);
if (reg_vif_num == VIFI_INVALID) {
- multicast_register_if.if_name = "register_vif";
- multicast_register_if.if_unit = 0;
+ if_initname(&multicast_register_if, "register_vif", 0);
multicast_register_if.if_flags = IFF_LOOPBACK;
bzero(&vifp->v_route, sizeof(vifp->v_route));
reg_vif_num = vifcp->vifc_vifi;
@@ -1355,11 +1353,11 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m,
if (rsvpdebug && ip->ip_p == IPPROTO_RSVP) {
struct vif *vifp = viftable + vifi;
- printf("Sending IPPROTO_RSVP from %lx to %lx on vif %d (%s%s%d)\n",
+ printf("Sending IPPROTO_RSVP from %lx to %lx on vif %d (%s%s)\n",
(long)ntohl(ip->ip_src.s_addr), (long)ntohl(ip->ip_dst.s_addr),
vifi,
(vifp->v_flags & VIFF_TUNNEL) ? "tunnel on " : "",
- vifp->v_ifp->if_name, vifp->v_ifp->if_unit);
+ vifp->v_ifp->if_xname);
}
error = ip_mdq(m, ifp, NULL, vifi);
MFC_UNLOCK();
diff --git a/sys/netinet6/ip6_fw.c b/sys/netinet6/ip6_fw.c
index ce56a0d..370ff78 100644
--- a/sys/netinet6/ip6_fw.c
+++ b/sys/netinet6/ip6_fw.c
@@ -326,14 +326,17 @@ iface_match(struct ifnet *ifp, union ip6_fw_if *ifu, int byname)
{
/* Check by name or by IP address */
if (byname) {
- /* Check unit number (-1 is wildcard) */
- if (ifu->fu_via_if.unit != -1
- && ifp->if_unit != ifu->fu_via_if.unit)
- return (0);
/* Check name */
- if (strncmp(ifp->if_name, ifu->fu_via_if.name, IP6FW_IFNLEN))
- return (0);
- return (1);
+ if (ifu->fu_via_if.glob) {
+ if (fnmatch(ifu->fu_via_if.name, ifp->if_xname, 0)
+ == FNM_NOMATCH)
+ return(0);
+ } else {
+ if (strncmp(ifp->if_xname, ifu->fu_via_if.name,
+ IP6FW_IFNLEN) != 0)
+ return(0);
+ }
+ return(1);
} else if (!IN6_IS_ADDR_UNSPECIFIED(&ifu->fu_via_ip6)) { /* Zero == wildcard */
struct ifaddr *ia;
diff --git a/sys/netinet6/ip6_fw.h b/sys/netinet6/ip6_fw.h
index 1866ccf..03df44f 100644
--- a/sys/netinet6/ip6_fw.h
+++ b/sys/netinet6/ip6_fw.h
@@ -68,7 +68,7 @@ union ip6_fw_if {
struct { /* Specified by interface name */
#define IP6FW_IFNLEN IFNAMSIZ
char name[IP6FW_IFNLEN];
- short unit; /* -1 means match any unit */
+ short glob; /* Is name a pattern or a name? */
} fu_via_if;
};
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c
index 8e4dc45..14cf7a6 100644
--- a/sys/netinet6/ip6_mroute.c
+++ b/sys/netinet6/ip6_mroute.c
@@ -584,7 +584,8 @@ add_m6if(mifcp)
if (mifcp->mif6c_flags & MIFF_REGISTER) {
if (reg_mif_num == (mifi_t)-1) {
- multicast_register_if.if_name = "register_mif";
+ strlcpy(multicast_register_if.if_xname, "register_mif",
+ IFNAMSIZ);
multicast_register_if.if_flags |= IFF_LOOPBACK;
multicast_register_if.if_index = mifcp->mif6c_mifi;
reg_mif_num = mifcp->mif6c_mifi;
@@ -626,9 +627,9 @@ add_m6if(mifcp)
#ifdef MRT6DEBUG
if (mrt6debug)
log(LOG_DEBUG,
- "add_mif #%d, phyint %s%d\n",
+ "add_mif #%d, phyint %s\n",
mifcp->mif6c_mifi,
- ifp->if_name, ifp->if_unit);
+ ifp->if_xname);
#endif
return (0);
diff --git a/sys/netipx/ipx_ip.c b/sys/netipx/ipx_ip.c
index 4fa0bfa..d069fb9 100644
--- a/sys/netipx/ipx_ip.c
+++ b/sys/netipx/ipx_ip.c
@@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$");
#include <netipx/ipx_var.h>
static struct ifnet ipxipif;
+static int ipxipif_units;
/* list of all hosts and gateways or broadcast addrs */
static struct ifnet_en *ipxip_list;
@@ -94,7 +95,7 @@ ipxipattach()
if (ipxipif.if_mtu == 0) {
ifp = &ipxipif;
- ifp->if_name = "ipxip";
+ if_initname(ifp, "ipxip", ipxipif_units);
ifp->if_mtu = LOMTU;
ifp->if_ioctl = ipxipioctl;
ifp->if_output = ipxipoutput;
@@ -109,13 +110,12 @@ ipxipattach()
ipxip_list = m;
ifp = &m->ifen_ifnet;
- ifp->if_name = "ipxip";
+ if_initname(ifp, "ipxip", ipxipif_units++);
ifp->if_mtu = LOMTU;
ifp->if_ioctl = ipxipioctl;
ifp->if_output = ipxipoutput;
ifp->if_start = ipxipstart;
ifp->if_flags = IFF_POINTOPOINT;
- ifp->if_unit = ipxipif.if_unit++;
if_attach(ifp);
return (m);
@@ -379,7 +379,7 @@ ipxip_route(so, sopt)
/*
* now configure this as a point to point link
*/
- ifr_ipxip.ifr_name[4] = '0' + ipxipif.if_unit - 1;
+ ifr_ipxip.ifr_name[4] = '0' + ipxipif_units - 1;
ifr_ipxip.ifr_dstaddr = *(struct sockaddr *)ipx_dst;
ipx_control(so, (int)SIOCSIFDSTADDR, (caddr_t)&ifr_ipxip,
(struct ifnet *)ifn, sopt->sopt_td);
diff --git a/sys/netnatm/natm.c b/sys/netnatm/natm.c
index ac16555f..87870b0 100644
--- a/sys/netnatm/natm.c
+++ b/sys/netnatm/natm.c
@@ -334,8 +334,8 @@ natm_usr_peeraddr(struct socket *so, struct sockaddr **nam)
bzero(snatm, sizeof(*snatm));
snatm->snatm_len = sizeof(*snatm);
snatm->snatm_family = AF_NATM;
- snprintf(snatm->snatm_if, sizeof(snatm->snatm_if),
- "%s%d", npcb->npcb_ifp->if_name, npcb->npcb_ifp->if_unit);
+ strlcpy(snatm->snatm_if, npcb->npcb_ifp->if_xname,
+ sizeof(snatm->snatm_if));
snatm->snatm_vci = npcb->npcb_vci;
snatm->snatm_vpi = npcb->npcb_vpi;
*nam = dup_sockaddr((struct sockaddr *)snatm, 0);
diff --git a/sys/nfsclient/bootp_subr.c b/sys/nfsclient/bootp_subr.c
index d79ecf8..957b360 100644
--- a/sys/nfsclient/bootp_subr.c
+++ b/sys/nfsclient/bootp_subr.c
@@ -339,7 +339,7 @@ bootpboot_p_rtentry(struct rtentry *rt)
printf(" ");
printf("flags %x", (unsigned short) rt->rt_flags);
printf(" %d", (int) rt->rt_rmx.rmx_expire);
- printf(" %s%d\n", rt->rt_ifp->if_name, rt->rt_ifp->if_unit);
+ printf(" %s\n", rt->rt_ifp->if_xname);
}
void
@@ -375,10 +375,8 @@ void
bootpboot_p_if(struct ifnet *ifp, struct ifaddr *ifa)
{
- printf("%s%d flags %x, addr ",
- ifp->if_name,
- ifp->if_unit,
- ifp->if_flags);
+ printf("%s flags %x, addr ",
+ ifp->if_xname, ifp->if_flags);
print_sin_addr((struct sockaddr_in *) ifa->ifa_addr);
printf(", broadcast ");
print_sin_addr((struct sockaddr_in *) ifa->ifa_dstaddr);
@@ -1667,8 +1665,8 @@ bootpc_init(void)
for (ifp = TAILQ_FIRST(&ifnet), ifctx = gctx->interfaces;
ifp != NULL && ifctx != NULL;
ifp = TAILQ_NEXT(ifp, if_link)) {
- snprintf(ifctx->ireq.ifr_name, sizeof(ifctx->ireq.ifr_name),
- "%s%d", ifp->if_name, ifp->if_unit);
+ strlcpy(ifctx->ireq.ifr_name, ifp->if_xname,
+ sizeof(ifctx->ireq.ifr_name));
#ifdef BOOTP_WIRED_TO
if (strcmp(ifctx->ireq.ifr_name,
__XSTRING(BOOTP_WIRED_TO)) != 0)
diff --git a/sys/nfsclient/nfs_diskless.c b/sys/nfsclient/nfs_diskless.c
index dc847de..4e09bde 100644
--- a/sys/nfsclient/nfs_diskless.c
+++ b/sys/nfsclient/nfs_diskless.c
@@ -124,7 +124,7 @@ nfs_setup_diskless(void)
printf("nfs_diskless: no interface\n");
return; /* no matching interface */
match_done:
- sprintf(nd->myif.ifra_name, "%s%d", ifp->if_name, ifp->if_unit);
+ strlcpy(nd->myif.ifra_name, ifp->if_xname, sizeof(nd->myif.ifra_name));
/* set up gateway */
inaddr_to_sockaddr("boot.netif.gateway", &nd->mygateway);
diff --git a/sys/pci/if_dc.c b/sys/pci/if_dc.c
index f6ebbb3..f483505 100644
--- a/sys/pci/if_dc.c
+++ b/sys/pci/if_dc.c
@@ -2228,8 +2228,7 @@ dc_attach(device_t dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "dc";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
/* XXX: bleah, MTU gets overwritten in ether_ifattach() */
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
diff --git a/sys/pci/if_de.c b/sys/pci/if_de.c
index 3a3d242..248101e 100644
--- a/sys/pci/if_de.c
+++ b/sys/pci/if_de.c
@@ -383,12 +383,12 @@ tulip_media_print(
if ((sc->tulip_flags & TULIP_LINKUP) == 0)
return;
if (sc->tulip_flags & TULIP_PRINTMEDIA) {
- printf("%s%d: enabling %s port\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: enabling %s port\n",
+ sc->tulip_xname,
tulip_mediums[sc->tulip_media]);
sc->tulip_flags &= ~(TULIP_PRINTMEDIA|TULIP_PRINTLINKUP);
} else if (sc->tulip_flags & TULIP_PRINTLINKUP) {
- printf("%s%d: link up\n", sc->tulip_name, sc->tulip_unit);
+ printf("%s: link up\n", sc->tulip_xname);
sc->tulip_flags &= ~TULIP_PRINTLINKUP;
}
}
@@ -435,8 +435,8 @@ tulip_21140_gpr_media_sense(
continue;
#if defined(TULIP_DEBUG)
- printf("%s%d: gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n",
- sc->tulip_name, sc->tulip_unit, tulip_mediums[media],
+ printf("%s: gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n",
+ sc->tulip_xname, tulip_mediums[media],
TULIP_CSR_READ(sc, csr_gp) & 0xFF,
mi->mi_actmask, mi->mi_actdata);
#endif
@@ -499,8 +499,8 @@ tulip_media_link_monitor(
abilities = (abilities << 6) & status;
if (abilities != sc->tulip_abilities) {
#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation changed: 0x%04x -> 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, sc->tulip_phyaddr,
+ loudprintf("%s(phy%d): autonegotiation changed: 0x%04x -> 0x%04x\n",
+ sc->tulip_xname, sc->tulip_phyaddr,
sc->tulip_abilities, abilities);
#endif
if (tulip_mii_map_abilities(sc, abilities)) {
@@ -542,8 +542,8 @@ tulip_media_link_monitor(
linkup = TULIP_LINK_UP;
#if defined(TULIP_DEBUG)
if (sc->tulip_probe_timeout <= 0)
- printf("%s%d: sia status = 0x%08x\n", sc->tulip_name,
- sc->tulip_unit, TULIP_CSR_READ(sc, csr_sia_status));
+ printf("%s: sia status = 0x%08x\n", sc->tulip_xname,
+ TULIP_CSR_READ(sc, csr_sia_status));
#endif
} else if (mi->mi_type == TULIP_MEDIAINFO_SYM) {
return TULIP_LINK_UNKNOWN;
@@ -558,7 +558,7 @@ tulip_media_link_monitor(
return TULIP_LINK_UP;
sc->tulip_flags &= ~TULIP_LINKUP;
- printf("%s%d: link down: cable problem?\n", sc->tulip_name, sc->tulip_unit);
+ printf("%s: link down: cable problem?\n", sc->tulip_xname);
}
#if defined(TULIP_DEBUG)
sc->tulip_dbg.dbg_link_downed++;
@@ -689,8 +689,8 @@ tulip_media_poll(
if (sc->tulip_probe_timeout > 0) {
tulip_media_t new_probe_media = tulip_21140_gpr_media_sense(sc);
#if defined(TULIP_DEBUG)
- printf("%s%d: media_poll: gpr sensing = %s\n",
- sc->tulip_name, sc->tulip_unit, tulip_mediums[new_probe_media]);
+ printf("%s: media_poll: gpr sensing = %s\n",
+ sc->tulip_xname, tulip_mediums[new_probe_media]);
#endif
if (new_probe_media != TULIP_MEDIA_UNKNOWN) {
if (new_probe_media == sc->tulip_probe_media) {
@@ -776,8 +776,8 @@ tulip_media_poll(
if (/* event == TULIP_MEDIAPOLL_TXPROBE_FAILED || */ sc->tulip_probe_timeout <= 0) {
#if defined(TULIP_DEBUG)
if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) {
- printf("%s%d: poll media unknown!\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: poll media unknown!\n",
+ sc->tulip_xname);
sc->tulip_probe_media = TULIP_MEDIA_MAX;
}
#endif
@@ -789,8 +789,8 @@ tulip_media_poll(
sc->tulip_probe_media -= 1;
if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) {
if (++sc->tulip_probe_passes == 3) {
- printf("%s%d: autosense failed: cable problem?\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: autosense failed: cable problem?\n",
+ sc->tulip_xname);
if ((sc->tulip_if.if_flags & IFF_UP) == 0) {
sc->tulip_if.if_flags &= ~IFF_RUNNING;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
@@ -806,7 +806,7 @@ tulip_media_poll(
|| TULIP_IS_MEDIA_FD(sc->tulip_probe_media));
#if defined(TULIP_DEBUG)
- printf("%s%d: %s: probing %s\n", sc->tulip_name, sc->tulip_unit,
+ printf("%s: %s: probing %s\n", sc->tulip_xname,
event == TULIP_MEDIAPOLL_TXPROBE_FAILED ? "txprobe failed" : "timeout",
tulip_mediums[sc->tulip_probe_media]);
#endif
@@ -1135,8 +1135,8 @@ tulip_21041_media_poll(
sc->tulip_flags &= ~TULIP_WANTRXACT;
sc->tulip_probe_timeout = TULIP_21041_PROBE_AUIBNC_TIMEOUT;
} else {
- printf("%s%d: autosense failed: cable problem?\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: autosense failed: cable problem?\n",
+ sc->tulip_xname);
if ((sc->tulip_if.if_flags & IFF_UP) == 0) {
sc->tulip_if.if_flags &= ~IFF_RUNNING;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
@@ -1347,8 +1347,8 @@ tulip_mii_autonegotiate(
tulip_timeout(sc);
return;
}
- printf("%s%d(phy%d): error: reset of PHY never completed!\n",
- sc->tulip_name, sc->tulip_unit, phyaddr);
+ printf("%s(phy%d): error: reset of PHY never completed!\n",
+ sc->tulip_xname, phyaddr);
sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE;
sc->tulip_probe_state = TULIP_PROBE_FAILED;
sc->tulip_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
@@ -1357,8 +1357,8 @@ tulip_mii_autonegotiate(
status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
if ((status & PHYSTS_CAN_AUTONEG) == 0) {
#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation disabled\n",
- sc->tulip_name, sc->tulip_unit, phyaddr);
+ loudprintf("%s(phy%d): autonegotiation disabled\n",
+ sc->tulip_xname, phyaddr);
#endif
sc->tulip_flags &= ~TULIP_DIDNWAY;
sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
@@ -1370,11 +1370,11 @@ tulip_mii_autonegotiate(
data = tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL);
#if defined(TULIP_DEBUG)
if ((data & PHYCTL_AUTONEG_ENABLE) == 0)
- loudprintf("%s%d(phy%d): oops: enable autonegotiation failed: 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, data);
+ loudprintf("%s(phy%d): oops: enable autonegotiation failed: 0x%04x\n",
+ sc->tulip_xname, phyaddr, data);
else
- loudprintf("%s%d(phy%d): autonegotiation restarted: 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, data);
+ loudprintf("%s(phy%d): autonegotiation restarted: 0x%04x\n",
+ sc->tulip_xname, phyaddr, data);
sc->tulip_dbg.dbg_nway_starts++;
#endif
sc->tulip_probe_state = TULIP_PROBE_PHYAUTONEG;
@@ -1390,8 +1390,8 @@ tulip_mii_autonegotiate(
return;
}
#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation timeout: sts=0x%04x, ctl=0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, status,
+ loudprintf("%s(phy%d): autonegotiation timeout: sts=0x%04x, ctl=0x%04x\n",
+ sc->tulip_xname, phyaddr, status,
tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL));
#endif
sc->tulip_flags &= ~TULIP_DIDNWAY;
@@ -1400,8 +1400,8 @@ tulip_mii_autonegotiate(
}
data = tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ABILITIES);
#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation complete: 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, data);
+ loudprintf("%s(phy%d): autonegotiation complete: 0x%04x\n",
+ sc->tulip_xname, phyaddr, data);
#endif
data = (data << 6) & status;
if (!tulip_mii_map_abilities(sc, data))
@@ -1416,8 +1416,8 @@ tulip_mii_autonegotiate(
}
}
#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation failure: state = %d\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, sc->tulip_probe_state);
+ loudprintf("%s(phy%d): autonegotiation failure: state = %d\n",
+ sc->tulip_xname, phyaddr, sc->tulip_probe_state);
sc->tulip_dbg.dbg_nway_failures++;
#endif
}
@@ -1452,8 +1452,8 @@ tulip_2114x_media_preset(
}
#if defined(TULIP_DEBUG)
} else {
- printf("%s%d: preset: bad media %d!\n",
- sc->tulip_name, sc->tulip_unit, media);
+ printf("%s: preset: bad media %d!\n",
+ sc->tulip_xname, media);
}
#endif
}
@@ -1508,8 +1508,8 @@ tulip_null_media_poll(
sc->tulip_dbg.dbg_events[event]++;
#endif
#if defined(DIAGNOSTIC)
- printf("%s%d: botch(media_poll) at line %d\n",
- sc->tulip_name, sc->tulip_unit, __LINE__);
+ printf("%s: botch(media_poll) at line %d\n",
+ sc->tulip_xname, __LINE__);
#endif
}
@@ -2276,7 +2276,7 @@ tulip_identify_asante_nic(
mi->mi_phyaddr = tulip_mii_get_phyaddr(sc, 0);
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
- printf("%s%d: can't find phy 0\n", sc->tulip_name, sc->tulip_unit);
+ printf("%s: can't find phy 0\n", sc->tulip_xname);
return;
}
@@ -2326,8 +2326,8 @@ tulip_identify_compex_nic(
sc->tulip_slaves = root_sc->tulip_slaves;
root_sc->tulip_slaves = sc;
} else if(sc->tulip_features & TULIP_HAVE_SLAVEDINTR) {
- printf("\nCannot find master device for de%d interrupts",
- sc->tulip_unit);
+ printf("\nCannot find master device for %s interrupts",
+ sc->tulip_xname);
}
} else {
strcat(sc->tulip_boardid, "unknown ");
@@ -2529,8 +2529,8 @@ tulip_srom_decode(
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
#if defined(TULIP_DEBUG)
- printf("%s%d: can't find phy %d\n",
- sc->tulip_name, sc->tulip_unit, phyno);
+ printf("%s: can't find phy %d\n",
+ sc->tulip_xname, phyno);
#endif
break;
}
@@ -2630,8 +2630,8 @@ tulip_srom_decode(
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
#if defined(TULIP_DEBUG)
- printf("%s%d: can't find phy %d\n",
- sc->tulip_name, sc->tulip_unit, phyno);
+ printf("%s: can't find phy %d\n",
+ sc->tulip_xname, phyno);
#endif
break;
}
@@ -3274,8 +3274,8 @@ tulip_reset(
(*sc->tulip_boardsw->bd_media_select)(sc);
#if defined(TULIP_DEBUG)
if ((sc->tulip_flags & TULIP_NEEDRESET) == TULIP_NEEDRESET)
- printf("%s%d: tulip_reset: additional reset needed?!?\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: tulip_reset: additional reset needed?!?\n",
+ sc->tulip_xname);
#endif
tulip_media_print(sc);
if (sc->tulip_features & TULIP_HAVE_DUALSENSE)
@@ -3503,8 +3503,8 @@ tulip_rx_intr(
}
#if defined(TULIP_VERBOSE)
if (error != NULL && (sc->tulip_flags & TULIP_NOMESSAGES) == 0) {
- printf("%s%d: receive: %6D: %s\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: receive: %6D: %s\n",
+ sc->tulip_xname,
mtod(ms, u_char *) + 6, ":",
error);
sc->tulip_flags |= TULIP_NOMESSAGES;
@@ -3615,8 +3615,8 @@ tulip_rx_intr(
error = bus_dmamap_load(sc->tulip_dmatag, map, mtod(ms, void *),
TULIP_RX_BUFLEN, NULL, BUS_DMA_NOWAIT);
if (error) {
- printf("%s%d: unable to load rx map, "
- "error = %d\n", sc->tulip_name, sc->tulip_unit, error);
+ printf("%s: unable to load rx map, "
+ "error = %d\n", sc->tulip_xname, error);
panic("tulip_rx_intr"); /* XXX */
}
nextout->d_addr1 = map->dm_segs[0].ds_addr;
@@ -3707,8 +3707,8 @@ tulip_tx_intr(
m_freem(m);
#if defined(TULIP_DEBUG)
} else {
- printf("%s%d: tx_intr: failed to dequeue mbuf?!?\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: tx_intr: failed to dequeue mbuf?!?\n",
+ sc->tulip_xname);
#endif
}
if (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) {
@@ -3797,7 +3797,7 @@ tulip_print_abnormal_interrupt(
const char thrsh[] = "72|128\0\0\0" "96|256\0\0\0" "128|512\0\0" "160|1024";
csr &= (1 << (sizeof(tulip_status_bits)/sizeof(tulip_status_bits[0]))) - 1;
- printf("%s%d: abnormal interrupt:", sc->tulip_name, sc->tulip_unit);
+ printf("%s: abnormal interrupt:", sc->tulip_xname);
for (sep = " ", mask = 1; mask <= csr; mask <<= 1, msgp++) {
if ((csr & mask) && *msgp != NULL) {
printf("%s%s", sep, *msgp);
@@ -3833,8 +3833,8 @@ tulip_intr_handler(
if (sc->tulip_flags & TULIP_NOMESSAGES) {
sc->tulip_flags |= TULIP_SYSTEMERROR;
} else {
- printf("%s%d: system error: %s\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: system error: %s\n",
+ sc->tulip_xname,
tulip_system_errors[sc->tulip_last_system_error]);
}
sc->tulip_flags |= TULIP_NEEDRESET;
@@ -4130,8 +4130,8 @@ tulip_txput(
#if defined(TULIP_DEBUG)
if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) {
- printf("%s%d: txput%s: tx not running\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: txput%s: tx not running\n",
+ sc->tulip_xname,
(sc->tulip_flags & TULIP_TXPROBE_ACTIVE) ? "(probe)" : "");
sc->tulip_flags |= TULIP_WANTTXSTART;
sc->tulip_dbg.dbg_txput_finishes[0]++;
@@ -4202,8 +4202,8 @@ tulip_txput(
error = bus_dmamap_load_mbuf(sc->tulip_dmatag, map, m, BUS_DMA_NOWAIT);
}
if (error != 0) {
- printf("%s%d: unable to load tx map, "
- "error = %d\n", sc->tulip_name, sc->tulip_unit, error);
+ printf("%s: unable to load tx map, "
+ "error = %d\n", sc->tulip_xname, error);
#if defined(TULIP_DEBUG)
sc->tulip_dbg.dbg_txput_finishes[3]++;
#endif
@@ -4455,8 +4455,8 @@ tulip_txput_setup(
#if defined(TULIP_DEBUG)
if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) {
- printf("%s%d: txput_setup: tx not running\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: txput_setup: tx not running\n",
+ sc->tulip_xname);
sc->tulip_flags |= TULIP_WANTTXSTART;
sc->tulip_if.if_start = tulip_ifstart;
return;
@@ -4705,8 +4705,8 @@ tulip_ifwatchdog(
tulip_rx_intr(sc);
if (sc->tulip_flags & TULIP_SYSTEMERROR) {
- printf("%s%d: %d system errors: last was %s\n",
- sc->tulip_name, sc->tulip_unit, sc->tulip_system_errors,
+ printf("%s: %d system errors: last was %s\n",
+ sc->tulip_xname, sc->tulip_system_errors,
tulip_system_errors[sc->tulip_last_system_error]);
}
if (sc->tulip_statusbits) {
@@ -4720,7 +4720,7 @@ tulip_ifwatchdog(
if (sc->tulip_txtimer)
tulip_tx_intr(sc);
if (sc->tulip_txtimer && --sc->tulip_txtimer == 0) {
- printf("%s%d: transmission timeout\n", sc->tulip_name, sc->tulip_unit);
+ printf("%s: transmission timeout\n", sc->tulip_xname);
if (TULIP_DO_AUTOSENSE(sc)) {
sc->tulip_media = TULIP_MEDIA_UNKNOWN;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
@@ -4766,6 +4766,9 @@ tulip_attach(
{
struct ifnet * const ifp = &sc->tulip_if;
+ /* XXX: driver name/unit should be set some other way */
+ ifp->if_dname = "de";
+ ifp->if_dunit = sc->tulip_unit;
ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST;
ifp->if_ioctl = tulip_ifioctl;
ifp->if_start = tulip_ifstart;
@@ -4774,16 +4777,16 @@ tulip_attach(
ifp->if_output = ether_output;
ifp->if_init = tulip_ifinit;
- printf("%s%d: %s%s pass %d.%d%s\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: %s%s pass %d.%d%s\n",
+ sc->tulip_xname,
sc->tulip_boardid,
tulip_chipdescs[sc->tulip_chipid],
(sc->tulip_revinfo & 0xF0) >> 4,
sc->tulip_revinfo & 0x0F,
(sc->tulip_features & (TULIP_HAVE_ISVSROM|TULIP_HAVE_OKSROM))
== TULIP_HAVE_ISVSROM ? " (invalid EESPROM checksum)" : "");
- printf("%s%d: address %6D\n",
- sc->tulip_name, sc->tulip_unit, sc->tulip_enaddr, ":");
+ printf("%s: address %6D\n",
+ sc->tulip_xname, sc->tulip_enaddr, ":");
#if defined(__alpha__)
/*
@@ -5142,7 +5145,7 @@ tulip_pci_attach(device_t dev)
#endif
sc->tulip_unit = unit;
- sc->tulip_name = "de";
+ snprintf(sc->tulip_xname, IFNAMSIZ, "de%d", sc->tulip_unit);
sc->tulip_revinfo = revinfo;
sc->tulip_if.if_softc = sc;
#if defined(TULIP_IOMAPPED)
@@ -5194,16 +5197,16 @@ tulip_pci_attach(device_t dev)
bit longer anyways) */
if ((retval = tulip_read_macaddr(sc)) < 0) {
- printf("%s%d", sc->tulip_name, sc->tulip_unit);
+ printf("%s", sc->tulip_xname);
printf(": can't read ENET ROM (why=%d) (", retval);
for (idx = 0; idx < 32; idx++)
printf("%02x", sc->tulip_rombuf[idx]);
printf("\n");
- printf("%s%d: %s%s pass %d.%d\n",
- sc->tulip_name, sc->tulip_unit,
+ printf("%s: %s%s pass %d.%d\n",
+ sc->tulip_xname,
sc->tulip_boardid, tulip_chipdescs[sc->tulip_chipid],
(sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F);
- printf("%s%d: address unknown\n", sc->tulip_name, sc->tulip_unit);
+ printf("%s: address unknown\n", sc->tulip_xname);
} else {
int s;
void (*intr_rtn)(void *) = tulip_intr_normal;
@@ -5219,8 +5222,8 @@ tulip_pci_attach(device_t dev)
0, ~0, 1, RF_SHAREABLE | RF_ACTIVE);
if (res == 0 || bus_setup_intr(dev, res, INTR_TYPE_NET,
intr_rtn, sc, &ih)) {
- printf("%s%d: couldn't map interrupt\n",
- sc->tulip_name, sc->tulip_unit);
+ printf("%s: couldn't map interrupt\n",
+ sc->tulip_xname);
free((caddr_t) sc->tulip_rxdescs, M_DEVBUF);
free((caddr_t) sc->tulip_txdescs, M_DEVBUF);
return ENXIO;
diff --git a/sys/pci/if_devar.h b/sys/pci/if_devar.h
index 13d2357..9b47cca 100644
--- a/sys/pci/if_devar.h
+++ b/sys/pci/if_devar.h
@@ -431,6 +431,7 @@ typedef struct {
*/
struct _tulip_softc_t {
struct ifmedia tulip_ifmedia;
+ int tulip_unit;
#if defined(TULIP_BUS_DMA)
bus_dma_tag_t tulip_dmatag; /* bus DMA tag */
#if !defined(TULIP_BUS_DMA_NOTX)
@@ -850,10 +851,7 @@ NETISR_SET(NETISR_DE, tulip_softintr);
#ifndef tulip_if
#define tulip_if tulip_ac.ac_if
#endif
-#ifndef tulip_unit
-#define tulip_unit tulip_if.if_unit
-#endif
-#define tulip_name tulip_if.if_name
+#define tulip_xname tulip_if.if_xname
#ifndef tulip_enaddr
#define tulip_enaddr tulip_ac.ac_enaddr
#endif
diff --git a/sys/pci/if_pcn.c b/sys/pci/if_pcn.c
index 98fa75e..57dd4a6 100644
--- a/sys/pci/if_pcn.c
+++ b/sys/pci/if_pcn.c
@@ -599,8 +599,7 @@ pcn_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "pcn";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = pcn_ioctl;
diff --git a/sys/pci/if_rl.c b/sys/pci/if_rl.c
index 721d4a8..d73abda 100644
--- a/sys/pci/if_rl.c
+++ b/sys/pci/if_rl.c
@@ -1095,8 +1095,7 @@ rl_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "rl";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = rl_ioctl;
diff --git a/sys/pci/if_sf.c b/sys/pci/if_sf.c
index fcd05ff..6642809 100644
--- a/sys/pci/if_sf.c
+++ b/sys/pci/if_sf.c
@@ -770,8 +770,7 @@ sf_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "sf";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = sf_ioctl;
diff --git a/sys/pci/if_sis.c b/sys/pci/if_sis.c
index 60140c5..896faf0 100644
--- a/sys/pci/if_sis.c
+++ b/sys/pci/if_sis.c
@@ -1368,8 +1368,7 @@ sis_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "sis";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = sis_ioctl;
diff --git a/sys/pci/if_sk.c b/sys/pci/if_sk.c
index 813c94d..2773236 100644
--- a/sys/pci/if_sk.c
+++ b/sys/pci/if_sk.c
@@ -1394,8 +1394,7 @@ sk_attach(dev)
ifp = &sc_if->arpcom.ac_if;
ifp->if_softc = sc_if;
- ifp->if_unit = sc_if->sk_unit;
- ifp->if_name = "sk";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = sk_ioctl;
diff --git a/sys/pci/if_ste.c b/sys/pci/if_ste.c
index 931c769..3bf8b33 100644
--- a/sys/pci/if_ste.c
+++ b/sys/pci/if_ste.c
@@ -1027,8 +1027,7 @@ ste_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "ste";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = ste_ioctl;
diff --git a/sys/pci/if_ti.c b/sys/pci/if_ti.c
index 95bbfc4..4cbea9b 100644
--- a/sys/pci/if_ti.c
+++ b/sys/pci/if_ti.c
@@ -2187,8 +2187,7 @@ ti_attach(dev)
/* Set up ifnet structure */
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = sc->ti_unit;
- ifp->if_name = "ti";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
tis[unit] = sc;
ifp->if_ioctl = ti_ioctl;
@@ -2810,7 +2809,7 @@ static void ti_init2(sc)
ifp = &sc->arpcom.ac_if;
/* Specify MTU and interface index. */
- CSR_WRITE_4(sc, TI_GCR_IFINDEX, ifp->if_unit);
+ CSR_WRITE_4(sc, TI_GCR_IFINDEX, sc->ti_unit);
CSR_WRITE_4(sc, TI_GCR_IFMTU, ifp->if_mtu +
ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN);
TI_DO_CMD(TI_CMD_UPDATE_GENCOM, 0, 0);
diff --git a/sys/pci/if_tl.c b/sys/pci/if_tl.c
index b7b2834..8063e77 100644
--- a/sys/pci/if_tl.c
+++ b/sys/pci/if_tl.c
@@ -1268,8 +1268,7 @@ tl_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "tl";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = tl_ioctl;
ifp->if_output = ether_output;
diff --git a/sys/pci/if_vr.c b/sys/pci/if_vr.c
index 35343da..ffd2c3e 100644
--- a/sys/pci/if_vr.c
+++ b/sys/pci/if_vr.c
@@ -849,8 +849,7 @@ vr_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "vr";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = vr_ioctl;
diff --git a/sys/pci/if_wb.c b/sys/pci/if_wb.c
index 3694c28..c53e41d 100644
--- a/sys/pci/if_wb.c
+++ b/sys/pci/if_wb.c
@@ -915,8 +915,7 @@ wb_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "wb";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = wb_ioctl;
diff --git a/sys/pci/if_xl.c b/sys/pci/if_xl.c
index 6bfd7fb..b3a69d5 100644
--- a/sys/pci/if_xl.c
+++ b/sys/pci/if_xl.c
@@ -1598,8 +1598,7 @@ xl_attach(dev)
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "xl";
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = xl_ioctl;
diff --git a/sys/security/mac_biba/mac_biba.c b/sys/security/mac_biba/mac_biba.c
index a784ed7..d825842 100644
--- a/sys/security/mac_biba/mac_biba.c
+++ b/sys/security/mac_biba/mac_biba.c
@@ -1101,7 +1101,7 @@ mac_biba_create_bpfdesc(struct ucred *cred, struct bpf_d *bpf_d,
static void
mac_biba_create_ifnet(struct ifnet *ifnet, struct label *ifnetlabel)
{
- char tifname[IFNAMSIZ], ifname[IFNAMSIZ], *p, *q;
+ char tifname[IFNAMSIZ], *p, *q;
char tiflist[sizeof(trusted_interfaces)];
struct mac_biba *dest;
int len, type;
@@ -1129,15 +1129,13 @@ mac_biba_create_ifnet(struct ifnet *ifnet, struct label *ifnetlabel)
if(*p != ' ' && *p != '\t')
*q = *p;
- snprintf(ifname, IFNAMSIZ, "%s%d", ifnet->if_name, ifnet->if_unit);
-
for (p = q = tiflist;; p++) {
if (*p == ',' || *p == '\0') {
len = p - q;
if (len < IFNAMSIZ) {
bzero(tifname, sizeof(tifname));
bcopy(q, tifname, len);
- if (strcmp(tifname, ifname) == 0) {
+ if (strcmp(tifname, ifnet->if_xname) == 0) {
type = MAC_BIBA_TYPE_HIGH;
break;
}
diff --git a/sys/security/mac_lomac/mac_lomac.c b/sys/security/mac_lomac/mac_lomac.c
index 2966f9f..50a6f7b 100644
--- a/sys/security/mac_lomac/mac_lomac.c
+++ b/sys/security/mac_lomac/mac_lomac.c
@@ -1240,7 +1240,7 @@ mac_lomac_create_bpfdesc(struct ucred *cred, struct bpf_d *bpf_d,
static void
mac_lomac_create_ifnet(struct ifnet *ifnet, struct label *ifnetlabel)
{
- char tifname[IFNAMSIZ], ifname[IFNAMSIZ], *p, *q;
+ char tifname[IFNAMSIZ], *p, *q;
char tiflist[sizeof(trusted_interfaces)];
struct mac_lomac *dest;
int len, grade;
@@ -1268,15 +1268,13 @@ mac_lomac_create_ifnet(struct ifnet *ifnet, struct label *ifnetlabel)
if(*p != ' ' && *p != '\t')
*q = *p;
- snprintf(ifname, IFNAMSIZ, "%s%d", ifnet->if_name, ifnet->if_unit);
-
for (p = q = tiflist;; p++) {
if (*p == ',' || *p == '\0') {
len = p - q;
if (len < IFNAMSIZ) {
bzero(tifname, sizeof(tifname));
bcopy(q, tifname, len);
- if (strcmp(tifname, ifname) == 0) {
+ if (strcmp(tifname, ifnet->if_xname) == 0) {
grade = MAC_LOMAC_TYPE_HIGH;
break;
}
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 42e242c..8503f4c 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -57,7 +57,7 @@
* scheme is: <major><two digit minor><0 if release branch, otherwise 1>xx
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 501112 /* Master, propagated to newvers */
+#define __FreeBSD_version 501113 /* Master, propagated to newvers */
#ifndef NULL
#define NULL 0
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index e563907..b2527cd 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -169,7 +169,7 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
short timer;
int drops;
struct sockaddr *sa = NULL;
- char name[32], tname[16];
+ char name[IFNAMSIZ];
short network_layer;
short link_layer;
@@ -216,13 +216,10 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
if (ifaddraddr == 0) {
ifnetfound = ifnetaddr;
- if (kread(ifnetaddr, (char *)&ifnet, sizeof ifnet) ||
- kread((u_long)ifnet.if_name, tname, 16))
+ if (kread(ifnetaddr, (char *)&ifnet, sizeof ifnet))
return;
- tname[sizeof(tname) - 1] = '\0';
+ strlcpy(name, ifnet.if_xname, sizeof(name));
ifnetaddr = (u_long)TAILQ_NEXT(&ifnet, if_link);
- snprintf(name, sizeof(name), "%s%d", tname,
- ifnet.if_unit);
if (interface != 0 && (strcmp(name, interface) != 0))
continue;
cp = index(name, '\0');
@@ -464,7 +461,7 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
struct iftot {
SLIST_ENTRY(iftot) chain;
- char ift_name[16]; /* interface name */
+ char ift_name[IFNAMSIZ]; /* interface name */
u_long ift_ip; /* input packets */
u_long ift_ie; /* input errors */
u_long ift_op; /* output packets */
@@ -508,14 +505,11 @@ sidewaysintpr(unsigned interval1, u_long off)
interesting = NULL;
interesting_off = 0;
for (off = firstifnet, ip = iftot; off;) {
- char name[16], tname[16];
+ char name[IFNAMSIZ];
if (kread(off, (char *)&ifnet, sizeof ifnet))
break;
- if (kread((u_long)ifnet.if_name, tname, sizeof(tname)))
- break;
- tname[sizeof(tname) - 1] = '\0';
- snprintf(name, sizeof(name), "%s%d", tname, ifnet.if_unit);
+ strlcpy(name, ifnet.if_xname, sizeof(name));
if (interface && strcmp(name, interface) == 0) {
interesting = ip;
interesting_off = off;
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index a61fb17..3dcd910 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -329,12 +329,9 @@ size_cols_rtentry(struct rtentry *rt)
}
if (rt->rt_ifp) {
if (rt->rt_ifp != lastif) {
- len = snprintf(buffer, sizeof(buffer), "%d",
- ifnet.if_unit);
kget(rt->rt_ifp, ifnet);
- kread((u_long)ifnet.if_name, buffer, sizeof(buffer));
lastif = rt->rt_ifp;
- len += strlen(buffer);
+ len = strlen(ifnet.if_xname);
wid_if = MAX(len, wid_if);
}
if (rt->rt_rmx.rmx_expire) {
@@ -750,10 +747,8 @@ p_rtentry(struct rtentry *rt)
if (rt->rt_ifp) {
if (rt->rt_ifp != lastif) {
kget(rt->rt_ifp, ifnet);
- kread((u_long)ifnet.if_name, buffer, sizeof(buffer));
lastif = rt->rt_ifp;
- snprintf(prettyname, sizeof(prettyname),
- "%s%d", buffer, ifnet.if_unit);
+ strlcpy(prettyname, ifnet.if_xname, sizeof(prettyname));
}
printf("%*.*s", wid_if, wid_if, prettyname);
if (rt->rt_rmx.rmx_expire) {
diff --git a/usr.sbin/ifmcstat/ifmcstat.c b/usr.sbin/ifmcstat/ifmcstat.c
index 72806ac..bde4a4c 100644
--- a/usr.sbin/ifmcstat/ifmcstat.c
+++ b/usr.sbin/ifmcstat/ifmcstat.c
@@ -150,9 +150,7 @@ char *ifname(ifp)
char ifnamebuf[IFNAMSIZ];
KREAD(ifp, &ifnet, struct ifnet);
- KREAD(ifnet.if_name, ifnamebuf, sizeof(ifnamebuf));
- snprintf(buf, sizeof(buf), "%s%d", ifnamebuf,
- ifnet.if_unit); /* does snprintf allow overlap copy?? */
+ strlcpy(buf, ifnet.if_xname, sizeof(buf));
return buf;
}
OpenPOWER on IntegriCloud