I find it really difficult to understand and work with the code of
rtsock.c because of the following defines:


        /* Sleazy use of local variables throughout file, warning!!!! */
        #define dst    info.rti_info[RTAX_DST]
        #define gate   info.rti_info[RTAX_GATEWAY]
        ...

But since this code is a mess, simply removing these defines makes it
harder to understand.  So the diff below introduces other defines to
make it clear that we manipulate a rt_addrinfo structure while
preserving the readability:

        #define rti_dst        rti_info[RTAX_DST]
        #define rti_gate       rti_info[RTAX_GATEWAY]
        ...

I converted rtsock.c and route.c and there's no object change with this
diff.  I'll happily convert the remaining files after putting this in.

Comments, ok?

Index: net/route.c
===================================================================
RCS file: /home/ncvs/src/sys/net/route.c,v
retrieving revision 1.147
diff -u -p -r1.147 route.c
--- net/route.c 20 Oct 2013 13:21:57 -0000      1.147
+++ net/route.c 8 Jan 2014 10:47:40 -0000
@@ -325,7 +325,7 @@ rtalloc1(struct sockaddr *dst, int flags
        int                      s = splsoftnet(), err = 0, msgtype = RTM_MISS;
 
        bzero(&info, sizeof(info));
-       info.rti_info[RTAX_DST] = dst;
+       info.rti_dst = dst;
 
        rnh = rt_gettable(dst->sa_family, tableid);
        if (rnh && (rn = rnh->rnh_matchaddr((caddr_t)dst, rnh)) &&
@@ -346,13 +346,13 @@ rtalloc1(struct sockaddr *dst, int flags
                        }
                        /* Inform listeners of the new route */
                        bzero(&info, sizeof(info));
-                       info.rti_info[RTAX_DST] = rt_key(rt);
-                       info.rti_info[RTAX_NETMASK] = rt_mask(rt);
-                       info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
+                       info.rti_dst = rt_key(rt);
+                       info.rti_mask = rt_mask(rt);
+                       info.rti_gate = rt->rt_gateway;
                        if (rt->rt_ifp != NULL) {
-                               info.rti_info[RTAX_IFP] =
+                               info.rti_ifpaddr =
                                    
TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr;
-                               info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
+                               info.rti_ifaaddr = rt->rt_ifa->ifa_addr;
                        }
                        rt_missmsg(RTM_ADD, &info, rt->rt_flags,
                            rt->rt_ifp, 0, tableid);
@@ -369,7 +369,7 @@ rtalloc1(struct sockaddr *dst, int flags
 miss:
                if (ISSET(flags, RT_REPORT) && dst->sa_family != PF_KEY) {
                        bzero((caddr_t)&info, sizeof(info));
-                       info.rti_info[RTAX_DST] = dst;
+                       info.rti_dst = dst;
                        rt_missmsg(msgtype, &info, 0, NULL, err, tableid);
                }
        }
@@ -490,9 +490,9 @@ create:
                                rtfree(rt);
                        flags |= RTF_GATEWAY | RTF_DYNAMIC;
                        bzero(&info, sizeof(info));
-                       info.rti_info[RTAX_DST] = dst;
-                       info.rti_info[RTAX_GATEWAY] = gateway;
-                       info.rti_info[RTAX_NETMASK] = netmask;
+                       info.rti_dst = dst;
+                       info.rti_gate = gateway;
+                       info.rti_mask = netmask;
                        info.rti_ifa = ifa;
                        info.rti_flags = flags;
                        rt = NULL;
@@ -526,10 +526,10 @@ out:
        else if (stat != NULL)
                (*stat)++;
        bzero((caddr_t)&info, sizeof(info));
-       info.rti_info[RTAX_DST] = dst;
-       info.rti_info[RTAX_GATEWAY] = gateway;
-       info.rti_info[RTAX_NETMASK] = netmask;
-       info.rti_info[RTAX_AUTHOR] = src;
+       info.rti_dst = dst;
+       info.rti_gate = gateway;
+       info.rti_mask = netmask;
+       info.rti_author = src;
        rt_missmsg(RTM_REDIRECT, &info, flags, ifp, error, rdomain);
 }
 
@@ -549,9 +549,9 @@ rtdeletemsg(struct rtentry *rt, u_int ta
         * be accurate (and consistent with route_output()).
         */
        bzero((caddr_t)&info, sizeof(info));
-       info.rti_info[RTAX_DST] = rt_key(rt);
-       info.rti_info[RTAX_NETMASK] = rt_mask(rt);
-       info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
+       info.rti_dst = rt_key(rt);
+       info.rti_mask = rt_mask(rt);
+       info.rti_gate = rt->rt_gateway;
        info.rti_flags = rt->rt_flags;
        ifp = rt->rt_ifp;
        error = rtrequest1(RTM_DELETE, &info, rt->rt_priority, &rt, tableid);
@@ -669,30 +669,27 @@ rt_getifa(struct rt_addrinfo *info, u_in
         * ifp may be specified by sockaddr_dl when protocol address
         * is ambiguous
         */
-       if (info->rti_ifp == NULL && info->rti_info[RTAX_IFP] != NULL
-           && info->rti_info[RTAX_IFP]->sa_family == AF_LINK &&
-           (ifa = ifa_ifwithnet((struct sockaddr *)info->rti_info[RTAX_IFP],
+       if (info->rti_ifp == NULL && info->rti_ifpaddr != NULL
+           && info->rti_ifpaddr->sa_family == AF_LINK &&
+           (ifa = ifa_ifwithnet((struct sockaddr *)info->rti_ifpaddr,
            rtid)) != NULL)
                info->rti_ifp = ifa->ifa_ifp;
 
-       if (info->rti_ifa == NULL && info->rti_info[RTAX_IFA] != NULL)
-               info->rti_ifa = ifa_ifwithaddr(info->rti_info[RTAX_IFA], rtid);
+       if (info->rti_ifa == NULL && info->rti_ifaaddr != NULL)
+               info->rti_ifa = ifa_ifwithaddr(info->rti_ifaaddr, rtid);
 
        if (info->rti_ifa == NULL) {
                struct sockaddr *sa;
 
-               if ((sa = info->rti_info[RTAX_IFA]) == NULL)
-                       if ((sa = info->rti_info[RTAX_GATEWAY]) == NULL)
-                               sa = info->rti_info[RTAX_DST];
+               if ((sa = info->rti_ifaaddr) == NULL)
+                       if ((sa = info->rti_gate) == NULL)
+                               sa = info->rti_dst;
 
                if (sa != NULL && info->rti_ifp != NULL)
                        info->rti_ifa = ifaof_ifpforaddr(sa, info->rti_ifp);
-               else if (info->rti_info[RTAX_DST] != NULL &&
-                   info->rti_info[RTAX_GATEWAY] != NULL)
+               else if (info->rti_dst != NULL && info->rti_gate != NULL)
                        info->rti_ifa = ifa_ifwithroute(info->rti_flags,
-                           info->rti_info[RTAX_DST],
-                           info->rti_info[RTAX_GATEWAY],
-                           rtid);
+                           info->rti_dst, info->rti_gate, rtid);
                else if (sa != NULL)
                        info->rti_ifa = ifa_ifwithroute(info->rti_flags,
                            sa, sa, rtid);
@@ -723,32 +720,30 @@ rtrequest1(int req, struct rt_addrinfo *
 #endif
 #define senderr(x) { error = x ; goto bad; }
 
-       if ((rnh = rt_gettable(info->rti_info[RTAX_DST]->sa_family, tableid)) ==
-           NULL)
+       if ((rnh = rt_gettable(info->rti_dst->sa_family, tableid)) == NULL)
                senderr(EAFNOSUPPORT);
        if (info->rti_flags & RTF_HOST)
-               info->rti_info[RTAX_NETMASK] = NULL;
+               info->rti_mask = NULL;
        switch (req) {
        case RTM_DELETE:
-               if ((rn = rnh->rnh_lookup(info->rti_info[RTAX_DST],
-                   info->rti_info[RTAX_NETMASK], rnh)) == NULL)
+               rn = rnh->rnh_lookup(info->rti_dst, info->rti_mask, rnh);
+               if (rn == NULL)
                        senderr(ESRCH);
                rt = (struct rtentry *)rn;
 #ifndef SMALL_KERNEL
                /*
                 * if we got multipath routes, we require users to specify
-                * a matching RTAX_GATEWAY.
+                * a matching rti_gate.
                 */
                if (rn_mpath_capable(rnh)) {
-                       rt = rt_mpath_matchgate(rt,
-                           info->rti_info[RTAX_GATEWAY], prio);
+                       rt = rt_mpath_matchgate(rt, info->rti_gate, prio);
                        rn = (struct radix_node *)rt;
                        if (!rt)
                                senderr(ESRCH);
                }
 #endif
-               if ((rn = rnh->rnh_deladdr(info->rti_info[RTAX_DST],
-                   info->rti_info[RTAX_NETMASK], rnh, rn)) == NULL)
+               if ((rn = rnh->rnh_deladdr(info->rti_dst,
+                   info->rti_mask, rnh, rn)) == NULL)
                        senderr(ESRCH);
                rt = (struct rtentry *)rn;
 
@@ -771,8 +766,8 @@ rtrequest1(int req, struct rt_addrinfo *
 
 #ifndef SMALL_KERNEL
                if (rn_mpath_capable(rnh)) {
-                       if ((rn = rnh->rnh_lookup(info->rti_info[RTAX_DST],
-                           info->rti_info[RTAX_NETMASK], rnh)) != NULL &&
+                       if ((rn = rnh->rnh_lookup(info->rti_dst,
+                           info->rti_mask, rnh)) != NULL &&
                            rt_mpath_next((struct rtentry *)rn) == NULL)
                                ((struct rtentry *)rn)->rt_flags &= ~RTF_MPATH;
                }
@@ -807,16 +802,15 @@ rtrequest1(int req, struct rt_addrinfo *
                         * will get the new address and interface later.
                         */
                        info->rti_ifa = NULL;
-                       info->rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
+                       info->rti_ifaaddr = rt->rt_ifa->ifa_addr;
                }
                info->rti_ifp = rt->rt_ifp;
                info->rti_flags = rt->rt_flags & ~(RTF_CLONING | RTF_STATIC);
                info->rti_flags |= RTF_CLONED;
-               info->rti_info[RTAX_GATEWAY] = rt->rt_gateway;
-               if ((info->rti_info[RTAX_NETMASK] = rt->rt_genmask) == NULL)
+               info->rti_gate = rt->rt_gateway;
+               if ((info->rti_mask = rt->rt_genmask) == NULL)
                        info->rti_flags |= RTF_HOST;
-               info->rti_info[RTAX_LABEL] =
-                   rtlabel_id2sa(rt->rt_labelid, &sa_rl2);
+               info->rti_label = rtlabel_id2sa(rt->rt_labelid, &sa_rl2);
                /* FALLTHROUGH */
 
        case RTM_ADD:
@@ -833,23 +827,23 @@ rtrequest1(int req, struct rt_addrinfo *
                        prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
                rt->rt_priority = prio; /* init routing priority */
                LIST_INIT(&rt->rt_timer);
-               if (rt_setgate(rt, info->rti_info[RTAX_DST],
-                   info->rti_info[RTAX_GATEWAY], tableid)) {
+               if (rt_setgate(rt, info->rti_dst,
+                   info->rti_gate, tableid)) {
                        pool_put(&rtentry_pool, rt);
                        senderr(ENOBUFS);
                }
                ndst = rt_key(rt);
-               if (info->rti_info[RTAX_NETMASK] != NULL) {
-                       rt_maskedcopy(info->rti_info[RTAX_DST], ndst,
-                           info->rti_info[RTAX_NETMASK]);
+               if (info->rti_mask != NULL) {
+                       rt_maskedcopy(info->rti_dst, ndst,
+                           info->rti_mask);
                } else
-                       Bcopy(info->rti_info[RTAX_DST], ndst,
-                           info->rti_info[RTAX_DST]->sa_len);
+                       Bcopy(info->rti_dst, ndst,
+                           info->rti_dst->sa_len);
 #ifndef SMALL_KERNEL
                if (rn_mpath_capable(rnh)) {
                        /* do not permit exactly the same dst/mask/gw pair */
                        if (rt_mpath_conflict(rnh, rt,
-                           info->rti_info[RTAX_NETMASK],
+                           info->rti_mask,
                            info->rti_flags & RTF_MPATH)) {
                                if (rt->rt_gwroute)
                                        rtfree(rt->rt_gwroute);
@@ -868,21 +862,19 @@ rtrequest1(int req, struct rt_addrinfo *
                }
 #endif
 
-               if (info->rti_info[RTAX_LABEL] != NULL) {
-                       sa_rl = (struct sockaddr_rtlabel *)
-                           info->rti_info[RTAX_LABEL];
+               if (info->rti_label != NULL) {
+                       sa_rl = (struct sockaddr_rtlabel *)info->rti_label;
                        rt->rt_labelid = rtlabel_name2id(sa_rl->sr_label);
                }
 
 #ifdef MPLS
                /* We have to allocate additional space for MPLS infos */ 
                if (info->rti_flags & RTF_MPLS &&
-                   (info->rti_info[RTAX_SRC] != NULL ||
-                   info->rti_info[RTAX_DST]->sa_family == AF_MPLS)) {
+                   (info->rti_src != NULL ||
+                   info->rti_dst->sa_family == AF_MPLS)) {
                        struct rt_mpls *rt_mpls;
 
-                       sa_mpls = (struct sockaddr_mpls *)
-                           info->rti_info[RTAX_SRC];
+                       sa_mpls = (struct sockaddr_mpls *)info->rti_src;
 
                        rt->rt_llinfo = (caddr_t)malloc(sizeof(struct rt_mpls),
                            M_TEMP, M_NOWAIT|M_ZERO);
@@ -942,14 +934,14 @@ rtrequest1(int req, struct rt_addrinfo *
                        rt->rt_parent->rt_refcnt++;
                }
                rn = rnh->rnh_addaddr((caddr_t)ndst,
-                   (caddr_t)info->rti_info[RTAX_NETMASK], rnh, rt->rt_nodes,
+                   (caddr_t)info->rti_mask, rnh, rt->rt_nodes,
                    rt->rt_priority);
                if (rn == NULL && (crt = rtalloc1(ndst, 0, tableid)) != NULL) {
                        /* overwrite cloned route */
                        if ((crt->rt_flags & RTF_CLONED) != 0) {
                                rtdeletemsg(crt, tableid);
                                rn = rnh->rnh_addaddr((caddr_t)ndst,
-                                   (caddr_t)info->rti_info[RTAX_NETMASK],
+                                   (caddr_t)info->rti_mask,
                                    rnh, rt->rt_nodes, rt->rt_priority);
                        }
                        RTFREE(crt);
@@ -967,8 +959,8 @@ rtrequest1(int req, struct rt_addrinfo *
 
 #ifndef SMALL_KERNEL
                if (rn_mpath_capable(rnh) &&
-                   (rn = rnh->rnh_lookup(info->rti_info[RTAX_DST],
-                   info->rti_info[RTAX_NETMASK], rnh)) != NULL &&
+                   (rn = rnh->rnh_lookup(info->rti_dst,
+                   info->rti_mask, rnh)) != NULL &&
                    (rn = rn_mpath_prio(rn, prio)) != NULL) {
                        if (rt_mpath_next((struct rtentry *)rn) == NULL)
                                ((struct rtentry *)rn)->rt_flags &= ~RTF_MPATH;
@@ -988,8 +980,8 @@ rtrequest1(int req, struct rt_addrinfo *
                        rtflushclone(rnh, rt);
                }
 
-               if_group_routechange(info->rti_info[RTAX_DST],
-                       info->rti_info[RTAX_NETMASK]);
+               if_group_routechange(info->rti_dst,
+                       info->rti_mask);
                break;
        }
 bad:
@@ -1105,11 +1097,10 @@ rtinit(struct ifaddr *ifa, int cmd, int 
        bzero(&info, sizeof(info));
        info.rti_ifa = ifa;
        info.rti_flags = flags | ifa->ifa_flags;
-       info.rti_info[RTAX_DST] = dst;
+       info.rti_dst = dst;
        if (cmd == RTM_ADD)
-               info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
-       info.rti_info[RTAX_LABEL] =
-           rtlabel_id2sa(ifa->ifa_ifp->if_rtlabelid, &sa_rl);
+               info.rti_gate = ifa->ifa_addr;
+       info.rti_label = rtlabel_id2sa(ifa->ifa_ifp->if_rtlabelid, &sa_rl);
 
        /*
         * XXX here, it seems that we are assuming that ifa_netmask is NULL
@@ -1117,7 +1108,7 @@ rtinit(struct ifaddr *ifa, int cmd, int 
         * variable) when RTF_HOST is 1.  still not sure if i can safely
         * change it to meet bsdi4 behavior.
         */
-       info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
+       info.rti_mask = ifa->ifa_netmask;
        error = rtrequest1(cmd, &info, RTP_CONNECTED, &nrt, rtableid);
        if (cmd == RTM_DELETE) {
                if (error == 0 && (rt = nrt) != NULL) {
@@ -1167,7 +1158,7 @@ static int                        rt_init_done = 0;
        } else {                                                \
                struct rt_addrinfo info;                        \
                bzero(&info, sizeof(info));                     \
-               info.rti_info[RTAX_DST] = rt_key(r->rtt_rt);    \
+               info.rti_dst = rt_key(r->rtt_rt);               \
                rtrequest1(RTM_DELETE, &info,                   \
                    r->rtt_rt->rt_priority, NULL, r->rtt_tableid);      \
        }                                                       \
Index: net/route.h
===================================================================
RCS file: /home/ncvs/src/sys/net/route.h,v
retrieving revision 1.83
diff -u -p -r1.83 route.h
--- net/route.h 31 Oct 2013 18:10:21 -0000      1.83
+++ net/route.h 8 Jan 2014 10:47:40 -0000
@@ -339,6 +339,17 @@ struct route {
 struct rt_addrinfo {
        int     rti_addrs;
        struct  sockaddr *rti_info[RTAX_MAX];
+#define rti_dst                rti_info[RTAX_DST]
+#define rti_gate       rti_info[RTAX_GATEWAY]
+#define rti_mask       rti_info[RTAX_NETMASK]
+#define rti_genmask    rti_info[RTAX_GENMASK]
+#define rti_ifpaddr    rti_info[RTAX_IFP]
+#define rti_ifaaddr    rti_info[RTAX_IFA]   
+#define rti_author     rti_info[RTAX_AUTHOR]
+#define rti_brdaddr    rti_info[RTAX_BRD]
+#define rti_src                rti_info[RTAX_SRC]   
+#define rti_label      rti_info[RTAX_LABEL]
+
        int     rti_flags;
        struct  ifaddr *rti_ifa;
        struct  ifnet *rti_ifp;
Index: net/rtsock.c
===================================================================
RCS file: /home/ncvs/src/sys/net/rtsock.c,v
retrieving revision 1.131
diff -u -p -r1.131 rtsock.c
--- net/rtsock.c        1 Nov 2013 20:09:14 -0000       1.131
+++ net/rtsock.c        8 Jan 2014 10:47:40 -0000
@@ -107,15 +107,6 @@ struct rt_omsghdr *rtmsg_5to4(struct rt_
 void rt_ogetmetrics(struct rt_kmetrics *in, struct rt_ometrics *out);
 #endif /* RTM_OVERSION */
 
-/* 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]
-
 struct routecb {
        struct rawcb    rcb;
        struct timeout  timeout;
@@ -474,7 +465,7 @@ route_output(struct mbuf *m, ...)
        so = va_arg(ap, struct socket *);
        va_end(ap);
 
-       dst = NULL;     /* for error handling (goto flush) */
+       info.rti_dst = NULL;    /* for error handling (goto flush) */
        if (m == 0 || ((m->m_len < sizeof(int32_t)) &&
            (m = m_pullup(m, sizeof(int32_t))) == 0))
                return (ENOBUFS);
@@ -588,19 +579,19 @@ route_output(struct mbuf *m, ...)
        info.rti_addrs = rtm->rtm_addrs;
        rt_xaddrs(rtm->rtm_hdrlen + (caddr_t)rtm, len + (caddr_t)rtm, &info);
        info.rti_flags = rtm->rtm_flags;
-       if (dst == 0 || dst->sa_family >= AF_MAX ||
-           (gate != 0 && gate->sa_family >= AF_MAX)) {
+       if (info.rti_dst == NULL || info.rti_dst->sa_family >= AF_MAX ||
+           (info.rti_gate != 0 && info.rti_gate->sa_family >= AF_MAX)) {
                error = EINVAL;
                goto flush;
        }
-       if (genmask) {
+       if (info.rti_genmask) {
                struct radix_node       *t;
-               t = rn_addmask(genmask, 0, 1);
-               if (t && genmask->sa_len >=
+               t = rn_addmask(info.rti_genmask, 0, 1);
+               if (t && info.rti_genmask->sa_len >=
                    ((struct sockaddr *)t->rn_key)->sa_len &&
-                   Bcmp((caddr_t *)genmask + 1, (caddr_t *)t->rn_key + 1,
+                   Bcmp((caddr_t *)info.rti_genmask + 1, (caddr_t *)t->rn_key 
+ 1,
                    ((struct sockaddr *)t->rn_key)->sa_len) - 1)
-                       genmask = (struct sockaddr *)(t->rn_key);
+                       info.rti_genmask = (struct sockaddr *)(t->rn_key);
                else {
                        error = ENOBUFS;
                        goto flush;
@@ -612,7 +603,7 @@ route_output(struct mbuf *m, ...)
 
        switch (rtm->rtm_type) {
        case RTM_ADD:
-               if (gate == 0) {
+               if (info.rti_gate == 0) {
                        error = EINVAL;
                        goto flush;
                }
@@ -622,7 +613,7 @@ route_output(struct mbuf *m, ...)
                        rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx,
                            &saved_nrt->rt_rmx);
                        saved_nrt->rt_refcnt--;
-                       saved_nrt->rt_genmask = genmask;
+                       saved_nrt->rt_genmask = info.rti_genmask;
                        /* write back the priority the kernel used */
                        rtm->rtm_priority = saved_nrt->rt_priority & RTP_MASK;
                        rtm->rtm_index = saved_nrt->rt_ifp->if_index;
@@ -640,11 +631,12 @@ route_output(struct mbuf *m, ...)
        case RTM_GET:
        case RTM_CHANGE:
        case RTM_LOCK:
-               if ((rnh = rt_gettable(dst->sa_family, tableid)) == NULL) {
+               rnh = rt_gettable(info.rti_dst->sa_family, tableid);
+               if (rnh == NULL) {
                        error = EAFNOSUPPORT;
                        goto flush;
                }
-               rt = rt_lookup(dst, netmask, tableid);
+               rt = rt_lookup(info.rti_dst, info.rti_mask, tableid);
                rn = (struct radix_node *)rt;
                if (rn == NULL || (rn->rn_flags & RNF_ROOT) != 0) {
                        error = ESRCH;
@@ -673,22 +665,23 @@ route_output(struct mbuf *m, ...)
 
                        /* if multipath routes */
                        if (rt_mpath_next(rt)) { /* XXX ignores down routes */
-                               if (gate)
-                                       rt = rt_mpath_matchgate(rt, gate, prio);
+                               if (info.rti_gate)
+                                       rt = rt_mpath_matchgate(rt,
+                                           info.rti_gate, prio);
                                else if (rtm->rtm_type != RTM_GET)
                                        /*
                                         * only RTM_GET may use an empty gate
                                         * on multipath ...
                                         */
                                        rt = NULL;
-                       } else if (gate && (rtm->rtm_type == RTM_GET ||
+                       } else if (info.rti_gate && (rtm->rtm_type == RTM_GET ||
                            rtm->rtm_type == RTM_LOCK))
                                /*
                                 * ... but if a gate is specified RTM_GET
                                 * and RTM_LOCK must match the gate no matter
                                 * what.
                                 */
-                               rt = rt_mpath_matchgate(rt, gate, prio);
+                               rt = rt_mpath_matchgate(rt, info.rti_gate, 
prio);
 
                        if (!rt) {
                                error = ESRCH;
@@ -708,7 +701,7 @@ route_output(struct mbuf *m, ...)
                 * if none of them have a netmask both are host routes which is
                 * also a perfect match.
                 */
-               if (rtm->rtm_type != RTM_GET && !rt_mask(rt) != !netmask) {
+               if (rtm->rtm_type != RTM_GET && !rt_mask(rt) != !info.rti_mask) 
{
                        error = ESRCH;
                        goto flush;
                }
@@ -716,10 +709,10 @@ route_output(struct mbuf *m, ...)
                switch (rtm->rtm_type) {
                case RTM_GET:
 report:
-                       dst = rt_key(rt);
-                       gate = rt->rt_gateway;
-                       netmask = rt_mask(rt);
-                       genmask = rt->rt_genmask;
+                       info.rti_dst = rt_key(rt);
+                       info.rti_gate = rt->rt_gateway;
+                       info.rti_mask = rt_mask(rt);
+                       info.rti_genmask = rt->rt_genmask;
 
                        if (rt->rt_labelid) {
                                bzero(&sa_rt, sizeof(sa_rt));
@@ -728,8 +721,7 @@ report:
                                if (label != NULL)
                                        strlcpy(sa_rt.sr_label, label,
                                            sizeof(sa_rt.sr_label));
-                               info.rti_info[RTAX_LABEL] =
-                                   (struct sockaddr *)&sa_rt;
+                               info.rti_label = (struct sockaddr *)&sa_rt;
                        }
 #ifdef MPLS
                        if (rt->rt_flags & RTF_MPLS) {
@@ -738,24 +730,24 @@ report:
                                sa_mpls.smpls_len = sizeof(sa_mpls);
                                sa_mpls.smpls_label = ((struct rt_mpls *)
                                    rt->rt_llinfo)->mpls_label;
-                               info.rti_info[RTAX_SRC] =
-                                   (struct sockaddr *)&sa_mpls;
+                               info.rti_src = (struct sockaddr *)&sa_mpls;
                                info.rti_mpls = ((struct rt_mpls *)
                                    rt->rt_llinfo)->mpls_operation;
                                rtm->rtm_mpls = info.rti_mpls;
                        }
 #endif
-                       ifpaddr = 0;
-                       ifaaddr = 0;
+                       info.rti_ifpaddr = 0;
+                       info.rti_ifaaddr = 0;
                        if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA) &&
                            (ifp = rt->rt_ifp) != NULL) {
-                               ifpaddr =
+                               info.rti_ifpaddr =
                                    TAILQ_FIRST(&ifp->if_addrlist)->ifa_addr;
-                               ifaaddr = rt->rt_ifa->ifa_addr;
+                               info.rti_ifaaddr = rt->rt_ifa->ifa_addr;
                                if (ifp->if_flags & IFF_POINTOPOINT)
-                                       brdaddr = rt->rt_ifa->ifa_dstaddr;
+                                       info.rti_brdaddr =
+                                           rt->rt_ifa->ifa_dstaddr;
                                else
-                                       brdaddr = 0;
+                                       info.rti_brdaddr = 0;
                                rtm->rtm_index = ifp->if_index;
                        }
                        len = rt_msg2(rtm->rtm_type, RTM_VERSION, &info, NULL,
@@ -788,23 +780,26 @@ report:
                        if ((error = rt_getifa(&info, tableid)) != 0)
                                goto flush;
                        newgate = 0;
-                       if (gate)
+                       if (info.rti_gate)
                                if (rt->rt_gateway == NULL ||
-                                   bcmp(rt->rt_gateway, gate, gate->sa_len))
+                                   bcmp(rt->rt_gateway, info.rti_gate,
+                                        info.rti_gate->sa_len))
                                        newgate = 1;
-                       if (gate && rt_setgate(rt, rt_key(rt), gate, tableid)) {
+                       if (info.rti_gate &&
+                          rt_setgate(rt, rt_key(rt), info.rti_gate, tableid)) {
                                error = EDQUOT;
                                goto flush;
                        }
-                       if (ifpaddr &&
-                           (ifa = ifa_ifwithnet(ifpaddr, tableid)) &&
-                           (ifp = ifa->ifa_ifp) && (ifaaddr || gate))
-                               ifa = ifaof_ifpforaddr(ifaaddr ? ifaaddr : gate,
-                                   ifp);
-                       else if ((ifaaddr &&
-                           (ifa = ifa_ifwithaddr(ifaaddr, tableid))) ||
-                           (gate && (ifa = ifa_ifwithroute(rt->rt_flags,
-                           rt_key(rt), gate, tableid))))
+                       if (info.rti_ifpaddr &&
+                           (ifa = ifa_ifwithnet(info.rti_ifpaddr, tableid)) &&
+                           (ifp = ifa->ifa_ifp) &&
+                           (info.rti_ifaaddr || info.rti_gate))
+                               ifa = ifaof_ifpforaddr(info.rti_ifaaddr ?
+                                   info.rti_ifaaddr : info.rti_gate, ifp);
+                       else if ((info.rti_ifaaddr &&
+                           (ifa = ifa_ifwithaddr(info.rti_ifaaddr, tableid))) 
||
+                           (info.rti_gate && (ifa = 
ifa_ifwithroute(rt->rt_flags,
+                           rt_key(rt), info.rti_gate, tableid))))
                                ifp = ifa->ifa_ifp;
                        if (ifa) {
                                struct ifaddr *oifa = rt->rt_ifa;
@@ -824,11 +819,11 @@ report:
                        }
 #ifdef MPLS
                        if ((rtm->rtm_flags & RTF_MPLS) &&
-                           info.rti_info[RTAX_SRC] != NULL) {
+                           info.rti_src != NULL) {
                                struct rt_mpls *rt_mpls;
 
                                psa_mpls = (struct sockaddr_mpls *)
-                                   info.rti_info[RTAX_SRC];
+                                   info.rti_src;
 
                                if (rt->rt_llinfo == NULL) {
                                        rt->rt_llinfo = (caddr_t)
@@ -876,16 +871,16 @@ report:
                        rtm->rtm_flags = rt->rt_flags;
                        if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
                                rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt);
-                       if (genmask)
-                               rt->rt_genmask = genmask;
-                       if (info.rti_info[RTAX_LABEL] != NULL) {
+                       if (info.rti_genmask)
+                               rt->rt_genmask = info.rti_genmask;
+                       if (info.rti_label != NULL) {
                                char *rtlabel = ((struct sockaddr_rtlabel *)
-                                   info.rti_info[RTAX_LABEL])->sr_label;
+                                   info.rti_label)->sr_label;
                                rtlabel_unref(rt->rt_labelid);
                                rt->rt_labelid =
                                    rtlabel_name2id(rtlabel);
                        }
-                       if_group_routechange(dst, netmask);
+                       if_group_routechange(info.rti_dst, info.rti_mask);
                        /* FALLTHROUGH */
                case RTM_LOCK:
                        rt->rt_rmx.rmx_locks &= ~(rtm->rtm_inits);
@@ -905,8 +900,8 @@ flush:
                        rtm->rtm_flags |= RTF_DONE;
                }
        }
-       if (dst)
-               route_proto.sp_protocol = dst->sa_family;
+       if (info.rti_dst)
+               route_proto.sp_protocol = info.rti_dst->sa_family;
        if (rt)
                rtfree(rt);
 
@@ -1164,7 +1159,7 @@ rt_missmsg(int type, struct rt_addrinfo 
 {
        struct rt_msghdr        *rtm;
        struct mbuf             *m;
-       struct sockaddr         *sa = rtinfo->rti_info[RTAX_DST];
+       struct sockaddr         *sa = rtinfo->rti_dst;
 
        if (route_cb.any_count == 0)
                return;
@@ -1242,10 +1237,10 @@ rt_newaddrmsg(int cmd, struct ifaddr *if
                        else
                                ncmd = RTM_DELADDR;
 
-                       ifaaddr = sa = ifa->ifa_addr;
-                       ifpaddr = TAILQ_FIRST(&ifp->if_addrlist)->ifa_addr;
-                       netmask = ifa->ifa_netmask;
-                       brdaddr = ifa->ifa_dstaddr;
+                       info.rti_ifaaddr = sa = ifa->ifa_addr;
+                       info.rti_ifpaddr = 
TAILQ_FIRST(&ifp->if_addrlist)->ifa_addr;
+                       info.rti_mask = ifa->ifa_netmask;
+                       info.rti_brdaddr = ifa->ifa_dstaddr;
                        if ((m = rt_msg1(ncmd, &info)) == NULL)
                                continue;
                        ifam = mtod(m, struct ifa_msghdr *);
@@ -1261,9 +1256,9 @@ rt_newaddrmsg(int cmd, struct ifaddr *if
                        
                        if (rt == 0)
                                continue;
-                       netmask = rt_mask(rt);
-                       dst = sa = rt_key(rt);
-                       gate = rt->rt_gateway;
+                       info.rti_mask = rt_mask(rt);
+                       info.rti_dst = sa = rt_key(rt);
+                       info.rti_gate = rt->rt_gateway;
                        if ((m = rt_msg1(cmd, &info)) == NULL)
                                continue;
                        rtm = mtod(m, struct rt_msghdr *);
@@ -1324,15 +1319,15 @@ sysctl_dumpentry(struct radix_node *rn, 
        if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg))
                return 0;
        bzero(&info, sizeof(info));
-       dst = rt_key(rt);
-       gate = rt->rt_gateway;
-       netmask = rt_mask(rt);
-       genmask = rt->rt_genmask;
+       info.rti_dst = rt_key(rt);
+       info.rti_gate = rt->rt_gateway;
+       info.rti_mask = rt_mask(rt);
+       info.rti_genmask = rt->rt_genmask;
        if (rt->rt_ifp) {
-               ifpaddr = TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr;
-               ifaaddr = rt->rt_ifa->ifa_addr;
+               info.rti_ifpaddr = 
TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr;
+               info.rti_ifaaddr = rt->rt_ifa->ifa_addr;
                if (rt->rt_ifp->if_flags & IFF_POINTOPOINT)
-                       brdaddr = rt->rt_ifa->ifa_dstaddr;
+                       info.rti_brdaddr = rt->rt_ifa->ifa_dstaddr;
        }
        if (rt->rt_labelid) {
                bzero(&sa_rt, sizeof(sa_rt));
@@ -1341,8 +1336,7 @@ sysctl_dumpentry(struct radix_node *rn, 
                if (label != NULL) {
                        strlcpy(sa_rt.sr_label, label,
                            sizeof(sa_rt.sr_label));
-                       info.rti_info[RTAX_LABEL] =
-                           (struct sockaddr *)&sa_rt;
+                       info.rti_label = (struct sockaddr *)&sa_rt;
                }
        }
 #ifdef MPLS
@@ -1352,7 +1346,7 @@ sysctl_dumpentry(struct radix_node *rn, 
                sa_mpls.smpls_len = sizeof(sa_mpls);
                sa_mpls.smpls_label = ((struct rt_mpls *)
                    rt->rt_llinfo)->mpls_label;
-               info.rti_info[RTAX_SRC] = (struct sockaddr *)&sa_mpls;
+               info.rti_src = (struct sockaddr *)&sa_mpls;
                info.rti_mpls = ((struct rt_mpls *)
                    rt->rt_llinfo)->mpls_operation;
        }
@@ -1416,7 +1410,7 @@ sysctl_iflist(int af, struct walkarg *w)
                ifa = TAILQ_FIRST(&ifp->if_addrlist);
                if (!ifa)
                        continue;
-               ifpaddr = ifa->ifa_addr;
+               info.rti_ifpaddr = ifa->ifa_addr;
                len = rt_msg2(RTM_IFINFO, RTM_VERSION, &info, 0, w);
                if (w->w_where && w->w_tmem && w->w_needed <= 0) {
                        struct if_msghdr *ifm;
@@ -1449,13 +1443,13 @@ sysctl_iflist(int af, struct walkarg *w)
                        w->w_where += len;
                }
 #endif /* RTM_OVERSION */
-               ifpaddr = 0;
+               info.rti_ifpaddr = 0;
                while ((ifa = TAILQ_NEXT(ifa, ifa_list)) != NULL) {
                        if (af && af != ifa->ifa_addr->sa_family)
                                continue;
-                       ifaaddr = ifa->ifa_addr;
-                       netmask = ifa->ifa_netmask;
-                       brdaddr = ifa->ifa_dstaddr;
+                       info.rti_ifaaddr = ifa->ifa_addr;
+                       info.rti_mask = ifa->ifa_netmask;
+                       info.rti_brdaddr = ifa->ifa_dstaddr;
                        len = rt_msg2(RTM_NEWADDR, RTM_VERSION, &info, 0, w);
                        if (w->w_where && w->w_tmem && w->w_needed <= 0) {
                                struct ifa_msghdr *ifam;
@@ -1487,7 +1481,7 @@ sysctl_iflist(int af, struct walkarg *w)
                        }
 #endif /* RTM_OVERSION */
                }
-               ifaaddr = netmask = brdaddr = 0;
+               info.rti_ifaaddr = info.rti_mask = info.rti_brdaddr = 0;
        }
        return (0);
 }

Reply via email to