From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none 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=X8NV8OKZ; 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 0B8C55A004E for ; Thu, 23 Jan 2025 12:54:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737633240; 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=lKpyw+GV3B0evbFxWgV7XpbaYYbGhZuFDOUCDhVla4I=; b=X8NV8OKZLuqEvTVPRIoGMcBV/P/tYpVazwbrYEvtsBTknVzmHavpJv9lSubyfUiPl7UDLd YXV7/PdxE6IkAu/VW+jILw0EtUPKmYqNGEDcBtvjDwocadq8fCYpz8fu0DppZggB7O/+vq I4XhmAScyGiS3RUMH+8q+MKi2iOPEEI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-163-rNfquCG-NyWYq91Qi9qq7A-1; Thu, 23 Jan 2025 06:53:59 -0500 X-MC-Unique: rNfquCG-NyWYq91Qi9qq7A-1 X-Mimecast-MFC-AGG-ID: rNfquCG-NyWYq91Qi9qq7A Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-385e00ebb16so311066f8f.3 for ; Thu, 23 Jan 2025 03:53:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737633237; x=1738238037; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=lKpyw+GV3B0evbFxWgV7XpbaYYbGhZuFDOUCDhVla4I=; b=lbLI8uZEy2AXrTo3+k1FmOR8ieM16h4CQjQ57OBRI874GEWNUyFcGA+baX+78ubuom XB+gSeWfyBEoN6Wg6jny5svQRg2x1bfLhjEq8w8NYP3vV/if1Sc+fvxxODz6fep67hMy YnFgu1fOJjfLK7lF19je92c5uxmILrsWerMqsFcKrVQxt1Zly5yaxTQ6YXXd4vMoLZCI g06e1/KvXQyO4JWf7E40HLns6BtRZA4ZuJ7gPyB++MZ/BkU5OblgxNgduYMMOSXqUBEB fS+/u0q1dRxeCnSpPFjAhiMFk8PHtllEFTqb5+XtpN7bmUvc9+YcF1Mx+S7u20vmC/Tk /+Sw== X-Gm-Message-State: AOJu0Yy4Tyu2PdrWxEF6MgHA71K1o/kICDib/JokuF6QYs5WMJ4609fQ s0E4hSXxJP8ycVuSi9tbjiOeMKCUGwMj+wtyg7nu5b+sQRflB7swc/nj7fyLKhdA8YQQsWJQLEr zPCvIDjeWxov9C7ZY42qT17fbEUspSwWGoSxaU/azo4kAlesM5KrgJwvmESEPYF9BSMm728EkCo 76qPXDrwYC0Dfw9+Q9NIkIAIbsW7v1FlJO X-Gm-Gg: ASbGncu5CAkf9TsG0FnnZ7VhHecFk3otzhwg3QPhOR7yiEiHdLioWpTvxrL5Vv70yxZ jgTsbi0vBpaUqTjYZra69EVqOhSqtnAiK917ZVYn/kHEZ4di5OWs7QyIfVG+QUIQ05fxvHliezS QIPPNoJHj2q6uQEZ/b5PC13droWwSrCXS4ttt0ED7yZBdPZMKaCU9oMTv/fR3VLj1jDahIhcbKh b2EWVGCyn6SJaQuMqj0V9/kNCJOVLftg+rYoJyJ0uZwqvefYlZ6b62etL4FBGZl+zZ9dhq5PLSn m1ERgA== X-Received: by 2002:a05:6000:2a8:b0:385:fb2c:6021 with SMTP id ffacd0b85a97d-38bf57a9620mr29997828f8f.39.1737633237142; Thu, 23 Jan 2025 03:53:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbwgB9igV/IKE3ZubP8rBbmv/XkgI8mH1Bkh7tkB31UUVtnw07g/P2WV1kM9MmBuUiqbr08w== X-Received: by 2002:a05:6000:2a8:b0:385:fb2c:6021 with SMTP id ffacd0b85a97d-38bf57a9620mr29997789f8f.39.1737633236715; Thu, 23 Jan 2025 03:53:56 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38bf3275901sm19287393f8f.61.2025.01.23.03.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 03:53:56 -0800 (PST) Date: Thu, 23 Jan 2025 12:53:54 +0100 From: Stefano Brivio To: Paul Holzinger Subject: Re: [PATCH] netlink: Skip loopback interface while looking for a template Message-ID: <20250123125354.0d25b157@elisabeth> In-Reply-To: <07aa7b5d-27b9-4494-88db-d675b7489f68@redhat.com> References: <20250123080548.1410738-1-sbrivio@redhat.com> <07aa7b5d-27b9-4494-88db-d675b7489f68@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: rtYlR8cNCM6qbnf6PvIBPXOS4pavSD8frw38eNBmFs0_1737633239 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: BM73ODO3ZSUHBHE2PUU3ROPNQYMCRBPK X-Message-ID-Hash: BM73ODO3ZSUHBHE2PUU3ROPNQYMCRBPK 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: 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 Thu, 23 Jan 2025 12:49:06 +0100 Paul Holzinger wrote: > On 23/01/2025 09:05, Stefano Brivio wrote: > > There might be reasons to have routes on the loopback interface, for > > example Any-IP/AnyIP routes as implemented by Linux kernel commit > > ab79ad14a2d5 ("ipv6: Implement Any-IP support for IPv6."). > > > > If we use the loopback interface as a template, though, we'll pick > > 'lo' (typically) as interface name for our tap interface, but we'll > > already have an interface called 'lo' in the target namespace, and as > > we TUNSETIFF on it, we'll fail with EINVAL, because it's not a tap > > interface. > > > > Skip the loopback interface while looking for a template interface or, > > more accurately, skip the interface with index 1. > > > > Strictly speaking, we should fetch interface flags via RTM_GETLINK > > instead, and check for IFF_LOOPBACK, but interleaving that request > > while we're iterating over routes is unnecessarily complicated. > > I think hard coding 1 is fine but I think there is also the IFF_LOOPBACK > flag that could be used instead. > > From strace: > ifi_index=if_nametoindex("lo"), > ifi_flags=IFF_UP|IFF_LOOPBACK|IFF_RUNNING|IFF_LOWER_UP Yeah but that's in the link flags, right? Am I missing something? Here we're looking at routes. Note that 'ip route show' will also fetch link attributes with RTM_GETLINK, which is the second netlink query I wanted to avoid here. -- Stefano