From: Vitaliy Makkoveev Subject: Re: const global TCP variables To: Alexander Bluhm Cc: tech@openbsd.org Date: Fri, 20 Dec 2024 23:54:45 +0300 > On 20 Dec 2024, at 23:36, Alexander Bluhm wrote: > > Hi, > > Some global TCP variables can be declared const. > > ok? > ok mvs > bluhm > > Index: netinet/tcp_fsm.h > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_fsm.h,v > diff -u -p -r1.9 tcp_fsm.h > --- netinet/tcp_fsm.h 5 Feb 2018 14:53:26 -0000 1.9 > +++ netinet/tcp_fsm.h 20 Dec 2024 19:35:32 -0000 > @@ -68,7 +68,7 @@ > * determined by state, with the proviso that TH_FIN is sent only > * if all data queued for output is included in the segment. > */ > -u_char tcp_outflags[TCP_NSTATES] = { > +const u_char tcp_outflags[TCP_NSTATES] = { > TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK, > TH_ACK, TH_ACK, > TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_ACK, TH_ACK, > @@ -76,7 +76,7 @@ u_char tcp_outflags[TCP_NSTATES] = { > #endif /* TCPOUTFLAGS */ > > #ifdef TCPSTATES > -const char *tcpstates[] = { > +const char *const tcpstates[] = { > "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", > "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING", > "LAST_ACK", "FIN_WAIT_2", "TIME_WAIT", > Index: netinet/tcp_timer.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_timer.c,v > diff -u -p -r1.76 tcp_timer.c > --- netinet/tcp_timer.c 28 Jan 2024 20:34:25 -0000 1.76 > +++ netinet/tcp_timer.c 20 Dec 2024 19:35:32 -0000 > @@ -167,10 +167,10 @@ tcp_canceltimers(struct tcpcb *tp) > TCP_TIMER_DISARM(tp, i); > } > > -int tcp_backoff[TCP_MAXRXTSHIFT + 1] = > +const int tcp_backoff[TCP_MAXRXTSHIFT + 1] = > { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 }; > > -int tcp_totbackoff = 511; /* sum of tcp_backoff[] */ > +const int tcp_totbackoff = 511; /* sum of tcp_backoff[] */ > > /* > * TCP timer processing. > Index: netinet/tcp_timer.h > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_timer.h,v > diff -u -p -r1.21 tcp_timer.h > --- netinet/tcp_timer.h 29 Jan 2024 22:47:13 -0000 1.21 > +++ netinet/tcp_timer.h 20 Dec 2024 19:35:32 -0000 > @@ -160,7 +160,7 @@ extern int tcp_keepidle; /* time before > extern int tcp_keepintvl; /* time between keepalive probes */ > extern int tcp_maxidle; /* time to drop after starting probes */ > extern int tcp_ttl; /* time to live for TCP segs */ > -extern int tcp_backoff[]; > +extern const int tcp_backoff[]; > > void tcp_timer_init(void); > #endif /* _KERNEL */ >