From 90acbcf20b5f896ca8f631923afe946c90d90de7 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Sun, 27 Jun 2010 21:22:11 +0200 Subject: Use netlink to detect going online Integrates libnl to detect adding routes. When a route is added, the offline status of all back ends is reset. This patch adds no heuristics to detect whether back end went offline. Fixes: #456 --- src/providers/data_provider_be.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/providers') diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index 059a0514..004ee097 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -55,11 +55,14 @@ static int data_provider_res_init(DBusMessage *message, struct sbus_connection *conn); static int data_provider_go_offline(DBusMessage *message, struct sbus_connection *conn); +static int data_provider_reset_offline(DBusMessage *message, + struct sbus_connection *conn); struct sbus_method monitor_be_methods[] = { { MON_CLI_METHOD_PING, monitor_common_pong }, { MON_CLI_METHOD_RES_INIT, data_provider_res_init }, { MON_CLI_METHOD_OFFLINE, data_provider_go_offline }, + { MON_CLI_METHOD_RESET_OFFLINE, data_provider_reset_offline }, { MON_CLI_METHOD_ROTATE, monitor_common_rotate_logs }, { NULL, NULL } }; @@ -170,6 +173,14 @@ void be_mark_offline(struct be_ctx *ctx) be_run_offline_cb(ctx); } +void be_reset_offline(struct be_ctx *ctx) +{ + DEBUG(8, ("Going back online!\n")); + + ctx->offstat.offline = false; + be_run_online_cb(ctx); +} + static int be_check_online(DBusMessage *message, struct sbus_connection *conn) { struct be_client *becli; @@ -1229,3 +1240,12 @@ static int data_provider_go_offline(DBusMessage *message, be_mark_offline(be_ctx); return monitor_common_pong(message, conn); } + +static int data_provider_reset_offline(DBusMessage *message, + struct sbus_connection *conn) +{ + struct be_ctx *be_ctx; + be_ctx = talloc_get_type(sbus_conn_get_private_data(conn), struct be_ctx); + be_reset_offline(be_ctx); + return monitor_common_pong(message, conn); +} -- cgit