summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ifstated/ifstated.c11
-rw-r--r--usr.sbin/ifstated/ifstated.h8
2 files changed, 13 insertions, 6 deletions
diff --git a/usr.sbin/ifstated/ifstated.c b/usr.sbin/ifstated/ifstated.c
index 40c61c54c91..2f54809abaa 100644
--- a/usr.sbin/ifstated/ifstated.c
+++ b/usr.sbin/ifstated/ifstated.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifstated.c,v 1.35 2009/06/25 17:14:57 sthen Exp $ */
+/* $OpenBSD: ifstated.c,v 1.36 2010/02/04 13:50:14 stevesk Exp $ */
/*
* Copyright (c) 2004 Marco Pfatschbacher <mpf@openbsd.org>
@@ -406,6 +406,9 @@ external_evtimer_setup(struct ifsd_state *state, int action)
}
}
+#define LINK_STATE_IS_DOWN(_s) \
+ (!LINK_STATE_IS_UP((_s)) && (_s) != LINK_STATE_UNKNOWN)
+
int
scan_ifstate_single(int ifindex, int s, struct ifsd_state *state)
{
@@ -422,7 +425,11 @@ scan_ifstate_single(int ifindex, int s, struct ifsd_state *state)
struct ifsd_expression *expression;
int truth;
- truth = (ifstate->ifstate == s) ||
+ truth =
+ (ifstate->ifstate == IFSD_LINKUNKNOWN &&
+ s == LINK_STATE_UNKNOWN) ||
+ (ifstate->ifstate == IFSD_LINKDOWN &&
+ LINK_STATE_IS_DOWN(s)) ||
(ifstate->ifstate == IFSD_LINKUP &&
LINK_STATE_IS_UP(s));
diff --git a/usr.sbin/ifstated/ifstated.h b/usr.sbin/ifstated/ifstated.h
index 85dace2ead3..15b2787d8c4 100644
--- a/usr.sbin/ifstated/ifstated.h
+++ b/usr.sbin/ifstated/ifstated.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifstated.h,v 1.5 2007/10/25 06:03:31 pyr Exp $ */
+/* $OpenBSD: ifstated.h,v 1.6 2010/02/04 13:50:14 stevesk Exp $ */
/*
* Copyright (c) 2004 Ryan McBride
@@ -37,9 +37,9 @@ struct ifsd_ifstate {
TAILQ_ENTRY(ifsd_ifstate) entries;
struct ifsd_expression_list expressions;
int ifstate;
-#define IFSD_LINKUNKNOWN 0 /* LINK_STATE_UNKNOWN */
-#define IFSD_LINKDOWN 1 /* LINK_STATE_DOWN */
-#define IFSD_LINKUP 2 /* LINK_STATE_UP */
+#define IFSD_LINKUNKNOWN 0
+#define IFSD_LINKDOWN 1
+#define IFSD_LINKUP 2
int prevstate;
u_int32_t refcount;
u_short ifindex;