]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/net/rtsock.c
xnu-1228.15.4.tar.gz
[apple/xnu.git] / bsd / net / rtsock.c
index 82cef1b0a0e13bf30cfe6d57793cb40537ad99e8..b6836fd6c07887efa35aadfdeea5dc8c3797b3f0 100644 (file)
@@ -1,23 +1,29 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * Copyright (c) 1988, 1991, 1993
 
 #include <machine/spl.h>
 
-extern void m_copydata(struct mbuf *, int, int, caddr_t);
-extern void m_copyback(struct mbuf *, int, int, caddr_t);
-
 extern struct rtstat rtstat;
-extern int rttrash;
+extern u_long route_generation;
+extern int use_routegenid;
+extern int check_routeselfref;
 
 MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables");
 
@@ -107,7 +112,9 @@ static int  sysctl_iflist2(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 *);
 static void    rt_setif(struct rtentry *, struct sockaddr *, struct sockaddr *,
-                             struct sockaddr *);
+                   struct sockaddr *, unsigned int);
+
+#define        SIN(sa)         ((struct sockaddr_in *)(size_t)(sa))
 
 /* Sleazy use of local variables throughout file, warning!!!! */
 #define dst    info.rti_info[RTAX_DST]
@@ -158,7 +165,7 @@ rts_attach(struct socket *so, int proto, __unused struct proc *p)
        rp = sotorawcb(so);
        if (error) {
                FREE(rp, M_PCB);
-               so->so_pcb = 0;
+               so->so_pcb = NULL;
                so->so_flags |= SOF_PCBCLEARING;
                return error;
        }
@@ -189,20 +196,16 @@ rts_attach(struct socket *so, int proto, __unused struct proc *p)
 static int
 rts_bind(struct socket *so, struct sockaddr *nam, struct proc *p)
 {
-       int s, error;
-       s = splnet();
+       int error;
        error = raw_usrreqs.pru_bind(so, nam, p); /* xxx just EINVAL */
-       splx(s);
        return error;
 }
 
 static int
 rts_connect(struct socket *so, struct sockaddr *nam, struct proc *p)
 {
-       int s, error;
-       s = splnet();
+       int error;
        error = raw_usrreqs.pru_connect(so, nam, p); /* XXX just EINVAL */
-       splx(s);
        return error;
 }
 
@@ -213,9 +216,8 @@ static int
 rts_detach(struct socket *so)
 {
        struct rawcb *rp = sotorawcb(so);
-       int s, error;
+       int error;
 
-       s = splnet();
        if (rp != 0) {
                switch(rp->rcb_proto.sp_protocol) {
                case AF_INET:
@@ -234,17 +236,14 @@ rts_detach(struct socket *so)
                route_cb.any_count--;
        }
        error = raw_usrreqs.pru_detach(so);
-       splx(s);
        return error;
 }
 
 static int
 rts_disconnect(struct socket *so)
 {
-       int s, error;
-       s = splnet();
+       int error;
        error = raw_usrreqs.pru_disconnect(so);
-       splx(s);
        return error;
 }
 
@@ -253,10 +252,8 @@ rts_disconnect(struct socket *so)
 static int
 rts_peeraddr(struct socket *so, struct sockaddr **nam)
 {
-       int s, error;
-       s = splnet();
+       int error;
        error = raw_usrreqs.pru_peeraddr(so, nam);
-       splx(s);
        return error;
 }
 
@@ -267,10 +264,8 @@ static int
 rts_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
         struct mbuf *control, struct proc *p)
 {
-       int s, error;
-       s = splnet();
+       int error;
        error = raw_usrreqs.pru_send(so, flags, m, nam, control, p);
-       splx(s);
        return error;
 }
 
@@ -279,20 +274,16 @@ rts_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
 static int
 rts_shutdown(struct socket *so)
 {
-       int s, error;
-       s = splnet();
+       int  error;
        error = raw_usrreqs.pru_shutdown(so);
-       splx(s);
        return error;
 }
 
 static int
 rts_sockaddr(struct socket *so, struct sockaddr **nam)
 {
-       int s, error;
-       s = splnet();
+       int error;
        error = raw_usrreqs.pru_sockaddr(so, nam);
-       splx(s);
        return error;
 }
 
