From patchwork Mon Jul 3 08:43:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 18561 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 6350881990 for ; Mon, 3 Jul 2023 10:43:24 +0200 (CEST) ARC-Seal: i=2; cv=pass; a=rsa-sha256; d=open-mesh.org; s=20121; t=1688373804; b=RWd6QYmCH7DgSXOFW8F2vExLNLbIf7HXiQrQ4mQinUS8RG0fM4iIlsBAdCq9XZhn34/98 vAQS7R3mdq9WAIQIgcqKEMA/s1PZzNNUwYK8fFVwvuBXMl6HLzpYpALf3xsHg640daJ5Q6H sHkfO6KTYU8DagrTkQrZaEubBvVdmPE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1688373804; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=A0OCey0jO27pxkiud+jDYq5fSNfWORPcVJ7hbsaxELg=; b=Z3ReIQQwP4qfd4eSRM4ShMDqZyzMLrz6vlR/Vh1W6uwOPoIuA65DTsmQAn0rekmvis2sJ cph9+rxhLaFze8aoKLHJKro5/tU73zwGT62TBSKA3Qv6ccPMvzAnwg5adppo6Ljgjqzgo3H DHDvh9R27dX423Pi3UwCE/nCu+7bBDs= ARC-Authentication-Results: i=2; open-mesh.org; dkim=fail; arc=pass; dmarc=none Authentication-Results: open-mesh.org; dkim=fail; arc=pass; dmarc=none Received: from s2.neomailbox.net (s2.neomailbox.net [5.148.176.60]) by diktynna.open-mesh.org (Postfix) with ESMTPS id BCF5981217 for ; Mon, 3 Jul 2023 10:43:16 +0200 (CEST) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1688373797; 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=A0OCey0jO27pxkiud+jDYq5fSNfWORPcVJ7hbsaxELg=; b=k8DHZRcrOxvw8N5az60Rm/MdYpzZVofwgC55+eIz3sGb5A6TTBmWRKdwB+f03YY0IwutGe V8ZhRy+1RUg1jdrEdKbgEhuD3VfzGvUEoLmkKLTWaJ08sxGp7QgcECQNhMZZFZUxdWp8lF EBlMU3Ery91Skmf3okwNo3WlDhpn7Go= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1688373797; a=rsa-sha256; cv=none; b=bKUsGHQukd4WNQPdZl7jfzNSnvARHrHgmsQOemXy2/RSHjE3soBItHSOMYwaFve7ZwAKp5 e9/ZdzVggCZsSV2lVz+yf36vkWQom5LqIlPCHotxb4RQ3ql0NEvYCHq3SXnRPEmmxe5inf 32KlpW1px6KDkYAJs353bPwi3LnY3Fc= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; dmarc=none; spf=pass (diktynna.open-mesh.org: domain of mareklindner@neomailbox.ch designates 5.148.176.60 as permitted sender) smtp.mailfrom=mareklindner@neomailbox.ch From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Subject: [PATCH] alfred: receive data with valid source on unix sock without active interface Date: Mon, 3 Jul 2023 10:43:01 +0200 Message-Id: <20230703084301.60455-1-mareklindner@neomailbox.ch> MIME-Version: 1.0 Message-ID-Hash: 47QZT5HF7TX6UKSYX4DP4VT2TFSZHU3A X-Message-ID-Hash: 47QZT5HF7TX6UKSYX4DP4VT2TFSZHU3A X-MailFrom: mareklindner@neomailbox.ch 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; digests; suspicious-header CC: Marek Lindner X-Mailman-Version: 3.3.8 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Marek Lindner --- 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); }