summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/ip6_input.c7
-rw-r--r--sys/netinet6/ip6_output.c101
2 files changed, 61 insertions, 47 deletions
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index b8a75c6..08f29a0 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -133,9 +133,11 @@ static struct netisr_handler ip6_nh = {
.nh_policy = NETISR_POLICY_FLOW,
};
+#define V_ipipsec_in_use VNET(ipipsec_in_use)
VNET_DECLARE(struct callout, in6_tmpaddrtimer_ch);
#define V_in6_tmpaddrtimer_ch VNET(in6_tmpaddrtimer_ch)
+SYSCTL_DECL(_net_inet6_ip6);
VNET_DEFINE(struct pfil_head, inet6_pfil_hook);
VNET_PCPUSTAT_DEFINE(struct ip6stat, ip6stat);
@@ -182,6 +184,9 @@ ip6_init(void)
if ((i = pfil_head_register(&V_inet6_pfil_hook)) != 0)
printf("%s: WARNING: unable to register pfil hook, "
"error %d\n", __func__, i);
+ else
+ pfil_head_export_sysctl(&V_inet6_pfil_hook,
+ SYSCTL_STATIC_CHILDREN(_net_inet6_ip6));
scope6_init();
addrsel_policy_init();
@@ -1000,6 +1005,7 @@ passin:
}
#ifdef IPSEC
+ if (V_ipipsec_in_use) {
/*
* enforce IPsec policy checking if we are seeing last header.
* note that we do not visit this with protocols with pcb layer
@@ -1007,6 +1013,7 @@ passin:
*/
if (ip6_ipsec_input(m, nxt))
goto bad;
+ }
#endif /* IPSEC */
/*
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 4fbac61..43c86d9 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -147,6 +147,7 @@ static int ip6_getpmtu(struct route_in6 *, struct route_in6 *,
struct ifnet *, struct in6_addr *, u_long *, int *, u_int);
static int copypktopts(struct ip6_pktopts *, struct ip6_pktopts *, int);
+#define V_ipipsec_in_use VNET(ipipsec_in_use)
/*
* Make an extension header from option data. hp is the source, and
@@ -345,19 +346,21 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt,
}
#ifdef IPSEC
- /*
- * IPSec checking which handles several cases.
- * FAST IPSEC: We re-injected the packet.
- */
- switch(ip6_ipsec_output(&m, inp, &flags, &error, &ifp))
- {
- case 1: /* Bad packet */
- goto freehdrs;
- case -1: /* IPSec done */
- goto done;
- case 0: /* No IPSec */
- default:
- break;
+ if (V_ipipsec_in_use) {
+ /*
+ * IPSec checking which handles several cases.
+ * FAST IPSEC: We re-injected the packet.
+ */
+ switch(ip6_ipsec_output(&m, inp, &flags, &error, &ifp))
+ {
+ case 1: /* Bad packet */
+ goto freehdrs;
+ case -1: /* IPSec done */
+ goto done;
+ case 0: /* No IPSec */
+ default:
+ break;
+ }
}
#endif /* IPSEC */
@@ -1722,19 +1725,21 @@ do { \
#ifdef IPSEC
case IPV6_IPSEC_POLICY:
{
- caddr_t req;
- struct mbuf *m;
+ if (V_ipipsec_in_use) {
+ caddr_t req;
+ struct mbuf *m;
- if ((error = soopt_getm(sopt, &m)) != 0) /* XXX */
- break;
- if ((error = soopt_mcopyin(sopt, m)) != 0) /* XXX */
+ if ((error = soopt_getm(sopt, &m)) != 0) /* XXX */
+ break;
+ if ((error = soopt_mcopyin(sopt, m)) != 0) /* XXX */
+ break;
+ req = mtod(m, caddr_t);
+ error = ipsec_set_policy(in6p, optname, req,
+ m->m_len, (sopt->sopt_td != NULL) ?
+ sopt->sopt_td->td_ucred : NULL);
+ m_freem(m);
break;
- req = mtod(m, caddr_t);
- error = ipsec_set_policy(in6p, optname, req,
- m->m_len, (sopt->sopt_td != NULL) ?
- sopt->sopt_td->td_ucred : NULL);
- m_freem(m);
- break;
+ }
}
#endif /* IPSEC */
@@ -1933,31 +1938,33 @@ do { \
#ifdef IPSEC
case IPV6_IPSEC_POLICY:
{
- caddr_t req = NULL;
- size_t len = 0;
- struct mbuf *m = NULL;
- struct mbuf **mp = &m;
- size_t ovalsize = sopt->sopt_valsize;
- caddr_t oval = (caddr_t)sopt->sopt_val;
-
- error = soopt_getm(sopt, &m); /* XXX */
- if (error != 0)
- break;
- error = soopt_mcopyin(sopt, m); /* XXX */
- if (error != 0)
+ if (V_ipipsec_in_use) {
+ caddr_t req = NULL;
+ size_t len = 0;
+ struct mbuf *m = NULL;
+ struct mbuf **mp = &m;
+ size_t ovalsize = sopt->sopt_valsize;
+ caddr_t oval = (caddr_t)sopt->sopt_val;
+
+ error = soopt_getm(sopt, &m); /* XXX */
+ if (error != 0)
+ break;
+ error = soopt_mcopyin(sopt, m); /* XXX */
+ if (error != 0)
+ break;
+ sopt->sopt_valsize = ovalsize;
+ sopt->sopt_val = oval;
+ if (m) {
+ req = mtod(m, caddr_t);
+ len = m->m_len;
+ }
+ error = ipsec_get_policy(in6p, req, len, mp);
+ if (error == 0)
+ error = soopt_mcopyout(sopt, m); /* XXX */
+ if (error == 0 && m)
+ m_freem(m);
break;
- sopt->sopt_valsize = ovalsize;
- sopt->sopt_val = oval;
- if (m) {
- req = mtod(m, caddr_t);
- len = m->m_len;
}
- error = ipsec_get_policy(in6p, req, len, mp);
- if (error == 0)
- error = soopt_mcopyout(sopt, m); /* XXX */
- if (error == 0 && m)
- m_freem(m);
- break;
}
#endif /* IPSEC */
OpenPOWER on IntegriCloud