-/* $OpenBSD: ip6_output.c,v 1.249 2021/01/11 13:28:54 bluhm Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.250 2021/02/01 12:08:50 bluhm Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
if (ipsec_in_use || inp) {
tdb = ip6_output_ipsec_lookup(m, &error, inp);
if (error != 0) {
- /*
+ /*
* -EINVAL is used to indicate that the packet should
* be silently dropped, typically because we've asked
* key management for an SA.
*/
- if (error == -EINVAL) /* Should silently drop packet */
+ if (error == -EINVAL) /* Should silently drop packet */
error = 0;
goto freehdrs;
*/
if (exthdrs.ip6e_dest2) {
if (!hdrsplit)
- panic("%s: assumption failed: hdr not split", __func__);
+ panic("%s: assumption failed: hdr not split",
+ __func__);
exthdrs.ip6e_dest2->m_next = m->m_next;
m->m_next = exthdrs.ip6e_dest2;
*mtod(exthdrs.ip6e_dest2, u_char *) = ip6->ip6_nxt;
struct ip6_rthdr *));
switch (rh->ip6r_type) {
case IPV6_RTHDR_TYPE_0:
- rh0 = (struct ip6_rthdr0 *)rh;
- addr = (struct in6_addr *)(rh0 + 1);
- ip6->ip6_dst = addr[0];
- bcopy(&addr[1], &addr[0],
- sizeof(struct in6_addr) * (rh0->ip6r0_segleft - 1));
- addr[rh0->ip6r0_segleft - 1] = finaldst;
- break;
+ rh0 = (struct ip6_rthdr0 *)rh;
+ addr = (struct in6_addr *)(rh0 + 1);
+ ip6->ip6_dst = addr[0];
+ bcopy(&addr[1], &addr[0],
+ sizeof(struct in6_addr) * (rh0->ip6r0_segleft - 1));
+ addr[rh0->ip6r0_segleft - 1] = finaldst;
+ break;
default: /* is it possible? */
- error = EINVAL;
- goto bad;
+ error = EINVAL;
+ goto bad;
}
}
if ((ip6->ip6_flow & htonl(0x03 << 20)) == 0)
mask |= 0x03;
if (mask != 0)
- ip6->ip6_flow |= htonl((opt->ip6po_tclass & mask) << 20);
+ ip6->ip6_flow |=
+ htonl((opt->ip6po_tclass & mask) << 20);
}
/* fill in or override the hop limit field, if necessary. */
mtu = IPV6_MMTU;
else if (opt && opt->ip6po_minmtu == IP6PO_MINMTU_ALL)
mtu = IPV6_MMTU;
- else if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) &&
- (opt == NULL ||
- opt->ip6po_minmtu != IP6PO_MINMTU_DISABLE)) {
+ else if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) && (opt == NULL ||
+ opt->ip6po_minmtu != IP6PO_MINMTU_DISABLE)) {
mtu = IPV6_MMTU;
}
}
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 */
+ /* use the trailing space of the last mbuf for fragment hdr */
*frghdrp = (struct ip6_frag *)(mtod(mlast, caddr_t) +
mlast->m_len);
mlast->m_len += sizeof(struct ip6_frag);
optp = &inp->inp_outputopts6;
error = ip6_pcbopt(IPV6_HOPLIMIT,
- (u_char *)&optval,
- sizeof(optval),
- optp,
- privileged, uproto);
+ (u_char *)&optval, sizeof(optval), optp,
+ privileged, uproto);
break;
}
* available only prior to bind(2).
* see ipng mailing list, Jun 22 2001.
*/
- if (inp->inp_lport ||
- !IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6)) {
+ if (inp->inp_lport || !IN6_IS_ADDR_UNSPECIFIED(
+ &inp->inp_laddr6)) {
error = EINVAL;
break;
}
{
struct ip6_pktopts **optp;
optp = &inp->inp_outputopts6;
- error = ip6_pcbopt(optname,
- (u_char *)&optval,
- sizeof(optval),
- optp,
- privileged, uproto);
+ error = ip6_pcbopt(optname, (u_char *)&optval,
+ sizeof(optval), optp, privileged, uproto);
break;
}
optbuflen = 0;
}
optp = &inp->inp_outputopts6;
- error = ip6_pcbopt(optname,
- optbuf, optbuflen,
- optp, privileged, uproto);
+ error = ip6_pcbopt(optname, optbuf, optbuflen, optp,
+ privileged, uproto);
break;
}
#undef OPTSET
switch (optname) {
case IPV6_AUTH_LEVEL:
- if (optval < IPSEC_AUTH_LEVEL_DEFAULT &&
+ if (optval < IPSEC_AUTH_LEVEL_DEFAULT &&
suser(p)) {
error = EACCES;
break;
break;
case IPV6_ESP_TRANS_LEVEL:
- if (optval < IPSEC_ESP_TRANS_LEVEL_DEFAULT &&
+ if (optval < IPSEC_ESP_TRANS_LEVEL_DEFAULT &&
suser(p)) {
error = EACCES;
break;
break;
case IPV6_ESP_NETWORK_LEVEL:
- if (optval < IPSEC_ESP_NETWORK_LEVEL_DEFAULT &&
+ if (optval < IPSEC_ESP_NETWORK_LEVEL_DEFAULT &&
suser(p)) {
error = EACCES;
break;
break;
case IPV6_IPCOMP_LEVEL:
- if (optval < IPSEC_IPCOMP_LEVEL_DEFAULT &&
+ if (optval < IPSEC_IPCOMP_LEVEL_DEFAULT &&
suser(p)) {
error = EACCES;
break;
* values or -1 as a special value.
*/
error = EINVAL;
- } else if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
+ } else if (so->so_proto->pr_protocol ==
+ IPPROTO_ICMPV6) {
if (optval != icmp6off)
error = EINVAL;
} else
#define PKTOPT_EXTHDRCPY(type) \
do {\
if (src->type) {\
- size_t hlen = (((struct ip6_ext *)src->type)->ip6e_len + 1) << 3;\
+ size_t hlen;\
+ hlen = (((struct ip6_ext *)src->type)->ip6e_len + 1) << 3;\
dst->type = malloc(hlen, M_IP6OPT, M_NOWAIT);\
if (dst->type == NULL)\
goto bad;\
in6_proto_cksum_out(m, encif);
#endif
- /* Check if we are allowed to fragment */
- ip6 = mtod(m, struct ip6_hdr *);
- if (ip_mtudisc && tdb->tdb_mtu &&
+ /* Check if we are allowed to fragment */
+ ip6 = mtod(m, struct ip6_hdr *);
+ if (ip_mtudisc && tdb->tdb_mtu &&
sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) > tdb->tdb_mtu &&
tdb->tdb_mtutimeout > gettime()) {
struct rtentry *rt = NULL;