- fix typo in comment.
- style. Obtained from: KAME
This commit is contained in:
parent
00165f8e92
commit
06cd0a3f97
sys
@ -316,8 +316,7 @@ gif_validate4(ip, sc, ifp)
|
||||
return 0;
|
||||
}
|
||||
/* reject packets with broadcast on source */
|
||||
TAILQ_FOREACH(ia4, &in_ifaddrhead, ia_link)
|
||||
{
|
||||
TAILQ_FOREACH(ia4, &in_ifaddrhead, ia_link) {
|
||||
if ((ia4->ia_ifa.ifa_ifp->if_flags & IFF_BROADCAST) == 0)
|
||||
continue;
|
||||
if (ip->ip_src.s_addr == ia4->ia_broadaddr.sin_addr.s_addr)
|
||||
|
@ -36,7 +36,7 @@
|
||||
#define GIF_TTL 30
|
||||
|
||||
struct gif_softc;
|
||||
void in_gif_input(struct mbuf *, int off);
|
||||
void in_gif_input(struct mbuf *, int);
|
||||
int in_gif_output(struct ifnet *, int, struct mbuf *);
|
||||
int gif_encapcheck4(const struct mbuf *, int, int, void *);
|
||||
int in_gif_attach(struct gif_softc *);
|
||||
|
@ -107,7 +107,6 @@ dest6_input(mp, offp, proto)
|
||||
case IP6OPT_PADN:
|
||||
optlen = *(opt + 1) + 2;
|
||||
break;
|
||||
|
||||
default: /* unknown option */
|
||||
optlen = ip6_unknown_opt(opt, m,
|
||||
opt - mtod(m, u_int8_t *));
|
||||
|
@ -188,7 +188,6 @@ esp_max_ivlen()
|
||||
if (esp_algorithms[idx].ivlenval > ivlen)
|
||||
ivlen = esp_algorithms[idx].ivlenval;
|
||||
}
|
||||
|
||||
return ivlen;
|
||||
}
|
||||
|
||||
|
@ -331,8 +331,8 @@ noreplaycheck:
|
||||
nxt = esptail.esp_nxt;
|
||||
taillen = esptail.esp_padlen + sizeof(esptail);
|
||||
|
||||
if (m->m_pkthdr.len < taillen
|
||||
|| m->m_pkthdr.len - taillen < hlen) { /* ? */
|
||||
if (m->m_pkthdr.len < taillen ||
|
||||
m->m_pkthdr.len - taillen < hlen) { /* ? */
|
||||
ipseclog((LOG_WARNING,
|
||||
"bad pad length in IPv4 ESP input: %s %s\n",
|
||||
ipsec4_logpacketstr(ip, spi), ipsec_logsastr(sav)));
|
||||
@ -715,14 +715,6 @@ noreplaycheck:
|
||||
flowinfo = ip6->ip6_flow;
|
||||
m_adj(m, off + esplen + ivlen);
|
||||
if (m->m_len < sizeof(*ip6)) {
|
||||
#ifndef PULLDOWN_TEST
|
||||
/*
|
||||
* m_pullup is prohibited in KAME IPv6 input processing
|
||||
* but there's no other way!
|
||||
*/
|
||||
#else
|
||||
/* okay to pullup in m_pulldown style */
|
||||
#endif
|
||||
m = m_pullup(m, sizeof(*ip6));
|
||||
if (!m) {
|
||||
ipsec6stat.in_inval++;
|
||||
|
@ -192,8 +192,7 @@ frag6_input(mp, offp, proto)
|
||||
*/
|
||||
if ((ip6f->ip6f_offlg & IP6F_MORE_FRAG) &&
|
||||
(((ntohs(ip6->ip6_plen) - offset) & 0x7) != 0)) {
|
||||
icmp6_error(m, ICMP6_PARAM_PROB,
|
||||
ICMP6_PARAMPROB_HEADER,
|
||||
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
|
||||
offsetof(struct ip6_hdr, ip6_plen));
|
||||
in6_ifstat_inc(dstifp, ifs6_reass_fail);
|
||||
return IPPROTO_DONE;
|
||||
@ -257,8 +256,8 @@ frag6_input(mp, offp, proto)
|
||||
*/
|
||||
fragoff = ntohs(ip6f->ip6f_offlg & IP6F_OFF_MASK);
|
||||
if (fragoff == 0) {
|
||||
q6->ip6q_unfrglen = offset - sizeof(struct ip6_hdr)
|
||||
- sizeof(struct ip6_frag);
|
||||
q6->ip6q_unfrglen = offset - sizeof(struct ip6_hdr) -
|
||||
sizeof(struct ip6_frag);
|
||||
q6->ip6q_nxt = ip6f->ip6f_nxt;
|
||||
}
|
||||
|
||||
@ -277,8 +276,7 @@ frag6_input(mp, offp, proto)
|
||||
frag6_doing_reass = 0;
|
||||
return (IPPROTO_DONE);
|
||||
}
|
||||
}
|
||||
else if (fragoff + frgpartlen > IPV6_MAXPACKET) {
|
||||
} else if (fragoff + frgpartlen > IPV6_MAXPACKET) {
|
||||
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
|
||||
offset - sizeof(struct ip6_frag) +
|
||||
offsetof(struct ip6_frag, ip6f_offlg));
|
||||
@ -564,7 +562,7 @@ frag6_freef(q6)
|
||||
/* adjust pointer */
|
||||
ip6 = mtod(m, struct ip6_hdr *);
|
||||
|
||||
/* restoure source and destination addresses */
|
||||
/* restore source and destination addresses */
|
||||
ip6->ip6_src = q6->ip6q_src;
|
||||
ip6->ip6_dst = q6->ip6q_dst;
|
||||
|
||||
|
@ -642,7 +642,7 @@ icmp6_input(mp, offp, proto)
|
||||
|
||||
case MLD_MTRACE_RESP:
|
||||
case MLD_MTRACE:
|
||||
/* XXX: these two are experimental. not officially defind. */
|
||||
/* XXX: these two are experimental. not officially defined. */
|
||||
/* XXX: per-interface statistics? */
|
||||
break; /* just pass it to applications */
|
||||
|
||||
@ -887,8 +887,7 @@ icmp6_notify_error(m, off, icmp6len, code)
|
||||
}
|
||||
#ifndef PULLDOWN_TEST
|
||||
IP6_EXTHDR_CHECK(m, off,
|
||||
sizeof(struct icmp6_hdr) + sizeof(struct ip6_hdr),
|
||||
-1);
|
||||
sizeof(struct icmp6_hdr) + sizeof(struct ip6_hdr), -1);
|
||||
icmp6 = (struct icmp6_hdr *)(mtod(m, caddr_t) + off);
|
||||
#else
|
||||
IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off,
|
||||
@ -922,9 +921,8 @@ icmp6_notify_error(m, off, icmp6len, code)
|
||||
case IPPROTO_DSTOPTS:
|
||||
case IPPROTO_AH:
|
||||
#ifndef PULLDOWN_TEST
|
||||
IP6_EXTHDR_CHECK(m, 0, eoff +
|
||||
sizeof(struct ip6_ext),
|
||||
-1);
|
||||
IP6_EXTHDR_CHECK(m, 0,
|
||||
eoff + sizeof(struct ip6_ext), -1);
|
||||
eh = (struct ip6_ext *)(mtod(m, caddr_t)
|
||||
+ eoff);
|
||||
#else
|
||||
@ -952,10 +950,9 @@ icmp6_notify_error(m, off, icmp6len, code)
|
||||
* destination (e.g. path MTU).
|
||||
*/
|
||||
#ifndef PULLDOWN_TEST
|
||||
IP6_EXTHDR_CHECK(m, 0, eoff + sizeof(*rth),
|
||||
-1);
|
||||
rth = (struct ip6_rthdr *)(mtod(m, caddr_t)
|
||||
+ eoff);
|
||||
IP6_EXTHDR_CHECK(m, 0, eoff + sizeof(*rth), -1);
|
||||
rth = (struct ip6_rthdr *)
|
||||
(mtod(m, caddr_t) + eoff);
|
||||
#else
|
||||
IP6_EXTHDR_GET(rth, struct ip6_rthdr *, m,
|
||||
eoff, sizeof(*rth));
|
||||
@ -978,9 +975,9 @@ icmp6_notify_error(m, off, icmp6len, code)
|
||||
int hops;
|
||||
|
||||
#ifndef PULLDOWN_TEST
|
||||
IP6_EXTHDR_CHECK(m, 0, eoff + rthlen,
|
||||
-1);
|
||||
rth0 = (struct ip6_rthdr0 *)(mtod(m, caddr_t) + eoff);
|
||||
IP6_EXTHDR_CHECK(m, 0, eoff + rthlen, -1);
|
||||
rth0 = (struct ip6_rthdr0 *)
|
||||
(mtod(m, caddr_t) + eoff);
|
||||
#else
|
||||
IP6_EXTHDR_GET(rth0,
|
||||
struct ip6_rthdr0 *, m,
|
||||
@ -1001,10 +998,9 @@ icmp6_notify_error(m, off, icmp6len, code)
|
||||
case IPPROTO_FRAGMENT:
|
||||
#ifndef PULLDOWN_TEST
|
||||
IP6_EXTHDR_CHECK(m, 0, eoff +
|
||||
sizeof(struct ip6_frag),
|
||||
-1);
|
||||
fh = (struct ip6_frag *)(mtod(m, caddr_t)
|
||||
+ eoff);
|
||||
sizeof(struct ip6_frag), -1);
|
||||
fh = (struct ip6_frag *)(mtod(m, caddr_t) +
|
||||
eoff);
|
||||
#else
|
||||
IP6_EXTHDR_GET(fh, struct ip6_frag *, m,
|
||||
eoff, sizeof(*fh));
|
||||
@ -1049,7 +1045,16 @@ icmp6_notify_error(m, off, icmp6len, code)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* retrieve parameters from the inner IPv6 header, and convert
|
||||
* them into sockaddr structures.
|
||||
* XXX: there is no guarantee that the source or destination
|
||||
* addresses of the inner packet are in the same scope as
|
||||
* the addresses of the icmp packet. But there is no other
|
||||
* way to determine the zone.
|
||||
*/
|
||||
eip6 = (struct ip6_hdr *)(icmp6 + 1);
|
||||
|
||||
bzero(&icmp6dst, sizeof(icmp6dst));
|
||||
icmp6dst.sin6_len = sizeof(struct sockaddr_in6);
|
||||
icmp6dst.sin6_family = AF_INET6;
|
||||
@ -1088,8 +1093,7 @@ icmp6_notify_error(m, off, icmp6len, code)
|
||||
goto freeit;
|
||||
}
|
||||
#endif
|
||||
icmp6src.sin6_flowinfo =
|
||||
(eip6->ip6_flow & IPV6_FLOWLABEL_MASK);
|
||||
icmp6src.sin6_flowinfo = (eip6->ip6_flow & IPV6_FLOWLABEL_MASK);
|
||||
|
||||
if (finaldst == NULL)
|
||||
finaldst = &eip6->ip6_dst;
|
||||
@ -1149,8 +1153,8 @@ icmp6_mtudisc_update(ip6cp, validated)
|
||||
rt = rtalloc1((struct sockaddr *)&sin6, 0,
|
||||
RTF_CLONING | RTF_PRCLONING);
|
||||
|
||||
if (rt && (rt->rt_flags & RTF_HOST)
|
||||
&& !(rt->rt_rmx.rmx_locks & RTV_MTU)) {
|
||||
if (rt && (rt->rt_flags & RTF_HOST) &&
|
||||
!(rt->rt_rmx.rmx_locks & RTV_MTU)) {
|
||||
if (mtu < IPV6_MMTU) {
|
||||
/* xxx */
|
||||
rt->rt_rmx.rmx_locks |= RTV_MTU;
|
||||
@ -1203,7 +1207,7 @@ ni6_input(m, off)
|
||||
IP6_EXTHDR_GET(ni6, struct icmp6_nodeinfo *, m, off, sizeof(*ni6));
|
||||
if (ni6 == NULL) {
|
||||
/* m is already reclaimed */
|
||||
return NULL;
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1307,7 +1311,8 @@ ni6_input(m, off)
|
||||
* XXX if we are to allow other cases, we should really
|
||||
* be careful about scope here.
|
||||
* basically, we should disallow queries toward IPv6
|
||||
* destination X with subject Y, if scope(X) > scope(Y).
|
||||
* destination X with subject Y,
|
||||
* if scope(X) > scope(Y).
|
||||
* if we allow scope(X) > scope(Y), it will result in
|
||||
* information leakage across scope boundary.
|
||||
*/
|
||||
@ -1439,8 +1444,7 @@ ni6_input(m, off)
|
||||
case NI_QTYPE_FQDN:
|
||||
nni6->ni_code = ICMP6_NI_SUCCESS;
|
||||
fqdn = (struct ni_reply_fqdn *)(mtod(n, caddr_t) +
|
||||
sizeof(struct ip6_hdr) +
|
||||
sizeof(struct icmp6_nodeinfo));
|
||||
sizeof(struct ip6_hdr) + sizeof(struct icmp6_nodeinfo));
|
||||
nni6->ni_flags = 0; /* XXX: meaningless TTL */
|
||||
fqdn->ni_fqdn_ttl = 0; /* ditto. */
|
||||
/*
|
||||
@ -1685,11 +1689,9 @@ ni6_addrs(ni6, m, ifpp, subj)
|
||||
}
|
||||
|
||||
IFNET_RLOCK();
|
||||
for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list))
|
||||
{
|
||||
for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) {
|
||||
addrsofif = 0;
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
|
||||
{
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6)
|
||||
continue;
|
||||
ifa6 = (struct in6_ifaddr *)ifa;
|
||||
@ -1773,11 +1775,9 @@ ni6_store_addrs(ni6, nni6, ifp0, resid)
|
||||
|
||||
IFNET_RLOCK();
|
||||
again:
|
||||
for (; ifp; ifp = TAILQ_NEXT(ifp, if_list))
|
||||
{
|
||||
for (; ifp; ifp = TAILQ_NEXT(ifp, if_list)) {
|
||||
for (ifa = ifp->if_addrlist.tqh_first; ifa;
|
||||
ifa = ifa->ifa_list.tqe_next)
|
||||
{
|
||||
ifa = ifa->ifa_list.tqe_next) {
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6)
|
||||
continue;
|
||||
ifa6 = (struct in6_ifaddr *)ifa;
|
||||
@ -1794,8 +1794,7 @@ ni6_store_addrs(ni6, nni6, ifp0, resid)
|
||||
ifp_dep = ifp;
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ((ifa6->ia6_flags & IN6_IFF_DEPRECATED) == 0 &&
|
||||
} else if ((ifa6->ia6_flags & IN6_IFF_DEPRECATED) == 0 &&
|
||||
allow_deprecated != 0)
|
||||
continue; /* we now collect deprecated addrs */
|
||||
|
||||
@ -1836,8 +1835,7 @@ ni6_store_addrs(ni6, nni6, ifp0, resid)
|
||||
* We give up much more copy.
|
||||
* Set the truncate flag and return.
|
||||
*/
|
||||
nni6->ni_flags |=
|
||||
NI_NODEADDR_FLAG_TRUNCATE;
|
||||
nni6->ni_flags |= NI_NODEADDR_FLAG_TRUNCATE;
|
||||
IFNET_RUNLOCK();
|
||||
return (copied);
|
||||
}
|
||||
@ -1879,8 +1877,7 @@ ni6_store_addrs(ni6, nni6, ifp0, resid)
|
||||
cp += sizeof(struct in6_addr);
|
||||
|
||||
resid -= (sizeof(struct in6_addr) + sizeof(u_int32_t));
|
||||
copied += (sizeof(struct in6_addr) +
|
||||
sizeof(u_int32_t));
|
||||
copied += (sizeof(struct in6_addr) + sizeof(u_int32_t));
|
||||
}
|
||||
if (ifp0) /* we need search only on the specified IF */
|
||||
break;
|
||||
@ -1921,7 +1918,7 @@ icmp6_rip6_input(mp, off)
|
||||
IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6));
|
||||
if (icmp6 == NULL) {
|
||||
/* m is already reclaimed */
|
||||
return IPPROTO_DONE;
|
||||
return (IPPROTO_DONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1931,8 +1928,7 @@ icmp6_rip6_input(mp, off)
|
||||
/* KAME hack: recover scopeid */
|
||||
(void)in6_recoverscope(&rip6src, &ip6->ip6_src, m->m_pkthdr.rcvif);
|
||||
|
||||
LIST_FOREACH(in6p, &ripcb, inp_list)
|
||||
{
|
||||
LIST_FOREACH(in6p, &ripcb, inp_list) {
|
||||
if ((in6p->inp_vflag & INP_IPV6) == 0)
|
||||
continue;
|
||||
#ifdef HAVE_NRL_INPCB
|
||||
@ -1959,8 +1955,8 @@ icmp6_rip6_input(mp, off)
|
||||
/* strip intermediate headers */
|
||||
m_adj(n, off);
|
||||
if (sbappendaddr(&last->in6p_socket->so_rcv,
|
||||
(struct sockaddr *)&rip6src,
|
||||
n, opts) == 0) {
|
||||
(struct sockaddr *)&rip6src, n, opts)
|
||||
== 0) {
|
||||
/* should notify about lost packet */
|
||||
m_freem(n);
|
||||
if (opts) {
|
||||
@ -2122,7 +2118,7 @@ icmp6_reflect(m, off)
|
||||
/*
|
||||
* If the incoming packet was addressed directly to us (i.e. unicast),
|
||||
* use dst as the src for the reply.
|
||||
* The IN6_IFF_NOTREADY case would be VERY rare, but is possible
|
||||
* The IN6_IFF_NOTREADY case should be VERY rare, but is possible
|
||||
* (for example) when we encounter an error while forwarding procedure
|
||||
* destined to a duplicated address of ours.
|
||||
*/
|
||||
@ -2270,7 +2266,8 @@ icmp6_redirect_input(m, off)
|
||||
if (!IN6_IS_ADDR_LINKLOCAL(&src6)) {
|
||||
nd6log((LOG_ERR,
|
||||
"ICMP6 redirect sent from %s rejected; "
|
||||
"must be from linklocal\n", ip6_sprintf(&src6)));
|
||||
"must be from linklocal\n",
|
||||
ip6_sprintf(&src6)));
|
||||
goto bad;
|
||||
}
|
||||
if (ip6->ip6_hlim != 255) {
|
||||
@ -2617,19 +2614,22 @@ nolladdropt:;
|
||||
/*
|
||||
* Redirected header option spec (RFC2461 4.6.3) talks nothing
|
||||
* about padding/truncate rule for the original IP packet.
|
||||
* From the discussion on IPv6imp in Feb 1999, the consensus was:
|
||||
* From the discussion on IPv6imp in Feb 1999,
|
||||
* the consensus was:
|
||||
* - "attach as much as possible" is the goal
|
||||
* - pad if not aligned (original size can be guessed by original
|
||||
* ip6 header)
|
||||
* - pad if not aligned (original size can be guessed by
|
||||
* original ip6 header)
|
||||
* Following code adds the padding if it is simple enough,
|
||||
* and truncates if not.
|
||||
*/
|
||||
if (m0->m_next || m0->m_pkthdr.len != m0->m_len)
|
||||
panic("assumption failed in %s:%d", __FILE__, __LINE__);
|
||||
panic("assumption failed in %s:%d", __FILE__,
|
||||
__LINE__);
|
||||
|
||||
if (len - sizeof(*nd_opt_rh) < m0->m_pkthdr.len) {
|
||||
/* not enough room, truncate */
|
||||
m0->m_pkthdr.len = m0->m_len = len - sizeof(*nd_opt_rh);
|
||||
m0->m_pkthdr.len = m0->m_len = len -
|
||||
sizeof(*nd_opt_rh);
|
||||
} else {
|
||||
/* enough room, pad or truncate */
|
||||
size_t extra;
|
||||
@ -2648,7 +2648,8 @@ nolladdropt:;
|
||||
}
|
||||
}
|
||||
len = m0->m_pkthdr.len + sizeof(*nd_opt_rh);
|
||||
m0->m_pkthdr.len = m0->m_len = len - sizeof(*nd_opt_rh);
|
||||
m0->m_pkthdr.len = m0->m_len = len -
|
||||
sizeof(*nd_opt_rh);
|
||||
}
|
||||
|
||||
nd_opt_rh = (struct nd_opt_rd_hdr *)p;
|
||||
@ -2689,8 +2690,8 @@ noredhdropt:;
|
||||
ip6->ip6_plen = htons(m->m_pkthdr.len - sizeof(struct ip6_hdr));
|
||||
|
||||
nd_rd->nd_rd_cksum = 0;
|
||||
nd_rd->nd_rd_cksum
|
||||
= in6_cksum(m, IPPROTO_ICMPV6, sizeof(*ip6), ntohs(ip6->ip6_plen));
|
||||
nd_rd->nd_rd_cksum = in6_cksum(m, IPPROTO_ICMPV6,
|
||||
sizeof(*ip6), ntohs(ip6->ip6_plen));
|
||||
|
||||
/* send the packet to outside... */
|
||||
ip6_output(m, NULL, NULL, 0, NULL, &outif, NULL);
|
||||
|
@ -137,7 +137,6 @@ static int in6_ifinit __P((struct ifnet *, struct in6_ifaddr *,
|
||||
static void in6_unlink_ifa __P((struct in6_ifaddr *, struct ifnet *));
|
||||
|
||||
struct in6_multihead in6_multihead; /* XXX BSS initialization */
|
||||
|
||||
int (*faithprefix_p)(struct in6_addr *);
|
||||
|
||||
/*
|
||||
@ -165,9 +164,9 @@ in6_ifloop_request(int cmd, struct ifaddr *ifa)
|
||||
* which changes the outgoing interface to the loopback interface.
|
||||
*/
|
||||
e = rtrequest(cmd, ifa->ifa_addr, ifa->ifa_addr,
|
||||
(struct sockaddr *)&all1_sa,
|
||||
RTF_UP|RTF_HOST|RTF_LLINFO, &nrt);
|
||||
(struct sockaddr *)&all1_sa, RTF_UP|RTF_HOST|RTF_LLINFO, &nrt);
|
||||
if (e != 0) {
|
||||
/* XXX need more descriptive message */
|
||||
log(LOG_ERR, "in6_ifloop_request: "
|
||||
"%s operation failed for %s (errno=%d)\n",
|
||||
cmd == RTM_ADD ? "ADD" : "DELETE",
|
||||
@ -269,7 +268,7 @@ in6_ifremloop(struct ifaddr *ifa)
|
||||
* Before deleting, check if a corresponding loopbacked host
|
||||
* route surely exists. With this check, we can avoid to
|
||||
* delete an interface direct route whose destination is same
|
||||
* as the address being removed. This can happen when remofing
|
||||
* as the address being removed. This can happen when removing
|
||||
* a subnet-router anycast address on an interface attahced
|
||||
* to a shared medium.
|
||||
*/
|
||||
@ -317,8 +316,8 @@ in6_mask2len(mask, lim0)
|
||||
int x = 0, y;
|
||||
u_char *lim = lim0, *p;
|
||||
|
||||
if (lim0 == NULL ||
|
||||
lim0 - (u_char *)mask > sizeof(*mask)) /* ignore the scope_id part */
|
||||
/* ignore the scope_id part */
|
||||
if (lim0 == NULL || lim0 - (u_char *)mask > sizeof(*mask))
|
||||
lim = (u_char *)mask + sizeof(*mask);
|
||||
for (p = (u_char *)mask; p < lim; x++, p++) {
|
||||
if (*p != 0xff)
|
||||
@ -398,7 +397,7 @@ in6_control(so, cmd, data, ifp, td)
|
||||
case SIOCSIFINFO_FLAGS:
|
||||
if (!privileged)
|
||||
return (EPERM);
|
||||
/* fall through */
|
||||
/* FALLTHROUGH */
|
||||
case OSIOCGIFINFO_IN6:
|
||||
case SIOCGIFINFO_IN6:
|
||||
case SIOCGDRLST_IN6:
|
||||
@ -440,7 +439,7 @@ in6_control(so, cmd, data, ifp, td)
|
||||
case SIOCDLIFADDR:
|
||||
if (!privileged)
|
||||
return (EPERM);
|
||||
/* fall through */
|
||||
/* FALLTHROUGH */
|
||||
case SIOCGLIFADDR:
|
||||
return in6_lifaddr_ioctl(so, cmd, data, ifp, td);
|
||||
}
|
||||
@ -509,7 +508,7 @@ in6_control(so, cmd, data, ifp, td)
|
||||
|
||||
case SIOCGIFADDR_IN6:
|
||||
/* This interface is basically deprecated. use SIOCGIFCONF. */
|
||||
/* fall through */
|
||||
/* FALLTHROUGH */
|
||||
case SIOCGIFAFLAG_IN6:
|
||||
case SIOCGIFNETMASK_IN6:
|
||||
case SIOCGIFDSTADDR_IN6:
|
||||
@ -635,8 +634,9 @@ in6_control(so, cmd, data, ifp, td)
|
||||
pr0.ndpr_ifp = ifp;
|
||||
pr0.ndpr_plen = in6_mask2len(&ifra->ifra_prefixmask.sin6_addr,
|
||||
NULL);
|
||||
if (pr0.ndpr_plen == 128)
|
||||
if (pr0.ndpr_plen == 128) {
|
||||
break; /* we don't need to install a host route. */
|
||||
}
|
||||
pr0.ndpr_prefix = ifra->ifra_addr;
|
||||
pr0.ndpr_mask = ifra->ifra_prefixmask.sin6_addr;
|
||||
/* apply the mask for safety. */
|
||||
@ -657,7 +657,7 @@ in6_control(so, cmd, data, ifp, td)
|
||||
pr0.ndpr_vltime = ifra->ifra_lifetime.ia6t_vltime;
|
||||
pr0.ndpr_pltime = ifra->ifra_lifetime.ia6t_pltime;
|
||||
|
||||
/* add the prefix if there's one. */
|
||||
/* add the prefix if not yet. */
|
||||
if ((pr = nd6_prefix_lookup(&pr0)) == NULL) {
|
||||
/*
|
||||
* nd6_prelist_add will install the corresponding
|
||||
@ -666,7 +666,7 @@ in6_control(so, cmd, data, ifp, td)
|
||||
if ((error = nd6_prelist_add(&pr0, NULL, &pr)) != 0)
|
||||
return (error);
|
||||
if (pr == NULL) {
|
||||
log(LOG_ERR, "nd6_prelist_add succedded but "
|
||||
log(LOG_ERR, "nd6_prelist_add succeeded but "
|
||||
"no prefix\n");
|
||||
return (EINVAL); /* XXX panic here? */
|
||||
}
|
||||
@ -718,7 +718,7 @@ in6_control(so, cmd, data, ifp, td)
|
||||
/*
|
||||
* If the address being deleted is the only one that owns
|
||||
* the corresponding prefix, expire the prefix as well.
|
||||
* XXX: theoretically, we don't have to warry about such
|
||||
* XXX: theoretically, we don't have to worry about such
|
||||
* relationship, since we separate the address management
|
||||
* and the prefix management. We do this, however, to provide
|
||||
* as much backward compatibility as possible in terms of
|
||||
@ -815,8 +815,7 @@ in6_update_ifa(ifp, ifra, ia)
|
||||
ifra->ifra_prefixmask.sin6_len);
|
||||
if (plen <= 0)
|
||||
return (EINVAL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/*
|
||||
* In this case, ia must not be NULL. We just use its prefix
|
||||
* length.
|
||||
@ -829,14 +828,13 @@ in6_update_ifa(ifp, ifra, ia)
|
||||
* zone identifier.
|
||||
*/
|
||||
dst6 = ifra->ifra_dstaddr;
|
||||
if ((ifp->if_flags & (IFF_POINTOPOINT|IFF_LOOPBACK)) &&
|
||||
if ((ifp->if_flags & (IFF_POINTOPOINT|IFF_LOOPBACK)) != 0 &&
|
||||
(dst6.sin6_family == AF_INET6)) {
|
||||
int scopeid;
|
||||
|
||||
#ifndef SCOPEDROUTING
|
||||
if ((error = in6_recoverscope(&dst6,
|
||||
&ifra->ifra_dstaddr.sin6_addr,
|
||||
ifp)) != 0)
|
||||
&ifra->ifra_dstaddr.sin6_addr, ifp)) != 0)
|
||||
return (error);
|
||||
#endif
|
||||
scopeid = in6_addr2scopeid(ifp, &dst6.sin6_addr);
|
||||
@ -901,11 +899,11 @@ in6_update_ifa(ifp, ifra, ia)
|
||||
hostIsNew = 1;
|
||||
/*
|
||||
* When in6_update_ifa() is called in a process of a received
|
||||
* RA, it is called under splnet(). So, we should call malloc
|
||||
* with M_NOWAIT.
|
||||
* RA, it is called under an interrupt context. So, we should
|
||||
* call malloc with M_NOWAIT.
|
||||
*/
|
||||
ia = (struct in6_ifaddr *)
|
||||
malloc(sizeof(*ia), M_IFADDR, M_NOWAIT);
|
||||
ia = (struct in6_ifaddr *) malloc(sizeof(*ia), M_IFADDR,
|
||||
M_NOWAIT);
|
||||
if (ia == NULL)
|
||||
return (ENOBUFS);
|
||||
bzero((caddr_t)ia, sizeof(*ia));
|
||||
@ -919,8 +917,8 @@ in6_update_ifa(ifp, ifra, ia)
|
||||
* XXX: some functions expect that ifa_dstaddr is not
|
||||
* NULL for p2p interfaces.
|
||||
*/
|
||||
ia->ia_ifa.ifa_dstaddr
|
||||
= (struct sockaddr *)&ia->ia_dstaddr;
|
||||
ia->ia_ifa.ifa_dstaddr =
|
||||
(struct sockaddr *)&ia->ia_dstaddr;
|
||||
} else {
|
||||
ia->ia_ifa.ifa_dstaddr = NULL;
|
||||
}
|
||||
@ -963,19 +961,16 @@ in6_update_ifa(ifp, ifra, ia)
|
||||
* p2p or loopback (see the check above.)
|
||||
*/
|
||||
if (dst6.sin6_family == AF_INET6 &&
|
||||
!IN6_ARE_ADDR_EQUAL(&dst6.sin6_addr,
|
||||
&ia->ia_dstaddr.sin6_addr)) {
|
||||
!IN6_ARE_ADDR_EQUAL(&dst6.sin6_addr, &ia->ia_dstaddr.sin6_addr)) {
|
||||
int e;
|
||||
|
||||
if ((ia->ia_flags & IFA_ROUTE) != 0 &&
|
||||
(e = rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST))
|
||||
!= 0) {
|
||||
(e = rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST)) != 0) {
|
||||
log(LOG_ERR, "in6_update_ifa: failed to remove "
|
||||
"a route to the old destination: %s\n",
|
||||
ip6_sprintf(&ia->ia_addr.sin6_addr));
|
||||
/* proceed anyway... */
|
||||
}
|
||||
else
|
||||
} else
|
||||
ia->ia_flags &= ~IFA_ROUTE;
|
||||
ia->ia_dstaddr = dst6;
|
||||
}
|
||||
@ -989,29 +984,14 @@ in6_update_ifa(ifp, ifra, ia)
|
||||
* not just go to unlink.
|
||||
*/
|
||||
|
||||
#if 0 /* disable this mechanism for now */
|
||||
/* update prefix list */
|
||||
if (hostIsNew &&
|
||||
(ifra->ifra_flags & IN6_IFF_NOPFX) == 0) { /* XXX */
|
||||
int iilen;
|
||||
|
||||
iilen = (sizeof(ia->ia_prefixmask.sin6_addr) << 3) - plen;
|
||||
if ((error = in6_prefix_add_ifid(iilen, ia)) != 0) {
|
||||
in6_purgeaddr((struct ifaddr *)ia);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((ifp->if_flags & IFF_MULTICAST) != 0) {
|
||||
struct sockaddr_in6 mltaddr, mltmask;
|
||||
struct in6_multi *in6m;
|
||||
|
||||
if (hostIsNew) {
|
||||
/*
|
||||
* join solicited multicast addr for new host id
|
||||
*/
|
||||
/* join solicited multicast addr for new host id */
|
||||
struct in6_addr llsol;
|
||||
|
||||
bzero(&llsol, sizeof(struct in6_addr));
|
||||
llsol.s6_addr16[0] = htons(0xff02);
|
||||
llsol.s6_addr16[1] = htons(ifp->if_index);
|
||||
@ -1191,8 +1171,7 @@ in6_purgeaddr(ifa)
|
||||
ip6_sprintf(&ia->ia_addr.sin6_addr), if_name(ifp),
|
||||
e);
|
||||
/* proceed anyway... */
|
||||
}
|
||||
else
|
||||
} else
|
||||
ia->ia_flags &= ~IFA_ROUTE;
|
||||
}
|
||||
|
||||
@ -1287,8 +1266,7 @@ in6_purgeif(ifp)
|
||||
{
|
||||
struct ifaddr *ifa, *nifa;
|
||||
|
||||
for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa != NULL; ifa = nifa)
|
||||
{
|
||||
for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa != NULL; ifa = nifa) {
|
||||
nifa = TAILQ_NEXT(ifa, ifa_list);
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6)
|
||||
continue;
|
||||
@ -1336,7 +1314,7 @@ in6_lifaddr_ioctl(so, cmd, data, ifp, td)
|
||||
/* sanity checks */
|
||||
if (!data || !ifp) {
|
||||
panic("invalid argument to in6_lifaddr_ioctl");
|
||||
/*NOTRECHED*/
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
@ -1407,8 +1385,7 @@ in6_lifaddr_ioctl(so, cmd, data, ifp, td)
|
||||
|
||||
/* copy args to in6_aliasreq, perform ioctl(SIOCAIFADDR_IN6). */
|
||||
bzero(&ifra, sizeof(ifra));
|
||||
bcopy(iflr->iflr_name, ifra.ifra_name,
|
||||
sizeof(ifra.ifra_name));
|
||||
bcopy(iflr->iflr_name, ifra.ifra_name, sizeof(ifra.ifra_name));
|
||||
|
||||
bcopy(&iflr->addr, &ifra.ifra_addr,
|
||||
((struct sockaddr *)&iflr->addr)->sa_len);
|
||||
@ -1476,8 +1453,7 @@ in6_lifaddr_ioctl(so, cmd, data, ifp, td)
|
||||
}
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
|
||||
{
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6)
|
||||
continue;
|
||||
if (!cmp)
|
||||
@ -1535,8 +1511,7 @@ in6_lifaddr_ioctl(so, cmd, data, ifp, td)
|
||||
bzero(&iflr->dstaddr, sizeof(iflr->dstaddr));
|
||||
|
||||
iflr->prefixlen =
|
||||
in6_mask2len(&ia->ia_prefixmask.sin6_addr,
|
||||
NULL);
|
||||
in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL);
|
||||
|
||||
iflr->flags = ia->ia6_flags; /* XXX */
|
||||
|
||||
@ -1591,8 +1566,7 @@ in6_ifinit(ifp, ia, sin6, newhost)
|
||||
* if this is its first address,
|
||||
* and to validate the address if necessary.
|
||||
*/
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
|
||||
{
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
|
||||
if (ifa->ifa_addr == NULL)
|
||||
continue; /* just for safety */
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6)
|
||||
@ -1698,7 +1672,7 @@ in6_addmulti(maddr6, ifp, errorp)
|
||||
LIST_INSERT_HEAD(&in6_multihead, in6m, in6m_entry);
|
||||
|
||||
/*
|
||||
* Let MLD6 know that we have joined a new IP6 multicast
|
||||
* Let MLD6 know that we have joined a new IPv6 multicast
|
||||
* group.
|
||||
*/
|
||||
mld6_start_listening(in6m);
|
||||
@ -1741,8 +1715,7 @@ in6ifa_ifpforlinklocal(ifp, ignoreflags)
|
||||
{
|
||||
struct ifaddr *ifa;
|
||||
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
|
||||
{
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
|
||||
if (ifa->ifa_addr == NULL)
|
||||
continue; /* just for safety */
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6)
|
||||
@ -1769,8 +1742,7 @@ in6ifa_ifpwithaddr(ifp, addr)
|
||||
{
|
||||
struct ifaddr *ifa;
|
||||
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
|
||||
{
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
|
||||
if (ifa->ifa_addr == NULL)
|
||||
continue; /* just for safety */
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6)
|
||||
@ -1845,10 +1817,12 @@ in6_localaddr(in6)
|
||||
if (IN6_IS_ADDR_LOOPBACK(in6) || IN6_IS_ADDR_LINKLOCAL(in6))
|
||||
return 1;
|
||||
|
||||
for (ia = in6_ifaddr; ia; ia = ia->ia_next)
|
||||
for (ia = in6_ifaddr; ia; ia = ia->ia_next) {
|
||||
if (IN6_ARE_MASKED_ADDR_EQUAL(in6, &ia->ia_addr.sin6_addr,
|
||||
&ia->ia_prefixmask.sin6_addr))
|
||||
&ia->ia_prefixmask.sin6_addr)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -1964,9 +1938,6 @@ in6_ifawithscope(oifp, dst)
|
||||
struct in6_ifaddr *ifa_best = NULL;
|
||||
|
||||
if (oifp == NULL) {
|
||||
#if 0
|
||||
printf("in6_ifawithscope: output interface is not specified\n");
|
||||
#endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -2252,8 +2223,7 @@ in6_ifawithifp(ifp, dst)
|
||||
* If two or more, return one which matches the dst longest.
|
||||
* If none, return one of global addresses assigned other ifs.
|
||||
*/
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
|
||||
{
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6)
|
||||
continue;
|
||||
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST)
|
||||
@ -2287,8 +2257,7 @@ in6_ifawithifp(ifp, dst)
|
||||
if (besta)
|
||||
return (besta);
|
||||
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
|
||||
{
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6)
|
||||
continue;
|
||||
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST)
|
||||
@ -2332,8 +2301,7 @@ in6_if_up(ifp)
|
||||
in6_ifattach(ifp, NULL);
|
||||
|
||||
dad_delay = 0;
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
|
||||
{
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6)
|
||||
continue;
|
||||
ia = (struct in6_ifaddr *)ifa;
|
||||
@ -2390,8 +2358,7 @@ in6_setmaxmtu()
|
||||
struct ifnet *ifp;
|
||||
|
||||
IFNET_RLOCK();
|
||||
for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list))
|
||||
{
|
||||
for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) {
|
||||
if ((ifp->if_flags & IFF_LOOPBACK) == 0 &&
|
||||
nd_ifinfo[ifp->if_index].linkmtu > maxmtu)
|
||||
maxmtu = nd_ifinfo[ifp->if_index].linkmtu;
|
||||
|
Loading…
x
Reference in New Issue
Block a user