On Mon, Mar 23, 2015 at 11:54:41PM -0400, Yonas Yanfa wrote:
> Hi,
> 
> I'm running relayd/OpenBSD 5.6-stable on a KVM virtual machine. relayd
> always crashes within a few hours of restarting it, but works properly
> before that.

I guess you are talking about reloading relayd (as in relayctl reload)...
 
> When relayd stops working, sometimes the relayd process is up but `relayctl
> show summary` says that /var/run/relayd.sock doesn't exist. Other times none
> of the relayd processes are running.
> 

I hit similar issues and came up with the following diff against -current.
It may apply to 5.6 but did not test that at all. I'm not 100% sure about
the ca.c change since OpenSSL is a black box.

-- 
:wq Claudio

Index: ca.c
===================================================================
RCS file: /cvs/src/usr.sbin/relayd/ca.c,v
retrieving revision 1.12
diff -u -p -r1.12 ca.c
--- ca.c        22 Jan 2015 17:42:09 -0000      1.12
+++ ca.c        23 Mar 2015 12:56:24 -0000
@@ -417,11 +417,14 @@ rsae_keygen(RSA *rsa, int bits, BIGNUM *
 void
 ca_engine_init(struct relayd *x_env)
 {
-       ENGINE          *e;
+       ENGINE          *e = NULL;
        const char      *errstr, *name;
 
        if (env == NULL)
                env = x_env;
+
+       if (rsa_default != NULL)
+               return;
 
        if ((e = ENGINE_get_default_RSA()) == NULL) {
                if ((e = ENGINE_new()) == NULL) {
Index: config.c
===================================================================
RCS file: /cvs/src/usr.sbin/relayd/config.c,v
retrieving revision 1.24
diff -u -p -r1.24 config.c
--- config.c    22 Jan 2015 17:42:09 -0000      1.24
+++ config.c    23 Mar 2015 13:12:19 -0000
@@ -142,7 +142,7 @@ config_purge(struct relayd *env, u_int r
 
        if (what & CONFIG_TABLES && env->sc_tables != NULL) {
                while ((table = TAILQ_FIRST(env->sc_tables)) != NULL)
-                       purge_table(env->sc_tables, table);
+                       purge_table(env, env->sc_tables, table);
                env->sc_tablecount = 0;
        }
        if (what & CONFIG_RDRS && env->sc_rdrs != NULL) {
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/relayd/parse.y,v
retrieving revision 1.203
diff -u -p -r1.203 parse.y
--- parse.y     8 Feb 2015 04:50:32 -0000       1.203
+++ parse.y     23 Mar 2015 13:11:47 -0000
@@ -531,12 +531,12 @@ rdroptsl  : forwardmode TO tablespec inte
 
                        if ($3->conf.check == CHECK_NOCHECK) {
                                yyerror("table %s has no check", $3->conf.name);
-                               purge_table(conf->sc_tables, $3);
+                               purge_table(conf, conf->sc_tables, $3);
                                YYERROR;
                        }
                        if (rdr->backup) {
                                yyerror("only one backup table is allowed");
-                               purge_table(conf->sc_tables, $3);
+                               purge_table(conf, conf->sc_tables, $3);
                                YYERROR;
                        }
                        if (rdr->table) {
@@ -1930,7 +1930,7 @@ routeoptsl        : ROUTE address '/' NUMBER {
                        if (router->rt_gwtable) {
                                yyerror("router %s table already specified",
                                    router->rt_conf.name);
-                               purge_table(conf->sc_tables, $3);
+                               purge_table(conf, conf->sc_tables, $3);
                                YYERROR;
                        }
                        router->rt_gwtable = $3;
@@ -3091,7 +3091,7 @@ table_inherit(struct table *tb)
                goto fail;
        }
        if ((oldtb = table_findbyconf(conf, tb)) != NULL) {
-               purge_table(NULL, tb);
+               purge_table(conf, NULL, tb);
                return (oldtb);
        }
 
@@ -3134,7 +3134,7 @@ table_inherit(struct table *tb)
        return (tb);
 
  fail:
-       purge_table(NULL, tb);
+       purge_table(conf, NULL, tb);
        return (NULL);
 }
 
Index: relayd.c
===================================================================
RCS file: /cvs/src/usr.sbin/relayd/relayd.c,v
retrieving revision 1.138
diff -u -p -r1.138 relayd.c
--- relayd.c    22 Jan 2015 17:42:09 -0000      1.138
+++ relayd.c    23 Mar 2015 13:10:07 -0000
@@ -546,12 +546,13 @@ parent_dispatch_ca(int fd, struct privse
 }
 
 void
-purge_table(struct tablelist *head, struct table *table)
+purge_table(struct relayd *conf, struct tablelist *head, struct table *table)
 {
        struct host             *host;
 
        while ((host = TAILQ_FIRST(&table->hosts)) != NULL) {
                TAILQ_REMOVE(&table->hosts, host, entry);
+               TAILQ_REMOVE(&conf->sc_hosts, host, globalentry);
                if (event_initialized(&host->cte.ev)) {
                        event_del(&host->cte.ev);
                        close(host->cte.s);
Index: relayd.h
===================================================================
RCS file: /cvs/src/usr.sbin/relayd/relayd.h,v
retrieving revision 1.208
diff -u -p -r1.208 relayd.h
--- relayd.h    9 Mar 2015 17:20:38 -0000       1.208
+++ relayd.h    23 Mar 2015 13:10:45 -0000
@@ -1253,7 +1253,8 @@ struct ca_pkey    *pkey_add(struct relayd *
 int             expand_string(char *, size_t, const char *, const char *);
 void            translate_string(char *);
 void            purge_key(char **, off_t);
-void            purge_table(struct tablelist *, struct table *);
+void            purge_table(struct relayd *, struct tablelist *,
+                   struct table *);
 void            purge_relay(struct relayd *, struct relay *);
 char           *digeststr(enum digest_type, const u_int8_t *, size_t, char *);
 const char     *canonicalize_host(const char *, char *, size_t);

Reply via email to