aboutsummaryrefslogtreecommitdiffstats
path: root/pingu_host.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-07-29 14:27:46 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2011-07-29 14:27:46 +0200
commitc761f12b0a67412cde8a4693f1e8d6aa14c0b70e (patch)
treed35341aacd1b42c9d5fe6aa85bf79b6d5022f9e0 /pingu_host.c
parent71a6bff30fae70332488863a621b0b22590398f0 (diff)
downloadpingu-c761f12b0a67412cde8a4693f1e8d6aa14c0b70e.tar.bz2
pingu-c761f12b0a67412cde8a4693f1e8d6aa14c0b70e.tar.xz
pingu: remove default gw from main route table when isp goes down
Diffstat (limited to 'pingu_host.c')
-rw-r--r--pingu_host.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/pingu_host.c b/pingu_host.c
index 427fe9a..640b928 100644
--- a/pingu_host.c
+++ b/pingu_host.c
@@ -1,4 +1,7 @@
+#include <arpa/inet.h>
+#include <linux/rtnetlink.h>
+
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -221,6 +224,7 @@ static void execute_action(const char *action)
int pingu_host_set_status(struct pingu_host *host, int status)
{
const char *action;
+ int route_action = 0;
host->burst.active = 0;
if (host->status == status) {
log_debug("%s: %s: status is still %i",
@@ -233,13 +237,16 @@ int pingu_host_set_status(struct pingu_host *host, int status)
switch (host->status) {
case 0:
action = host->down_action;
+ route_action = RTM_DELROUTE;
break;
case 1:
action = host->up_action;
+ route_action = RTM_NEWROUTE;
break;
}
if (action != NULL)
execute_action(action);
+ pingu_iface_update_routes(host->iface, route_action);
exec_route_change_hook();
return status;
}