sbin/setkey: add -Z option to disable receive timeouts

Sponsored by:	NVidia networking
MFC after:	1 week
This commit is contained in:
Konstantin Belousov
2026-01-20 14:09:47 +02:00
parent 69de2b4e96
commit d47c1c2cf5
+15 -9
View File
@@ -86,6 +86,7 @@ static int f_policy = 0;
static int f_hexdump = 0;
static int f_tflag = 0;
static int f_scope = 0;
static int f_notimeout = 0;
static time_t thiszone;
extern int lineno;
@@ -129,7 +130,7 @@ main(int ac, char **av)
thiszone = gmt2local(0);
while ((c = getopt(ac, av, "acde:f:ghltvxDFP")) != -1) {
while ((c = getopt(ac, av, "abcde:f:ghltvxDFPZ")) != -1) {
switch (c) {
case 'c':
f_mode = MODE_SCRIPT;
@@ -187,6 +188,9 @@ main(int ac, char **av)
case 'v':
f_verbose = 1;
break;
case 'Z':
f_notimeout = 1;
break;
default:
usage();
/*NOTREACHED*/
@@ -332,16 +336,18 @@ sendkeymsg(char *buf, size_t len)
u_char rbuf[1024 * 32]; /* XXX: Enough ? Should I do MSG_PEEK ? */
ssize_t l;
struct sadb_msg *msg;
{
struct timeval tv;
tv.tv_sec = 1;
tv.tv_usec = 0;
if (setsockopt(so, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
perror("setsockopt");
goto end;
if (!f_notimeout) {
tv.tv_sec = 1;
tv.tv_usec = 0;
if (setsockopt(so, SOL_SOCKET, SO_RCVTIMEO, &tv,
sizeof(tv)) < 0) {
perror("setsockopt");
goto end;
}
}
}
if (f_forever)
shortdump_hdr();