summaryrefslogtreecommitdiffstats
path: root/sys/netipsec/ipsec_input.c
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2014-10-02 02:00:21 +0000
committerae <ae@FreeBSD.org>2014-10-02 02:00:21 +0000
commit8adffba139cee31c2ecbf8cf0454800ba87ffea3 (patch)
tree05dd41475a4f83882899770ee958903b53646194 /sys/netipsec/ipsec_input.c
parentfd6a7f8ca9a6e8a5ad987094edf77b876f3e7284 (diff)
downloadFreeBSD-src-8adffba139cee31c2ecbf8cf0454800ba87ffea3.zip
FreeBSD-src-8adffba139cee31c2ecbf8cf0454800ba87ffea3.tar.gz
Do not strip outer header when operating in transport mode.
Instead requeue mbuf back to IPv4 protocol handler. If there is one extra IP-IP encapsulation, it will be handled with tunneling interface. And thus proper interface will be exposed into mbuf's rcvif. Also, tcpdump that listens on tunneling interface will see packets in both directions. Sponsored by: Yandex LLC
Diffstat (limited to 'sys/netipsec/ipsec_input.c')
-rw-r--r--sys/netipsec/ipsec_input.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/netipsec/ipsec_input.c b/sys/netipsec/ipsec_input.c
index a305bb6..b778fe5 100644
--- a/sys/netipsec/ipsec_input.c
+++ b/sys/netipsec/ipsec_input.c
@@ -391,7 +391,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
#endif /* DEV_ENC */
/* IP-in-IP encapsulation */
- if (prot == IPPROTO_IPIP) {
+ if (prot == IPPROTO_IPIP &&
+ saidx->mode != IPSEC_MODE_TRANSPORT) {
if (m->m_pkthdr.len - skip < sizeof(struct ip)) {
IPSEC_ISTAT(sproto, hdrops);
@@ -431,7 +432,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
}
#ifdef INET6
/* IPv6-in-IP encapsulation. */
- if (prot == IPPROTO_IPV6) {
+ if (prot == IPPROTO_IPV6 &&
+ saidx->mode != IPSEC_MODE_TRANSPORT) {
if (m->m_pkthdr.len - skip < sizeof(struct ip6_hdr)) {
IPSEC_ISTAT(sproto, hdrops);
@@ -502,6 +504,12 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
key_sa_recordxfer(sav, m); /* record data transfer */
+ /*
+ * In transport mode requeue decrypted mbuf back to IPv4 protocol
+ * handler. This is necessary to correctly expose rcvif.
+ */
+ if (saidx->mode == IPSEC_MODE_TRANSPORT)
+ prot = IPPROTO_IPIP;
#ifdef DEV_ENC
/*
* Pass the mbuf to enc0 for bpf and pfil.
OpenPOWER on IntegriCloud