From 8de92fe7791878815b9af01d60cb7264e217b976 Mon Sep 17 00:00:00 2001 From: hrs Date: Sun, 13 Sep 2015 01:59:50 +0000 Subject: MFC 287095, 287610, 287611, 287617: Remove obsolete API (SIOCGDRLST_IN6 and SIOCGPRLST_IN6) support. --- sys/netinet6/in6.c | 2 - sys/netinet6/in6_var.h | 5 -- sys/netinet6/nd6.c | 129 ++++++------------------------- usr.sbin/ndp/ndp.c | 201 ------------------------------------------------- 4 files changed, 22 insertions(+), 315 deletions(-) diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 432b08a..2898d61 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -323,8 +323,6 @@ in6_control(struct socket *so, u_long cmd, caddr_t data, /* FALLTHROUGH */ case OSIOCGIFINFO_IN6: case SIOCGIFINFO_IN6: - case SIOCGDRLST_IN6: - case SIOCGPRLST_IN6: case SIOCGNBRINFO_IN6: case SIOCGDEFIFACE_IN6: return (nd6_ioctl(cmd, data, ifp)); diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h index 8f681bb..fefb1ef 100644 --- a/sys/netinet6/in6_var.h +++ b/sys/netinet6/in6_var.h @@ -447,11 +447,6 @@ struct in6_rrenumreq { #define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq) -#define SIOCGDRLST_IN6 _IOWR('i', 74, struct in6_drlist) -#ifdef _KERNEL -/* XXX: SIOCGPRLST_IN6 is exposed in KAME but in6_oprlist is not. */ -#define SIOCGPRLST_IN6 _IOWR('i', 75, struct in6_oprlist) -#endif #ifdef _KERNEL #define OSIOCGIFINFO_IN6 _IOWR('i', 76, struct in6_ondireq) #endif diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 94add9a..d2aa188 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1246,99 +1246,14 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) int nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) { - struct in6_drlist *drl = (struct in6_drlist *)data; - struct in6_oprlist *oprl = (struct in6_oprlist *)data; struct in6_ndireq *ndi = (struct in6_ndireq *)data; struct in6_nbrinfo *nbi = (struct in6_nbrinfo *)data; struct in6_ndifreq *ndif = (struct in6_ndifreq *)data; - struct nd_defrouter *dr; - struct nd_prefix *pr; - int i = 0, error = 0; + int error = 0; if (ifp->if_afdata[AF_INET6] == NULL) return (EPFNOSUPPORT); switch (cmd) { - case SIOCGDRLST_IN6: - /* - * obsolete API, use sysctl under net.inet6.icmp6 - */ - bzero(drl, sizeof(*drl)); - TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) { - if (i >= DRLSTSIZ) - break; - drl->defrouter[i].rtaddr = dr->rtaddr; - in6_clearscope(&drl->defrouter[i].rtaddr); - - drl->defrouter[i].flags = dr->flags; - drl->defrouter[i].rtlifetime = dr->rtlifetime; - drl->defrouter[i].expire = dr->expire + - (time_second - time_uptime); - drl->defrouter[i].if_index = dr->ifp->if_index; - i++; - } - break; - case SIOCGPRLST_IN6: - /* - * obsolete API, use sysctl under net.inet6.icmp6 - * - * XXX the structure in6_prlist was changed in backward- - * incompatible manner. in6_oprlist is used for SIOCGPRLST_IN6, - * in6_prlist is used for nd6_sysctl() - fill_prlist(). - */ - /* - * XXX meaning of fields, especialy "raflags", is very - * differnet between RA prefix list and RR/static prefix list. - * how about separating ioctls into two? - */ - bzero(oprl, sizeof(*oprl)); - LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) { - struct nd_pfxrouter *pfr; - int j; - - if (i >= PRLSTSIZ) - break; - oprl->prefix[i].prefix = pr->ndpr_prefix.sin6_addr; - oprl->prefix[i].raflags = pr->ndpr_raf; - oprl->prefix[i].prefixlen = pr->ndpr_plen; - oprl->prefix[i].vltime = pr->ndpr_vltime; - oprl->prefix[i].pltime = pr->ndpr_pltime; - oprl->prefix[i].if_index = pr->ndpr_ifp->if_index; - if (pr->ndpr_vltime == ND6_INFINITE_LIFETIME) - oprl->prefix[i].expire = 0; - else { - time_t maxexpire; - - /* XXX: we assume time_t is signed. */ - maxexpire = (-1) & - ~((time_t)1 << - ((sizeof(maxexpire) * 8) - 1)); - if (pr->ndpr_vltime < - maxexpire - pr->ndpr_lastupdate) { - oprl->prefix[i].expire = - pr->ndpr_lastupdate + - pr->ndpr_vltime + - (time_second - time_uptime); - } else - oprl->prefix[i].expire = maxexpire; - } - - j = 0; - LIST_FOREACH(pfr, &pr->ndpr_advrtrs, pfr_entry) { - if (j < DRLSTSIZ) { -#define RTRADDR oprl->prefix[i].advrtr[j] - RTRADDR = pfr->router->rtaddr; - in6_clearscope(&RTRADDR); -#undef RTRADDR - } - j++; - } - oprl->prefix[i].advrtrs = j; - oprl->prefix[i].origin = PR_ORIG_RA; - - i++; - } - - break; case OSIOCGIFINFO_IN6: #define ND ndi->ndi /* XXX: old ndp(8) assumes a positive value for linkmtu. */ @@ -1398,22 +1313,19 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) * do not clear ND6_IFF_IFDISABLED. * See RFC 4862, Section 5.4.5. */ - int duplicated_linklocal = 0; - IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ia = (struct in6_ifaddr *)ifa; if ((ia->ia6_flags & IN6_IFF_DUPLICATED) && - IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) { - duplicated_linklocal = 1; + IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) break; - } } IF_ADDR_RUNLOCK(ifp); - if (duplicated_linklocal) { + if (ifa != NULL) { + /* LLA is duplicated. */ ND.flags |= ND6_IFF_IFDISABLED; log(LOG_ERR, "Cannot enable an interface" " with a link-local address marked" @@ -1429,14 +1341,18 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) /* Mark all IPv6 address as tentative. */ ND_IFINFO(ifp)->flags |= ND6_IFF_IFDISABLED; - IF_ADDR_RLOCK(ifp); - TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { - if (ifa->ifa_addr->sa_family != AF_INET6) - continue; - ia = (struct in6_ifaddr *)ifa; - ia->ia6_flags |= IN6_IFF_TENTATIVE; + if ((ND_IFINFO(ifp)->flags & ND6_IFF_NO_DAD) == 0) { + IF_ADDR_RLOCK(ifp); + TAILQ_FOREACH(ifa, &ifp->if_addrhead, + ifa_link) { + if (ifa->ifa_addr->sa_family != + AF_INET6) + continue; + ia = (struct in6_ifaddr *)ifa; + ia->ia6_flags |= IN6_IFF_TENTATIVE; + } + IF_ADDR_RUNLOCK(ifp); } - IF_ADDR_RUNLOCK(ifp); } if (ND.flags & ND6_IFF_AUTO_LINKLOCAL) { @@ -1454,20 +1370,19 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) * address is assigned, and IFF_UP, try to * assign one. */ - int haslinklocal = 0; - IF_ADDR_RLOCK(ifp); - TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { - if (ifa->ifa_addr->sa_family != AF_INET6) + TAILQ_FOREACH(ifa, &ifp->if_addrhead, + ifa_link) { + if (ifa->ifa_addr->sa_family != + AF_INET6) continue; ia = (struct in6_ifaddr *)ifa; - if (IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) { - haslinklocal = 1; + if (IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) break; - } } IF_ADDR_RUNLOCK(ifp); - if (!haslinklocal) + if (ifa != NULL) + /* No LLA is configured. */ in6_ifattach(ifp, NULL); } } diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index 830f344..fa5ed80 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -156,14 +156,12 @@ static void setdefif(char *); static char *sec2str(time_t); static void ts_print(const struct timeval *); -#ifdef ICMPV6CTL_ND6_DRLIST static char *rtpref_str[] = { "medium", /* 00 */ "high", /* 01 */ "rsv", /* 10 */ "low" /* 11 */ }; -#endif int mode = 0; char *arg = NULL; @@ -1076,7 +1074,6 @@ ifinfo(ifname, argc, argv) void rtrlist() { -#ifdef ICMPV6CTL_ND6_DRLIST int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_DRLIST }; char *buf; struct in6_defrouter *p, *ep; @@ -1124,54 +1121,11 @@ rtrlist() sec2str(p->expire - now.tv_sec)); } free(buf); -#else - struct in6_drlist dr; - int s, i; - struct timeval now; - - if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { - err(1, "socket"); - /* NOTREACHED */ - } - bzero(&dr, sizeof(dr)); - strlcpy(dr.ifname, "lo0", sizeof(dr.ifname)); /* dummy */ - if (ioctl(s, SIOCGDRLST_IN6, (caddr_t)&dr) < 0) { - err(1, "ioctl(SIOCGDRLST_IN6)"); - /* NOTREACHED */ - } -#define DR dr.defrouter[i] - for (i = 0 ; DR.if_index && i < DRLSTSIZ ; i++) { - struct sockaddr_in6 sin6; - - bzero(&sin6, sizeof(sin6)); - sin6.sin6_family = AF_INET6; - sin6.sin6_len = sizeof(sin6); - sin6.sin6_addr = DR.rtaddr; - getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len, host_buf, - sizeof(host_buf), NULL, 0, - (nflag ? NI_NUMERICHOST : 0)); - - printf("%s if=%s", host_buf, - if_indextoname(DR.if_index, ifix_buf)); - printf(", flags=%s%s", - DR.flags & ND_RA_FLAG_MANAGED ? "M" : "", - DR.flags & ND_RA_FLAG_OTHER ? "O" : ""); - gettimeofday(&now, 0); - if (DR.expire == 0) - printf(", expire=Never\n"); - else - printf(", expire=%s\n", - sec2str(DR.expire - now.tv_sec)); - } -#undef DR - close(s); -#endif } void plist() { -#ifdef ICMPV6CTL_ND6_PRLIST int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_PRLIST }; char *buf; struct in6_prefix *p, *ep, *n; @@ -1281,161 +1235,6 @@ plist() printf(" No advertising router\n"); } free(buf); -#else - struct in6_prlist pr; - int s, i; - struct timeval now; - - gettimeofday(&now, 0); - - if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { - err(1, "socket"); - /* NOTREACHED */ - } - bzero(&pr, sizeof(pr)); - strlcpy(pr.ifname, "lo0", sizeof(pr.ifname)); /* dummy */ - if (ioctl(s, SIOCGPRLST_IN6, (caddr_t)&pr) < 0) { - err(1, "ioctl(SIOCGPRLST_IN6)"); - /* NOTREACHED */ - } -#define PR pr.prefix[i] - for (i = 0; PR.if_index && i < PRLSTSIZ ; i++) { - struct sockaddr_in6 p6; - char namebuf[NI_MAXHOST]; - int niflags; - -#ifdef NDPRF_ONLINK - p6 = PR.prefix; -#else - memset(&p6, 0, sizeof(p6)); - p6.sin6_family = AF_INET6; - p6.sin6_len = sizeof(p6); - p6.sin6_addr = PR.prefix; -#endif - niflags = NI_NUMERICHOST; - if (getnameinfo((struct sockaddr *)&p6, - sizeof(p6), namebuf, sizeof(namebuf), - NULL, 0, niflags)) { - warnx("getnameinfo failed"); - continue; - } - printf("%s/%d if=%s\n", namebuf, PR.prefixlen, - if_indextoname(PR.if_index, ifix_buf)); - - gettimeofday(&now, 0); - /* - * meaning of fields, especially flags, is very different - * by origin. notify the difference to the users. - */ -#if 0 - printf(" %s", - PR.origin == PR_ORIG_RA ? "" : "advertise: "); -#endif -#ifdef NDPRF_ONLINK - printf("flags=%s%s%s%s%s", - PR.raflags.onlink ? "L" : "", - PR.raflags.autonomous ? "A" : "", - (PR.flags & NDPRF_ONLINK) != 0 ? "O" : "", - (PR.flags & NDPRF_DETACHED) != 0 ? "D" : "", -#ifdef NDPRF_HOME - (PR.flags & NDPRF_HOME) != 0 ? "H" : "" -#else - "" -#endif - ); -#else - printf("flags=%s%s", - PR.raflags.onlink ? "L" : "", - PR.raflags.autonomous ? "A" : ""); -#endif - if (PR.vltime == ND6_INFINITE_LIFETIME) - printf(" vltime=infinity"); - else - printf(" vltime=%lu", PR.vltime); - if (PR.pltime == ND6_INFINITE_LIFETIME) - printf(", pltime=infinity"); - else - printf(", pltime=%lu", PR.pltime); - if (PR.expire == 0) - printf(", expire=Never"); - else if (PR.expire >= now.tv_sec) - printf(", expire=%s", - sec2str(PR.expire - now.tv_sec)); - else - printf(", expired"); -#ifdef NDPRF_ONLINK - printf(", ref=%d", PR.refcnt); -#endif -#if 0 - switch (PR.origin) { - case PR_ORIG_RA: - printf(", origin=RA"); - break; - case PR_ORIG_RR: - printf(", origin=RR"); - break; - case PR_ORIG_STATIC: - printf(", origin=static"); - break; - case PR_ORIG_KERNEL: - printf(", origin=kernel"); - break; - default: - printf(", origin=?"); - break; - } -#endif - printf("\n"); - /* - * "advertising router" list is meaningful only if the prefix - * information is from RA. - */ - if (0 && /* prefix origin is almost obsolted */ - PR.origin != PR_ORIG_RA) - ; - else if (PR.advrtrs) { - int j; - printf(" advertised by\n"); - for (j = 0; j < PR.advrtrs; j++) { - struct sockaddr_in6 sin6; - struct in6_nbrinfo *nbi; - - bzero(&sin6, sizeof(sin6)); - sin6.sin6_family = AF_INET6; - sin6.sin6_len = sizeof(sin6); - sin6.sin6_addr = PR.advrtr[j]; - sin6.sin6_scope_id = PR.if_index; /* XXX */ - getnameinfo((struct sockaddr *)&sin6, - sin6.sin6_len, host_buf, - sizeof(host_buf), NULL, 0, - (nflag ? NI_NUMERICHOST : 0)); - printf(" %s", host_buf); - - nbi = getnbrinfo(&sin6.sin6_addr, - PR.if_index, 0); - if (nbi) { - switch (nbi->state) { - case ND6_LLINFO_REACHABLE: - case ND6_LLINFO_STALE: - case ND6_LLINFO_DELAY: - case ND6_LLINFO_PROBE: - printf(" (reachable)\n"); - break; - default: - printf(" (unreachable)\n"); - } - } else - printf(" (no neighbor state)\n"); - } - if (PR.advrtrs > DRLSTSIZ) - printf(" and %d routers\n", - PR.advrtrs - DRLSTSIZ); - } else - printf(" No advertising router\n"); - } -#undef PR - close(s); -#endif } void -- cgit v1.1