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 | |
parent | 7179ffad04c7ecffda3812591d161dc659346c3a (diff) |
inform hoststatectl monitor of ruleset changes and table syncs.
ok reyk@
-rw-r--r-- | usr.sbin/hoststatectl/hoststatectl.c | 5 | ||||
-rw-r--r-- | usr.sbin/hoststated/hoststated.h | 5 | ||||
-rw-r--r-- | usr.sbin/hoststated/pfe.c | 24 | ||||
-rw-r--r-- | usr.sbin/relayctl/relayctl.c | 5 | ||||
-rw-r--r-- | usr.sbin/relayd/pfe.c | 24 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 5 |
6 files changed, 60 insertions, 8 deletions
diff --git a/usr.sbin/hoststatectl/hoststatectl.c b/usr.sbin/hoststatectl/hoststatectl.c index 301488a9dc9..2fa8106cfc5 100644 --- a/usr.sbin/hoststatectl/hoststatectl.c +++ b/usr.sbin/hoststatectl/hoststatectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststatectl.c,v 1.13 2007/02/03 17:51:46 reyk Exp $ */ +/* $OpenBSD: hoststatectl.c,v 1.14 2007/02/06 08:45:46 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -68,6 +68,9 @@ struct imsgname imsgs[] = { { IMSG_CTL_TABLE_ENABLE, "ctl_table_enable", monitor_id }, { IMSG_CTL_HOST_DISABLE, "ctl_host_disable", monitor_id }, { IMSG_CTL_HOST_ENABLE, "ctl_host_enable", monitor_id }, + { IMSG_CTL_TABLE_CHANGED, "ctl_table_changed", monitor_id }, + { IMSG_CTL_PULL_RULESET, "ctl_pull_ruleset", monitor_id }, + { IMSG_CTL_PUSH_RULESET, "ctl_push_ruleset", monitor_id }, { IMSG_SYNC, "sync", NULL }, { 0, NULL, NULL } }; diff --git a/usr.sbin/hoststated/hoststated.h b/usr.sbin/hoststated/hoststated.h index 07931328c8f..bed4f5d0406 100644 --- a/usr.sbin/hoststated/hoststated.h +++ b/usr.sbin/hoststated/hoststated.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststated.h,v 1.18 2007/02/01 20:03:39 pyr Exp $ */ +/* $OpenBSD: hoststated.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, diff --git a/usr.sbin/hoststated/pfe.c b/usr.sbin/hoststated/pfe.c index b77b411d82b..5584b5df928 100644 --- a/usr.sbin/hoststated/pfe.c +++ b/usr.sbin/hoststated/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/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index 39746e0d34a..b5993bd237f 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.13 2007/02/03 17:51:46 reyk Exp $ */ +/* $OpenBSD: relayctl.c,v 1.14 2007/02/06 08:45:46 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -68,6 +68,9 @@ struct imsgname imsgs[] = { { IMSG_CTL_TABLE_ENABLE, "ctl_table_enable", monitor_id }, { IMSG_CTL_HOST_DISABLE, "ctl_host_disable", monitor_id }, { IMSG_CTL_HOST_ENABLE, "ctl_host_enable", monitor_id }, + { IMSG_CTL_TABLE_CHANGED, "ctl_table_changed", monitor_id }, + { IMSG_CTL_PULL_RULESET, "ctl_pull_ruleset", monitor_id }, + { IMSG_CTL_PUSH_RULESET, "ctl_push_ruleset", monitor_id }, { IMSG_SYNC, "sync", NULL }, { 0, NULL, NULL } }; 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, |