Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: bgpd: fix pauseaccept handling for control sockets
To:
tech@openbsd.org
Date:
Thu, 7 May 2026 11:00:42 +0200

Download raw body.

Thread
On Thu, May 07, 2026 at 10:48:34AM +0200, Claudio Jeker wrote:
> In rev. 1.525 of session.c the pauseaccept was converted to a deadline.
> The problem is that control.c was missed and in that case the deadline
> is immediate which results in a no-sleep poll which is not desired.
> 
> Fix is copied over from session_accept().

ok tb

> -- 
> :wq Claudio
> 
> Index: control.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/control.c,v
> diff -u -p -r1.138 control.c
> --- control.c	17 Mar 2026 15:12:05 -0000	1.138
> +++ control.c	5 May 2026 18:50:40 -0000
> @@ -167,7 +167,8 @@ control_accept(int listenfd, int restric
>  	    (struct sockaddr *)&sa_un, &len,
>  	    SOCK_NONBLOCK | SOCK_CLOEXEC)) == -1) {
>  		if (errno == ENFILE || errno == EMFILE) {
> -			pauseaccept = getmonotime();
> +			pauseaccept = monotime_add(getmonotime(),
> +			    monotime_from_sec(PAUSEACCEPT_TIMEOUT));
>  			return (0);
>  		} else if (errno != EWOULDBLOCK && errno != EINTR &&
>  		    errno != ECONNABORTED)
> Index: session.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
> diff -u -p -r1.530 session.c
> --- session.c	27 Apr 2026 15:06:01 -0000	1.530
> +++ session.c	5 May 2026 18:50:11 -0000
> @@ -55,7 +55,6 @@
>  #define PFD_LISTENERS_START	5
>  
>  #define MAX_TIMEOUT		240
> -#define PAUSEACCEPT_TIMEOUT	1
>  
>  void	session_sighdlr(int);
>  int	setup_listeners(u_int *);
> Index: session.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/session.h,v
> diff -u -p -r1.195 session.h
> --- session.h	27 Apr 2026 15:06:01 -0000	1.195
> +++ session.h	6 May 2026 08:28:55 -0000
> @@ -39,6 +39,7 @@
>  #define	MSGSIZE_RREFRESH_MIN		MSGSIZE_RREFRESH
>  #define	MSG_PROCESS_LIMIT		25
>  #define	SESSION_CLEAR_DELAY		5
> +#define	PAUSEACCEPT_TIMEOUT		1
>  
>  enum session_state {
>  	STATE_NONE,
>