On Sun, May 28, 2017 at 10:29:43PM +0200, Sebastian Benoit wrote: > Peter Hessler(phess...@theapt.org) on 2017.05.28 20:56:39 +0200: > > looks fine to me, OK > > > > > > On 2017 May 28 (Sun) at 19:12:34 +0200 (+0200), Sebastian Benoit wrote: > > :Hi, > > : > > :testing hennigs diff i found having to specify the socket on the command > > :line annoying: > > : > > : bgpctl -s /var/run/rdomain123.bgpd.sock sh rib > > : > > :srly? > > : > > :I figure when you are debuging things in rdomain <r>, you will want to > > route > > :-T <r> exec ksh anyway, so this makes bgpd create /var/run/bgpd.sock.<r> > > when run in rdomain > > :<r>, and bgpctl to use /var/run/bgpd.sock.<r> when run in rdomain <r>. > > : > > :ok? > > : > > :(claudio suggested that we should do this in other routing daemons too - i > > :will send diffs if this is acceptable). > > Job Snijders suggested to append .<rdomain> in all cases including rdomain > 0. > > diff updated, including manpage. > > How do we do do placeholders like the <rdomain> below in manpages?
Reads good to me. No idea about the manpage though. > diff --git usr.sbin/bgpctl/bgpctl.8 usr.sbin/bgpctl/bgpctl.8 > index c17f4dcdd37..85a26b4174d 100644 > --- usr.sbin/bgpctl/bgpctl.8 > +++ usr.sbin/bgpctl/bgpctl.8 > @@ -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.<rdomain> > +where > +.Ar <rdomain> > +is the routing domain > +.Xr bgpctl 8 > +is running in. > .El > .Pp > The commands are as follows: > diff --git usr.sbin/bgpctl/bgpctl.c usr.sbin/bgpctl/bgpctl.c > index c1acceec05c..036044acb33 100644 > --- usr.sbin/bgpctl/bgpctl.c > +++ usr.sbin/bgpctl/bgpctl.c > @@ -20,6 +20,7 @@ > > #include <sys/types.h> > #include <sys/socket.h> > +#include <sys/stat.h> > #include <sys/un.h> > #include <net/if.h> > #include <net/if_media.h> > @@ -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 usr.sbin/bgpd/bgpd.conf.5 usr.sbin/bgpd/bgpd.conf.5 > index 45bfe634203..8e21a5cec5f 100644 > --- usr.sbin/bgpd/bgpd.conf.5 > +++ usr.sbin/bgpd/bgpd.conf.5 > @@ -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.<rdomain> > +is used where > +.Ar <rdomain> > +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 usr.sbin/bgpd/config.c usr.sbin/bgpd/config.c > index 8d0f34e2653..8c76976e2c3 100644 > --- usr.sbin/bgpd/config.c > +++ usr.sbin/bgpd/config.c > @@ -28,6 +28,7 @@ > #include <ifaddrs.h> > #include <netdb.h> > #include <stdlib.h> > +#include <stdio.h> > #include <string.h> > #include <unistd.h> > > @@ -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) -- :wq Claudio