diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-09-09 13:16:24 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-09-09 13:16:24 +0200 |
commit | e148ba2db8e2b2e38c5e4f8ec672de74f72fcf6d (patch) | |
tree | ea9e56ee09c530b044421df399378f2734cdb613 | |
parent | 78f7022bed26685f49dcbf7a5ab2489106bc1300 (diff) | |
download | pingu-e148ba2db8e2b2e38c5e4f8ec672de74f72fcf6d.tar.bz2 pingu-e148ba2db8e2b2e38c5e4f8ec672de74f72fcf6d.tar.xz |
pingu_netlink: do not add dead routes to multipath
We don't was add a multipath via an interface that a pinghost has set
as DOWN.
-rw-r--r-- | pingu_host.c | 9 | ||||
-rw-r--r-- | pingu_host.h | 1 | ||||
-rw-r--r-- | pingu_netlink.c | 5 |
3 files changed, 14 insertions, 1 deletions
diff --git a/pingu_host.c b/pingu_host.c index 1f1b534..360ec6d 100644 --- a/pingu_host.c +++ b/pingu_host.c @@ -102,6 +102,15 @@ struct pingu_host *pingu_host_new(char *hoststr, float burst_interval, return host; } +struct pingu_host *pingu_host_find_by_iface(struct pingu_iface *iface) +{ + struct pingu_host *host; + list_for_each_entry(host, &host_list, host_list_entry) + if (host->iface == iface) + return host; + return NULL; +} + int pingu_host_init(struct ev_loop *loop) { struct pingu_host *host; diff --git a/pingu_host.h b/pingu_host.h index 71e83a7..80a1f53 100644 --- a/pingu_host.h +++ b/pingu_host.h @@ -27,6 +27,7 @@ struct pingu_host *pingu_host_new(char *hoststr, float burst_interval, float timeout, const char *up_action, const char *down_action); +struct pingu_host *pingu_host_find_by_iface(struct pingu_iface *iface); int pingu_host_set_status(struct pingu_host *host, int status); int pingu_host_init(struct ev_loop *loop); int pingu_host_verify_status(struct ev_loop *loop, struct pingu_host *host); diff --git a/pingu_netlink.c b/pingu_netlink.c index 735df81..81fcad1 100644 --- a/pingu_netlink.c +++ b/pingu_netlink.c @@ -35,6 +35,7 @@ #include "log.h" #include "pingu_iface.h" +#include "pingu_host.h" #include "pingu_netlink.h" #ifndef ARRAY_SIZE @@ -359,6 +360,7 @@ static int add_nexthops(struct nlmsghdr *nlh, size_t nlh_size, struct rtnexthop *rtnh; struct pingu_iface *iface; struct pingu_gateway *route; + struct pingu_host *host; int count = 0; memset(buf, 0, sizeof(buf)); @@ -370,8 +372,9 @@ static int add_nexthops(struct nlmsghdr *nlh, size_t nlh_size, route = pingu_gateway_first_default(&iface->gateway_list); switch (action_type) { case RTM_NEWROUTE: + host = pingu_host_find_by_iface(iface); if ((!iface->balance) || iface->index == 0 - || route == NULL) + || (host != NULL && !host->status) || route == NULL) continue; iface->has_multipath = 1; break; |