KNF a bit
This commit is contained in:
parent
14df31ceb3
commit
05f0c3e705
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip6_output.c,v 1.48 2002/06/07 04:18:12 itojun Exp $ */
|
||||
/* $NetBSD: ip6_output.c,v 1.49 2002/06/07 14:29:10 itojun Exp $ */
|
||||
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -66,7 +66,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.48 2002/06/07 04:18:12 itojun Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.49 2002/06/07 14:29:10 itojun Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -339,12 +339,11 @@ ip6_output(m0, opt, ro, flags, im6o, ifpp)
|
||||
* m will point to IPv6 header. mprev will point to the
|
||||
* extension header prior to dest2 (rthdr in the above case).
|
||||
*/
|
||||
MAKE_CHAIN(exthdrs.ip6e_hbh, mprev,
|
||||
nexthdrp, IPPROTO_HOPOPTS);
|
||||
MAKE_CHAIN(exthdrs.ip6e_dest1, mprev,
|
||||
nexthdrp, IPPROTO_DSTOPTS);
|
||||
MAKE_CHAIN(exthdrs.ip6e_rthdr, mprev,
|
||||
nexthdrp, IPPROTO_ROUTING);
|
||||
MAKE_CHAIN(exthdrs.ip6e_hbh, mprev, nexthdrp, IPPROTO_HOPOPTS);
|
||||
MAKE_CHAIN(exthdrs.ip6e_dest1, mprev, nexthdrp,
|
||||
IPPROTO_DSTOPTS);
|
||||
MAKE_CHAIN(exthdrs.ip6e_rthdr, mprev, nexthdrp,
|
||||
IPPROTO_ROUTING);
|
||||
|
||||
#ifdef IPSEC
|
||||
if (!needipsec)
|
||||
@ -407,11 +406,11 @@ skip_ipsec2:;
|
||||
* with the first hop of the routing header.
|
||||
*/
|
||||
if (exthdrs.ip6e_rthdr) {
|
||||
struct ip6_rthdr *rh =
|
||||
(struct ip6_rthdr *)(mtod(exthdrs.ip6e_rthdr,
|
||||
struct ip6_rthdr *));
|
||||
struct ip6_rthdr *rh;
|
||||
struct ip6_rthdr0 *rh0;
|
||||
|
||||
rh = (struct ip6_rthdr *)(mtod(exthdrs.ip6e_rthdr,
|
||||
struct ip6_rthdr *));
|
||||
finaldst = ip6->ip6_dst;
|
||||
switch (rh->ip6r_type) {
|
||||
case IPV6_RTHDR_TYPE_0:
|
||||
@ -419,8 +418,7 @@ skip_ipsec2:;
|
||||
ip6->ip6_dst = rh0->ip6r0_addr[0];
|
||||
bcopy((caddr_t)&rh0->ip6r0_addr[1],
|
||||
(caddr_t)&rh0->ip6r0_addr[0],
|
||||
sizeof(struct in6_addr) * (rh0->ip6r0_segleft - 1)
|
||||
);
|
||||
sizeof(struct in6_addr) * (rh0->ip6r0_segleft - 1));
|
||||
rh0->ip6r0_addr[rh0->ip6r0_segleft - 1] = finaldst;
|
||||
break;
|
||||
default: /* is it possible? */
|
||||
@ -633,8 +631,7 @@ skip_ipsec2:;
|
||||
if (ifp == NULL) {
|
||||
if (ro->ro_rt == 0) {
|
||||
ro->ro_rt = rtalloc1((struct sockaddr *)
|
||||
&ro->ro_dst, 0
|
||||
);
|
||||
&ro->ro_dst, 0);
|
||||
}
|
||||
if (ro->ro_rt == 0) {
|
||||
ip6stat.ip6s_noroute++;
|
||||
@ -759,8 +756,7 @@ skip_ipsec2:;
|
||||
*/
|
||||
if (origifp == NULL)
|
||||
origifp = ifp;
|
||||
}
|
||||
else
|
||||
} else
|
||||
origifp = ifp;
|
||||
if (IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_src))
|
||||
ip6->ip6_src.s6_addr16[1] = 0;
|
||||
@ -785,10 +781,8 @@ skip_ipsec2:;
|
||||
*/
|
||||
m->m_flags |= M_LOOP;
|
||||
m->m_pkthdr.rcvif = ifp;
|
||||
if (ip6_process_hopopts(m,
|
||||
(u_int8_t *)(hbh + 1),
|
||||
((hbh->ip6h_len + 1) << 3) -
|
||||
sizeof(struct ip6_hbh),
|
||||
if (ip6_process_hopopts(m, (u_int8_t *)(hbh + 1),
|
||||
((hbh->ip6h_len + 1) << 3) - sizeof(struct ip6_hbh),
|
||||
&dummy1, &dummy2) < 0) {
|
||||
/* m was already freed at this point */
|
||||
error = EINVAL;/* better error? */
|
||||
@ -802,8 +796,7 @@ skip_ipsec2:;
|
||||
/*
|
||||
* Run through list of hooks for output packets.
|
||||
*/
|
||||
if ((error = pfil_run_hooks(&inet6_pfil_hook, &m, ifp,
|
||||
PFIL_OUT)) != 0)
|
||||
if ((error = pfil_run_hooks(&inet6_pfil_hook, &m, ifp, PFIL_OUT)) != 0)
|
||||
goto done;
|
||||
if (m == NULL)
|
||||
goto done;
|
||||
@ -814,22 +807,7 @@ skip_ipsec2:;
|
||||
* If necessary, do IPv6 fragmentation before sending.
|
||||
*/
|
||||
tlen = m->m_pkthdr.len;
|
||||
if (tlen <= mtu
|
||||
#ifdef notyet
|
||||
/*
|
||||
* On any link that cannot convey a 1280-octet packet in one piece,
|
||||
* link-specific fragmentation and reassembly must be provided at
|
||||
* a layer below IPv6. [RFC 2460, sec.5]
|
||||
* Thus if the interface has ability of link-level fragmentation,
|
||||
* we can just send the packet even if the packet size is
|
||||
* larger than the link's MTU.
|
||||
* XXX: IFF_FRAGMENTABLE (or such) flag has not been defined yet...
|
||||
*/
|
||||
|
||||
|| ifp->if_flags & IFF_FRAGMENTABLE
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (tlen <= mtu) {
|
||||
#ifdef IFA_STATS
|
||||
struct in6_ifaddr *ia6;
|
||||
ip6 = mtod(m, struct ip6_hdr *);
|
||||
@ -930,8 +908,7 @@ skip_ipsec2:;
|
||||
else
|
||||
ip6f->ip6f_offlg |= IP6F_MORE_FRAG;
|
||||
mhip6->ip6_plen = htons((u_short)(len + hlen +
|
||||
sizeof(*ip6f) -
|
||||
sizeof(struct ip6_hdr)));
|
||||
sizeof(*ip6f) - sizeof(struct ip6_hdr)));
|
||||
if ((m_frgpart = m_copy(m0, off, len)) == 0) {
|
||||
error = ENOBUFS;
|
||||
ip6stat.ip6s_odropped++;
|
||||
@ -1165,8 +1142,8 @@ ip6_insertfraghdr(m0, m, hlen, frghdrp)
|
||||
if ((mlast->m_flags & M_EXT) == 0 &&
|
||||
M_TRAILINGSPACE(mlast) >= sizeof(struct ip6_frag)) {
|
||||
/* use the trailing space of the last mbuf for the fragment hdr */
|
||||
*frghdrp =
|
||||
(struct ip6_frag *)(mtod(mlast, caddr_t) + mlast->m_len);
|
||||
*frghdrp = (struct ip6_frag *)(mtod(mlast, caddr_t) +
|
||||
mlast->m_len);
|
||||
mlast->m_len += sizeof(struct ip6_frag);
|
||||
m->m_pkthdr.len += sizeof(struct ip6_frag);
|
||||
} else {
|
||||
@ -1304,10 +1281,12 @@ ip6_ctloutput(op, so, level, optname, mp)
|
||||
}
|
||||
break;
|
||||
#define OPTSET(bit) \
|
||||
do { \
|
||||
if (optval) \
|
||||
in6p->in6p_flags |= bit; \
|
||||
in6p->in6p_flags |= (bit); \
|
||||
else \
|
||||
in6p->in6p_flags &= ~bit;
|
||||
in6p->in6p_flags &= ~(bit); \
|
||||
} while (0)
|
||||
|
||||
case IPV6_RECVOPTS:
|
||||
OPTSET(IN6P_RECVOPTS);
|
||||
@ -1352,8 +1331,7 @@ else \
|
||||
* see ipng mailing list, Jun 22 2001.
|
||||
*/
|
||||
if (in6p->in6p_lport ||
|
||||
!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr))
|
||||
{
|
||||
!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
@ -1373,7 +1351,8 @@ else \
|
||||
case IPV6_MULTICAST_LOOP:
|
||||
case IPV6_JOIN_GROUP:
|
||||
case IPV6_LEAVE_GROUP:
|
||||
error = ip6_setmoptions(optname, &in6p->in6p_moptions, m);
|
||||
error = ip6_setmoptions(optname,
|
||||
&in6p->in6p_moptions, m);
|
||||
break;
|
||||
|
||||
case IPV6_PORTRANGE:
|
||||
@ -1801,8 +1780,8 @@ ip6_setmoptions(optname, im6op, m)
|
||||
* if the address has link-local scope.
|
||||
*/
|
||||
if (IN6_IS_ADDR_MC_LINKLOCAL(&mreq->ipv6mr_multiaddr)) {
|
||||
mreq->ipv6mr_multiaddr.s6_addr16[1]
|
||||
= htons(mreq->ipv6mr_interface);
|
||||
mreq->ipv6mr_multiaddr.s6_addr16[1] =
|
||||
htons(mreq->ipv6mr_interface);
|
||||
}
|
||||
/*
|
||||
* See if the membership already exists.
|
||||
@ -1862,16 +1841,15 @@ ip6_setmoptions(optname, im6op, m)
|
||||
* if the address has link-local scope.
|
||||
*/
|
||||
if (IN6_IS_ADDR_MC_LINKLOCAL(&mreq->ipv6mr_multiaddr)) {
|
||||
mreq->ipv6mr_multiaddr.s6_addr16[1]
|
||||
= htons(mreq->ipv6mr_interface);
|
||||
mreq->ipv6mr_multiaddr.s6_addr16[1] =
|
||||
htons(mreq->ipv6mr_interface);
|
||||
}
|
||||
/*
|
||||
* Find the membership in the membership list.
|
||||
*/
|
||||
for (imm = im6o->im6o_memberships.lh_first;
|
||||
imm != NULL; imm = imm->i6mm_chain.le_next) {
|
||||
if ((ifp == NULL ||
|
||||
imm->i6mm_maddr->in6m_ifp == ifp) &&
|
||||
if ((ifp == NULL || imm->i6mm_maddr->in6m_ifp == ifp) &&
|
||||
IN6_ARE_ADDR_EQUAL(&imm->i6mm_maddr->in6m_addr,
|
||||
&mreq->ipv6mr_multiaddr))
|
||||
break;
|
||||
@ -2018,8 +1996,8 @@ ip6_setpktoptions(control, opt, priv)
|
||||
opt->ip6po_pktinfo->ipi6_addr.s6_addr16[1] =
|
||||
htons(opt->ip6po_pktinfo->ipi6_ifindex);
|
||||
|
||||
if (opt->ip6po_pktinfo->ipi6_ifindex > if_index
|
||||
|| opt->ip6po_pktinfo->ipi6_ifindex < 0) {
|
||||
if (opt->ip6po_pktinfo->ipi6_ifindex > if_index ||
|
||||
opt->ip6po_pktinfo->ipi6_ifindex < 0) {
|
||||
return(ENXIO);
|
||||
}
|
||||
|
||||
@ -2074,8 +2052,8 @@ ip6_setpktoptions(control, opt, priv)
|
||||
if (!priv)
|
||||
return(EPERM);
|
||||
|
||||
if (cm->cmsg_len < sizeof(u_char) ||
|
||||
/* check if cmsg_len is large enough for sa_len */
|
||||
if (cm->cmsg_len < sizeof(u_char) ||
|
||||
cm->cmsg_len < CMSG_LEN(*CMSG_DATA(cm)))
|
||||
return(EINVAL);
|
||||
|
||||
@ -2106,16 +2084,14 @@ ip6_setpktoptions(control, opt, priv)
|
||||
opt->ip6po_dest1 =
|
||||
(struct ip6_dest *)CMSG_DATA(cm);
|
||||
if (cm->cmsg_len !=
|
||||
CMSG_LEN((opt->ip6po_dest1->ip6d_len + 1)
|
||||
<< 3))
|
||||
CMSG_LEN((opt->ip6po_dest1->ip6d_len + 1) << 3));
|
||||
return(EINVAL);
|
||||
}
|
||||
else {
|
||||
opt->ip6po_dest2 =
|
||||
(struct ip6_dest *)CMSG_DATA(cm);
|
||||
if (cm->cmsg_len !=
|
||||
CMSG_LEN((opt->ip6po_dest2->ip6d_len + 1)
|
||||
<< 3))
|
||||
CMSG_LEN((opt->ip6po_dest2->ip6d_len + 1) << 3))
|
||||
return(EINVAL);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user