summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2021-01-19 09:42:11 +0000
committerclaudio <claudio@openbsd.org>2021-01-19 09:42:11 +0000
commitbf1e0606c1341c792bc2a62baa7a3fe3f6caaa9b (patch)
tree86928b73c57ec1fec48b7deaaf267cc701a58008
parentMake the imsg event structures static, properly define ospfd_process and (diff)
downloadwireguard-openbsd-bf1e0606c1341c792bc2a62baa7a3fe3f6caaa9b.tar.xz
wireguard-openbsd-bf1e0606c1341c792bc2a62baa7a3fe3f6caaa9b.zip
Do the same control cleanup as in ospfd. Move control_state and ctl_conns
into control.c nothing outside needs access to this.
-rw-r--r--usr.sbin/ospf6d/control.c14
-rw-r--r--usr.sbin/ospf6d/control.h10
-rw-r--r--usr.sbin/ospf6d/ospfe.c6
-rw-r--r--usr.sbin/ospf6d/ospfe.h6
4 files changed, 19 insertions, 17 deletions
diff --git a/usr.sbin/ospf6d/control.c b/usr.sbin/ospf6d/control.c
index 0bb41a70e34..ce018c3e5f0 100644
--- a/usr.sbin/ospf6d/control.c
+++ b/usr.sbin/ospf6d/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.29 2020/09/16 20:50:10 remi Exp $ */
+/* $OpenBSD: control.c,v 1.30 2021/01/19 09:42:11 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -32,12 +32,20 @@
#include "log.h"
#include "control.h"
+TAILQ_HEAD(ctl_conns, ctl_conn) ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns);
+
#define CONTROL_BACKLOG 5
struct ctl_conn *control_connbyfd(int);
struct ctl_conn *control_connbypid(pid_t);
void control_close(int);
+struct {
+ struct event ev;
+ struct event evt;
+ int fd;
+} control_state;
+
int
control_check(char *path)
{
@@ -108,8 +116,10 @@ control_init(char *path)
}
int
-control_listen(void)
+control_listen(int fd)
{
+ control_state.fd = fd;
+
if (listen(control_state.fd, CONTROL_BACKLOG) == -1) {
log_warn("control_listen: listen");
return (-1);
diff --git a/usr.sbin/ospf6d/control.h b/usr.sbin/ospf6d/control.h
index 67dbfe99467..bc3e864ca90 100644
--- a/usr.sbin/ospf6d/control.h
+++ b/usr.sbin/ospf6d/control.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.h,v 1.7 2020/09/16 20:50:10 remi Exp $ */
+/* $OpenBSD: control.h,v 1.8 2021/01/19 09:42:11 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -23,12 +23,6 @@
#include <sys/time.h>
#include <event.h>
-struct {
- struct event ev;
- struct event evt;
- int fd;
-} control_state;
-
struct ctl_conn {
TAILQ_ENTRY(ctl_conn) entry;
struct imsgev iev;
@@ -36,7 +30,7 @@ struct ctl_conn {
int control_check(char *);
int control_init(char *);
-int control_listen(void);
+int control_listen(int);
void control_accept(int, short, void *);
void control_dispatch_imsg(int, short, void *);
int control_imsg_relay(struct imsg *);
diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c
index 6fa80b6d891..69f91d026fe 100644
--- a/usr.sbin/ospf6d/ospfe.c
+++ b/usr.sbin/ospf6d/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.63 2020/05/16 15:54:12 denis Exp $ */
+/* $OpenBSD: ospfe.c,v 1.64 2021/01/19 09:42:11 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -410,10 +410,8 @@ ospfe_dispatch_main(int fd, short event, void *bula)
if ((fd = imsg.fd) == -1)
fatalx("%s: expected to receive imsg control"
"fd but didn't receive any", __func__);
- control_state.fd = fd;
/* Listen on control socket. */
- TAILQ_INIT(&ctl_conns);
- control_listen();
+ control_listen(fd);
if (pledge("stdio inet mcast", NULL) == -1)
fatal("pledge");
break;
diff --git a/usr.sbin/ospf6d/ospfe.h b/usr.sbin/ospf6d/ospfe.h
index e8c4f9b2985..ec46bdc3ffc 100644
--- a/usr.sbin/ospf6d/ospfe.h
+++ b/usr.sbin/ospf6d/ospfe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.h,v 1.23 2020/01/02 10:16:46 denis Exp $ */
+/* $OpenBSD: ospfe.h,v 1.24 2021/01/19 09:42:11 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -26,8 +26,6 @@
#include <netinet/in.h>
#include <netinet/ip.h>
-TAILQ_HEAD(ctl_conns, ctl_conn) ctl_conns;
-
struct lsa_entry {
TAILQ_ENTRY(lsa_entry) entry;
union {
@@ -95,6 +93,8 @@ struct nbr {
u_int8_t dd_snapshot; /* snapshot running */
};
+struct ctl_conn;
+
/* database.c */
int send_db_description(struct nbr *);
void recv_db_description(struct nbr *, char *, u_int16_t);