public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Jon Maloy <jmaloy@redhat.com>
Cc: dgibson@redhat.com, david@gibson.dropbear.id.au, passt-dev@passt.top
Subject: Re: [PATCH] arp/ndp: don't send messages on uninitialized tap interface
Date: Thu, 27 Nov 2025 23:33:56 +0100	[thread overview]
Message-ID: <20251127233356.2b006d54@elisabeth> (raw)
In-Reply-To: <20251127005316.3015592-1-jmaloy@redhat.com>

On Wed, 26 Nov 2025 19:53:16 -0500
Jon Maloy <jmaloy@redhat.com> wrote:

> When running pasta without --config-net, the tap interface is opened
> and assigned a valid file descriptor, but intentionally not brought
> up in the namespace. This is the expected behavior when the user wants
> to configure the namespace manually.
> 
> However, in PASTA mode the code is attempting to send ARP announcements
> and NDP messages (initial requests and unsolicited NAs) based solely on
> whether c->fd_tap is valid, without checking if the interface actually
> is up and ready to transmit. This results in send failures, and when
> debug is activated (pasta -d) we see error printouts for these early
> messages.
> 
> We now add new function tap_is_ready() which checks both conditions:
> - Whether fd_tap is valid (all modes)
> - Whether the tap interface is up (pasta mode only). In this mode, we
>   use the existing c->pasta_conf_ns flag, which indicates whether
>   pasta_ns_conf() configured and brought up the interface. This test
>   is simple, and good enough for now.
> 
> We update all functions that send unsolicited ARP/NDP messages to
> check with the new function before making any send attempt.
> 
> This eliminates spurious send errors when starting pasta without
> --config-net, while preserving correct behavior when the interface
> is properly initialized.
> 
> Signed-off-by: Jon Maloy <jmaloy@redhat.com>
> ---
>  arp.c |  3 +++
>  ndp.c |  5 +++--
>  tap.c | 27 +++++++++++++++++++++++++++
>  tap.h |  1 +
>  4 files changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/arp.c b/arp.c
> index 33b03cf..bb042e9 100644
> --- a/arp.c
> +++ b/arp.c
> @@ -168,6 +168,9 @@ void arp_announce(const struct ctx *c, struct in_addr *ip,
>  		struct arpmsg am;
>  	} __attribute__((__packed__)) msg;
>  
> +	if (!tap_is_ready(c))
> +		return;
> +
>  	/* Ethernet header */
>  	msg.eh.h_proto = htons(ETH_P_ARP);
>  	memcpy(msg.eh.h_dest, MAC_BROADCAST, sizeof(msg.eh.h_dest));
> diff --git a/ndp.c b/ndp.c
> index a33239d..eb9e313 100644
> --- a/ndp.c
> +++ b/ndp.c
> @@ -227,7 +227,8 @@ static void ndp_na(const struct ctx *c, const struct in6_addr *dst,
>   */
>  void ndp_unsolicited_na(const struct ctx *c, const struct in6_addr *addr)
>  {
> -	ndp_na(c, &in6addr_ll_all_nodes, addr);
> +	if (tap_is_ready(c))
> +		ndp_na(c, &in6addr_ll_all_nodes, addr);
>  }
>  
>  /**
> @@ -411,7 +412,7 @@ void ndp_timer(const struct ctx *c, const struct timespec *now)
>  	time_t max_rtr_adv_interval = DEFAULT_MAX_RTR_ADV_INTERVAL;
>  	time_t min_rtr_adv_interval, interval;
>  
> -	if (c->fd_tap < 0 || c->no_ra || now->tv_sec < next_ra)
> +	if (!tap_is_ready(c) || c->no_ra || now->tv_sec < next_ra)
>  		return;

Thanks for catching this one as well! I actually spotted the warning a
while ago but never had time to investigate.

Applied.

-- 
Stefano


      reply	other threads:[~2025-11-27 22:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27  0:53 Jon Maloy
2025-11-27 22:33 ` Stefano Brivio [this message]

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=20251127233356.2b006d54@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=dgibson@redhat.com \
    --cc=jmaloy@redhat.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).