From: Marek Lindner <mareklindner@neomailbox.ch>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Marek Lindner <mareklindner@neomailbox.ch>
Subject: [PATCH] alfred: receive data with valid source on unix sock without active interface
Date: Mon, 3 Jul 2023 10:43:01 +0200 [thread overview]
Message-ID: <20230703084301.60455-1-mareklindner@neomailbox.ch> (raw)
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
unix_sock.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/unix_sock.c b/unix_sock.c
index ce08a51..e6208ef 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -108,10 +108,6 @@ static int unix_sock_add_data(struct globals *globals,
int len, data_len, ret = -1;
struct interface *interface;
- interface = netsock_first_interface(globals);
- if (!interface)
- goto err;
-
len = ntohs(push->header.length);
if (len < (int)(sizeof(*push) - sizeof(push->header)))
@@ -133,11 +129,26 @@ static int unix_sock_add_data(struct globals *globals,
* source addresses. Otherwise the data would not be
* synced between primary servers.
*/
- if (is_valid_ether_addr(data->source)) {
+ if (is_iface_disabled(globals->net_iface)) {
+ if (!is_valid_ether_addr(data->source))
+ goto err;
+
+ if (globals->opmode != OPMODE_PRIMARY)
+ goto err;
+
+ } else if (is_valid_ether_addr(data->source)) {
+ interface = netsock_first_interface(globals);
+ if (!interface)
+ goto err;
+
if (memcmp(data->source, &interface->hwaddr, ETH_ALEN) != 0 &&
globals->opmode != OPMODE_PRIMARY)
goto err;
} else {
+ interface = netsock_first_interface(globals);
+ if (!interface)
+ goto err;
+
memcpy(data->source, &interface->hwaddr, ETH_ALEN);
}
--
2.38.1
reply other threads:[~2023-07-03 8:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230703084301.60455-1-mareklindner@neomailbox.ch \
--to=mareklindner@neomailbox.ch \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).