diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-10-30 21:04:46 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-10-30 21:04:46 +0000 |
commit | 12dfe0b012c16d3dff4e465111307f3ef6fa3a79 (patch) | |
tree | dd01d6e92c7bfe7b2febec9d7e928c22b30c2735 /usr.sbin | |
parent | f0458ebfc0a449cfbdfb8b7e72c8c851991c209f (diff) |
untangle a mess in the state update logic
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/hoststated/pfe.c | 18 | ||||
-rw-r--r-- | usr.sbin/relayd/pfe.c | 18 |
2 files changed, 16 insertions, 20 deletions
diff --git a/usr.sbin/hoststated/pfe.c b/usr.sbin/hoststated/pfe.c index e1df108a719..4eb3b094940 100644 --- a/usr.sbin/hoststated/pfe.c +++ b/usr.sbin/hoststated/pfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfe.c,v 1.38 2007/10/19 14:15:14 pyr Exp $ */ +/* $OpenBSD: pfe.c,v 1.39 2007/10/30 21:04:45 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -284,24 +284,22 @@ pfe_dispatch_imsg(int fd, short event, void *ptr) log_debug("pfe_dispatch_imsg: state %d for host %u %s", st.up, host->conf.id, host->conf.name); - if ((st.up == HOST_UNKNOWN && !HOST_ISUP(host->up)) || - (!HOST_ISUP(st.up) && host->up == HOST_UNKNOWN)) { - host->up = st.up; - break; - } - - if (st.up == HOST_UP) { + /* + * Do not change the table state when the host + * state switches between UNKNOWN and DOWN. + */ + if (HOST_ISUP(st.up)) { table->conf.flags |= F_CHANGED; table->up++; host->flags |= F_ADD; host->flags &= ~(F_DEL); - host->up = HOST_UP; - } else { + } else if (HOST_ISUP(host->up)) { table->up--; table->conf.flags |= F_CHANGED; host->flags |= F_DEL; host->flags &= ~(F_ADD); } + host->up = st.up; break; case IMSG_SYNC: diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c index e1df108a719..4eb3b094940 100644 --- a/usr.sbin/relayd/pfe.c +++ b/usr.sbin/relayd/pfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfe.c,v 1.38 2007/10/19 14:15:14 pyr Exp $ */ +/* $OpenBSD: pfe.c,v 1.39 2007/10/30 21:04:45 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -284,24 +284,22 @@ pfe_dispatch_imsg(int fd, short event, void *ptr) log_debug("pfe_dispatch_imsg: state %d for host %u %s", st.up, host->conf.id, host->conf.name); - if ((st.up == HOST_UNKNOWN && !HOST_ISUP(host->up)) || - (!HOST_ISUP(st.up) && host->up == HOST_UNKNOWN)) { - host->up = st.up; - break; - } - - if (st.up == HOST_UP) { + /* + * Do not change the table state when the host + * state switches between UNKNOWN and DOWN. + */ + if (HOST_ISUP(st.up)) { table->conf.flags |= F_CHANGED; table->up++; host->flags |= F_ADD; host->flags &= ~(F_DEL); - host->up = HOST_UP; - } else { + } else if (HOST_ISUP(host->up)) { table->up--; table->conf.flags |= F_CHANGED; host->flags |= F_DEL; host->flags &= ~(F_ADD); } + host->up = st.up; break; case IMSG_SYNC: |