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 $ */
2
2
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
3
3
4
4
/*
@@ -1801,6 +1801,12 @@ icmp6_sysctl_icmp6stat(void *oldp, size_t *oldlenp, void *newp)
1801
1801
return (ret );
1802
1802
}
1803
1803
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
+
1804
1810
int
1805
1811
icmp6_sysctl (int * name , u_int namelen , void * oldp , size_t * oldlenp ,
1806
1812
void * newp , size_t newlen )
@@ -1812,15 +1818,22 @@ icmp6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
1812
1818
return (ENOTDIR );
1813
1819
1814
1820
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 );
1817
1825
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
+ }
1823
1834
1835
+ return (error );
1836
+ }
1824
1837
case ICMPV6CTL_STATS :
1825
1838
error = icmp6_sysctl_icmp6stat (oldp , oldlenp , newp );
1826
1839
break ;
0 commit comments