diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-02-06 08:45:47 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-02-06 08:45:47 +0000 |
commit | 39659b52b3422ff9282ee8e076893e3c3f7f957c (patch) | |
tree | a51ff16f67f60c144c5959999003c382e783f755 /usr.sbin/relayd | |
parent | 7179ffad04c7ecffda3812591d161dc659346c3a (diff) |
inform hoststatectl monitor of ruleset changes and table syncs.
ok reyk@
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r-- | usr.sbin/relayd/pfe.c | 24 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 5 |
2 files changed, 26 insertions, 3 deletions
diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c index b77b411d82b..5584b5df928 100644 --- a/usr.sbin/relayd/pfe.c +++ b/usr.sbin/relayd/pfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfe.c,v 1.10 2007/02/01 20:03:39 pyr Exp $ */ +/* $OpenBSD: pfe.c,v 1.11 2007/02/06 08:45:46 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -497,7 +497,11 @@ pfe_sync(void) struct service *service; struct table *active; int backup; + struct ctl_id id; + struct imsg imsg; + bzero(&id, sizeof(id)); + bzero(&imsg, sizeof(imsg)); TAILQ_FOREACH(service, &env->services, entry) { backup = (service->flags & F_BACKUP); service->flags &= ~(F_BACKUP); @@ -515,8 +519,14 @@ pfe_sync(void) } else active = service->table; - if (active != NULL && active->flags & F_CHANGED) + if (active != NULL && active->flags & F_CHANGED) { + id.id = active->id; + imsg.hdr.type = IMSG_CTL_TABLE_CHANGED; + imsg.hdr.len = sizeof(id) + IMSG_HEADER_SIZE; + imsg.data = &id; sync_table(env, service, active); + control_imsg_forward(&imsg); + } service->table->flags &= ~(F_CHANGED); service->backup->flags &= ~(F_CHANGED); @@ -526,12 +536,22 @@ pfe_sync(void) flush_table(env, service); log_debug("pfe_sync: disabling ruleset"); service->flags &= ~(F_ACTIVE_RULESET); + id.id = service->id; + imsg.hdr.type = IMSG_CTL_PULL_RULESET; + imsg.hdr.len = sizeof(id) + IMSG_HEADER_SIZE; + imsg.data = &id; sync_ruleset(env, service, 0); + control_imsg_forward(&imsg); } } else if (!(service->flags & F_ACTIVE_RULESET)) { log_debug("pfe_sync: enabling ruleset"); service->flags |= F_ACTIVE_RULESET; + id.id = service->id; + imsg.hdr.type = IMSG_CTL_PUSH_RULESET; + imsg.hdr.len = sizeof(id) + IMSG_HEADER_SIZE; + imsg.data = &id; sync_ruleset(env, service, 1); + control_imsg_forward(&imsg); } } } diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index bd16884396a..4fcb75a129d 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.18 2007/02/01 20:03:39 pyr Exp $ */ +/* $OpenBSD: relayd.h,v 1.19 2007/02/06 08:45:46 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -80,6 +80,9 @@ enum imsg_type { IMSG_CTL_SERVICE, IMSG_CTL_TABLE, IMSG_CTL_HOST, + IMSG_CTL_TABLE_CHANGED, + IMSG_CTL_PULL_RULESET, + IMSG_CTL_PUSH_RULESET, IMSG_CTL_SHOW_SUM, /* hoststatectl requests */ IMSG_CTL_SERVICE_ENABLE, IMSG_CTL_SERVICE_DISABLE, |