-/* $OpenBSD: ip_ipsp.c,v 1.275 2022/11/11 18:09:58 cheloha Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.276 2023/08/07 03:43:57 dlg Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
#include "pf.h"
#include "pfsync.h"
+#include "sec.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <net/if_pfsync.h>
#endif
+#if NSEC > 0
+#include <net/if_sec.h>
+#endif
+
#include <netinet/ip_ipsp.h>
#include <net/pfkeyv2.h>
tdbp->tdb_hnext = tdbh[hashval];
tdbh[hashval] = tdbp;
- hashval = tdb_hash(0, &tdbp->tdb_dst, tdbp->tdb_sproto);
- tdbp->tdb_dnext = tdbdst[hashval];
- tdbdst[hashval] = tdbp;
-
- hashval = tdb_hash(0, &tdbp->tdb_src, tdbp->tdb_sproto);
- tdbp->tdb_snext = tdbsrc[hashval];
- tdbsrc[hashval] = tdbp;
-
tdb_count++;
#ifdef IPSEC
if ((tdbp->tdb_flags & (TDBF_INVALID|TDBF_TUNNELING)) == TDBF_TUNNELING)
#endif /* IPSEC */
ipsec_last_added = getuptime();
+
+ if (ISSET(tdbp->tdb_flags, TDBF_IFACE)) {
+#if NSEC > 0
+ sec_tdb_insert(tdbp);
+#endif
+ return;
+ }
+
+ hashval = tdb_hash(0, &tdbp->tdb_dst, tdbp->tdb_sproto);
+ tdbp->tdb_dnext = tdbdst[hashval];
+ tdbdst[hashval] = tdbp;
+
+ hashval = tdb_hash(0, &tdbp->tdb_src, tdbp->tdb_sproto);
+ tdbp->tdb_snext = tdbsrc[hashval];
+ tdbsrc[hashval] = tdbp;
}
void
tdbp->tdb_hnext = NULL;
+ tdb_count--;
+#ifdef IPSEC
+ if ((tdbp->tdb_flags & (TDBF_INVALID|TDBF_TUNNELING)) ==
+ TDBF_TUNNELING) {
+ ipsecstat_dec(ipsec_tunnels);
+ ipsecstat_inc(ipsec_prevtunnels);
+ }
+#endif /* IPSEC */
+
+ if (ISSET(tdbp->tdb_flags, TDBF_IFACE)) {
+#if NSEC > 0
+ sec_tdb_remove(tdbp);
+#endif
+ return;
+ }
+
hashval = tdb_hash(0, &tdbp->tdb_dst, tdbp->tdb_sproto);
if (tdbdst[hashval] == tdbp) {
}
tdbp->tdb_snext = NULL;
- tdb_count--;
-#ifdef IPSEC
- if ((tdbp->tdb_flags & (TDBF_INVALID|TDBF_TUNNELING)) ==
- TDBF_TUNNELING) {
- ipsecstat_dec(ipsec_tunnels);
- ipsecstat_inc(ipsec_prevtunnels);
- }
-#endif /* IPSEC */
}
void
-/* $OpenBSD: ipsec_input.c,v 1.204 2023/05/13 13:35:17 bluhm Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.205 2023/08/07 03:43:57 dlg Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
*/
#include "pf.h"
+#include "sec.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <net/pfvar.h>
#endif
+#if NSEC > 0
+#include <net/if_sec.h>
+#endif
+
#ifdef INET6
#include <netinet6/in6_var.h>
#include <netinet/ip6.h>
}
#endif
+ if (ISSET(tdbp->tdb_flags, TDBF_IFACE)) {
+#if NSEC > 0
+ if (ISSET(tdbp->tdb_flags, TDBF_TUNNELING) &&
+ tdbp->tdb_iface_dir == IPSP_DIRECTION_IN) {
+ struct sec_softc *sc = sec_get(tdbp->tdb_iface);
+ if (sc == NULL)
+ goto baddone;
+
+ sec_input(sc, af, prot, m);
+ sec_put(sc);
+ return IPPROTO_DONE;
+ }
+#endif /* NSEC > 0 */
+ goto baddone;
+ }
+
#if NPF > 0
/*
* The ip_deliver() shortcut avoids running through ip_input() with the