diff options
author | mvs <mvs@openbsd.org> | 2020-06-22 10:01:03 +0000 |
---|---|---|
committer | mvs <mvs@openbsd.org> | 2020-06-22 10:01:03 +0000 |
commit | 5cb27655b6fa9fff13c366871caeee1bbd1d1352 (patch) | |
tree | 004dd3da8e2de78891c0c226ed240ba997c5434c | |
parent | drm/amd/display: Correct updating logic of dcn21's pipe VM flags (diff) | |
download | wireguard-openbsd-5cb27655b6fa9fff13c366871caeee1bbd1d1352.tar.xz wireguard-openbsd-5cb27655b6fa9fff13c366871caeee1bbd1d1352.zip |
Rework checks for `pppx_ifs' tree modification.
- There is no panic() condition while inserting `pxi' to tree so drop
RBT_FIND() to avoid two lookups.
- Modify text in panic() message in delete case.
ok yasuoka@ claudio@
-rw-r--r-- | sys/net/if_pppx.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index 93e765b7b6d..4c5cb972caa 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.88 2020/06/18 14:20:12 mvs Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.89 2020/06/22 10:01:03 mvs Exp $ */ /* * Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org> @@ -696,14 +696,10 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) pxi->pxi_key.pxik_protocol = req->pr_protocol; pxi->pxi_dev = pxd; - /* this is safe without splnet since we're not modifying it */ - if (RBT_FIND(pppx_ifs, &pppx_ifs, pxi) != NULL) { + if (RBT_INSERT(pppx_ifs, &pppx_ifs, pxi) != NULL) { error = EADDRINUSE; goto out; } - - if (RBT_INSERT(pppx_ifs, &pppx_ifs, pxi) != NULL) - panic("%s: pppx_ifs modified while lock was held", __func__); LIST_INSERT_HEAD(&pxd->pxd_pxis, pxi, pxi_list); snprintf(ifp->if_xname, sizeof(ifp->if_xname), "%s%d", "pppx", unit); @@ -777,7 +773,7 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) remove: if (RBT_REMOVE(pppx_ifs, &pppx_ifs, pxi) == NULL) - panic("%s: pppx_ifs modified while lock was held", __func__); + panic("%s: inconsistent RB tree", __func__); LIST_REMOVE(pxi, pxi_list); out: pool_put(pppx_if_pl, pxi); @@ -871,7 +867,7 @@ pppx_if_destroy(struct pppx_dev *pxd, struct pppx_if *pxi) pipex_rele_session(session); if (RBT_REMOVE(pppx_ifs, &pppx_ifs, pxi) == NULL) - panic("%s: pppx_ifs modified while lock was held", __func__); + panic("%s: inconsistent RB tree", __func__); LIST_REMOVE(pxi, pxi_list); pool_put(pppx_if_pl, pxi); |