Re: relayd/ctl alternative control socket
Kapetanakis Giannis(bil...@edu.physics.uoc.gr) on 2017.11.29 11:40:41 +0200: > On 28/11/17 17:06, Sebastian benoit wrote: > > Hi, > > > > your diff looks good, but i would rather do it the way bgpd/bgpctl do it: > > > > there the default is? /var/run/bgpd.sock. where is the > > routing domain bgpctl is running in.? To administer bgpd(8) in a different > > routing domain, run bgpctl in said routing domain. > > > > i.e. it detects the rdomain at startup, bgpctl does the same. > > > > Can you do that in relayd? It was commited there in sometime in summer. > > > > /Benno > > I followed snmpd way. > > My first diff was with -s command line option (ospfd, ldpd, iscsid, slaccd, > ripd way). > Then I changed it to relayd.conf socket option cause I saw a comment from > Reyk on an older thread that this is the way to go. > https://marc.info/?l=openbsd-tech=148840138521470=2 > > I don't think locking on rdomain is good in relayd since someone might want > to run multiple daemons on same rdomain. With bgpd this is not a requirement. well, i was thinking of having both the option and the automatic .. anyway, i commited your diff. Thanks. > Anyway if the patch is ok I believe it should go in because this feature is > really needed by many people. > Then later on if a universal way is decided on handling control sockets it > should be changed on all daemons > not following that decision. > > G >
Re: relayd/ctl alternative control socket
On 28/11/17 17:06, Sebastian benoit wrote: > Hi, > > your diff looks good, but i would rather do it the way bgpd/bgpctl do it: > > there the default is /var/run/bgpd.sock. where is the > routing domain bgpctl is running in. To administer bgpd(8) in a different > routing domain, run bgpctl in said routing domain. > > i.e. it detects the rdomain at startup, bgpctl does the same. > > Can you do that in relayd? It was commited there in sometime in summer. > > /Benno I followed snmpd way. My first diff was with -s command line option (ospfd, ldpd, iscsid, slaccd, ripd way). Then I changed it to relayd.conf socket option cause I saw a comment from Reyk on an older thread that this is the way to go. https://marc.info/?l=openbsd-tech=148840138521470=2 I don't think locking on rdomain is good in relayd since someone might want to run multiple daemons on same rdomain. With bgpd this is not a requirement. Anyway if the patch is ok I believe it should go in because this feature is really needed by many people. Then later on if a universal way is decided on handling control sockets it should be changed on all daemons not following that decision. G
Re: relayd/ctl alternative control socket
bgpd uses that way *because* it can use an alternate socket. Being able to specify a different socket for daemon/client is pretty helpful. On 2017 Nov 28 (Tue) at 16:06:51 +0100 (+0100), Sebastian benoit wrote: :Hi, : :your diff looks good, but i would rather do it the way bgpd/bgpctl do it: : :there the default is /var/run/bgpd.sock. where is the :routing domain bgpctl is running in. To administer bgpd(8) in a different :routing domain, run bgpctl in said routing domain. : :i.e. it detects the rdomain at startup, bgpctl does the same. : :Can you do that in relayd? It was commited there in sometime in summer. : :/Benno : : :On 11/28/17 11:54, Kapetanakis Giannis wrote: :> Hi, :> :> On June I've posted a patch about using alternative control socket for relayd and relayctl. :> There was a comment from David Gwynne which was evaluated. :> :> Is it OK to get this is in order to be able to control multiple relayd daemons on different rdomains? :> :> thanks :> :> Giannis :> -- "All my friends and I are crazy. That's the only thing that keeps us sane."
Re: relayd/ctl alternative control socket
But what about people not running relay on rdomain, but rather just want to run separate instances of relayd ? > 28 nov. 2017 kl. 16:06 skrev Sebastian benoit >: > > Hi, > > your diff looks good, but i would rather do it the way bgpd/bgpctl do it: > > there the default is /var/run/bgpd.sock. where is the > routing domain bgpctl is running in. To administer bgpd(8) in a different > routing domain, run bgpctl in said routing domain. > > i.e. it detects the rdomain at startup, bgpctl does the same. > > Can you do that in relayd? It was commited there in sometime in summer. > > /Benno > > > On 11/28/17 11:54, Kapetanakis Giannis wrote: >> Hi, >> On June I've posted a patch about using alternative control socket for >> relayd and relayctl. >> There was a comment from David Gwynne which was evaluated. >> Is it OK to get this is in order to be able to control multiple relayd >> daemons on different rdomains? >> thanks >> Giannis >> Index: config.c >> === >> RCS file: /cvs/src/usr.sbin/relayd/config.c,v >> retrieving revision 1.35 >> diff -u -p -r1.35 config.c >> --- config.c 27 Nov 2017 23:21:16 - 1.35 >> +++ config.c 28 Nov 2017 10:43:37 - >> @@ -44,6 +44,7 @@ config_init(struct relayd *env) >> env->sc_conf.interval.tv_usec = 0; >> env->sc_conf.prefork_relay = RELAY_NUMPROC; >> env->sc_conf.statinterval.tv_sec = RELAY_STATINTERVAL; >> +env->sc_ps->ps_csock.cs_name = RELAYD_SOCKET; >> } >> ps->ps_what[PROC_PARENT] = CONFIG_ALL; >> Index: parse.y >> === >> RCS file: /cvs/src/usr.sbin/relayd/parse.y,v >> retrieving revision 1.220 >> diff -u -p -r1.220 parse.y >> --- parse.y 27 Nov 2017 23:21:16 - 1.220 >> +++ parse.y 28 Nov 2017 10:43:38 - >> @@ -418,6 +418,9 @@ main : INTERVAL NUMBER { >> AGENTX_SOCKET, >> sizeof(conf->sc_conf.snmp_path)); >> } >> +| SOCKET STRING { >> +conf->sc_ps->ps_csock.cs_name = $2; >> +} >> ; >>trap : /* nothing */ { $$ = 0; } >> Index: relayd.c >> === >> RCS file: /cvs/src/usr.sbin/relayd/relayd.c,v >> retrieving revision 1.170 >> diff -u -p -r1.170 relayd.c >> --- relayd.c 27 Nov 2017 21:06:26 - 1.170 >> +++ relayd.c 28 Nov 2017 10:43:38 - >> @@ -199,9 +199,6 @@ main(int argc, char *argv[]) >> if ((ps->ps_pw = getpwnam(RELAYD_USER)) == NULL) >> errx(1, "unknown user %s", RELAYD_USER); >> - /* Configure the control socket */ >> -ps->ps_csock.cs_name = RELAYD_SOCKET; >> - >> log_init(debug, LOG_DAEMON); >> log_setverbose(verbose); >> Index: relayd.conf.5 >> === >> RCS file: /cvs/src/usr.sbin/relayd/relayd.conf.5,v >> retrieving revision 1.180 >> diff -u -p -r1.180 relayd.conf.5 >> --- relayd.conf.527 Nov 2017 23:21:16 - 1.180 >> +++ relayd.conf.528 Nov 2017 10:43:38 - >> @@ -163,6 +163,12 @@ will be used. >> See >> .Xr snmpd.conf 5 >> for more information about SNMP configuration. >> +.It Ic socket Qo Ar path Qc >> +Create a control socket at >> +.Ar path . >> +By default >> +.Pa /var/run/relayd.sock >> +is created and no other sockets are created. >> .It Ic timeout Ar number >> Set the global timeout in milliseconds for checks. >> This can be overridden by the timeout value in the table definitions. >> Index: relayctl.8 >> === >> RCS file: /cvs/src/usr.sbin/relayctl/relayctl.8,v >> retrieving revision 1.32 >> diff -u -p -r1.32 relayctl.8 >> --- relayctl.8 28 Nov 2015 01:22:44 - 1.32 >> +++ relayctl.8 28 Nov 2017 10:43:22 - >> @@ -23,6 +23,7 @@ >> .Nd control the relay daemon >> .Sh SYNOPSIS >> .Nm >> +.Op Fl s Ar socket >> .Ar command >> .Op Ar argument ... >> .Sh DESCRIPTION >> @@ -31,6 +32,17 @@ The >> program controls the >> .Xr relayd 8 >> daemon. >> +.Pp >> +The following options are available: >> +.Bl -tag -width Ds >> +.It Fl s Ar socket >> +Use >> +.Ar socket >> +instead of the default >> +.Pa /var/run/relayd.sock >> +to communicate with >> +.Xr relayd 8 . >> +.El >> .Pp >> The following commands are available: >> .Bl -tag -width Ds >> Index: relayctl.c >> === >> RCS file: /cvs/src/usr.sbin/relayctl/relayctl.c,v >> retrieving revision 1.57 >> diff -u -p -r1.57 relayctl.c >> --- relayctl.c 3 Sep 2016 14:44:21 - 1.57 >> +++ relayctl.c 28 Nov 2017 10:43:22 - >> @@ -88,7 +88,8 @@ usage(void) >> { >> extern char *__progname; >> - fprintf(stderr,
Re: relayd/ctl alternative control socket
Hi, your diff looks good, but i would rather do it the way bgpd/bgpctl do it: there the default is /var/run/bgpd.sock. where is the routing domain bgpctl is running in. To administer bgpd(8) in a different routing domain, run bgpctl in said routing domain. i.e. it detects the rdomain at startup, bgpctl does the same. Can you do that in relayd? It was commited there in sometime in summer. /Benno On 11/28/17 11:54, Kapetanakis Giannis wrote: Hi, On June I've posted a patch about using alternative control socket for relayd and relayctl. There was a comment from David Gwynne which was evaluated. Is it OK to get this is in order to be able to control multiple relayd daemons on different rdomains? thanks Giannis Index: config.c === RCS file: /cvs/src/usr.sbin/relayd/config.c,v retrieving revision 1.35 diff -u -p -r1.35 config.c --- config.c27 Nov 2017 23:21:16 - 1.35 +++ config.c28 Nov 2017 10:43:37 - @@ -44,6 +44,7 @@ config_init(struct relayd *env) env->sc_conf.interval.tv_usec = 0; env->sc_conf.prefork_relay = RELAY_NUMPROC; env->sc_conf.statinterval.tv_sec = RELAY_STATINTERVAL; + env->sc_ps->ps_csock.cs_name = RELAYD_SOCKET; } ps->ps_what[PROC_PARENT] = CONFIG_ALL; Index: parse.y === RCS file: /cvs/src/usr.sbin/relayd/parse.y,v retrieving revision 1.220 diff -u -p -r1.220 parse.y --- parse.y 27 Nov 2017 23:21:16 - 1.220 +++ parse.y 28 Nov 2017 10:43:38 - @@ -418,6 +418,9 @@ main: INTERVAL NUMBER { AGENTX_SOCKET, sizeof(conf->sc_conf.snmp_path)); } + | SOCKET STRING { + conf->sc_ps->ps_csock.cs_name = $2; + } ; trap : /* nothing */ { $$ = 0; } Index: relayd.c === RCS file: /cvs/src/usr.sbin/relayd/relayd.c,v retrieving revision 1.170 diff -u -p -r1.170 relayd.c --- relayd.c27 Nov 2017 21:06:26 - 1.170 +++ relayd.c28 Nov 2017 10:43:38 - @@ -199,9 +199,6 @@ main(int argc, char *argv[]) if ((ps->ps_pw = getpwnam(RELAYD_USER)) == NULL) errx(1, "unknown user %s", RELAYD_USER); - /* Configure the control socket */ - ps->ps_csock.cs_name = RELAYD_SOCKET; - log_init(debug, LOG_DAEMON); log_setverbose(verbose); Index: relayd.conf.5 === RCS file: /cvs/src/usr.sbin/relayd/relayd.conf.5,v retrieving revision 1.180 diff -u -p -r1.180 relayd.conf.5 --- relayd.conf.5 27 Nov 2017 23:21:16 - 1.180 +++ relayd.conf.5 28 Nov 2017 10:43:38 - @@ -163,6 +163,12 @@ will be used. See .Xr snmpd.conf 5 for more information about SNMP configuration. +.It Ic socket Qo Ar path Qc +Create a control socket at +.Ar path . +By default +.Pa /var/run/relayd.sock +is created and no other sockets are created. .It Ic timeout Ar number Set the global timeout in milliseconds for checks. This can be overridden by the timeout value in the table definitions. Index: relayctl.8 === RCS file: /cvs/src/usr.sbin/relayctl/relayctl.8,v retrieving revision 1.32 diff -u -p -r1.32 relayctl.8 --- relayctl.8 28 Nov 2015 01:22:44 - 1.32 +++ relayctl.8 28 Nov 2017 10:43:22 - @@ -23,6 +23,7 @@ .Nd control the relay daemon .Sh SYNOPSIS .Nm +.Op Fl s Ar socket .Ar command .Op Ar argument ... .Sh DESCRIPTION @@ -31,6 +32,17 @@ The program controls the .Xr relayd 8 daemon. +.Pp +The following options are available: +.Bl -tag -width Ds +.It Fl s Ar socket +Use +.Ar socket +instead of the default +.Pa /var/run/relayd.sock +to communicate with +.Xr relayd 8 . +.El .Pp The following commands are available: .Bl -tag -width Ds Index: relayctl.c === RCS file: /cvs/src/usr.sbin/relayctl/relayctl.c,v retrieving revision 1.57 diff -u -p -r1.57 relayctl.c --- relayctl.c 3 Sep 2016 14:44:21 - 1.57 +++ relayctl.c 28 Nov 2017 10:43:22 - @@ -88,7 +88,8 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s command [argument ...]\n", __progname); + fprintf(stderr, "usage: %s [-s socket] command [argument ...]\n", + __progname); exit(1); } @@ -101,9 +102,25 @@ main(int argc, char *argv[]) int ctl_sock; int done = 0; int n, verbose = 0; + int ch; + const char *sockname; + + sockname = RELAYD_SOCKET; + while ((ch =
Re: relayd/ctl alternative control socket
Hi, On June I've posted a patch about using alternative control socket for relayd and relayctl. There was a comment from David Gwynne which was evaluated. Is it OK to get this is in order to be able to control multiple relayd daemons on different rdomains? thanks Giannis Index: config.c === RCS file: /cvs/src/usr.sbin/relayd/config.c,v retrieving revision 1.35 diff -u -p -r1.35 config.c --- config.c27 Nov 2017 23:21:16 - 1.35 +++ config.c28 Nov 2017 10:43:37 - @@ -44,6 +44,7 @@ config_init(struct relayd *env) env->sc_conf.interval.tv_usec = 0; env->sc_conf.prefork_relay = RELAY_NUMPROC; env->sc_conf.statinterval.tv_sec = RELAY_STATINTERVAL; + env->sc_ps->ps_csock.cs_name = RELAYD_SOCKET; } ps->ps_what[PROC_PARENT] = CONFIG_ALL; Index: parse.y === RCS file: /cvs/src/usr.sbin/relayd/parse.y,v retrieving revision 1.220 diff -u -p -r1.220 parse.y --- parse.y 27 Nov 2017 23:21:16 - 1.220 +++ parse.y 28 Nov 2017 10:43:38 - @@ -418,6 +418,9 @@ main: INTERVAL NUMBER { AGENTX_SOCKET, sizeof(conf->sc_conf.snmp_path)); } + | SOCKET STRING { + conf->sc_ps->ps_csock.cs_name = $2; + } ; trap : /* nothing */ { $$ = 0; } Index: relayd.c === RCS file: /cvs/src/usr.sbin/relayd/relayd.c,v retrieving revision 1.170 diff -u -p -r1.170 relayd.c --- relayd.c27 Nov 2017 21:06:26 - 1.170 +++ relayd.c28 Nov 2017 10:43:38 - @@ -199,9 +199,6 @@ main(int argc, char *argv[]) if ((ps->ps_pw = getpwnam(RELAYD_USER)) == NULL) errx(1, "unknown user %s", RELAYD_USER); - /* Configure the control socket */ - ps->ps_csock.cs_name = RELAYD_SOCKET; - log_init(debug, LOG_DAEMON); log_setverbose(verbose); Index: relayd.conf.5 === RCS file: /cvs/src/usr.sbin/relayd/relayd.conf.5,v retrieving revision 1.180 diff -u -p -r1.180 relayd.conf.5 --- relayd.conf.5 27 Nov 2017 23:21:16 - 1.180 +++ relayd.conf.5 28 Nov 2017 10:43:38 - @@ -163,6 +163,12 @@ will be used. See .Xr snmpd.conf 5 for more information about SNMP configuration. +.It Ic socket Qo Ar path Qc +Create a control socket at +.Ar path . +By default +.Pa /var/run/relayd.sock +is created and no other sockets are created. .It Ic timeout Ar number Set the global timeout in milliseconds for checks. This can be overridden by the timeout value in the table definitions. Index: relayctl.8 === RCS file: /cvs/src/usr.sbin/relayctl/relayctl.8,v retrieving revision 1.32 diff -u -p -r1.32 relayctl.8 --- relayctl.8 28 Nov 2015 01:22:44 - 1.32 +++ relayctl.8 28 Nov 2017 10:43:22 - @@ -23,6 +23,7 @@ .Nd control the relay daemon .Sh SYNOPSIS .Nm +.Op Fl s Ar socket .Ar command .Op Ar argument ... .Sh DESCRIPTION @@ -31,6 +32,17 @@ The program controls the .Xr relayd 8 daemon. +.Pp +The following options are available: +.Bl -tag -width Ds +.It Fl s Ar socket +Use +.Ar socket +instead of the default +.Pa /var/run/relayd.sock +to communicate with +.Xr relayd 8 . +.El .Pp The following commands are available: .Bl -tag -width Ds Index: relayctl.c === RCS file: /cvs/src/usr.sbin/relayctl/relayctl.c,v retrieving revision 1.57 diff -u -p -r1.57 relayctl.c --- relayctl.c 3 Sep 2016 14:44:21 - 1.57 +++ relayctl.c 28 Nov 2017 10:43:22 - @@ -88,7 +88,8 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s command [argument ...]\n", __progname); + fprintf(stderr, "usage: %s [-s socket] command [argument ...]\n", + __progname); exit(1); } @@ -101,9 +102,25 @@ main(int argc, char *argv[]) int ctl_sock; int done = 0; int n, verbose = 0; + int ch; + const char *sockname; + + sockname = RELAYD_SOCKET; + while ((ch = getopt(argc, argv, "s:")) != -1) { + switch (ch) { + case 's': + sockname = optarg; + break; + default: + usage(); + /* NOTREACHED */ + } + } + argc -= optind; + argv += optind; /* parse options */ - if ((res = parse(argc - 1, argv + 1)) == NULL) + if ((res = parse(argc, argv)) ==
Re: relayd/ctl alternative control socket
On 23/06/17 11:07, Kapetanakis Giannis wrote: > On 23/06/17 04:43, David Gwynne wrote: >> >>> On 23 Jun 2017, at 01:15, Kapetanakis Giannis>>> wrote: >>> >>> Hi, >>> >>> Here is a patch for using alternative control socket for relayd and >>> relayctl. >>> It's based on ospfd. I would like for this to get in order to be able to >>> control multiple relayd daemons on different rdomains. >> >> i had something very much like this here, but more to limit the scope of >> failure than run in multiple rdomains. >> >> id like to see some tweaks for the ctl side though. see below. > > Thanks for the comments. > updated diff bellow > > btw char instead of const char is used all over the tree, also for conf files. > > G Hi, After reading back in the archive, I found out that it's preferred for this to be in conf file instead of argument. Here is an updated version for relayd that uses configuration file. relayctl is the same so I don't post again. regards, Giannis Index: config.c === RCS file: /cvs/src/usr.sbin/relayd/config.c,v retrieving revision 1.32 diff -u -p -r1.32 config.c --- config.c27 May 2017 08:33:25 - 1.32 +++ config.c10 Jul 2017 08:49:09 - @@ -44,6 +44,7 @@ config_init(struct relayd *env) env->sc_conf.interval.tv_usec = 0; env->sc_conf.prefork_relay = RELAY_NUMPROC; env->sc_conf.statinterval.tv_sec = RELAY_STATINTERVAL; + env->sc_ps->ps_csock.cs_name = RELAYD_SOCKET; } ps->ps_what[PROC_PARENT] = CONFIG_ALL; Index: parse.y === RCS file: /cvs/src/usr.sbin/relayd/parse.y,v retrieving revision 1.215 diff -u -p -r1.215 parse.y --- parse.y 27 May 2017 08:33:25 - 1.215 +++ parse.y 10 Jul 2017 08:49:09 - @@ -413,6 +413,9 @@ main: INTERVAL NUMBER { AGENTX_SOCKET, sizeof(conf->sc_conf.snmp_path)); } + | SOCKET STRING { + conf->sc_ps->ps_csock.cs_name = $2; + } ; trap : /* nothing */ { $$ = 0; } Index: relayd.c === RCS file: /cvs/src/usr.sbin/relayd/relayd.c,v retrieving revision 1.169 diff -u -p -r1.169 relayd.c --- relayd.c31 May 2017 04:14:34 - 1.169 +++ relayd.c10 Jul 2017 08:49:09 - @@ -199,9 +199,6 @@ main(int argc, char *argv[]) if ((ps->ps_pw = getpwnam(RELAYD_USER)) == NULL) errx(1, "unknown user %s", RELAYD_USER); - /* Configure the control socket */ - ps->ps_csock.cs_name = RELAYD_SOCKET; - log_init(debug, LOG_DAEMON); log_setverbose(verbose); Index: relayd.conf.5 === RCS file: /cvs/src/usr.sbin/relayd/relayd.conf.5,v retrieving revision 1.177 diff -u -p -r1.177 relayd.conf.5 --- relayd.conf.5 19 Apr 2017 10:48:57 - 1.177 +++ relayd.conf.5 10 Jul 2017 08:49:09 - @@ -163,6 +163,12 @@ will be used. See .Xr snmpd.conf 5 for more information about SNMP configuration. +.It Ic socket Qo Ar path Qc +Create a control socket at +.Ar path . +By default +.Pa /var/run/relayd.sock +is created and no other sockets are created. .It Ic timeout Ar number Set the global timeout in milliseconds for checks. This can be overridden by the timeout value in the table definitions. > > Index: relayctl/relayctl.8 > === > RCS file: /cvs/src/usr.sbin/relayctl/relayctl.8,v > retrieving revision 1.32 > diff -u -p -r1.32 relayctl.8 > --- relayctl/relayctl.8 28 Nov 2015 01:22:44 - 1.32 > +++ relayctl/relayctl.8 23 Jun 2017 07:57:59 - > @@ -23,6 +23,7 @@ > .Nd control the relay daemon > .Sh SYNOPSIS > .Nm > +.Op Fl s Ar socket > .Ar command > .Op Ar argument ... > .Sh DESCRIPTION > @@ -31,6 +32,21 @@ The > program controls the > .Xr relayd 8 > daemon. > +Commands may be abbreviated to the minimum unambiguous prefix; for example, > +.Cm sh su > +for > +.Cm show summary . > +.Pp > +The following options are available: > +.Bl -tag -width Ds > +.It Fl s Ar socket > +Use > +.Ar socket > +instead of the default > +.Pa /var/run/relayd.sock > +to communicate with > +.Xr relayd 8 . > +.El > .Pp > The following commands are available: > .Bl -tag -width Ds > Index: relayctl/relayctl.c > === > RCS file: /cvs/src/usr.sbin/relayctl/relayctl.c,v > retrieving revision 1.57 > diff -u -p -r1.57 relayctl.c > --- relayctl/relayctl.c 3 Sep 2016 14:44:21 - 1.57 > +++ relayctl/relayctl.c 23 Jun 2017 07:57:59 - > @@ -88,7 +88,8 @@ usage(void) > { >
Re: relayd/ctl alternative control socket
On 23/06/17 04:43, David Gwynne wrote: > >> On 23 Jun 2017, at 01:15, Kapetanakis Giannis>> wrote: >> >> Hi, >> >> Here is a patch for using alternative control socket for relayd and relayctl. >> It's based on ospfd. I would like for this to get in order to be able to >> control multiple relayd daemons on different rdomains. > > i had something very much like this here, but more to limit the scope of > failure than run in multiple rdomains. > > id like to see some tweaks for the ctl side though. see below. Thanks for the comments. updated diff bellow btw char instead of const char is used all over the tree, also for conf files. G Index: relayctl/relayctl.8 === RCS file: /cvs/src/usr.sbin/relayctl/relayctl.8,v retrieving revision 1.32 diff -u -p -r1.32 relayctl.8 --- relayctl/relayctl.8 28 Nov 2015 01:22:44 - 1.32 +++ relayctl/relayctl.8 23 Jun 2017 07:57:59 - @@ -23,6 +23,7 @@ .Nd control the relay daemon .Sh SYNOPSIS .Nm +.Op Fl s Ar socket .Ar command .Op Ar argument ... .Sh DESCRIPTION @@ -31,6 +32,21 @@ The program controls the .Xr relayd 8 daemon. +Commands may be abbreviated to the minimum unambiguous prefix; for example, +.Cm sh su +for +.Cm show summary . +.Pp +The following options are available: +.Bl -tag -width Ds +.It Fl s Ar socket +Use +.Ar socket +instead of the default +.Pa /var/run/relayd.sock +to communicate with +.Xr relayd 8 . +.El .Pp The following commands are available: .Bl -tag -width Ds Index: relayctl/relayctl.c === RCS file: /cvs/src/usr.sbin/relayctl/relayctl.c,v retrieving revision 1.57 diff -u -p -r1.57 relayctl.c --- relayctl/relayctl.c 3 Sep 2016 14:44:21 - 1.57 +++ relayctl/relayctl.c 23 Jun 2017 07:57:59 - @@ -88,7 +88,8 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s command [argument ...]\n", __progname); + fprintf(stderr, "usage: %s [-s socket] command [argument ...]\n", + __progname); exit(1); } @@ -101,9 +102,25 @@ main(int argc, char *argv[]) int ctl_sock; int done = 0; int n, verbose = 0; + int ch; + const char *sockname; + + sockname = RELAYD_SOCKET; + while ((ch = getopt(argc, argv, "s:")) != -1) { + switch (ch) { + case 's': + sockname = optarg; + break; + default: + usage(); + /* NOTREACHED */ + } + } + argc -= optind; + argv += optind; /* parse options */ - if ((res = parse(argc - 1, argv + 1)) == NULL) + if ((res = parse(argc, argv)) == NULL) exit(1); /* connect to relayd control socket */ @@ -112,7 +129,9 @@ main(int argc, char *argv[]) bzero(, sizeof(sun)); sun.sun_family = AF_UNIX; - (void)strlcpy(sun.sun_path, RELAYD_SOCKET, sizeof(sun.sun_path)); + if (strlcpy(sun.sun_path, sockname, sizeof(sun.sun_path)) >= + sizeof(sun.sun_path)) + errx(1, "socket `%s' too long", sockname); reconnect: if (connect(ctl_sock, (struct sockaddr *), sizeof(sun)) == -1) { /* Keep retrying if running in monitor mode */ @@ -121,7 +140,7 @@ main(int argc, char *argv[]) usleep(100); goto reconnect; } - err(1, "connect: %s", RELAYD_SOCKET); + err(1, "connect: %s", sockname); } if (pledge("stdio", NULL) == -1) Index: relayd/relayd.8 === RCS file: /cvs/src/usr.sbin/relayd/relayd.8,v retrieving revision 1.25 diff -u -p -r1.25 relayd.8 --- relayd/relayd.8 27 Jul 2015 14:50:58 - 1.25 +++ relayd/relayd.8 23 Jun 2017 07:57:26 - @@ -25,6 +25,7 @@ .Op Fl dnv .Op Fl D Ar macro Ns = Ns Ar value .Op Fl f Ar file +.Op Fl s Ar socket .Sh DESCRIPTION .Nm is a daemon to relay and dynamically redirect incoming connections to @@ -118,6 +119,8 @@ The default is .It Fl n Configtest mode. Only check the configuration file for validity. +.It Fl s Ar socket +Use an alternate location for the default control socket. .It Fl v Produce more verbose output. .El Index: relayd/relayd.c === RCS file: /cvs/src/usr.sbin/relayd/relayd.c,v retrieving revision 1.169 diff -u -p -r1.169 relayd.c --- relayd/relayd.c 31 May 2017 04:14:34 - 1.169 +++ relayd/relayd.c 23 Jun 2017 07:57:26 - @@ -107,7 +107,8 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s [-dnv] [-D macro=value] [-f file]\n", +
Re: relayd/ctl alternative control socket
> On 23 Jun 2017, at 01:15, Kapetanakis Giannis> wrote: > > Hi, > > Here is a patch for using alternative control socket for relayd and relayctl. > It's based on ospfd. I would like for this to get in order to be able to > control multiple relayd daemons on different rdomains. i had something very much like this here, but more to limit the scope of failure than run in multiple rdomains. id like to see some tweaks for the ctl side though. see below. > > regards, > > Giannis > > Index: relayd.8 > === > RCS file: /cvs/src/usr.sbin/relayd/relayd.8,v > retrieving revision 1.25 > diff -u -p -u -r1.25 relayd.8 > --- relayd.8 27 Jul 2015 14:50:58 - 1.25 > +++ relayd.8 22 Jun 2017 15:08:26 - > @@ -25,6 +25,7 @@ > .Op Fl dnv > .Op Fl D Ar macro Ns = Ns Ar value > .Op Fl f Ar file > +.Op Fl s Ar socket > .Sh DESCRIPTION > .Nm > is a daemon to relay and dynamically redirect incoming connections to > @@ -118,6 +119,8 @@ The default is > .It Fl n > Configtest mode. > Only check the configuration file for validity. > +.It Fl s Ar socket > +Use an alternate location for the default control socket. > .It Fl v > Produce more verbose output. > .El > Index: relayd.c > === > RCS file: /cvs/src/usr.sbin/relayd/relayd.c,v > retrieving revision 1.169 > diff -u -p -u -r1.169 relayd.c > --- relayd.c 31 May 2017 04:14:34 - 1.169 > +++ relayd.c 22 Jun 2017 15:08:26 - > @@ -107,7 +107,8 @@ usage(void) > { > extern char *__progname; > > - fprintf(stderr, "usage: %s [-dnv] [-D macro=value] [-f file]\n", > + fprintf(stderr, "usage: %s [-dnv] [-D macro=value] [-f file]" > + " [-s socket]\n", > __progname); > exit(1); > } > @@ -121,12 +122,13 @@ main(int argc, char *argv[]) > struct relayd *env; > struct privsep *ps; > const char *conffile = CONF_FILE; > + const char *sockname = RELAYD_SOCKET; > enum privsep_procid proc_id = PROC_PARENT; > int proc_instance = 0; > const char *errp, *title = NULL; > int argc0 = argc; > > - while ((c = getopt(argc, argv, "dD:nI:P:f:v")) != -1) { > + while ((c = getopt(argc, argv, "dD:nI:P:f:s:v")) != -1) { > switch (c) { > case 'd': > debug = 2; > @@ -143,6 +145,9 @@ main(int argc, char *argv[]) > case 'f': > conffile = optarg; > break; > + case 's': > + sockname = optarg; > + break; > case 'v': > verbose++; > opts |= RELAYD_OPT_VERBOSE; > @@ -200,7 +205,7 @@ main(int argc, char *argv[]) > errx(1, "unknown user %s", RELAYD_USER); > > /* Configure the control socket */ > - ps->ps_csock.cs_name = RELAYD_SOCKET; > + ps->ps_csock.cs_name = sockname; > > log_init(debug, LOG_DAEMON); > log_setverbose(verbose); > > Index: relayctl.8 > === > RCS file: /cvs/src/usr.sbin/relayctl/relayctl.8,v > retrieving revision 1.32 > diff -u -p -u -r1.32 relayctl.8 > --- relayctl.828 Nov 2015 01:22:44 - 1.32 > +++ relayctl.822 Jun 2017 15:08:37 - > @@ -23,6 +23,7 @@ > .Nd control the relay daemon > .Sh SYNOPSIS > .Nm > +.Op Fl s Ar socket > .Ar command > .Op Ar argument ... > .Sh DESCRIPTION > @@ -31,6 +32,21 @@ The > program controls the > .Xr relayd 8 > daemon. > +Commands may be abbreviated to the minimum unambiguous prefix; for example, > +.Cm sh su > +for > +.Cm show summary . > +.Pp > +The following options are available: > +.Bl -tag -width Ds > +.It Fl s Ar socket > +Use > +.Ar socket > +instead of the default > +.Pa /var/run/relayd.sock > +to communicate with > +.Xr relayd 8 . > +.El > .Pp > The following commands are available: > .Bl -tag -width Ds > Index: relayctl.c > === > RCS file: /cvs/src/usr.sbin/relayctl/relayctl.c,v > retrieving revision 1.57 > diff -u -p -u -r1.57 relayctl.c > --- relayctl.c3 Sep 2016 14:44:21 - 1.57 > +++ relayctl.c22 Jun 2017 15:08:37 - > @@ -88,7 +88,8 @@ usage(void) > { > extern char *__progname; > > - fprintf(stderr, "usage: %s command [argument ...]\n", __progname); > + fprintf(stderr, "usage: %s [-s socket] command [argument ...]\n", > + __progname); > exit(1); > } > > @@ -101,9 +102,25 @@ main(int argc, char *argv[]) > int ctl_sock; > int done = 0; > int n, verbose = 0; > + int ch; > + char
relayd/ctl alternative control socket
Hi, Here is a patch for using alternative control socket for relayd and relayctl. It's based on ospfd. I would like for this to get in order to be able to control multiple relayd daemons on different rdomains. regards, Giannis Index: relayd.8 === RCS file: /cvs/src/usr.sbin/relayd/relayd.8,v retrieving revision 1.25 diff -u -p -u -r1.25 relayd.8 --- relayd.827 Jul 2015 14:50:58 - 1.25 +++ relayd.822 Jun 2017 15:08:26 - @@ -25,6 +25,7 @@ .Op Fl dnv .Op Fl D Ar macro Ns = Ns Ar value .Op Fl f Ar file +.Op Fl s Ar socket .Sh DESCRIPTION .Nm is a daemon to relay and dynamically redirect incoming connections to @@ -118,6 +119,8 @@ The default is .It Fl n Configtest mode. Only check the configuration file for validity. +.It Fl s Ar socket +Use an alternate location for the default control socket. .It Fl v Produce more verbose output. .El Index: relayd.c === RCS file: /cvs/src/usr.sbin/relayd/relayd.c,v retrieving revision 1.169 diff -u -p -u -r1.169 relayd.c --- relayd.c31 May 2017 04:14:34 - 1.169 +++ relayd.c22 Jun 2017 15:08:26 - @@ -107,7 +107,8 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s [-dnv] [-D macro=value] [-f file]\n", + fprintf(stderr, "usage: %s [-dnv] [-D macro=value] [-f file]" + " [-s socket]\n", __progname); exit(1); } @@ -121,12 +122,13 @@ main(int argc, char *argv[]) struct relayd *env; struct privsep *ps; const char *conffile = CONF_FILE; + const char *sockname = RELAYD_SOCKET; enum privsep_procid proc_id = PROC_PARENT; int proc_instance = 0; const char *errp, *title = NULL; int argc0 = argc; - while ((c = getopt(argc, argv, "dD:nI:P:f:v")) != -1) { + while ((c = getopt(argc, argv, "dD:nI:P:f:s:v")) != -1) { switch (c) { case 'd': debug = 2; @@ -143,6 +145,9 @@ main(int argc, char *argv[]) case 'f': conffile = optarg; break; + case 's': + sockname = optarg; + break; case 'v': verbose++; opts |= RELAYD_OPT_VERBOSE; @@ -200,7 +205,7 @@ main(int argc, char *argv[]) errx(1, "unknown user %s", RELAYD_USER); /* Configure the control socket */ - ps->ps_csock.cs_name = RELAYD_SOCKET; + ps->ps_csock.cs_name = sockname; log_init(debug, LOG_DAEMON); log_setverbose(verbose); Index: relayctl.8 === RCS file: /cvs/src/usr.sbin/relayctl/relayctl.8,v retrieving revision 1.32 diff -u -p -u -r1.32 relayctl.8 --- relayctl.8 28 Nov 2015 01:22:44 - 1.32 +++ relayctl.8 22 Jun 2017 15:08:37 - @@ -23,6 +23,7 @@ .Nd control the relay daemon .Sh SYNOPSIS .Nm +.Op Fl s Ar socket .Ar command .Op Ar argument ... .Sh DESCRIPTION @@ -31,6 +32,21 @@ The program controls the .Xr relayd 8 daemon. +Commands may be abbreviated to the minimum unambiguous prefix; for example, +.Cm sh su +for +.Cm show summary . +.Pp +The following options are available: +.Bl -tag -width Ds +.It Fl s Ar socket +Use +.Ar socket +instead of the default +.Pa /var/run/relayd.sock +to communicate with +.Xr relayd 8 . +.El .Pp The following commands are available: .Bl -tag -width Ds Index: relayctl.c === RCS file: /cvs/src/usr.sbin/relayctl/relayctl.c,v retrieving revision 1.57 diff -u -p -u -r1.57 relayctl.c --- relayctl.c 3 Sep 2016 14:44:21 - 1.57 +++ relayctl.c 22 Jun 2017 15:08:37 - @@ -88,7 +88,8 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s command [argument ...]\n", __progname); + fprintf(stderr, "usage: %s [-s socket] command [argument ...]\n", + __progname); exit(1); } @@ -101,9 +102,25 @@ main(int argc, char *argv[]) int ctl_sock; int done = 0; int n, verbose = 0; + int ch; + char*sockname; + + sockname = RELAYD_SOCKET; + while ((ch = getopt(argc, argv, "s:")) != -1) { + switch (ch) { + case 's': + sockname = optarg; + break; + default: + usage(); + /* NOTREACHED */ + } + } + argc -= optind; + argv += optind; /* parse options */ - if ((res =