Date: Tue, 30 Sep 2003 14:17:20 -0700 (PDT) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 38919 for review Message-ID: <200309302117.h8ULHKTX024604@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=38919 Change 38919 by sam@sam_ebb on 2003/09/30 14:16:42 cleanup and lock routing socket support: o use ansi decls o remove egregious shorthand #defines for info[*] o eliminate route_proto global variable o make route_cb and associated struct decl private o remove lots of register decls Affected files ... .. //depot/projects/netperf/sys/net/route.c#10 edit .. //depot/projects/netperf/sys/net/route.h#5 edit .. //depot/projects/netperf/sys/net/rtsock.c#4 edit Differences ... ==== //depot/projects/netperf/sys/net/route.c#10 (text+ko) ==== @@ -53,7 +53,6 @@ #define SA(p) ((struct sockaddr *)(p)) -struct route_cb route_cb; static struct rtstat rtstat; struct radix_node_head *rt_tables[AF_MAX+1]; ==== //depot/projects/netperf/sys/net/route.h#5 (text+ko) ==== @@ -257,13 +257,6 @@ struct ifnet *rti_ifp; }; -struct route_cb { - int ip_count; - int ip6_count; - int ipx_count; - int any_count; -}; - #ifdef _KERNEL #define RT_LOCK_INIT(_rt) \ @@ -288,7 +281,6 @@ RTFREE_LOCKED(_rt); \ } while (0) -extern struct route_cb route_cb; extern struct radix_node_head *rt_tables[AF_MAX+1]; struct ifmultiaddr; ==== //depot/projects/netperf/sys/net/rtsock.c#4 (text+ko) ==== @@ -34,7 +34,6 @@ * $FreeBSD: src/sys/net/rtsock.c,v 1.89 2003/03/05 19:24:22 peter Exp $ */ - #include <sys/param.h> #include <sys/domain.h> #include <sys/kernel.h> @@ -55,10 +54,24 @@ MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables"); +/* NB: these are not modified */ static struct sockaddr route_dst = { 2, PF_ROUTE, }; static struct sockaddr route_src = { 2, PF_ROUTE, }; static struct sockaddr sa_zero = { sizeof(sa_zero), AF_INET, }; -static struct sockproto route_proto = { PF_ROUTE, }; + +static struct { + int ip_count; /* attacked w/ AF_INET */ + int ip6_count; /* attached w/ AF_INET6 */ + int ipx_count; /* attached w/ AF_IPX */ + int any_count; /* total attached */ +} route_cb; + +struct mtx rtsock_mtx; +MTX_SYSINIT(rtsock, &rtsock_mtx, "rtsock route_cb lock", MTX_DEF); + +#define RTSOCK_LOCK() mtx_lock(&rtsock_mtx) +#define RTSOCK_UNLOCK() mtx_unlock(&rtsock_mtx) +#define RTSOCK_LOCK_ASSERT() mtx_assert(&rtsock_mtx, MA_OWNED) struct walkarg { int w_tmemsize; @@ -67,23 +80,14 @@ struct sysctl_req *w_req; }; -static struct mbuf * - rt_msg1(int, struct rt_addrinfo *); +static struct mbuf *rt_msg1(int, struct rt_addrinfo *); static int rt_msg2(int, struct rt_addrinfo *, caddr_t, struct walkarg *); static int rt_xaddrs(caddr_t, caddr_t, struct rt_addrinfo *); static int sysctl_dumpentry(struct radix_node *rn, void *vw); static int sysctl_iflist(int af, struct walkarg *w); -static int route_output(struct mbuf *, struct socket *); -static void rt_setmetrics(u_long, struct rt_metrics *, struct rt_metrics *); - -/* Sleazy use of local variables throughout file, warning!!!! */ -#define dst info.rti_info[RTAX_DST] -#define gate info.rti_info[RTAX_GATEWAY] -#define netmask info.rti_info[RTAX_NETMASK] -#define genmask info.rti_info[RTAX_GENMASK] -#define ifpaddr info.rti_info[RTAX_IFP] -#define ifaaddr info.rti_info[RTAX_IFA] -#define brdaddr info.rti_info[RTAX_BRD] +static int route_output(struct mbuf *, struct socket *); +static void rt_setmetrics(u_long, struct rt_metrics *, struct rt_metrics *); +static void rt_dispatch(struct mbuf *, struct sockaddr *); /* * It really doesn't make any sense at all for this code to share much @@ -131,6 +135,7 @@ free(rp, M_PCB); return error; } + RTSOCK_LOCK(); switch(rp->rcb_proto.sp_protocol) { case AF_INET: route_cb.ip_count++; @@ -144,6 +149,7 @@ } rp->rcb_faddr = &route_src; route_cb.any_count++; + RTSOCK_UNLOCK(); soisconnected(so); so->so_options |= SO_USELOOPBACK; splx(s); @@ -181,6 +187,7 @@ s = splnet(); if (rp != 0) { + RTSOCK_LOCK(); switch(rp->rcb_proto.sp_protocol) { case AF_INET: route_cb.ip_count--; @@ -193,6 +200,7 @@ break; } route_cb.any_count--; + RTSOCK_UNLOCK(); } error = raw_usrreqs.pru_detach(so); splx(s); @@ -271,6 +279,7 @@ register struct mbuf *m; struct socket *so; { +#define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0) register struct rt_msghdr *rtm = 0; register struct rtentry *rt = 0; struct radix_node_head *rnh; @@ -288,36 +297,40 @@ len = m->m_pkthdr.len; if (len < sizeof(*rtm) || len != mtod(m, struct rt_msghdr *)->rtm_msglen) { - dst = 0; + info.rti_info[RTAX_DST] = 0; senderr(EINVAL); } R_Malloc(rtm, struct rt_msghdr *, len); if (rtm == 0) { - dst = 0; + info.rti_info[RTAX_DST] = 0; senderr(ENOBUFS); } m_copydata(m, 0, len, (caddr_t)rtm); if (rtm->rtm_version != RTM_VERSION) { - dst = 0; + info.rti_info[RTAX_DST] = 0; senderr(EPROTONOSUPPORT); } rtm->rtm_pid = curproc->p_pid; bzero(&info, sizeof(info)); info.rti_addrs = rtm->rtm_addrs; if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) { - dst = 0; + info.rti_info[RTAX_DST] = 0; senderr(EINVAL); } info.rti_flags = rtm->rtm_flags; - if (dst == 0 || (dst->sa_family >= AF_MAX) - || (gate != 0 && (gate->sa_family >= AF_MAX))) + if (info.rti_info[RTAX_DST] == 0 || + info.rti_info[RTAX_DST]->sa_family >= AF_MAX || + (info.rti_info[RTAX_GATEWAY] != 0 && + info.rti_info[RTAX_GATEWAY]->sa_family >= AF_MAX)) senderr(EINVAL); - if (genmask) { + if (info.rti_info[RTAX_GENMASK]) { struct radix_node *t; - t = rn_addmask((caddr_t)genmask, 0, 1); - if (t && Bcmp((caddr_t *)genmask + 1, (caddr_t *)t->rn_key + 1, + t = rn_addmask((caddr_t) info.rti_info[RTAX_GENMASK], 0, 1); + if (t && Bcmp((caddr_t *) info.rti_info[RTAX_GENMASK] + 1, + (caddr_t *)t->rn_key + 1, *(u_char *)t->rn_key - 1) == 0) - genmask = (struct sockaddr *)(t->rn_key); + info.rti_info[RTAX_GENMASK] = + (struct sockaddr *)(t->rn_key); else senderr(ENOBUFS); } @@ -333,7 +346,7 @@ struct rtentry *saved_nrt; case RTM_ADD: - if (gate == 0) + if (info.rti_info[RTAX_GATEWAY] == 0) senderr(EINVAL); saved_nrt = 0; error = rtrequest1(RTM_ADD, &info, &saved_nrt); @@ -345,7 +358,7 @@ saved_nrt->rt_rmx.rmx_locks |= (rtm->rtm_inits & rtm->rtm_rmx.rmx_locks); saved_nrt->rt_refcnt--; - saved_nrt->rt_genmask = genmask; + saved_nrt->rt_genmask = info.rti_info[RTAX_GENMASK]; RT_UNLOCK(saved_nrt); } break; @@ -363,36 +376,40 @@ case RTM_GET: case RTM_CHANGE: case RTM_LOCK: - if ((rnh = rt_tables[dst->sa_family]) == 0) + rnh = rt_tables[info.rti_info[RTAX_DST]->sa_family]; + if (rnh == 0) senderr(EAFNOSUPPORT); RADIX_NODE_HEAD_LOCK(rnh); - rt = (struct rtentry *) rnh->rnh_lookup(dst, netmask, rnh); + rt = (struct rtentry *) rnh->rnh_lookup(info.rti_info[RTAX_DST], + info.rti_info[RTAX_NETMASK], rnh); RADIX_NODE_HEAD_UNLOCK(rnh); - if (rt != NULL) { /* XXX looks bogus */ - RT_LOCK(rt); - rt->rt_refcnt++; - } else + if (rt == NULL) /* XXX looks bogus */ senderr(ESRCH); + RT_LOCK(rt); + rt->rt_refcnt++; switch(rtm->rtm_type) { case RTM_GET: report: - dst = rt_key(rt); - gate = rt->rt_gateway; - netmask = rt_mask(rt); - genmask = rt->rt_genmask; + RT_LOCK_ASSERT(rt); + info.rti_info[RTAX_DST] = rt_key(rt); + info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; + info.rti_info[RTAX_NETMASK] = rt_mask(rt); + info.rti_info[RTAX_GENMASK] = rt->rt_genmask; if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) { ifp = rt->rt_ifp; if (ifp) { - ifpaddr = TAILQ_FIRST(&ifp->if_addrhead)->ifa_addr; - ifaaddr = rt->rt_ifa->ifa_addr; + info.rti_info[RTAX_IFP] = TAILQ_FIRST(&ifp->if_addrhead)->ifa_addr; + info.rti_info[RTAX_IFA] = + rt->rt_ifa->ifa_addr; if (ifp->if_flags & IFF_POINTOPOINT) - brdaddr = rt->rt_ifa->ifa_dstaddr; + info.rti_info[RTAX_BRD] = + rt->rt_ifa->ifa_dstaddr; rtm->rtm_index = ifp->if_index; } else { - ifpaddr = 0; - ifaaddr = 0; + info.rti_info[RTAX_IFP] = 0; + info.rti_info[RTAX_IFA] = 0; } } len = rt_msg2(rtm->rtm_type, &info, (caddr_t)0, @@ -415,22 +432,25 @@ break; case RTM_CHANGE: - /* new gateway could require new ifaddr, ifp; - flags may also be different; ifp may be specified - by ll sockaddr when protocol address is ambiguous */ -/* compare two sockaddr structures */ -#define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0) - if (((rt->rt_flags & RTF_GATEWAY) && gate != NULL) || - ifpaddr != NULL || - (ifaaddr != NULL && - !sa_equal(ifaaddr, rt->rt_ifa->ifa_addr))) { + /* + * New gateway could require new ifaddr, ifp; + * flags may also be different; ifp may be specified + * by ll sockaddr when protocol address is ambiguous + */ + if (((rt->rt_flags & RTF_GATEWAY) && + info.rti_info[RTAX_GATEWAY] != NULL) || + info.rti_info[RTAX_IFP] != NULL || + (info.rti_info[RTAX_IFA] != NULL && + !sa_equal(info.rti_info[RTAX_IFA], + rt->rt_ifa->ifa_addr))) { if ((error = rt_getifa(&info)) != 0) { RT_UNLOCK(rt); senderr(error); } } - if (gate != NULL && - (error = rt_setgate(rt, rt_key(rt), gate)) != 0) { + if (info.rti_info[RTAX_GATEWAY] != NULL && + (error = rt_setgate(rt, rt_key(rt), + info.rti_info[RTAX_GATEWAY])) != 0) { RT_UNLOCK(rt); senderr(error); } @@ -453,8 +473,8 @@ &rt->rt_rmx); if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest) rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, &info); - if (genmask) - rt->rt_genmask = genmask; + if (info.rti_info[RTAX_GENMASK]) + rt->rt_genmask = info.rti_info[RTAX_GENMASK]; /* FALLTHROUGH */ case RTM_LOCK: rt->rt_rmx.rmx_locks &= ~(rtm->rtm_inits); @@ -502,22 +522,26 @@ m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len); Free(rtm); } - if (rp) - rp->rcb_proto.sp_family = 0; /* Avoid us */ - if (dst) - route_proto.sp_protocol = dst->sa_family; - if (m) - raw_input(m, &route_proto, &route_src, &route_dst); - if (rp) - rp->rcb_proto.sp_family = PF_ROUTE; + if (m) { + if (rp) { + /* + * XXX insure we don't get a copy by + * invalidating our protocol + */ + unsigned short family = rp->rcb_proto.sp_family; + rp->rcb_proto.sp_family = 0; + rt_dispatch(m, info.rti_info[RTAX_DST]); + rp->rcb_proto.sp_family = family; + } else + rt_dispatch(m, info.rti_info[RTAX_DST]); + } } return (error); +#undef sa_equal } static void -rt_setmetrics(which, in, out) - u_long which; - register struct rt_metrics *in, *out; +rt_setmetrics(u_long which, struct rt_metrics *in, struct rt_metrics *out) { #define metric(f, e) if (which & (f)) out->e = in->e; metric(RTV_RPIPE, rmx_recvpipe); @@ -533,33 +557,28 @@ #define ROUNDUP(a) \ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) -#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) - /* * Extract the addresses of the passed sockaddrs. * Do a little sanity checking so as to avoid bad memory references. * This data is derived straight from userland. */ static int -rt_xaddrs(cp, cplim, rtinfo) - register caddr_t cp, cplim; - register struct rt_addrinfo *rtinfo; +rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo) { +#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) register struct sockaddr *sa; register int i; - for (i = 0; (i < RTAX_MAX) && (cp < cplim); i++) { + for (i = 0; i < RTAX_MAX && cp < cplim; i++) { if ((rtinfo->rti_addrs & (1 << i)) == 0) continue; sa = (struct sockaddr *)cp; /* * It won't fit. */ - if ( (cp + sa->sa_len) > cplim ) { + if (cp + sa->sa_len > cplim) return (EINVAL); - } - /* * there are no more.. quit now * If there are more bits, they are in error. @@ -571,18 +590,16 @@ rtinfo->rti_info[i] = &sa_zero; return (0); /* should be EINVAL but for compat */ } - /* accept it */ rtinfo->rti_info[i] = sa; ADVANCE(cp, sa); } return (0); +#undef ADVANCE } static struct mbuf * -rt_msg1(type, rtinfo) - int type; - register struct rt_addrinfo *rtinfo; +rt_msg1(int type, struct rt_addrinfo *rtinfo) { register struct rt_msghdr *rtm; register struct mbuf *m; @@ -648,11 +665,7 @@ } static int -rt_msg2(type, rtinfo, cp, w) - int type; - register struct rt_addrinfo *rtinfo; - caddr_t cp; - struct walkarg *w; +rt_msg2(int type, struct rt_addrinfo *rtinfo, caddr_t cp, struct walkarg *w) { register int i; int len, dlen, second_time = 0; @@ -727,12 +740,10 @@ * destination. */ void -rt_missmsg(type, rtinfo, flags, error) - int type, flags, error; - register struct rt_addrinfo *rtinfo; +rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, int error) { - register struct rt_msghdr *rtm; - register struct mbuf *m; + struct rt_msghdr *rtm; + struct mbuf *m; struct sockaddr *sa = rtinfo->rti_info[RTAX_DST]; if (route_cb.any_count == 0) @@ -744,8 +755,7 @@ rtm->rtm_flags = RTF_DONE | flags; rtm->rtm_errno = error; rtm->rtm_addrs = rtinfo->rti_addrs; - route_proto.sp_protocol = sa ? sa->sa_family : 0; - raw_input(m, &route_proto, &route_src, &route_dst); + rt_dispatch(m, sa); } /* @@ -753,10 +763,9 @@ * socket indicating that the status of a network interface has changed. */ void -rt_ifmsg(ifp) - register struct ifnet *ifp; +rt_ifmsg(struct ifnet *ifp) { - register struct if_msghdr *ifm; + struct if_msghdr *ifm; struct mbuf *m; struct rt_addrinfo info; @@ -771,8 +780,7 @@ ifm->ifm_flags = ifp->if_flags; ifm->ifm_data = ifp->if_data; ifm->ifm_addrs = 0; - route_proto.sp_protocol = 0; - raw_input(m, &route_proto, &route_src, &route_dst); + rt_dispatch(m, NULL); } /* @@ -784,10 +792,7 @@ * copies of it. */ void -rt_newaddrmsg(cmd, ifa, error, rt) - int cmd, error; - register struct ifaddr *ifa; - register struct rtentry *rt; +rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt) { struct rt_addrinfo info; struct sockaddr *sa = 0; @@ -804,10 +809,10 @@ register struct ifa_msghdr *ifam; int ncmd = cmd == RTM_ADD ? RTM_NEWADDR : RTM_DELADDR; - ifaaddr = sa = ifa->ifa_addr; - ifpaddr = TAILQ_FIRST(&ifp->if_addrhead)->ifa_addr; - netmask = ifa->ifa_netmask; - brdaddr = ifa->ifa_dstaddr; + info.rti_info[RTAX_IFA] = sa = ifa->ifa_addr; + info.rti_info[RTAX_IFP] = TAILQ_FIRST(&ifp->if_addrhead)->ifa_addr; + info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask; + info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr; if ((m = rt_msg1(ncmd, &info)) == NULL) continue; ifam = mtod(m, struct ifa_msghdr *); @@ -822,9 +827,9 @@ if (rt == 0) continue; - netmask = rt_mask(rt); - dst = sa = rt_key(rt); - gate = rt->rt_gateway; + info.rti_info[RTAX_NETMASK] = rt_mask(rt); + info.rti_info[RTAX_DST] = sa = rt_key(rt); + info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; if ((m = rt_msg1(cmd, &info)) == NULL) continue; rtm = mtod(m, struct rt_msghdr *); @@ -833,8 +838,7 @@ rtm->rtm_errno = error; rtm->rtm_addrs = info.rti_addrs; } - route_proto.sp_protocol = sa ? sa->sa_family : 0; - raw_input(m, &route_proto, &route_src, &route_dst); + rt_dispatch(m, sa); } } @@ -844,9 +848,7 @@ * there is no route state to worry about. */ void -rt_newmaddrmsg(cmd, ifma) - int cmd; - struct ifmultiaddr *ifma; +rt_newmaddrmsg(int cmd, struct ifmultiaddr *ifma) { struct rt_addrinfo info; struct mbuf *m = 0; @@ -857,23 +859,24 @@ return; bzero((caddr_t)&info, sizeof(info)); - ifaaddr = ifma->ifma_addr; + info.rti_info[RTAX_IFA] = ifma->ifma_addr; if (ifp && TAILQ_FIRST(&ifp->if_addrhead)) - ifpaddr = TAILQ_FIRST(&ifp->if_addrhead)->ifa_addr; + info.rti_info[RTAX_IFP] = + TAILQ_FIRST(&ifp->if_addrhead)->ifa_addr; else - ifpaddr = NULL; + info.rti_info[RTAX_IFP] = NULL; /* * If a link-layer address is present, present it as a ``gateway'' * (similarly to how ARP entries, e.g., are presented). */ - gate = ifma->ifma_lladdr; - if ((m = rt_msg1(cmd, &info)) == NULL) + info.rti_info[RTAX_GATEWAY] = ifma->ifma_lladdr; + m = rt_msg1(cmd, &info); + if (m == NULL) return; ifmam = mtod(m, struct ifma_msghdr *); ifmam->ifmam_index = ifp->if_index; ifmam->ifmam_addrs = info.rti_addrs; - route_proto.sp_protocol = ifma->ifma_addr->sa_family; - raw_input(m, &route_proto, &route_src, &route_dst); + rt_dispatch(m, ifma->ifma_addr); } /* @@ -881,9 +884,7 @@ * network interface arrival and departure. */ void -rt_ifannouncemsg(ifp, what) - struct ifnet *ifp; - int what; +rt_ifannouncemsg(struct ifnet *ifp, int what) { struct if_announcemsghdr *ifan; struct mbuf *m; @@ -900,39 +901,47 @@ snprintf(ifan->ifan_name, sizeof(ifan->ifan_name), "%s%d", ifp->if_name, ifp->if_unit); ifan->ifan_what = what; - route_proto.sp_protocol = 0; + rt_dispatch(m, NULL); + } + +static void +rt_dispatch(struct mbuf *m, struct sockaddr *sa) +{ + struct sockproto route_proto; + + route_proto.sp_family = PF_ROUTE; + route_proto.sp_protocol = sa ? sa->sa_family : 0; raw_input(m, &route_proto, &route_src, &route_dst); - } +} /* * This is used in dumping the kernel table via sysctl(). */ static int -sysctl_dumpentry(rn, vw) - struct radix_node *rn; - void *vw; +sysctl_dumpentry(struct radix_node *rn, void *vw) { - register struct walkarg *w = vw; - register struct rtentry *rt = (struct rtentry *)rn; + struct walkarg *w = vw; + struct rtentry *rt = (struct rtentry *)rn; int error = 0, size; struct rt_addrinfo info; if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg)) return 0; bzero((caddr_t)&info, sizeof(info)); - dst = rt_key(rt); - gate = rt->rt_gateway; - netmask = rt_mask(rt); - genmask = rt->rt_genmask; + info.rti_info[RTAX_DST] = rt_key(rt); + info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; + info.rti_info[RTAX_NETMASK] = rt_mask(rt); + info.rti_info[RTAX_GENMASK] = rt->rt_genmask; if (rt->rt_ifp) { - ifpaddr = TAILQ_FIRST(&rt->rt_ifp->if_addrhead)->ifa_addr; - ifaaddr = rt->rt_ifa->ifa_addr; + info.rti_info[RTAX_IFP] = + TAILQ_FIRST(&rt->rt_ifp->if_addrhead)->ifa_addr; + info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; if (rt->rt_ifp->if_flags & IFF_POINTOPOINT) - brdaddr = rt->rt_ifa->ifa_dstaddr; + info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; } size = rt_msg2(RTM_GET, &info, 0, w); if (w->w_req && w->w_tmem) { - register struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem; + struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem; rtm->rtm_flags = rt->rt_flags; rtm->rtm_use = rt->rt_use; @@ -947,14 +956,12 @@ } static int -sysctl_iflist(af, w) - int af; - register struct walkarg *w; +sysctl_iflist(int af, struct walkarg *w) { - register struct ifnet *ifp; - register struct ifaddr *ifa; - struct rt_addrinfo info; - int len, error = 0; + struct ifnet *ifp; + struct ifaddr *ifa; + struct rt_addrinfo info; + int len, error = 0; bzero((caddr_t)&info, sizeof(info)); /* IFNET_RLOCK(); */ /* could sleep XXX */ @@ -962,11 +969,11 @@ if (w->w_arg && w->w_arg != ifp->if_index) continue; ifa = TAILQ_FIRST(&ifp->if_addrhead); - ifpaddr = ifa->ifa_addr; + info.rti_info[RTAX_IFP] = ifa->ifa_addr; len = rt_msg2(RTM_IFINFO, &info, (caddr_t)0, w); - ifpaddr = 0; + info.rti_info[RTAX_IFP] = 0; if (w->w_req && w->w_tmem) { - register struct if_msghdr *ifm; + struct if_msghdr *ifm; ifm = (struct if_msghdr *)w->w_tmem; ifm->ifm_index = ifp->if_index; @@ -983,12 +990,12 @@ if (jailed(curthread->td_ucred) && prison_if(curthread->td_ucred, ifa->ifa_addr)) continue; - ifaaddr = ifa->ifa_addr; - netmask = ifa->ifa_netmask; - brdaddr = ifa->ifa_dstaddr; + info.rti_info[RTAX_IFA] = ifa->ifa_addr; + info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask; + info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr; len = rt_msg2(RTM_NEWADDR, &info, 0, w); if (w->w_req && w->w_tmem) { - register struct ifa_msghdr *ifam; + struct ifa_msghdr *ifam; ifam = (struct ifa_msghdr *)w->w_tmem; ifam->ifam_index = ifa->ifa_ifp->if_index; @@ -1000,7 +1007,8 @@ goto done; } } - ifaaddr = netmask = brdaddr = 0; + info.rti_info[RTAX_IFA] = info.rti_info[RTAX_NETMASK] = + info.rti_info[RTAX_BRD] = 0; } done: /* IFNET_RUNLOCK(); */ /* XXX */ @@ -1012,7 +1020,7 @@ { int *name = (int *)arg1; u_int namelen = arg2; - register struct radix_node_head *rnh; + struct radix_node_head *rnh; int i, s, error = EINVAL; u_char af; struct walkarg w;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200309302117.h8ULHKTX024604>