The branch main has been updated by tuexen:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d4290f7e62374ae3ad9853128a31c39347a4dae1

commit d4290f7e62374ae3ad9853128a31c39347a4dae1
Author:     Michael Tuexen <[email protected]>
AuthorDate: 2022-04-02 12:49:14 +0000
Commit:     Michael Tuexen <[email protected]>
CommitDate: 2022-04-02 12:49:14 +0000

    Revert "sctp: remove a test, which isn't safe"
    
    It included unrelated changes still under review.
    This reverts commit b1fe92b28ba2e77395598db1c2ff1976b55c86ab.
---
 sys/netinet/cc/cc.c       | 29 ++++++++++-------------------
 sys/netinet/sctp_output.c |  5 +++++
 2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/sys/netinet/cc/cc.c b/sys/netinet/cc/cc.c
index a009998ca920..55a5f6ef652e 100644
--- a/sys/netinet/cc/cc.c
+++ b/sys/netinet/cc/cc.c
@@ -280,12 +280,15 @@ cc_init(void)
 /*
  * Returns non-zero on success, 0 on failure.
  */
-static int
-cc_deregister_algo_locked(struct cc_algo *remove_cc)
+int
+cc_deregister_algo(struct cc_algo *remove_cc)
 {
        struct cc_algo *funcs;
        int found = 0;
 
+       /* Remove algo from cc_list so that new connections can't use it. */
+       CC_LIST_WLOCK();
+       
        /* This is unlikely to fail */
        STAILQ_FOREACH(funcs, &cc_list, entries) {
                if (funcs == remove_cc)
@@ -293,34 +296,23 @@ cc_deregister_algo_locked(struct cc_algo *remove_cc)
        }
        if (found == 0) {
                /* Nothing to remove? */
+               CC_LIST_WUNLOCK();
                return (ENOENT);
        }
        /* We assert it should have been MOD_QUIESCE'd */
        KASSERT((remove_cc->flags & CC_MODULE_BEING_REMOVED),
                ("remove_cc:%p does not have CC_MODULE_BEING_REMOVED flag", 
remove_cc));
        if (cc_check_default(remove_cc)) {
+               CC_LIST_WUNLOCK();
                return(EBUSY);
        }
        if (remove_cc->cc_refcount != 0) {
+               CC_LIST_WUNLOCK();
                return (EBUSY);
        }
-       /* Remove algo from cc_list so that new connections can't use it. */
        STAILQ_REMOVE(&cc_list, remove_cc, cc_algo, entries);
-       return (0);
-}
-
-/*
- * Returns non-zero on success, 0 on failure.
- */
-int
-cc_deregister_algo(struct cc_algo *remove_cc)
-{
-       int ret;
-
-       CC_LIST_WLOCK();
-       ret = cc_deregister_algo_locked(remove_cc);
        CC_LIST_WUNLOCK();
-       return (ret);
+       return (0);
 }
 
 /*
@@ -636,8 +628,7 @@ cc_modevent(module_t mod, int event_type, void *data)
                 * If -f was used and users are still attached to
                 * the algorithm things are going to go boom.
                 */
-               err = cc_deregister_algo_locked(algo);
-               CC_LIST_WUNLOCK();
+               err = cc_deregister_algo(algo);
                if ((err == 0) && (algo->mod_destroy != NULL)) {
                        algo->mod_destroy();
                }
diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c
index 4ef771b0cc1a..5f205b1c3af4 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -13657,6 +13657,11 @@ out_unlocked:
                if (free_cnt_applied) {
                        atomic_subtract_int(&asoc->refcnt, 1);
                }
+#ifdef INVARIANTS
+               if (mtx_owned(&stcb->tcb_mtx)) {
+                       panic("Leaving with tcb mtx owned?");
+               }
+#endif
        }
        if (top != NULL) {
                sctp_m_freem(top);

Reply via email to