diff options
author | Kevin Steves <stevesk@cvs.openbsd.org> | 2010-02-04 13:50:15 +0000 |
---|---|---|
committer | Kevin Steves <stevesk@cvs.openbsd.org> | 2010-02-04 13:50:15 +0000 |
commit | 96a8896bb8870825048c559788a1159806572af7 (patch) | |
tree | 54761c1b6846def1f5531ce37576e0dd02569e7f /usr.sbin/ifstated | |
parent | dd6260d67fca912de7bf4260fa09f45c9f3479f2 (diff) |
remove assumption that internal IFSD_LINK* defines are the same as
LINK_STATE* defines in <net/if.h>, which were changed Sep 14. this
fixes link state down being treated as up.
ok claudio@ henning@
Diffstat (limited to 'usr.sbin/ifstated')
-rw-r--r-- | usr.sbin/ifstated/ifstated.c | 11 | ||||
-rw-r--r-- | usr.sbin/ifstated/ifstated.h | 8 |
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; |