From 8d7b500c2ac3625a5b524c5e150619612af2dd36 Mon Sep 17 00:00:00 2001 From: benno Date: Mon, 29 May 2017 09:56:33 +0000 Subject: [PATCH] change bgpd's control socket from /var/run/bgpd.sock to /var/run/bgpd.sock. in both bgpd and bgpctl. makes life easier for admins. ok phessler, claudio, henning, feedback from Job Snijders --- usr.sbin/bgpctl/bgpctl.8 | 15 ++++++++++----- usr.sbin/bgpctl/bgpctl.c | 10 +++++++--- usr.sbin/bgpd/bgpd.conf.5 | 11 +++++++---- usr.sbin/bgpd/config.c | 8 +++++--- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/usr.sbin/bgpctl/bgpctl.8 b/usr.sbin/bgpctl/bgpctl.8 index c17f4dcdd37..b0f82937aaa 100644 --- a/usr.sbin/bgpctl/bgpctl.8 +++ b/usr.sbin/bgpctl/bgpctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bgpctl.8,v 1.73 2017/02/13 14:48:44 phessler Exp $ +.\" $OpenBSD: bgpctl.8,v 1.74 2017/05/29 09:56:33 benno Exp $ .\" .\" Copyright (c) 2003 Henning Brauer .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 13 2017 $ +.Dd $Mdocdate: May 29 2017 $ .Dt BGPCTL 8 .Os .Sh NAME @@ -44,10 +44,15 @@ Show neighbors' IP addresses instead of their description. .It Fl s Ar socket Use .Ar socket -instead of the default -.Pa /var/run/bgpd.sock to communicate with -.Xr bgpd 8 . +.Xr bgpd 8 +instead of the default +.Pa /var/run/bgpd.sock. +where +.Ar +is the routing domain +.Xr bgpctl 8 +is running in. .El .Pp The commands are as follows: diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index c1acceec05c..f66be1102c3 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.193 2017/01/23 23:38:51 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.194 2017/05/29 09:56:33 benno Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -117,7 +118,7 @@ int main(int argc, char *argv[]) { struct sockaddr_un sun; - int fd, n, done, ch, nodescr = 0, verbose = 0; + int fd, n, done, ch, nodescr = 0, verbose = 0, r; struct imsg imsg; struct network_config net; struct parse_result *res; @@ -126,10 +127,13 @@ main(int argc, char *argv[]) char *sockname; enum imsg_type type; + r = getrtable(); + if (asprintf(&sockname, "%s.%d", SOCKET_NAME, r) == -1) + err(1, "asprintf"); + if (pledge("stdio rpath wpath cpath unix inet dns", NULL) == -1) err(1, "pledge"); - sockname = SOCKET_NAME; while ((ch = getopt(argc, argv, "ns:")) != -1) { switch (ch) { case 'n': diff --git a/usr.sbin/bgpd/bgpd.conf.5 b/usr.sbin/bgpd/bgpd.conf.5 index 45bfe634203..dfa6600070e 100644 --- a/usr.sbin/bgpd/bgpd.conf.5 +++ b/usr.sbin/bgpd/bgpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bgpd.conf.5,v 1.157 2017/05/28 16:52:27 jmc Exp $ +.\" $OpenBSD: bgpd.conf.5,v 1.158 2017/05/29 09:56:33 benno Exp $ .\" .\" Copyright (c) 2004 Claudio Jeker .\" Copyright (c) 2003, 2004 Henning Brauer @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 28 2017 $ +.Dd $Mdocdate: May 29 2017 $ .Dt BGPD.CONF 5 .Os .Sh NAME @@ -417,8 +417,11 @@ If .Ic restricted is specified a restricted control socket will be created. By default -.Pa /var/run/bgpd.sock -is used and no restricted socket is created. +.Pa /var/run/bgpd.sock. +is used where +.Ar +is the routing domain in which bgpd has been started. +By default, no restricted socket is created. .Pp .It Xo .Ic transparent-as diff --git a/usr.sbin/bgpd/config.c b/usr.sbin/bgpd/config.c index 8d0f34e2653..62781a8ad2e 100644 --- a/usr.sbin/bgpd/config.c +++ b/usr.sbin/bgpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.66 2017/05/28 15:16:33 henning Exp $ */ +/* $OpenBSD: config.c,v 1.67 2017/05/29 09:56:33 benno Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -44,7 +45,7 @@ void free_rdomains(struct rdomain_head *); struct bgpd_config * new_config(void) { - struct bgpd_config *conf; + struct bgpd_config *conf; if ((conf = calloc(1, sizeof(struct bgpd_config))) == NULL) fatal(NULL); @@ -54,7 +55,8 @@ new_config(void) conf->fib_priority = RTP_BGP; conf->default_tableid = getrtable(); - if ((conf->csock = strdup(SOCKET_NAME)) == NULL) + if (asprintf(&conf->csock, "%s.%d", SOCKET_NAME, + conf->default_tableid) == -1) fatal(NULL); if ((conf->filters = calloc(1, sizeof(struct filter_head))) == NULL) -- 2.20.1