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 
> <openbsd-t...@mondlandefahrzeug.de>:
> 
> 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.<rdomain> where <rdomain> 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 -0000      1.35
>> +++ config.c 28 Nov 2017 10:43:37 -0000
>> @@ -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 -0000      1.220
>> +++ parse.y  28 Nov 2017 10:43:38 -0000
>> @@ -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 -0000      1.170
>> +++ relayd.c 28 Nov 2017 10:43:38 -0000
>> @@ -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 -0000      1.180
>> +++ relayd.conf.5    28 Nov 2017 10:43:38 -0000
>> @@ -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 -0000      1.32
>> +++ relayctl.8       28 Nov 2017 10:43:22 -0000
>> @@ -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 -0000       1.57
>> +++ relayctl.c       28 Nov 2017 10:43:22 -0000
>> @@ -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(&sun, 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 *)&sun, 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)
> 

Reply via email to