diff options
author | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2023-04-26 19:54:36 +0000 |
---|---|---|
committer | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2023-04-26 19:54:36 +0000 |
commit | dc90b7a5f854bb2fd0f789cf4df4dbbbf5971ea5 (patch) | |
tree | ba910487e341956fd3c174317f64fe8daf25e6bd /sys/net/pf_ioctl.c | |
parent | 045da8ae492a84ecf85c67e25310c5b49c9d9523 (diff) |
Introduce `rtlabel_mtx' mutex(9) to protect route labels storage. This
time kernel and net locks are held in various combination to protect it.
We don't want to put kernel lock to all the places. Netlock also can't
be used because rtfree(9) which calls rtlabel_unref() has unknown
netlock state within.
This new `rtlabel_mtx' mutex(9) protects `rt_labels' list and `label'
entry dereference. Since we don't export 'rt_label' structure, keep this
lock private to net/route.c. For this reason rtlabel_id2name() now
copies label string to externally passed buffer instead of returning
address of `rt_labels' list data. This is the way which rtlabel_id2sa()
already works.
ok bluhm@
Diffstat (limited to 'sys/net/pf_ioctl.c')
-rw-r--r-- | sys/net/pf_ioctl.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/sys/net/pf_ioctl.c b/sys/net/pf_ioctl.c index 1141069dcf6..8045a818d03 100644 --- a/sys/net/pf_ioctl.c +++ b/sys/net/pf_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_ioctl.c,v 1.397 2023/01/06 17:44:34 sashan Exp $ */ +/* $OpenBSD: pf_ioctl.c,v 1.398 2023/04/26 19:54:35 mvs Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -491,15 +491,11 @@ pf_rtlabel_remove(struct pf_addr_wrap *a) void pf_rtlabel_copyout(struct pf_addr_wrap *a) { - const char *name; - if (a->type == PF_ADDR_RTLABEL && a->v.rtlabel) { - if ((name = rtlabel_id2name(a->v.rtlabel)) == NULL) + if (rtlabel_id2name(a->v.rtlabel, a->v.rtlabelname, + sizeof(a->v.rtlabelname)) == NULL) strlcpy(a->v.rtlabelname, "?", sizeof(a->v.rtlabelname)); - else - strlcpy(a->v.rtlabelname, name, - sizeof(a->v.rtlabelname)); } } |