From 547fa50847452ed7a93eb593268c4ff9dbbc4e68 Mon Sep 17 00:00:00 2001 From: jan Date: Sat, 5 Nov 2022 22:33:11 +0000 Subject: [PATCH] Fix kernel build without IPSEC option. ok deraadt@ --- sys/net/if_pfsync.c | 19 +++++++++++++++++-- sys/netinet/ip_ipsp.c | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c index c78ca62766e..7174e50ecf4 100644 --- a/sys/net/if_pfsync.c +++ b/sys/net/if_pfsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pfsync.c,v 1.305 2022/04/21 15:22:49 sashan Exp $ */ +/* $OpenBSD: if_pfsync.c,v 1.306 2022/11/05 22:33:11 jan Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff @@ -1576,7 +1576,9 @@ pfsync_grab_snapshot(struct pfsync_snapshot *sn, struct pfsync_softc *sc) int q; struct pf_state *st; struct pfsync_upd_req_item *ur; +#if defined(IPSEC) struct tdb *tdb; +#endif sn->sn_sc = sc; @@ -1602,6 +1604,7 @@ pfsync_grab_snapshot(struct pfsync_snapshot *sn, struct pfsync_softc *sc) } TAILQ_INIT(&sn->sn_tdb_q); +#if defined(IPSEC) while ((tdb = TAILQ_FIRST(&sc->sc_tdb_q)) != NULL) { TAILQ_REMOVE(&sc->sc_tdb_q, tdb, tdb_sync_entry); TAILQ_INSERT_TAIL(&sn->sn_tdb_q, tdb, tdb_sync_snap); @@ -1611,6 +1614,7 @@ pfsync_grab_snapshot(struct pfsync_snapshot *sn, struct pfsync_softc *sc) SET(tdb->tdb_flags, TDBF_PFSYNC_SNAPPED); mtx_leave(&tdb->tdb_mtx); } +#endif sn->sn_len = sc->sc_len; sc->sc_len = PFSYNC_MINPKT; @@ -1630,7 +1634,9 @@ pfsync_drop_snapshot(struct pfsync_snapshot *sn) { struct pf_state *st; struct pfsync_upd_req_item *ur; +#if defined(IPSEC) struct tdb *t; +#endif int q; for (q = 0; q < PFSYNC_S_COUNT; q++) { @@ -1652,6 +1658,7 @@ pfsync_drop_snapshot(struct pfsync_snapshot *sn) pool_put(&sn->sn_sc->sc_pool, ur); } +#if defined(IPSEC) while ((t = TAILQ_FIRST(&sn->sn_tdb_q)) != NULL) { TAILQ_REMOVE(&sn->sn_tdb_q, t, tdb_sync_snap); mtx_enter(&t->tdb_mtx); @@ -1660,6 +1667,7 @@ pfsync_drop_snapshot(struct pfsync_snapshot *sn) CLR(t->tdb_flags, TDBF_PFSYNC); mtx_leave(&t->tdb_mtx); } +#endif } int @@ -1748,7 +1756,6 @@ pfsync_sendout(void) struct pfsync_subheader *subh; struct pf_state *st; struct pfsync_upd_req_item *ur; - struct tdb *t; int offset; int q, count = 0; @@ -1842,7 +1849,10 @@ pfsync_sendout(void) sn.sn_plus = NULL; /* XXX memory leak ? */ } +#if defined(IPSEC) if (!TAILQ_EMPTY(&sn.sn_tdb_q)) { + struct tdb *t; + subh = (struct pfsync_subheader *)(m->m_data + offset); offset += sizeof(*subh); @@ -1865,6 +1875,7 @@ pfsync_sendout(void) subh->len = sizeof(struct pfsync_tdb) >> 2; subh->count = htons(count); } +#endif /* walk the queues */ for (q = 0; q < PFSYNC_S_COUNT; q++) { @@ -2486,6 +2497,7 @@ pfsync_q_del(struct pf_state *st) pf_state_unref(st); } +#if defined(IPSEC) void pfsync_update_tdb(struct tdb *t, int output) { @@ -2540,7 +2552,9 @@ pfsync_update_tdb(struct tdb *t, int output) CLR(t->tdb_flags, TDBF_PFSYNC_RPL); mtx_leave(&t->tdb_mtx); } +#endif +#if defined(IPSEC) void pfsync_delete_tdb(struct tdb *t) { @@ -2576,6 +2590,7 @@ pfsync_delete_tdb(struct tdb *t) tdb_unref(t); } +#endif void pfsync_out_tdb(struct tdb *t, void *buf) diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c index 4f9d1b97a09..5da0622c337 100644 --- a/sys/netinet/ip_ipsp.c +++ b/sys/netinet/ip_ipsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipsp.c,v 1.273 2022/08/06 15:57:59 bluhm Exp $ */ +/* $OpenBSD: ip_ipsp.c,v 1.274 2022/11/05 22:33:11 jan Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr), @@ -1081,7 +1081,7 @@ tdb_free(struct tdb *tdbp) tdbp->tdb_xform = NULL; } -#if NPFSYNC > 0 +#if NPFSYNC > 0 && defined(IPSEC) /* Cleanup pfsync references */ pfsync_delete_tdb(tdbp); #endif -- 2.20.1