diff options
Diffstat (limited to 'sys/netinet/ip_ipcomp.c')
-rw-r--r-- | sys/netinet/ip_ipcomp.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/netinet/ip_ipcomp.c b/sys/netinet/ip_ipcomp.c index 3bfb99c8daf..65026466d48 100644 --- a/sys/netinet/ip_ipcomp.c +++ b/sys/netinet/ip_ipcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipcomp.c,v 1.88 2021/11/21 16:17:48 mvs Exp $ */ +/* $OpenBSD: ip_ipcomp.c,v 1.89 2021/12/11 16:33:47 bluhm Exp $ */ /* * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org) @@ -205,11 +205,15 @@ ipcomp_input(struct mbuf **mp, struct tdb *tdb, int skip, int protoff) goto drop; } /* Notify on soft expiration */ + mtx_enter(&tdb->tdb_mtx); if ((tdb->tdb_flags & TDBF_SOFT_BYTES) && (tdb->tdb_cur_bytes >= tdb->tdb_soft_bytes)) { + tdb->tdb_flags &= ~TDBF_SOFT_BYTES; /* Turn off checking */ + mtx_leave(&tdb->tdb_mtx); + /* may sleep in solock() for the pfkey socket */ pfkeyv2_expire(tdb, SADB_EXT_LIFETIME_SOFT); - tdb->tdb_flags &= ~TDBF_SOFT_BYTES; /* Turn off checking */ - } + } else + mtx_leave(&tdb->tdb_mtx); /* In case it's not done already, adjust the size of the mbuf chain */ m->m_pkthdr.len = clen + hlen + skip; @@ -393,12 +397,18 @@ ipcomp_output(struct mbuf *m, struct tdb *tdb, int skip, int protoff) error = EINVAL; goto drop; } + /* Soft byte expiration */ + mtx_enter(&tdb->tdb_mtx); if ((tdb->tdb_flags & TDBF_SOFT_BYTES) && (tdb->tdb_cur_bytes >= tdb->tdb_soft_bytes)) { + tdb->tdb_flags &= ~TDBF_SOFT_BYTES; /* Turn off checking */ + mtx_leave(&tdb->tdb_mtx); + /* may sleep in solock() for the pfkey socket */ pfkeyv2_expire(tdb, SADB_EXT_LIFETIME_SOFT); - tdb->tdb_flags &= ~TDBF_SOFT_BYTES; /* Turn off checking */ - } + } else + mtx_leave(&tdb->tdb_mtx); + /* * Loop through mbuf chain; if we find a readonly mbuf, * copy the packet. |