public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Nikolay Edigaryev <edigaryev@gmail.com>
To: passt-dev@passt.top
Cc: Nikolay Edigaryev <edigaryev@gmail.com>
Subject: [PATCH] arp: only send ARP replies for --gateway address
Date: Fri, 15 Sep 2023 18:20:45 +0400	[thread overview]
Message-ID: <20230915142045.73457-1-edigaryev@gmail.com> (raw)

Problem: when passt/pasta are working in a broadcast domain with more
than one host machine, it will answer for all of these machines,
except for the one having --address. This is akin to ARP spoofing
and breaks connection with these machines if passt/pasta ARP reply
arrives before the original one.

Solution: only be responsible and send ARP replies
for the --gateway's address.
---
 arp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arp.c b/arp.c
index a35c1b6..f873491 100644
--- a/arp.c
+++ b/arp.c
@@ -67,8 +67,8 @@ int arp(const struct ctx *c, const struct pool *p)
 	    !memcmp(am->sip, am->tip, sizeof(am->sip)))
 		return 1;
 
-	/* Don't resolve our own address, either. */
-	if (!memcmp(am->tip, &c->ip4.addr, sizeof(am->tip)))
+	/* Don't resolve anything but gateway address. */
+	if (memcmp(am->tip, &c->ip4.gw, sizeof(am->tip)) != 0)
 		return 1;
 
 	ah->ar_op = htons(ARPOP_REPLY);
-- 
@@ -67,8 +67,8 @@ int arp(const struct ctx *c, const struct pool *p)
 	    !memcmp(am->sip, am->tip, sizeof(am->sip)))
 		return 1;
 
-	/* Don't resolve our own address, either. */
-	if (!memcmp(am->tip, &c->ip4.addr, sizeof(am->tip)))
+	/* Don't resolve anything but gateway address. */
+	if (memcmp(am->tip, &c->ip4.gw, sizeof(am->tip)) != 0)
 		return 1;
 
 	ah->ar_op = htons(ARPOP_REPLY);
-- 
2.39.2 (Apple Git-144)


             reply	other threads:[~2023-09-15 14:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 14:20 Nikolay Edigaryev [this message]
2023-09-18  2:26 ` [PATCH] arp: only send ARP replies for --gateway address David Gibson
2023-09-18 14:01   ` Stefano Brivio
2023-09-18 15:52     ` Nikolay Edigaryev
2023-09-19  2:09       ` David Gibson
2023-10-12  4:35         ` David Gibson

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=20230915142045.73457-1-edigaryev@gmail.com \
    --to=edigaryev@gmail.com \
    --cc=passt-dev@passt.top \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).