Skip to content

Commit 7e20b1f

Browse files
author
mvs
committed
Unlock ICMPV6CTL_REDIRTIMEOUT case of icmp6_sysctl().
rt_timer_queue_change() is mp-safe, so make unlocking in the way of IP{V6}CTL_MTUDISCTIMEOUT cases of ip{,6}_sysctl(). ok bluhm
1 parent 0895402 commit 7e20b1f

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

sys/netinet6/icmp6.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: icmp6.c,v 1.271 2025/07/27 17:46:58 mvs Exp $ */
1+
/* $OpenBSD: icmp6.c,v 1.272 2025/08/02 09:03:54 mvs Exp $ */
22
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
33

44
/*
@@ -1801,6 +1801,12 @@ icmp6_sysctl_icmp6stat(void *oldp, size_t *oldlenp, void *newp)
18011801
return (ret);
18021802
}
18031803

1804+
/*
1805+
* Temporary, should be replaced with sysctl_lock after icmp6_sysctl()
1806+
* unlocking.
1807+
*/
1808+
struct rwlock icmp6_sysctl_lock = RWLOCK_INITIALIZER("icmp6rwl");
1809+
18041810
int
18051811
icmp6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
18061812
void *newp, size_t newlen)
@@ -1812,15 +1818,22 @@ icmp6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
18121818
return (ENOTDIR);
18131819

18141820
switch (name[0]) {
1815-
case ICMPV6CTL_REDIRTIMEOUT:
1816-
NET_LOCK();
1821+
case ICMPV6CTL_REDIRTIMEOUT: {
1822+
int oldval, newval, error;
1823+
1824+
oldval = newval = atomic_load_int(&icmp6_redirtimeout);
18171825
error = sysctl_int_bounded(oldp, oldlenp, newp, newlen,
1818-
&icmp6_redirtimeout, 0, INT_MAX);
1819-
rt_timer_queue_change(&icmp6_redirect_timeout_q,
1820-
icmp6_redirtimeout);
1821-
NET_UNLOCK();
1822-
break;
1826+
&newval, 0, INT_MAX);
1827+
if (error == 0 && oldval != newval) {
1828+
rw_enter_write(&icmp6_sysctl_lock);
1829+
atomic_store_int(&icmp6_redirtimeout, newval);
1830+
rt_timer_queue_change(&icmp6_redirect_timeout_q,
1831+
newval);
1832+
rw_exit_write(&icmp6_sysctl_lock);
1833+
}
18231834

1835+
return (error);
1836+
}
18241837
case ICMPV6CTL_STATS:
18251838
error = icmp6_sysctl_icmp6stat(oldp, oldlenp, newp);
18261839
break;

0 commit comments

Comments
 (0)