- return EPERM;
- error = 0;
-
- for (dr = TAILQ_FIRST(&nd_defrouter);
- dr;
- dr = TAILQ_NEXT(dr, dr_entry)) {
- d = (struct in6_defrouter *)buf;
- de = (struct in6_defrouter *)(buf + sizeof(buf));
-
- if (d + 1 <= de) {
- bzero(d, sizeof(*d));
- d->rtaddr.sin6_family = AF_INET6;
- d->rtaddr.sin6_len = sizeof(d->rtaddr);
- if (in6_recoverscope(&d->rtaddr, &dr->rtaddr,
- dr->ifp) != 0)
- log(LOG_ERR,
- "scope error in "
- "default router list (%s)\n",
- ip6_sprintf(&dr->rtaddr));
- d->flags = dr->flags;
- d->rtlifetime = dr->rtlifetime;
- d->expire = dr->expire;
- d->if_index = dr->ifp->if_index;
- } else
- panic("buffer too short");
-
- error = SYSCTL_OUT(req, buf, sizeof(*d));
- if (error)
- break;
+ return (EPERM);
+
+ lck_mtx_lock(nd6_mutex);
+ if (p64) {
+ struct in6_defrouter_64 *d, *de;
+
+ for (dr = TAILQ_FIRST(&nd_defrouter);
+ dr;
+ dr = TAILQ_NEXT(dr, dr_entry)) {
+ d = (struct in6_defrouter_64 *)buf;
+ de = (struct in6_defrouter_64 *)(buf + sizeof (buf));
+
+ if (d + 1 <= de) {
+ bzero(d, sizeof (*d));
+ d->rtaddr.sin6_family = AF_INET6;
+ d->rtaddr.sin6_len = sizeof (d->rtaddr);
+ if (in6_recoverscope(&d->rtaddr, &dr->rtaddr,
+ dr->ifp) != 0)
+ log(LOG_ERR,
+ "scope error in "
+ "default router list (%s)\n",
+ ip6_sprintf(&dr->rtaddr));
+ d->flags = dr->flags;
+ d->rtlifetime = dr->rtlifetime;
+ d->expire = dr->expire;
+ d->if_index = dr->ifp->if_index;
+ } else {
+ panic("buffer too short");
+ }
+ error = SYSCTL_OUT(req, buf, sizeof (*d));
+ if (error)
+ break;
+ }
+ } else {
+ struct in6_defrouter_32 *d_32, *de_32;
+
+ for (dr = TAILQ_FIRST(&nd_defrouter);
+ dr;
+ dr = TAILQ_NEXT(dr, dr_entry)) {
+ d_32 = (struct in6_defrouter_32 *)buf;
+ de_32 = (struct in6_defrouter_32 *)(buf + sizeof (buf));
+
+ if (d_32 + 1 <= de_32) {
+ bzero(d_32, sizeof (*d_32));
+ d_32->rtaddr.sin6_family = AF_INET6;
+ d_32->rtaddr.sin6_len = sizeof (d_32->rtaddr);
+ if (in6_recoverscope(&d_32->rtaddr, &dr->rtaddr,
+ dr->ifp) != 0)
+ log(LOG_ERR,
+ "scope error in "
+ "default router list (%s)\n",
+ ip6_sprintf(&dr->rtaddr));
+ d_32->flags = dr->flags;
+ d_32->rtlifetime = dr->rtlifetime;
+ d_32->expire = dr->expire;
+ d_32->if_index = dr->ifp->if_index;
+ } else {
+ panic("buffer too short");
+ }
+ error = SYSCTL_OUT(req, buf, sizeof (*d_32));
+ if (error)
+ break;
+ }