ROUTE(8): Disable routing socket timeout support

FIXME: This reverts the following change in FreeBSD.

commit 76a39ff8dc5e1f7bc8a065115ec3837761ed0600
Author: ae <ae@FreeBSD.org>
Date:   Wed Jul 27 08:26:34 2016 +0000

    Due to dropped mbuf in netisr queue route(8) can fall into infinity
    loop of reading the rtsock's feed. When it used by some scripts,
    this leads to growing number of not finished route(8) instances and
    thus growing number of rtsock consumers. Add SIGALRM handler to
    prevent this.
This commit is contained in:
Sebastian Huber 2017-01-11 14:15:31 +01:00
parent f11bfc2a5f
commit fb288fabea
2 changed files with 12 additions and 1 deletions

View File

@ -164,6 +164,7 @@ static int fiboptlist_range(const char *, struct fibl_head_t *);
static void usage(const char *) __dead2;
#ifndef __rtems__
#define READ_TIMEOUT 10
static volatile sig_atomic_t stop_read;
@ -173,6 +174,9 @@ stopit(int sig __unused)
stop_read = 1;
}
#else /* __rtems__ */
#define stop_read 0
#endif /* __rtems__ */
static void
usage(const char *cp)
@ -838,7 +842,9 @@ set_metric(char *value, int key)
static void
newroute(int argc, char **argv)
{
#ifndef __rtems__
struct sigaction sa;
#endif /* __rtems__ */
struct hostent *hp;
struct fibl *fl;
char *cmd;
@ -854,11 +860,13 @@ newroute(int argc, char **argv)
hp = NULL;
TAILQ_INIT(&fibl_head);
#ifndef __rtems__
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = stopit;
if (sigaction(SIGALRM, &sa, 0) == -1)
warn("sigaction SIGALRM");
#endif /* __rtems__ */
cmd = argv[0];
if (*cmd != 'g' && *cmd != 's')
@ -1610,17 +1618,21 @@ rtmsg(int cmd, int flags, int fib)
return (-1);
}
if (cmd == RTM_GET) {
#ifndef __rtems__
stop_read = 0;
alarm(READ_TIMEOUT);
#endif /* __rtems__ */
do {
l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
} while (l > 0 && stop_read == 0 &&
(rtm.rtm_seq != rtm_seq || rtm.rtm_pid != pid));
#ifndef __rtems__
if (stop_read != 0) {
warnx("read from routing socket timed out");
return (-1);
} else
alarm(0);
#endif /* __rtems__ */
if (l < 0)
warn("read from routing socket");
else

View File

@ -23,7 +23,6 @@ RTEMS_LINKER_RWSET_CONTENT(bsd_prog_route, static _Bool domain_initialized);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_route, static int rtm_seq);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_route, static struct m_rtmsg m_rtmsg);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_route, static struct fibl_head_t fibl_head);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_route, static sig_atomic_t volatile stop_read);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_route, static struct sockaddr_storage so[]);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_route, static char domain[]);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_route, static char rt_line[]);