This commit is contained in:
maxv 2018-04-18 06:43:10 +00:00
parent f811c85e06
commit 1e45b2f110
2 changed files with 27 additions and 26 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsec_output.c,v 1.71 2018/03/05 11:50:25 maxv Exp $ */
/* $NetBSD: ipsec_output.c,v 1.72 2018/04/18 06:52:35 maxv Exp $ */
/*
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.71 2018/03/05 11:50:25 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.72 2018/04/18 06:52:35 maxv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@ -89,7 +89,7 @@ static percpu_t *ipsec_rtcache_percpu __cacheline_aligned;
* processed this packet.
*/
static int
ipsec_register_done(struct mbuf *m, int * error)
ipsec_register_done(struct mbuf *m, int *error)
{
struct m_tag *mtag;
@ -144,14 +144,14 @@ ipsec_process_done(struct mbuf *m, const struct ipsecrequest *isr,
struct secasindex *saidx;
int error;
#ifdef INET
struct ip * ip;
struct ip *ip;
#endif
#ifdef INET6
struct ip6_hdr * ip6;
struct ip6_hdr *ip6;
#endif
struct mbuf * mo;
struct mbuf *mo;
struct udphdr *udp = NULL;
uint64_t * data = NULL;
uint64_t *data = NULL;
int hlen, roff;
IPSEC_SPLASSERT_SOFTNET("ipsec_process_done");
@ -175,7 +175,7 @@ ipsec_process_done(struct mbuf *m, const struct ipsecrequest *isr,
IPSECLOG(LOG_DEBUG,
"failed to inject %u byte UDP for SA %s/%08lx\n",
hlen, ipsec_address(&saidx->dst, buf, sizeof(buf)),
(u_long) ntohl(sav->spi));
(u_long)ntohl(sav->spi));
error = ENOBUFS;
goto bad;
}
@ -196,10 +196,12 @@ ipsec_process_done(struct mbuf *m, const struct ipsecrequest *isr,
udp->uh_ulen = htons(m->m_pkthdr.len - (ip->ip_hl << 2));
}
/*
* Fix the header length, for AH processing.
*/
switch (saidx->dst.sa.sa_family) {
#ifdef INET
case AF_INET:
/* Fix the header length, for AH processing. */
ip = mtod(m, struct ip *);
ip->ip_len = htons(m->m_pkthdr.len);
if (sav->natt_type != 0)
@ -208,7 +210,6 @@ ipsec_process_done(struct mbuf *m, const struct ipsecrequest *isr,
#endif
#ifdef INET6
case AF_INET6:
/* Fix the header length, for AH processing. */
if (m->m_pkthdr.len < sizeof(struct ip6_hdr)) {
error = ENXIO;
goto bad;
@ -260,9 +261,9 @@ ipsec_process_done(struct mbuf *m, const struct ipsecrequest *isr,
}
/*
* We're done with IPsec processing,
* mark that we have already processed the packet
* transmit it packet using the appropriate network protocol (IP or IPv6).
* We're done with IPsec processing, mark the packet as processed,
* and transmit it using the appropriate network protocol
* (IPv4/IPv6).
*/
if (ipsec_register_done(m, &error) < 0)
@ -412,8 +413,8 @@ again:
ipsec_get_reqlevel(isr));
isr = isr->next;
/*
* No more rules to apply, return NULL isr and no error
* It can happen when the last rules are USE rules
* No more rules to apply, return NULL isr and no error.
* It can happen when the last rules are USE rules.
*/
if (isr == NULL) {
*ret = NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xform_ipip.c,v 1.63 2018/02/15 10:41:51 maxv Exp $ */
/* $NetBSD: xform_ipip.c,v 1.64 2018/04/18 06:43:10 maxv Exp $ */
/* $FreeBSD: src/sys/netipsec/xform_ipip.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_ipip.c,v 1.25 2002/06/10 18:04:55 itojun Exp $ */
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.63 2018/02/15 10:41:51 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.64 2018/04/18 06:43:10 maxv Exp $");
/*
* IP-inside-IP processing
@ -268,7 +268,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
AF_INET)
continue;
sin = (struct sockaddr_in *) ifa->ifa_addr;
sin = (struct sockaddr_in *)ifa->ifa_addr;
if (sin->sin_addr.s_addr ==
ip4->ip_src.s_addr) {
@ -278,7 +278,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
return;
}
}
#endif /* INET */
#endif
#ifdef INET6
if (ip6) {
@ -286,7 +286,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
AF_INET6)
continue;
sin6 = (struct sockaddr_in6 *) ifa->ifa_addr;
sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &ip6->ip6_src)) {
pserialize_read_exit(s);
@ -296,7 +296,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
}
}
#endif /* INET6 */
#endif
}
}
pserialize_read_exit(s);
@ -355,7 +355,7 @@ ipip_output(struct mbuf *m, const struct ipsecrequest *isr,
DPRINTF(("%s: unspecified tunnel endpoint "
"address in SA %s/%08lx\n", __func__,
ipsec_address(&saidx->dst, buf, sizeof(buf)),
(u_long) ntohl(sav->spi)));
(u_long)ntohl(sav->spi)));
IPIP_STATINC(IPIP_STAT_UNSPEC);
error = EINVAL;
goto bad;
@ -411,7 +411,7 @@ ipip_output(struct mbuf *m, const struct ipsecrequest *isr,
ipo->ip_p = IPPROTO_IPV6;
ipo->ip_off = 0;
}
#endif /* INET6 */
#endif
else {
goto nofamily;
}
@ -430,7 +430,7 @@ ipip_output(struct mbuf *m, const struct ipsecrequest *isr,
DPRINTF(("%s: unspecified tunnel endpoint "
"address in SA %s/%08lx\n", __func__,
ipsec_address(&saidx->dst, buf, sizeof(buf)),
(u_long) ntohl(sav->spi)));
(u_long)ntohl(sav->spi)));
IPIP_STATINC(IPIP_STAT_UNSPEC);
error = ENOBUFS;
goto bad;
@ -479,7 +479,7 @@ ipip_output(struct mbuf *m, const struct ipsecrequest *isr,
/* This is really IPVERSION. */
ip6o->ip6_nxt = IPPROTO_IPIP;
} else
#endif /* INET */
#endif
if (tp == (IPV6_VERSION >> 4)) {
uint32_t itos32;
@ -496,7 +496,7 @@ ipip_output(struct mbuf *m, const struct ipsecrequest *isr,
otos = 0;
ip_ecn_ingress(ECN_ALLOWED, &otos, &itos);
ip6o->ip6_flow |= htonl((uint32_t) otos << 20);
ip6o->ip6_flow |= htonl((uint32_t)otos << 20);
break;
#endif /* INET6 */