summaryrefslogtreecommitdiffstats
path: root/sys/netipsec
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-08-17 13:52:58 -0300
committerRenato Botelho <renato@netgate.com>2015-08-17 13:52:58 -0300
commit5b128f054452e56b96564210c998510e0dd45130 (patch)
tree6f79ca547f337c0d9b9dc90822fa8e02e2641c2e /sys/netipsec
parent570dae5561e54cd2703f546b04a3fa029c92dc62 (diff)
downloadFreeBSD-src-5b128f054452e56b96564210c998510e0dd45130.zip
FreeBSD-src-5b128f054452e56b96564210c998510e0dd45130.tar.gz
Importing pfSense patch ipsec_altq.RELENG_10.diff
Diffstat (limited to 'sys/netipsec')
-rw-r--r--sys/netipsec/ipsec.h2
-rw-r--r--sys/netipsec/ipsec_input.c12
-rw-r--r--sys/netipsec/ipsec_output.c27
-rw-r--r--sys/netipsec/keydb.h2
4 files changed, 34 insertions, 9 deletions
diff --git a/sys/netipsec/ipsec.h b/sys/netipsec/ipsec.h
index 6da3fc7..e50c401 100644
--- a/sys/netipsec/ipsec.h
+++ b/sys/netipsec/ipsec.h
@@ -386,7 +386,7 @@ extern int m_striphdr(struct mbuf *m, int skip, int hlen);
#define ENC_AFTER 0x0002
#define ENC_IN 0x0100
#define ENC_OUT 0x0200
-extern int ipsec_filter(struct mbuf **, int, int);
+extern int ipsec_filter(struct mbuf **, struct secasindex *, int, int);
extern void ipsec_bpf(struct mbuf *, struct secasvar *, int, int);
#endif
#endif /* _KERNEL */
diff --git a/sys/netipsec/ipsec_input.c b/sys/netipsec/ipsec_input.c
index 66de530..18a9b0c 100644
--- a/sys/netipsec/ipsec_input.c
+++ b/sys/netipsec/ipsec_input.c
@@ -354,7 +354,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
/* Pass the mbuf to enc0 for bpf and pfil. */
ipsec_bpf(m, sav, AF_INET, ENC_IN|ENC_BEFORE);
- if ((error = ipsec_filter(&m, PFIL_IN, ENC_IN|ENC_BEFORE)) != 0)
+ if ((error = ipsec_filter(&m, &sav->sah->saidx, PFIL_IN,
+ ENC_IN|ENC_BEFORE)) != 0)
return (error);
#endif /* DEV_ENC */
@@ -498,7 +499,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
ipsec_bpf(m, sav, AF_INET6, ENC_IN|ENC_AFTER);
#endif
- if ((error = ipsec_filter(&m, PFIL_IN, ENC_IN|ENC_AFTER)) != 0)
+ if ((error = ipsec_filter(&m, &sav->sah->saidx, PFIL_IN,
+ ENC_IN|ENC_AFTER)) != 0)
return (error);
#endif /* DEV_ENC */
@@ -653,7 +655,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
/* Pass the mbuf to enc0 for bpf and pfil. */
ipsec_bpf(m, sav, AF_INET6, ENC_IN|ENC_BEFORE);
- if ((error = ipsec_filter(&m, PFIL_IN, ENC_IN|ENC_BEFORE)) != 0)
+ if ((error = ipsec_filter(&m, &sav->sah->saidx, PFIL_IN,
+ ENC_IN|ENC_BEFORE)) != 0)
return (error);
#endif /* DEV_ENC */
@@ -782,7 +785,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
if (prot == IPPROTO_IPV6)
ipsec_bpf(m, sav, AF_INET6, ENC_IN|ENC_AFTER);
- if ((error = ipsec_filter(&m, PFIL_IN, ENC_IN|ENC_AFTER)) != 0)
+ if ((error = ipsec_filter(&m, &sav->sah->saidx, PFIL_IN,
+ ENC_IN|ENC_AFTER)) != 0)
return (error);
#endif /* DEV_ENC */
/*
diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c
index 442fb7a..33b84e0 100644
--- a/sys/netipsec/ipsec_output.c
+++ b/sys/netipsec/ipsec_output.c
@@ -43,6 +43,11 @@
#include <sys/errno.h>
#include <sys/syslog.h>
+#ifdef DEV_ENC
+#include <altq/if_altq.h>
+#include <netpfil/pf/pf_mtag.h>
+#endif
+
#include <net/if.h>
#include <net/pfil.h>
#include <net/vnet.h>
@@ -98,6 +103,7 @@ ipsec_process_done(struct mbuf *m, struct ipsecrequest *isr)
struct m_tag *mtag;
struct secasvar *sav;
struct secasindex *saidx;
+ struct pf_mtag *atag = NULL;
int error;
IPSEC_ASSERT(m != NULL, ("null mbuf"));
@@ -189,6 +195,15 @@ ipsec_process_done(struct mbuf *m, struct ipsecrequest *isr)
}
key_sa_recordxfer(sav, m); /* record data transfer */
+#ifdef DEV_ENC
+ if (saidx->qid && (atag = pf_find_mtag(m)) != NULL) {
+ atag->qid = saidx->qid;
+ /* add hints for ecn */
+ atag->af = saidx->dst.sa.sa_family;
+ atag->hdr = NULL; /* This should be safe! */
+ }
+#endif
+
/*
* We're done with IPsec processing, transmit the packet using the
* appropriate network protocol (IP or IPv6). SPD lookup will be
@@ -455,7 +470,8 @@ ipsec4_process_packet(
/* pass the mbuf to enc0 for bpf processing */
ipsec_bpf(m, sav, AF_INET, ENC_OUT|ENC_BEFORE);
/* pass the mbuf to enc0 for packet filtering */
- if ((error = ipsec_filter(&m, PFIL_OUT, ENC_OUT|ENC_BEFORE)) != 0)
+ if ((error = ipsec_filter(&m, &sav->sah->saidx, PFIL_OUT,
+ ENC_OUT|ENC_BEFORE)) != 0)
goto bad;
#endif
@@ -554,7 +570,8 @@ ipsec4_process_packet(
/* pass the mbuf to enc0 for bpf processing */
ipsec_bpf(m, sav, sav->sah->saidx.dst.sa.sa_family, ENC_OUT|ENC_AFTER);
/* pass the mbuf to enc0 for packet filtering */
- if ((error = ipsec_filter(&m, PFIL_OUT, ENC_OUT|ENC_AFTER)) != 0)
+ if ((error = ipsec_filter(&m, &sav->sah->saidx, PFIL_OUT,
+ ENC_OUT|ENC_AFTER)) != 0)
goto bad;
#endif
@@ -657,7 +674,8 @@ ipsec6_process_packet(
/* pass the mbuf to enc0 for bpf processing */
ipsec_bpf(m, isr->sav, AF_INET6, ENC_OUT|ENC_BEFORE);
/* pass the mbuf to enc0 for packet filtering */
- if ((error = ipsec_filter(&m, PFIL_OUT, ENC_OUT|ENC_BEFORE)) != 0)
+ if ((error = ipsec_filter(&m, &sav->sah->saidx, PFIL_OUT,
+ ENC_OUT|ENC_BEFORE)) != 0)
goto bad;
#endif /* DEV_ENC */
@@ -709,7 +727,8 @@ ipsec6_process_packet(
#ifdef DEV_ENC
ipsec_bpf(m, isr->sav, dst->sa.sa_family, ENC_OUT|ENC_AFTER);
/* pass the mbuf to enc0 for packet filtering */
- if ((error = ipsec_filter(&m, PFIL_OUT, ENC_OUT|ENC_AFTER)) != 0)
+ if ((error = ipsec_filter(&m, &sav->sah->saidx, PFIL_OUT,
+ ENC_OUT|ENC_AFTER)) != 0)
goto bad;
#endif /* DEV_ENC */
diff --git a/sys/netipsec/keydb.h b/sys/netipsec/keydb.h
index 15dbc9c..56f44fc 100644
--- a/sys/netipsec/keydb.h
+++ b/sys/netipsec/keydb.h
@@ -58,6 +58,8 @@ struct secasindex {
u_int8_t mode; /* mode of protocol, see ipsec.h */
u_int32_t reqid; /* reqid id who owned this SA */
/* see IPSEC_MANUAL_REQID_MAX. */
+ u_int32_t qid; /* used for ALTQ shaping inside */
+ /* tunnel */
};
/*
OpenPOWER on IntegriCloud