From patchwork Mon Feb 15 20:01:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18262 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id A23B083D6F; Mon, 15 Feb 2021 21:10:13 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [IPv6:2a00:17d8:100::8b1]) by diktynna.open-mesh.org (Postfix) with ESMTPS id B07B080949 for ; Mon, 15 Feb 2021 21:10:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1613419333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=OJdFKRVvbbF/1YVXaxwrnRxA+gyPJenNCi3ipWAtP0E=; b=HuyORGAQ12mqzTALV1g+qu3gWSF/uQnwXoTjx+9OFENwlZNUvYt0sOrWhrvha2OziIk52V xKEgNg/pCqO4lD6zJ+Ecnvg142rWfcG5vDZg8Ki7vRtNA8Ktu24qkIbNF2x6NWSQAy3Tw4 GdE2rV0tpSLjlFR72Sz8tYjLscNpMjg= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Cc: Sven Eckelmann Subject: [PATCH 1/4] alfred: Show error message for invalid batadv interface Date: Mon, 15 Feb 2021 21:01:23 +0100 Message-Id: <20210215200126.140253-1-sven@narfation.org> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=HuyORGAQ; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 2a00:17d8:100::8b1 as permitted sender) smtp.mailfrom=sven@narfation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1613419804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=OJdFKRVvbbF/1YVXaxwrnRxA+gyPJenNCi3ipWAtP0E=; b=gYNZPZpU9FztBR3ulPQcpx9vFXrb4jgGzP/OkOFlDUmug6s/RSZKetHeIalKN2oO6gFBiw QDtzljVzEtbOiYgTW6LFn+O5xQ1pJKQ+eO5kLtlrtbAK+D1uGcC8z27i33V1wgP6Ve64FJ ckJcSHZiH36CAP1CDmm6EY6QFWFz2D4= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1613419804; a=rsa-sha256; cv=none; b=cYAoD9rZG9oVvplRyg2BLPnkSsYIeY3tAo/9sXjJE+RDkXQnLU2KAHbZnEy/7MtYZ8yxP1 xRxAGxWZEnPHF07R0ONhs0q0YxQgzhgWJZbENc5D0GE+k22zU0U5eSHM6oyDemJK8oa+Su w46/wUM4ZH0fTnIhcbWonAy4tgShi60= Message-ID-Hash: QFDVACZYBX3V72IMQVV6FH5TYAYA4LOG X-Message-ID-Hash: QFDVACZYBX3V72IMQVV6FH5TYAYA4LOG X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: The alfred server process always stopped without any informational message when the provided batman-adv was not "none" and was not accessible. This made it extremely hard to debug the reason why alfred directly stopped after launching it. Signed-off-by: Sven Eckelmann --- server.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server.c b/server.c index fc27246..efac5ad 100644 --- a/server.c +++ b/server.c @@ -385,8 +385,11 @@ int alfred_server(struct globals *globals) } if (strcmp(globals->mesh_iface, "none") != 0 && - batadv_interface_check(globals->mesh_iface) < 0) + batadv_interface_check(globals->mesh_iface) < 0) { + fprintf(stderr, "Can't start server: batman-adv interface %s not found\n", + globals->mesh_iface); return -1; + } num_socks = netsock_open_all(globals); if (num_socks <= 0) { From patchwork Mon Feb 15 20:01:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18261 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 2925E806DA; Mon, 15 Feb 2021 21:10:08 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [IPv6:2a00:17d8:100::8b1]) by diktynna.open-mesh.org (Postfix) with ESMTPS id B1E6E81DA8 for ; Mon, 15 Feb 2021 21:10:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1613419336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kYjJXK47JlcMyrdY3zoKMFYJWEoq6cflPdx8YKHqQ/Q=; b=BTbZ5tEyPZWbZRvka588GFztoRMiOup7uP08Lsruu2vPyF3+t6XYz06AbGyve4VxlF5BIY mqG4mYctLxOaFOcoKJMVo1DyEJZMLrnHHC633yKQ86vPousIsO77+vzzMFYLRQqVs0Dfs0 xnoxUqRf1DRVa89UXAm9vuFTy6rEOmM= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Cc: Sven Eckelmann Subject: [PATCH 2/4] alfred: Allow exactly one interface for secondary mode Date: Mon, 15 Feb 2021 21:01:24 +0100 Message-Id: <20210215200126.140253-2-sven@narfation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210215200126.140253-1-sven@narfation.org> References: <20210215200126.140253-1-sven@narfation.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=BTbZ5tEy; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 2a00:17d8:100::8b1 as permitted sender) smtp.mailfrom=sven@narfation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1613419804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kYjJXK47JlcMyrdY3zoKMFYJWEoq6cflPdx8YKHqQ/Q=; b=HxGaLpt5Yoa5ghyF5H5pfGIK32ywKH9hEvyRdmRWGQeW8XFywp8rWl8VjFmR76Fv9I+QEA Qt48kCUV1GhqEmPKsJfg0YKTB331GK9JJPz45xLmNV4oz8VOHweseV90viotrQ1VE03l8t 7j2kHZTSqArJxjqSWHiIiEL6jm2aj38= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1613419804; a=rsa-sha256; cv=none; b=b60cgJVAwA9PI1GluFB/9q0TlqsUW5tk7E0pebNBVj7PxDbiFstfXI85UTPHGyzuX60Oyd nXO93W2L48Y49Wqbvyv9kSmtMI6odYBstg1DaUPRUHSGXK3fxBBzLdPscjtzjepVIyw4QN /iqfc5johkEVLNhEDSTP/UCoZwdAqWg= Message-ID-Hash: 7A22GQOEW6NJWCVHECUKD24WUY3BSGCQ X-Message-ID-Hash: 7A22GQOEW6NJWCVHECUKD24WUY3BSGCQ X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: A primary alfred daemon allows syncing over more than one interface. But the secondary alfred daemon needs exactly one interface. But the check for this property was insufficient because it allowed paramters like "-i wlan0,asd" when wlan0 is valid and asd is not valid. The better solution is to really use the number of interfaces given to alfred instead of the number of interfaces evaluated as "valid". Fixes: 67ae5f57eedd ("alfred: Add support for multiple interfaces per master") Signed-off-by: Sven Eckelmann --- alfred.h | 1 + netsock.c | 11 +++++++++++ server.c | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/alfred.h b/alfred.h index 1e2c058..7d6b0b3 100644 --- a/alfred.h +++ b/alfred.h @@ -182,6 +182,7 @@ int unix_sock_req_data_finish(struct globals *globals, int vis_update_data(struct globals *globals); /* netsock.c */ int netsock_open_all(struct globals *globals); +size_t netsocket_count_interfaces(struct globals *globals); void netsock_close_all(struct globals *globals); int netsock_set_interfaces(struct globals *globals, char *interfaces); struct interface *netsock_first_interface(struct globals *globals); diff --git a/netsock.c b/netsock.c index 367b207..84b0ec3 100644 --- a/netsock.c +++ b/netsock.c @@ -471,6 +471,17 @@ int netsock_open_all(struct globals *globals) return num_socks; } +size_t netsocket_count_interfaces(struct globals *globals) +{ + struct interface *interface; + size_t count = 0; + + list_for_each_entry(interface, &globals->interfaces, list) + count++; + + return count; +} + void netsock_reopen(struct globals *globals) { struct interface *interface; diff --git a/server.c b/server.c index efac5ad..eb2bc8a 100644 --- a/server.c +++ b/server.c @@ -371,6 +371,7 @@ int alfred_server(struct globals *globals) int maxsock, ret, recvs; struct timespec last_check, now, tv; fd_set fds, errfds; + size_t num_interfaces; int num_socks; if (create_hashes(globals)) @@ -397,7 +398,8 @@ int alfred_server(struct globals *globals) return -1; } - if (num_socks > 1 && globals->opmode == OPMODE_SECONDARY) { + num_interfaces = netsocket_count_interfaces(globals); + if (num_interfaces > 1 && globals->opmode == OPMODE_SECONDARY) { fprintf(stderr, "More than one interface specified in secondary mode\n"); return -1; } From patchwork Mon Feb 15 20:01:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18260 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 9E8CC83D52; Mon, 15 Feb 2021 21:10:07 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 997148039C for ; Mon, 15 Feb 2021 21:10:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1613419339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ElSEHzDZqh/x46o9bSoCGe0yAyutISQuhGI6RqRmMyM=; b=PkVNHbil8wNGeh7itpaBlwhPquJ9JHf4g/hYfdsC8KFn3Z1UymJyssc9GPV/MY7sFvVeuX b1l1RiodxIqiIn9DP5Bdp5kI8HQjOXvKrNWVkoaf5SceXEPQVdxwDhCssCPGMzR8XiqSA8 PH4rQiP5AfXBK8mW/Qid0Wa3kFeYMyI= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Cc: Sven Eckelmann Subject: [PATCH 3/4] alfred: Save global mode flags in bitfield Date: Mon, 15 Feb 2021 21:01:25 +0100 Message-Id: <20210215200126.140253-3-sven@narfation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210215200126.140253-1-sven@narfation.org> References: <20210215200126.140253-1-sven@narfation.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=PkVNHbil; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 213.160.73.56 as permitted sender) smtp.mailfrom=sven@narfation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1613419804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ElSEHzDZqh/x46o9bSoCGe0yAyutISQuhGI6RqRmMyM=; b=igjouaaUTLxeeNBtjsZANmmXxwYvNMxEQV0isyDPso5CR/f/M9ErF/8g/LLLK8Efky6k5Q mh7Emve4YvkiUlqaeYBx268DpgC9DaQ7qsOBb1O12Q1Nv3mPrgQOLe7ERnhEbZrYFTvedg ptwO7FP09+qRnJK4l7XC7My8rQXWt/A= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1613419804; a=rsa-sha256; cv=none; b=SIAGYUvXwWmy7f/4rhH+jcDT+4EyCM2QLPaOi5zCP/6LQS1qM3KMNS2X8txYHoSLGCY+YA W4oTdBr86zGS6l+2pdQX4lIEfX4glsruRo0QrKBCuHUTRxiyEGyB+AjafUYv1deDE3nxdc teEj6M1n/JdcUxIl+MObSzo5N6VNu70= Message-ID-Hash: LQCMENSFDDN4TRQZTVDLMIJ6JNRWF5DU X-Message-ID-Hash: LQCMENSFDDN4TRQZTVDLMIJ6JNRWF5DU X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: The verbose and ipv4mode entries in the globals structure is only used to save a boolean information. So just use a bit in a bitfield to store this information instead of a full int. Signed-off-by: Sven Eckelmann --- alfred.h | 4 ++-- main.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/alfred.h b/alfred.h index 7d6b0b3..c64ff17 100644 --- a/alfred.h +++ b/alfred.h @@ -115,8 +115,8 @@ struct globals { enum clientmode clientmode; int clientmode_arg; int clientmode_version; - int verbose; - int ipv4mode; + uint8_t verbose:1; + uint8_t ipv4mode:1; int unix_sock; const char *unix_path; diff --git a/main.c b/main.c index 7b866cc..f25b6cc 100644 --- a/main.c +++ b/main.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -181,8 +182,8 @@ static struct globals *alfred_init(int argc, char *argv[]) globals->clientmode_version = 0; globals->mesh_iface = "bat0"; globals->unix_path = ALFRED_SOCK_PATH_DEFAULT; - globals->verbose = 0; - globals->ipv4mode = 0; + globals->verbose = false; + globals->ipv4mode = false; globals->update_command = NULL; globals->sync_period.tv_sec = ALFRED_INTERVAL; globals->sync_period.tv_nsec = 0; @@ -252,7 +253,7 @@ static struct globals *alfred_init(int argc, char *argv[]) globals->unix_path = optarg; break; case 'd': - globals->verbose++; + globals->verbose = true; break; case 'c': globals->update_command = optarg; @@ -268,7 +269,7 @@ static struct globals *alfred_init(int argc, char *argv[]) printf(" ** Setting sync interval to: %.9f seconds (%ld.%09ld)\n", sync_period, globals->sync_period.tv_sec, globals->sync_period.tv_nsec); break; case '4': - globals->ipv4mode = 1; + globals->ipv4mode = true; inet_pton(AF_INET, optarg, &alfred_mcast.ipv4); printf(" ** IPv4 Multicast Mode: %x\n", alfred_mcast.ipv4.s_addr); break; From patchwork Mon Feb 15 20:01:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18263 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 2C9F783D67; Mon, 15 Feb 2021 21:10:14 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [IPv6:2a00:17d8:100::8b1]) by diktynna.open-mesh.org (Postfix) with ESMTPS id B367982FE3 for ; Mon, 15 Feb 2021 21:10:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1613419341; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VJGucoXsKrx/eAdThUHsXzS13r6UIHVzZSU8BwedkzI=; b=FHKOeDBUSpFd1wHWlJx0b8x3Ov02Kn6/xCGfVLE6hPuNBc/xieeV8Jh7UvUSFPmEtguml1 wS1gDsmb0UbI0eIrGrgWqgJX+cQOjvPZBYCPkbxbBYI/95ZAaV309Ab7PZqtStL7UHLyHs UTaNP8olorVSOBqyFgwr/Ij2XnuINbo= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Cc: Sven Eckelmann Subject: [PATCH 4/4] alfred: Allow start of server without valid interface Date: Mon, 15 Feb 2021 21:01:26 +0100 Message-Id: <20210215200126.140253-4-sven@narfation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210215200126.140253-1-sven@narfation.org> References: <20210215200126.140253-1-sven@narfation.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=FHKOeDBU; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 2a00:17d8:100::8b1 as permitted sender) smtp.mailfrom=sven@narfation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1613419804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VJGucoXsKrx/eAdThUHsXzS13r6UIHVzZSU8BwedkzI=; b=Vom4VDxEErYTJ5l7T87mP+HYyR2gOLl9wo0tXs/Wwlmco/qx2OqXbxhKkRR/g4hQAEAgvb tsFVTa49WU9VaoyP+sT6btBjK4TwQSELpZBytTT+ynwHowCwipLStlXYrZy4G7tWwSSjNB iuY82VWOaBrhqxmQcu8QI3Y9IgFvYH8= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1613419804; a=rsa-sha256; cv=none; b=dGX1Xma+akYMQo/AjIzlQP26AHqSGgBfMiiyT4vGYSueRCz+yH0yO4z5gPt9y/oH5kyS2x 5ryJE6gl1IDHcWOTxutP8FxM8PBNzS5h6APqbfW8ujOlNLui2jAYQujPbrSIXlN5hmXpBP p4c8jJfs5rvEJcYG2HthlM30zqZgB8o= Message-ID-Hash: EWBGCC6UPUD4EPVGO3BCJJ3QQI6RGQLE X-Message-ID-Hash: EWBGCC6UPUD4EPVGO3BCJJ3QQI6RGQLE X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: The alfred server always needs interfaces to operate on. But these interfaces might not exist at the moment when the daemon process is started. This caused an error and stopped the process. But alfred is able to deal with interfaces which disappeared at runtime but existed at startup. To force a similar behavior for the alfred startup, the parameter "--force" or "-f" is introduced. Signed-off-by: Sven Eckelmann --- alfred.h | 1 + main.c | 7 ++++++- man/alfred.8 | 3 +++ server.c | 5 +++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/alfred.h b/alfred.h index c64ff17..ac08253 100644 --- a/alfred.h +++ b/alfred.h @@ -117,6 +117,7 @@ struct globals { int clientmode_version; uint8_t verbose:1; uint8_t ipv4mode:1; + uint8_t force:1; int unix_sock; const char *unix_path; diff --git a/main.c b/main.c index f25b6cc..e190d42 100644 --- a/main.c +++ b/main.c @@ -164,6 +164,7 @@ static struct globals *alfred_init(int argc, char *argv[]) {"version", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'd'}, {"sync-period", required_argument, NULL, 'p'}, + {"force", no_argument, NULL, 'f'}, {NULL, 0, NULL, 0}, }; @@ -184,6 +185,7 @@ static struct globals *alfred_init(int argc, char *argv[]) globals->unix_path = ALFRED_SOCK_PATH_DEFAULT; globals->verbose = false; globals->ipv4mode = false; + globals->force = false; globals->update_command = NULL; globals->sync_period.tv_sec = ALFRED_INTERVAL; globals->sync_period.tv_nsec = 0; @@ -191,7 +193,7 @@ static struct globals *alfred_init(int argc, char *argv[]) time_random_seed(); - while ((opt = getopt_long(argc, argv, "ms:r:hi:b:vV:M:I:u:dc:p:4:", long_options, + while ((opt = getopt_long(argc, argv, "ms:r:hi:b:vV:M:I:u:dc:p:4:f", long_options, &opt_ind)) != -1) { switch (opt) { case 'r': @@ -273,6 +275,9 @@ static struct globals *alfred_init(int argc, char *argv[]) inet_pton(AF_INET, optarg, &alfred_mcast.ipv4); printf(" ** IPv4 Multicast Mode: %x\n", alfred_mcast.ipv4.s_addr); break; + case 'f': + globals->force = true; + break; case 'h': default: alfred_usage(); diff --git a/man/alfred.8 b/man/alfred.8 index 25591be..e965db8 100644 --- a/man/alfred.8 +++ b/man/alfred.8 @@ -72,6 +72,9 @@ Collect data from the network and prints it on the network \fB\-d\fP, \fB\-\-verbose\fP Show extra information in the data output .TP +\fB\-d\fP, \fB\-\-force\fP +Start server even when batman-adv or interface(s) are not yet available. +.TP \fB\-V\fP, \fB\-\-req\-version\fP \fIversion\fP Specify the data version set for \fB\-s\fP diff --git a/server.c b/server.c index eb2bc8a..b4925e7 100644 --- a/server.c +++ b/server.c @@ -386,14 +386,15 @@ int alfred_server(struct globals *globals) } if (strcmp(globals->mesh_iface, "none") != 0 && - batadv_interface_check(globals->mesh_iface) < 0) { + batadv_interface_check(globals->mesh_iface) < 0 && + !globals->force) { fprintf(stderr, "Can't start server: batman-adv interface %s not found\n", globals->mesh_iface); return -1; } num_socks = netsock_open_all(globals); - if (num_socks <= 0) { + if (num_socks <= 0 && !globals->force) { fprintf(stderr, "Failed to open interfaces\n"); return -1; }