diff options
author | brooks <brooks@FreeBSD.org> | 2003-10-31 18:32:15 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2003-10-31 18:32:15 +0000 |
commit | f1e94c6f29b079e4ad9d9305ef3e90a719bcbbda (patch) | |
tree | 4d9e6671d486576767506230a4240131526fea49 /sys/netinet | |
parent | be546fdee455a96afdefee10d0bdba8547399f5b (diff) | |
download | FreeBSD-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)
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/if_ether.c | 21 | ||||
-rw-r--r-- | sys/netinet/ip_divert.c | 5 | ||||
-rw-r--r-- | sys/netinet/ip_dummynet.c | 11 | ||||
-rw-r--r-- | sys/netinet/ip_fw.h | 2 | ||||
-rw-r--r-- | sys/netinet/ip_fw2.c | 17 | ||||
-rw-r--r-- | sys/netinet/ip_mroute.c | 10 |
6 files changed, 31 insertions, 35 deletions
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(); |