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=hagCqBb7; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 145D85A0272 for ; Fri, 03 Oct 2025 03:03:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759453408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ndXePmvhuEeBC0TzvBAHypsl4gvw64w5UQiQnLRUBNU=; b=hagCqBb7dTBBKhkz24gWnvnBpjFcqpNaCfHCqKRF9dQllPlbcq6z39TtpxFIYVplpKAZxm b4bGwyMlu/FxzJYKzwkJRNGiIKzepOK9zVp9rVJ+ZvcI2S7fDvtjKz8OEYJKUNYXiaMp+w he+M6R1WYrTBr14i7Htfw7sUYU5d2L4= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-IulG3OIcNCCIzli6pAzgeQ-1; Thu, 02 Oct 2025 21:03:26 -0400 X-MC-Unique: IulG3OIcNCCIzli6pAzgeQ-1 X-Mimecast-MFC-AGG-ID: IulG3OIcNCCIzli6pAzgeQ_1759453406 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4d91b91b6f8so21555931cf.3 for ; Thu, 02 Oct 2025 18:03:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759453406; x=1760058206; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ndXePmvhuEeBC0TzvBAHypsl4gvw64w5UQiQnLRUBNU=; b=E+GIBUDfp9LDVU4w/oDVBfMAvAf34OsbvXvfVZSyAer15O259bUTK/tobWVPE3/+Zl wvD7ZDQ7v82+ehXMNyjZTUJlRBpag312O3m9pv8hfPJxiOyhrse0SfEQVKzVaSLSz6jf MbiWD6stiGJBnjA9x2NNdI52mdpMDHa8Qw3UGyH0sCcWcWEe748QwKkvsJgevCQo0pBS zkZGxmsrD+l56G4yygXTJSaVb347f8yypsaxI8nwzl0qLgSULex+BGk4qFXFRfbUZSIH wMT8FrmsX0HMB7W0OixnUEVQKOskbQIqJG+52L3zTqr+o8KMFoSNpKeJMUxSPmgjaZAC FGPg== X-Forwarded-Encrypted: i=1; AJvYcCVDKSzz/Raq4L8D77YiRtxKZ2wnhStzJor+2OVRZ/JDyL3cBeBwKUG8KfI/8hf3kuU6tZsxBf9o2Qg=@passt.top X-Gm-Message-State: AOJu0YyK89r0biJdE8SWI0dEcq/Kg0RUYjlV4kkS+WgCH9yHLdnxFKK6 Okzlw4eV+W3ugKQWdYi6UD9tvdz7O0gXDF/DQCnUSHO/aG6ISGb9Uy1j7NgG/cFpZreldNuqobD GLOeFNCUglojYe1+849qA7HKI/nNRTOrNq9DyVy494qV57zZRxjbTQQ== X-Gm-Gg: ASbGncueS8G4L26WLI//jIAwOrQX3nU+5OQAwwyYZ6woXp6wp7RjinHnM/f8qVXJ6Rx J/Nk/9ztbvuONDkczVDI9MzNON1ZpdXShu+BAl0utIJcr3gPnehZ8xGR1is3D8qFGe/6ERFM9/4 i3Xx+aObIf5ulwgdZxOjE/W76XNu78dWMuUVB1RnfYIBOY808GQEArzhmuwfHevpts6xUnzVF67 lusyoAMwlFXzGNWH6UTWaTUOOXSzMVhETOKpWdVn9F5nDNu34BvtnEqDIMby7EFZLdxS09W1ClA g3NwpATAgnigAAYTm/uprwLItzA7KD2vOSjuSux0k6HxsZlno1u/XQeIStHl7tXk3oW78/V2jMX Fsbof1YBSf04Gy0Y= X-Received: by 2002:ac8:570f:0:b0:4c7:130f:72ef with SMTP id d75a77b69052e-4e576a41e31mr20020241cf.9.1759453406369; Thu, 02 Oct 2025 18:03:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzqk9UH/YZfnCa3Ao01BZ9CkaCjYv2XPuUqjythE+0VVjfofpV+I01FVpJCDWFPky83IS8og== X-Received: by 2002:ac8:570f:0:b0:4c7:130f:72ef with SMTP id d75a77b69052e-4e576a41e31mr20019911cf.9.1759453405890; Thu, 02 Oct 2025 18:03:25 -0700 (PDT) Received: from ?IPV6:2001:4958:2193:9901:6217:960c:2ef1:f0f3? ([2001:4958:2193:9901:6217:960c:2ef1:f0f3]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4e55c9e7409sm29181271cf.31.2025.10.02.18.03.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Oct 2025 18:03:25 -0700 (PDT) Message-ID: <56d0df04-d925-4a66-b411-34243c0d2805@redhat.com> Date: Thu, 2 Oct 2025 21:03:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v12 2/9] fwd: Add cache table for ARP/NDP contents To: sbrivio@redhat.com, dgibson@redhat.com, david@gibson.dropbear.id.au, passt-dev@passt.top References: <20251003003412.588801-1-jmaloy@redhat.com> <20251003003412.588801-3-jmaloy@redhat.com> From: Jon Maloy In-Reply-To: <20251003003412.588801-3-jmaloy@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: oWnjFFP1jdScVKYBL1r6McVxT4q-Ni28bZhXkNHk7Tw_1759453406 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: GRWMUKTLHWBOB352DP5SRTMERGEO3RO7 X-Message-ID-Hash: GRWMUKTLHWBOB352DP5SRTMERGEO3RO7 X-MailFrom: jmaloy@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 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 2025-10-02 20:34, Jon Maloy wrote: > We add a cache table to keep track of the contents of the kernel ARP > and NDP tables. The table is fed from the just introduced netlink based > neigbour subscription function. The new table eliminates the need for > explicit netlink calls to find a host's MAC address. > > Signed-off-by: Jon Maloy > > --- > v5: - Moved to earlier in series to reduce rebase conflicts > v6: - Sqashed the hash list commit and the FIFO/LRU queue commit > - Removed hash lookup. We now only use linear lookup in a > linked list > - Eliminated dynamic memory allocation. > - Ensured there is only one call to clock_gettime() > - Using MAC_ZERO instead of the previously dedicated definitions > v7: - NOW using MAC_ZERO where needed > - I am still using linear back-off for empty cache entries. Even > an incoming, flow-creating packet from a local host gives no > guarantee that its MAC address is in the ARP table, so we must > allow for a few new attempts at first possible occasions. Only > after several failed lookups can we conclude that we probably > never will succeed. Hence the back-off. > - Fixed a bug that David inadvertently made me aware of: I only > intended to set the initial expiry value to MAC_CACHE_RENEWAL > when an ARP/NDP table lookup was successful. > - Improved struct and function description comments. > v8: - Total re-design of table, adapting to the new, subscription > based way of updating it. > v9: - Catering for MAC address change for an existing host. > v10: - Changes according to feedback from David Gibson > v12: - Changes according to feedback from David and Stefano > - Added dummy entries for loopback and default GW addresses > --- > conf.c | 1 + > fwd.c | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > fwd.h | 7 +++ > netlink.c | 7 ++- > 4 files changed, 195 insertions(+), 2 deletions(-) > [...] > + return !!e; > +} > + > +/** > + * fwd_neigh_table_init() - Initialize the neighbour table > + * @c: Execution context > + */ > +void fwd_neigh_table_init(const struct ctx *c) > +{ > + struct neigh_table *t = &neigh_table; > + const uint8_t *omac = c->our_tap_mac; > + struct neigh_table_entry *e; > + int i; > + > + memset(t, 0, sizeof(*t)); > + for (i = 0; i < NEIGH_TABLE_SIZE; i++) { > + e = &t->entries[i]; > + e->next = t->free; > + t->free = e; > + } > + > + /* These addresses must always map to our own MAC address */ > + fwd_neigh_table_update(c, &inany_loopback4, omac); > + fwd_neigh_table_update(c, &inany_loopback6, omac); > + fwd_neigh_table_update(c, &inany_from_v4(c->ip4.guest_gw), omac); > + fwd_neigh_table_update(c, (union inany_addr *)&c->ip6.guest_gw, omac); > +} > + Stefano, I know this isn't exactly what we agreed upon when we discussed this, but I really cannot see the guest address being handled anywhere in a way that justifies adding it to the the neigbour table. As far as I can see, the above, plus a fix in the next commit, solves all the problems regarding host and default GW access. Please correct me if I am wrong. ///jon