b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] alfred: receive data with valid source on unix sock without active interface
@ 2023-07-03  8:43 Marek Lindner
  0 siblings, 0 replies; only message in thread
From: Marek Lindner @ 2023-07-03  8:43 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Marek Lindner

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-03  8:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03  8:43 [PATCH] alfred: receive data with valid source on unix sock without active interface Marek Lindner

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 NNTP newsgroup(s).