From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OfIXCUbY; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id AA2425A061A for ; Thu, 27 Nov 2025 23:34:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764282847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=faw/GDF676zKHWtYJvByD1vjO6TPT8yjTWAQmnH6zE8=; b=OfIXCUbYzaQDeaDrBFJgKyOzsJpF9jNEM7ouQokIRScEyZJ6q1Bx649P0IVb/GvHYMZuCO dWdEV749J1djSghpbs4t/WLVKddzA8YH1Fp2URhLlG+NbLqGDz5l0S3BPHUmIxGhMDeED+ a1SkZckM6BOMp3EQurPE5wNHocwz+yc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-KW6ZtbfVM5mtwZJJHgrzRA-1; Thu, 27 Nov 2025 17:33:59 -0500 X-MC-Unique: KW6ZtbfVM5mtwZJJHgrzRA-1 X-Mimecast-MFC-AGG-ID: KW6ZtbfVM5mtwZJJHgrzRA_1764282838 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-429c5c8ae3bso1027466f8f.0 for ; Thu, 27 Nov 2025 14:33:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764282838; x=1764887638; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=faw/GDF676zKHWtYJvByD1vjO6TPT8yjTWAQmnH6zE8=; b=cL7ewVRj2cpDCp5jvh+tNKl4Jv1s13OloNbDxkMkfxftoUCDfa6s/GZbrkFmLr20Gf +V6KHK35oM7qKNf0bzFtzt3e1gzOW37t5/Oo71l1Dv4f4hfUySZvuQ06hiqQ5eyWXM6K o/GGIdWlNOXTtUMnHBIe6rM2VxVFvmIS/wwQtu9wXslR1gBqHSGnobvFzwYVftpfVauw D9SvK35varBKQQr+QsUTimW7kkA+bkxaHcntNn4Qj+cPf207NCgX1oORO0dKuK0ULuVv mtYnsWESNpivHBfter6L1Yiuep2dXNolFPM8VdvIbN0+s/FpzD0BIfy3Xf52tbQw2FVR 2TmQ== X-Forwarded-Encrypted: i=1; AJvYcCUsvm88LBj7Jb/TBWL5m0sxbUOi0rh+mqE3DsA5oR7x/EtYuPlarMU9fyGi4eDmK2g4dFAOnL+cgbY=@passt.top X-Gm-Message-State: AOJu0Yy+59tXahixeFjjdUYdnd1zZJcy80ew4VSpDYc8TiuEVz+HKQqB jjQhIkrgkxMD1WKPF1ML8h61hRUhf+Ysw6OxzdkXVbfoazQ4wwW12dB732Oohs6D38uxKlZyMoz mr9Tnr7TZggDkv04L35FHvSFrnMV17VHoOZ2S73/zcsKaFmoed5yU9A== X-Gm-Gg: ASbGncvwy2WwSCKGA/rHE/Px2EFjU8zKofzWlDArnjhYimtlyU6V4zZu0ZJHw4nhg3n vU1bf93LYKPXe4UGo/UnRDMwCYFvJi41TIW9o8WBJAdz9tRHjWhah91IxamV5szhcyIYjj427uH y95P2zXfwvK73DWgHItGnpIWkIyRmGxk1Z6hYZ9XAQcErEgZtkSVAAm8sqX5bmbjJUVNgOs+MA6 fZEhlZ36HnLVnmaE9pEOtvXxU6a6x27ghpRlnkjlYT3wpCcMFxsv3x6sKFVn1ugWq5dx6OFJ+H9 jUSvH/y2HMZ3TYhlAuft40NbH1xmlt9ZHwrzSegZt45u0AtP1OTIG+FVCU3HomJRlmzgLXz7gOi wleWgh/psMErCYFiW7hXVNWR6W1uIcxnUKh6lGQ== X-Received: by 2002:a05:6000:430d:b0:429:ba48:4d6 with SMTP id ffacd0b85a97d-42e0f1fc42dmr12357934f8f.10.1764282838386; Thu, 27 Nov 2025 14:33:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqSB7gL/TrGh9DJNZK7SsrFv+YSzOCT9pCkn/O1Rcu8BhorZLkoep9lgbfUwZ9JhfsbBzRUg== X-Received: by 2002:a05:6000:430d:b0:429:ba48:4d6 with SMTP id ffacd0b85a97d-42e0f1fc42dmr12357921f8f.10.1764282837912; Thu, 27 Nov 2025 14:33:57 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42e1cab9af3sm5797222f8f.41.2025.11.27.14.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Nov 2025 14:33:57 -0800 (PST) Date: Thu, 27 Nov 2025 23:33:56 +0100 From: Stefano Brivio To: Jon Maloy Subject: Re: [PATCH] arp/ndp: don't send messages on uninitialized tap interface Message-ID: <20251127233356.2b006d54@elisabeth> In-Reply-To: <20251127005316.3015592-1-jmaloy@redhat.com> References: <20251127005316.3015592-1-jmaloy@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YAMMXY5FNcTsW7rV16z5mnR3Jeh5GBgf1bKVPrHgupQ_1764282838 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 5D5IICLDVKTV2OMNRR7CYDSWHCTJVW3V X-Message-ID-Hash: 5D5IICLDVKTV2OMNRR7CYDSWHCTJVW3V X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: dgibson@redhat.com, david@gibson.dropbear.id.au, passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, 26 Nov 2025 19:53:16 -0500 Jon Maloy 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 > --- > 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