@@ -306,24 +297,25 @@ static struct pr_usrreqs route_usrreqs = {
 
 /*ARGSUSED*/
 static int
-route_output(m, so)
-       struct mbuf *m;
-       struct socket *so;
+route_output(struct mbuf *m, struct socket *so)
 {
-       struct rt_msghdr *rtm = 0;
-       struct rtentry *rt = 0;
-       struct rtentry *saved_nrt = 0;
+       struct rt_msghdr *rtm = NULL;
+       struct rtentry *rt = NULL;
+       struct rtentry *saved_nrt = NULL;
        struct radix_node_head *rnh;
        struct rt_addrinfo info;
        int len, error = 0;
-       struct ifnet *ifp = 0;
+       struct ifnet *ifp = NULL;
 #ifndef __APPLE__
        struct proc  *curproc = current_proc();
 #endif
+       struct sockaddr_in dst_in, gate_in;
        int sendonlytoself = 0;
+       unsigned int ifscope = IFSCOPE_NONE;
 
 #define senderr(e) { error = e; goto flush;}
-       if (m == 0 || ((m->m_len < sizeof(long)) && (m = m_pullup(m, sizeof(long))) == 0))
+       if (m == NULL ||
+           ((m->m_len < sizeof(long)) && (m = m_pullup(m, sizeof(long))) == 0))
                return (ENOBUFS);
        if ((m->m_flags & M_PKTHDR) == 0)
                panic("route_output");
@@ -335,20 +327,20 @@ route_output(m, so)
        len = m->m_pkthdr.len;
        if (len < sizeof(*rtm) ||
            len != mtod(m, struct rt_msghdr *)->rtm_msglen) {
-               dst = 0;
+               dst = NULL;
                senderr(EINVAL);
        }
        R_Malloc(rtm, struct rt_msghdr *, len);
-       if (rtm == 0) {
-               dst = 0;
+       if (rtm == NULL) {
+               dst = NULL;
                senderr(ENOBUFS);
        }
        m_copydata(m, 0, len, (caddr_t)rtm);
        if (rtm->rtm_version != RTM_VERSION) {
-               dst = 0;
+               dst = NULL;
                senderr(EPROTONOSUPPORT);
        }
-       
+
        /*
         * Silent version of RTM_GET for Reachabiltiy APIs. We may change
         * all RTM_GETs to be silent in the future, so this is private for now.
@@ -359,26 +351,52 @@ route_output(m, so)
                sendonlytoself = 1;
                rtm->rtm_type = RTM_GET;
        }
-       
+
        /*
         * Perform permission checking, only privileged sockets
         * may perform operations other than RTM_GET
         */
        if (rtm->rtm_type != RTM_GET && (so->so_state & SS_PRIV) == 0) {
-               dst = 0;
+               dst = NULL;
                senderr(EPERM);
        }
 
        rtm->rtm_pid = proc_selfpid();
        info.rti_addrs = rtm->rtm_addrs;
        if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) {
-               dst = 0;
+               dst = NULL;
                senderr(EINVAL);
        }
-       if (dst == 0 || (dst->sa_family >= AF_MAX)
-           || (gate != 0 && (gate->sa_family >= AF_MAX))) {
+       if (dst == NULL || (dst->sa_family >= AF_MAX) ||
+           (gate != NULL && (gate->sa_family >= AF_MAX))) {
                senderr(EINVAL);
        }
+
+       if (dst->sa_family == AF_INET && dst->sa_len != sizeof (dst_in)) {
+               /* At minimum, we need up to sin_addr */
+               if (dst->sa_len < offsetof(struct sockaddr_in, sin_zero))
+                       senderr(EINVAL);
+               bzero(&dst_in, sizeof (dst_in));
+               dst_in.sin_len = sizeof (dst_in);
+               dst_in.sin_family = AF_INET;
+               dst_in.sin_port = SIN(dst)->sin_port;
+               dst_in.sin_addr = SIN(dst)->sin_addr;
+               dst = (struct sockaddr *)&dst_in;
+       }
+
+       if (gate != NULL &&
+           gate->sa_family == AF_INET && gate->sa_len != sizeof (gate_in)) {
+               /* At minimum, we need up to sin_addr */
+               if (gate->sa_len < offsetof(struct sockaddr_in, sin_zero))
+                       senderr(EINVAL);
+               bzero(&gate_in, sizeof (gate_in));
+               gate_in.sin_len = sizeof (gate_in);
+               gate_in.sin_family = AF_INET;
+               gate_in.sin_port = SIN(gate)->sin_port;
+               gate_in.sin_addr = SIN(gate)->sin_addr;
+               gate = (struct sockaddr *)&gate_in;
+       }
+
        if (genmask) {
                struct radix_node *t;
                t = rn_addmask((caddr_t)genmask, 0, 1);
@@ -387,10 +405,21 @@ route_output(m, so)
                else
                        senderr(ENOBUFS);
        }
+
+       /*
+        * If RTF_IFSCOPE flag is set, then rtm_index specifies the scope.
+        */
+       if (rtm->rtm_flags & RTF_IFSCOPE) {
+               /* Scoped routing is for AF_INET only */
+               if (dst->sa_family != AF_INET)
+                       senderr(EINVAL);
+               ifscope = rtm->rtm_index;
+       }
+
        switch (rtm->rtm_type) {
-       
+
                case RTM_ADD:
-                       if (gate == 0)
+                       if (gate == NULL)
                                senderr(EINVAL);
 
 #ifdef __APPLE__
@@ -406,7 +435,6 @@ route_output(m, so)
  * confusing the routing table with a wrong route to the previous default gateway
  */
 {
-                       extern int check_routeselfref;
 #define satosinaddr(sa) (((struct sockaddr_in *)sa)->sin_addr.s_addr)
        
                        if (check_routeselfref && (dst && dst->sa_family == AF_INET) && 
@@ -422,8 +450,8 @@ route_output(m, so)
                        }
 }
 #endif 
-                       error = rtrequest_locked(RTM_ADD, dst, gate, netmask,
-                                               rtm->rtm_flags, &saved_nrt);
+                       error = rtrequest_scoped_locked(RTM_ADD, dst, gate,
+                           netmask, rtm->rtm_flags, &saved_nrt, ifscope);
                        if (error == 0 && saved_nrt) {
 #ifdef __APPLE__
                                /* 
@@ -454,24 +482,24 @@ route_output(m, so)
                                 * dwiggins@bbn.com
                                 */
        
-                               rt_setif(saved_nrt, ifpaddr, ifaaddr, gate);
+                               rt_setif(saved_nrt, ifpaddr, ifaaddr, gate,
+                                   ifscope);
 #endif
                                rt_setmetrics(rtm->rtm_inits,
                                        &rtm->rtm_rmx, &saved_nrt->rt_rmx);
                                saved_nrt->rt_rmx.rmx_locks &= ~(rtm->rtm_inits);
                                saved_nrt->rt_rmx.rmx_locks |=
                                        (rtm->rtm_inits & rtm->rtm_rmx.rmx_locks);
-                               rtunref(saved_nrt);
                                saved_nrt->rt_genmask = genmask;
+                               rtunref(saved_nrt);
                        }
                        break;
 
                case RTM_DELETE:
-                       error = rtrequest_locked(RTM_DELETE, dst, gate, netmask,
-                                       rtm->rtm_flags, &saved_nrt);
+                       error = rtrequest_scoped_locked(RTM_DELETE, dst,
+                           gate, netmask, rtm->rtm_flags, &saved_nrt, ifscope);
                        if (error == 0) {
-                               if ((rt = saved_nrt))
-                                       rtref(rt);
+                               rt = saved_nrt;
                                goto report;
                        }
                        break;
@@ -479,13 +507,17 @@ route_output(m, so)
                case RTM_GET:
                case RTM_CHANGE:
                case RTM_LOCK:
-                       if ((rnh = rt_tables[dst->sa_family]) == 0) {
+                       if ((rnh = rt_tables[dst->sa_family]) == NULL)
                                senderr(EAFNOSUPPORT);
-                       } else if ((rt = (struct rtentry *)
-                                       rnh->rnh_lookup(dst, netmask, rnh)) != NULL)
-                               rtref(rt);
-                       else
+
+                       /*
+                        * Lookup the best match based on the key-mask pair;
+                        * callee adds a reference and checks for root node.
+                        */
+                       rt = rt_lookup(TRUE, dst, netmask, rnh, ifscope);
+                       if (rt == NULL)
                                senderr(ESRCH);
+
                        switch(rtm->rtm_type) {
 
                                case RTM_GET: {
@@ -548,7 +580,8 @@ route_output(m, so)
                                         * equivalent to the code found at this very spot
                                         * in BSD.
                                         */
-                                       rt_setif(rt, ifpaddr, ifaaddr, gate);
+                                       rt_setif(rt, ifpaddr, ifaaddr, gate,
+                                           ifscope);
 #endif
                
                                        rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx,
@@ -634,9 +667,7 @@ flush:
 }
 
 static void
-rt_setmetrics(which, in, out)
-       u_long which;
-       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);
@@ -654,28 +685,28 @@ rt_setmetrics(which, in, out)
  * Set route's interface given ifpaddr, ifaaddr, and gateway.
  */
 static void
-rt_setif(
-       struct rtentry *rt,
-       struct sockaddr *Ifpaddr,
-       struct sockaddr *Ifaaddr,
-       struct sockaddr *Gate)
+rt_setif(struct rtentry *rt, struct sockaddr *Ifpaddr, struct sockaddr *Ifaaddr,
+    struct sockaddr *Gate, unsigned int ifscope)
 {
        struct ifaddr *ifa = 0;
        struct ifnet  *ifp = 0;
 
        lck_mtx_assert(rt_mtx, LCK_MTX_ASSERT_OWNED);
 
-       /* 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 (Ifpaddr && (ifa = ifa_ifwithnet(Ifpaddr)) &&
+       /* trigger route cache reevaluation */
+       if (use_routegenid)
+               route_generation++;
+
+       /*
+        * 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 (Ifpaddr && (ifa = ifa_ifwithnet_scoped(Ifpaddr, ifscope)) &&
            (ifp = ifa->ifa_ifp) && (Ifaaddr || Gate)) {
-           ifafree(ifa);
-               ifa = ifaof_ifpforaddr(Ifaaddr ? Ifaaddr : Gate,
-                                       ifp);
-       }
-       else
-       {
+               ifafree(ifa);
+               ifa = ifaof_ifpforaddr(Ifaaddr ? Ifaaddr : Gate, ifp);
+       } else {
                if (ifa) {
                        ifafree(ifa);
                        ifa = 0;
@@ -683,32 +714,36 @@ rt_setif(
                if (Ifpaddr && (ifp = if_withname(Ifpaddr)) ) {
                        if (Gate) {
                                ifa = ifaof_ifpforaddr(Gate, ifp);
-                       }
-                       else {
+                       } else {
                                ifnet_lock_shared(ifp);
                                ifa = TAILQ_FIRST(&ifp->if_addrhead);
                                ifaref(ifa);
                                ifnet_lock_done(ifp);
                        }
-               }
-               else if (Ifaaddr && (ifa = ifa_ifwithaddr(Ifaaddr))) {
+               } else if (Ifaaddr &&
+                   (ifa = ifa_ifwithaddr_scoped(Ifaaddr, ifscope))) {
                        ifp = ifa->ifa_ifp;
-               }
-               else if (Gate && (ifa = ifa_ifwithroute(rt->rt_flags,
-                                               rt_key(rt), Gate))) {
+               } else if (Gate &&
+                   (ifa = ifa_ifwithroute_scoped_locked(rt->rt_flags,
+                   rt_key(rt), Gate, ifscope))) {
                        ifp = ifa->ifa_ifp;
                }
        }
        if (ifa) {
                struct ifaddr *oifa = rt->rt_ifa;
                if (oifa != ifa) {
-                   if (oifa && oifa->ifa_rtrequest)
-                       oifa->ifa_rtrequest(RTM_DELETE,
-                                               rt, Gate);
+                       if (oifa && oifa->ifa_rtrequest)
+                               oifa->ifa_rtrequest(RTM_DELETE, rt, Gate);
                        rtsetifa(rt, ifa);
-                   rt->rt_ifp = ifp;
-                   rt->rt_rmx.rmx_mtu = ifp->if_mtu;
-                   if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
+                       rt->rt_ifp = ifp;
+                       /*
+                        * If this is the (non-scoped) default route, record
+                        * the interface index used for the primary ifscope.
+                        */
+                       if (rt_inet_default(rt, rt_key(rt)))
+                               set_primary_ifscope(rt->rt_ifp->if_index);
+                       rt->rt_rmx.rmx_mtu = ifp->if_mtu;
+                       if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
                                rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, Gate);
                } else {
                        ifafree(ifa);
@@ -717,7 +752,7 @@ rt_setif(
                ifafree(ifa);
                return;
        }
-      call_ifareq:
+call_ifareq:
        /* XXX: to reset gateway to correct value, at RTM_CHANGE */
        if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
                rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, Gate);
@@ -735,9 +770,7 @@ rt_setif(
  * This data is derived straight from userland.
  */
 static int
-rt_xaddrs(cp, cplim, rtinfo)
-       caddr_t cp, cplim;
-       struct rt_addrinfo *rtinfo;
+rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo)
 {
        struct sockaddr *sa;
        int i;
@@ -838,11 +871,7 @@ rt_msg1(
 }
 
 static int
-rt_msg2(type, rtinfo, cp, w)
-       int type;
-       struct rt_addrinfo *rtinfo;
-       caddr_t cp;
-       struct walkarg *w;
+rt_msg2(int type, struct rt_addrinfo *rtinfo, caddr_t cp, struct walkarg *w)
 {
        int i;
        int len, dlen, second_time = 0;
@@ -933,9 +962,7 @@ again:
  * destination.
  */
 void
-rt_missmsg(type, rtinfo, flags, error)
-       int type, flags, error;
-       struct rt_addrinfo *rtinfo;
+rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, int error)
 {
        struct rt_msghdr *rtm;
        struct mbuf *m;
@@ -977,7 +1004,7 @@ rt_ifmsg(
        ifm = mtod(m, struct if_msghdr *);
        ifm->ifm_index = ifp->if_index;
        ifm->ifm_flags = (u_short)ifp->if_flags;
-       if_data_internal_to_if_data(&ifp->if_data, &ifm->ifm_data);
+       if_data_internal_to_if_data(ifp, &ifp->if_data, &ifm->ifm_data);
        ifm->ifm_addrs = 0;
        route_proto.sp_protocol = 0;
        raw_input(m, &route_proto, &route_src, &route_dst);
@@ -995,10 +1022,7 @@ rt_ifmsg(
  * interface will be locked.
  */
 void
-rt_newaddrmsg(cmd, ifa, error, rt)
-       int cmd, error;
-       struct ifaddr *ifa;
-       struct rtentry *rt;
+rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt)
 {
        struct rt_addrinfo info;
        struct sockaddr *sa = 0;
@@ -1055,9 +1079,7 @@ rt_newaddrmsg(cmd, ifa, error, rt)
  * 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;
@@ -1091,9 +1113,7 @@ rt_newmaddrmsg(cmd, ifma)
  * This is used in dumping the kernel table via sysctl().
  */
 int
-sysctl_dumpentry(rn, vw)
-       struct radix_node *rn;
-       void *vw;
+sysctl_dumpentry(struct radix_node *rn, void *vw)
 {
        struct walkarg *w = vw;
        struct rtentry *rt = (struct rtentry *)rn;
@@ -1175,7 +1195,7 @@ sysctl_iflist(
                        ifm = (struct if_msghdr *)w->w_tmem;
                        ifm->ifm_index = ifp->if_index;
                        ifm->ifm_flags = (u_short)ifp->if_flags;
-                       if_data_internal_to_if_data(&ifp->if_data, &ifm->ifm_data);
+                       if_data_internal_to_if_data(ifp, &ifp->if_data, &ifm->ifm_data);
                        ifm->ifm_addrs = info.rti_addrs;
                        error = SYSCTL_OUT(w->w_req,(caddr_t)ifm, len);
                        if (error) {
@@ -1186,10 +1206,6 @@ sysctl_iflist(
                while ((ifa = ifa->ifa_link.tqe_next) != 0) {
                        if (af && af != ifa->ifa_addr->sa_family)
                                continue;
-#ifndef __APPLE__
-                       if (curproc->p_prison && prison_if(curproc, ifa->ifa_addr))
-                               continue;
-#endif
                        ifaaddr = ifa->ifa_addr;
                        netmask = ifa->ifa_netmask;
                        brdaddr = ifa->ifa_dstaddr;
@@ -1247,7 +1263,7 @@ sysctl_iflist2(
                        ifm->ifm_snd_maxlen = ifp->if_snd.ifq_maxlen;
                        ifm->ifm_snd_drops = ifp->if_snd.ifq_drops;
                        ifm->ifm_timer = ifp->if_timer;
-                       if_data_internal_to_if_data64(&ifp->if_data, &ifm->ifm_data);
+                       if_data_internal_to_if_data64(ifp, &ifp->if_data, &ifm->ifm_data);
                        error = SYSCTL_OUT(w->w_req, w->w_tmem, len);
                        if (error) {
                                ifnet_lock_done(ifp);
@@ -1342,6 +1358,7 @@ sysctl_rttrash(struct sysctl_req *req)
 static int
 sysctl_rtsock SYSCTL_HANDLER_ARGS
 {
+#pragma unused(oidp)
        int     *name = (int *)arg1;
        u_int   namelen = arg2;
        struct radix_node_head *rnh;
@@ -1415,7 +1432,7 @@ static struct protosw routesw[] = {
 struct domain routedomain =
     { PF_ROUTE, "route", route_init, 0, 0,
       routesw, 
-      0, 0, 0, 0, 0, 0, 0, 0, 
+      NULL, NULL, 0, 0, 0, 0, NULL, 0, 
       { 0, 0 } };
 
 DOMAIN_SET(route);