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=R/hB095w; 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 A63CB5A028A for ; Thu, 12 Jun 2025 17:17:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749741455; 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=qmBbTVbCMdJy5ay/lhyGwwer2NF9N1lNo1CFkkUwndo=; b=R/hB095waEfUkjHWWSp6q8Iv3f2/lMzkxjtR+8FPjCmVN3NOZCk0ue23voZDtZlYohtuyJ rUBilN9xWHC9K3QyDsjCPujrXZy4Fv8uZPmoyUUnecdZvUEQ1Fz6jZS6bnGT8ICZD66BaN d5aY/xClp8LcL1gU1VIh3amf81KYQhk= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-kTUfgAHaNbS67sJ_2FoQmQ-1; Thu, 12 Jun 2025 11:17:34 -0400 X-MC-Unique: kTUfgAHaNbS67sJ_2FoQmQ-1 X-Mimecast-MFC-AGG-ID: kTUfgAHaNbS67sJ_2FoQmQ_1749741453 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-450d290d542so6269555e9.1 for ; Thu, 12 Jun 2025 08:17:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749741452; x=1750346252; 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=ijE9n0aCj9Zr2FtwjAKC9G68rDsCl5f6f5rBkPo6xIU=; b=VOuGu+JoKV8HO8LuXAaeoWHYwFC0fN2ikUYK3SqgG4HvpfADZ7TyS+2xdWS0G8aqA3 4LfXMr6XeqmQ9CZ+xLc52e7Pu+G5AYEpTQbDoacOPGBlNe4eWn+c4Af/ZPl/kDUwP5EJ nue7bD8CsvS5rYoZ8XqvMfOw9sEIyuoviY72BFqU/72OC7uCVsiLCBcP5Cu2ruLjKpUb LFnE/JAFC+7B2B3mSzDyHMXENaxk26v4X8vpJlkioD7XqvN491DUKXWhWleQUsZdNorv BaOvWq8I9+gnpBOx+h9qe0qothvQ9gphAOTFv4/dzZG0N8Z73e9AKPnn0svNi8CxBmgQ eJLQ== X-Forwarded-Encrypted: i=1; AJvYcCWtIxCBbfgnFNoECcV+pA6GSU/qj2Ijfv/h5WNQLx0q80Bkd2hisa3H2OZyg5edRCDfa17imfUivPs=@passt.top X-Gm-Message-State: AOJu0YyrtankSnk9uI5EEwHt9LnKWNrSP+9FvkAUeBb9dY2AJqXAJ+Kz G+J2Xh7F0Br9gbQDsdYOHaTkZ0lTvL0Sq4TVl6pKKnRy+IO1veNC6m8rA1jm7gFHHAb/UaNZuk7 U3PJPieloEBCUnqVxe5QIm1skgWNRyHxoYeBkwom39xq4/1aUyqvYmcOHNeQs43LFoezaxCp986 tYlc5Er34ftnZ6k30apsGJBRJpf0mHWe4e7mw3 X-Gm-Gg: ASbGncvtSAF2BK8e15XC4CgBTnYpzC2Av1HfWvBsZaICem8KBDmlN/BQezP1zPe+vYX nLVmo+jOOr/LSrMQUL4pDWYbQ16RJsPCkPrFDUbmPFr7Uk/cd5fdnB28BF4fWRrBc/NQroqWTJ7 5Q+enuLdUOMn09YdoeYGUZTlvBvRQNB6GlS7+j0ckeQArEdIr93wDhmEC06jsiDOiyJnM24hOHE SrOLXe/urlCZ35Hmx5jrTOQRmQwTtZdClPBXckIatWTpqlO2qms25kyU7u15QnN0IV8x0HhUQZy dkh/KH04VRy+qH8r1IWuyD2/Ayhb2hS2YQ== X-Received: by 2002:a05:600c:8587:b0:43b:ca39:6c75 with SMTP id 5b1f17b1804b1-453249d1c3fmr53967835e9.16.1749741452034; Thu, 12 Jun 2025 08:17:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFejRrAZBlFXeV4+aR1OOWOQCyQ0gWIvHBBjI7Kj8MVdZw8nxjG4Gkgb6zk8rvbNPq+mg/HdA== X-Received: by 2002:a05:600c:8587:b0:43b:ca39:6c75 with SMTP id 5b1f17b1804b1-453249d1c3fmr53967465e9.16.1749741451548; Thu, 12 Jun 2025 08:17:31 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532de8c2d2sm24901865e9.1.2025.06.12.08.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jun 2025 08:17:30 -0700 (PDT) Date: Thu, 12 Jun 2025 17:17:29 +0200 From: Stefano Brivio To: Jon Maloy Subject: Re: [PATCH v2 3/8] flow: add mac address of LAN local remote hosts to flow Message-ID: <20250612171729.6a1144f4@elisabeth> In-Reply-To: <20250612042152.695879-4-jmaloy@redhat.com> References: <20250612042152.695879-1-jmaloy@redhat.com> <20250612042152.695879-4-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: qFgHIM3QI-_9W6GH0wAhvIe5kVpA5caSr3L1jPd9aNA_1749741453 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: OQVNWSQK4V45J2Z3CJE5QRGMXCOUYV4Z X-Message-ID-Hash: OQVNWSQK4V45J2Z3CJE5QRGMXCOUYV4Z 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, 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, 12 Jun 2025 00:21:47 -0400 Jon Maloy wrote: > When communicating with remote hosts on the local network, some guest > applications want to see the real mac address of that host instead > of passt/pasta's own tap address. The flowside structure is a convenient > location for storing that address, so we do that in this commit. >=20 > Note that we don=C2=B4t add usage of this address in this commit, - that > will come in later commits. >=20 > Signed-off-by: Jon Maloy > --- > flow.c | 13 ++++++++++++- > flow.h | 2 ++ > 2 files changed, 14 insertions(+), 1 deletion(-) >=20 > diff --git a/flow.c b/flow.c > index da5c813..fffc817 100644 > --- a/flow.c > +++ b/flow.c > @@ -20,6 +20,7 @@ > #include "flow.h" > #include "flow_table.h" > #include "repair.h" > +#include "netlink.h" > =20 > const char *flow_state_str[] =3D { > =09[FLOW_STATE_FREE]=09=3D "FREE", > @@ -438,7 +439,7 @@ struct flowside *flow_target(const struct ctx *c, uni= on flow *flow, > { > =09char estr[INANY_ADDRSTRLEN], fstr[INANY_ADDRSTRLEN]; > =09struct flow_common *f =3D &flow->f; > -=09const struct flowside *ini =3D &f->side[INISIDE]; > +=09struct flowside *ini =3D &f->side[INISIDE]; > =09struct flowside *tgt =3D &f->side[TGTSIDE]; > =09uint8_t tgtpif =3D PIF_NONE; > =20 > @@ -446,10 +447,16 @@ struct flowside *flow_target(const struct ctx *c, u= nion flow *flow, > =09ASSERT(f->type =3D=3D FLOW_TYPE_NONE); > =09ASSERT(f->pif[INISIDE] !=3D PIF_NONE && f->pif[TGTSIDE] =3D=3D PIF_NO= NE); > =09ASSERT(flow->f.state =3D=3D FLOW_STATE_INI); > +=09memcpy(ini->mac, c->our_tap_mac, ETH_ALEN); > +=09memcpy(tgt->mac, c->our_tap_mac, ETH_ALEN); > =20 > =09switch (f->pif[INISIDE]) { > =09case PIF_TAP: > =09=09tgtpif =3D fwd_nat_from_tap(c, proto, ini, tgt); > + > +=09=09/* If remote host on local network - insert its mac address */ > +=09=09if (!memcmp(&tgt->eaddr, &ini->oaddr, sizeof(ini->oaddr))) > +=09=09=09nl_mac_get(nl_sock, &ini->oaddr, ini->mac); > =09=09break; > =20 > =09case PIF_SPLICE: > @@ -458,6 +465,10 @@ struct flowside *flow_target(const struct ctx *c, un= ion flow *flow, > =20 > =09case PIF_HOST: > =09=09tgtpif =3D fwd_nat_from_host(c, proto, ini, tgt); > + > +=09=09/* If remote host on local network - insert its mac address */ > +=09=09if (!memcmp(&tgt->oaddr, &ini->eaddr, sizeof(ini->eaddr))) > +=09=09=09nl_mac_get(nl_sock, &tgt->oaddr, tgt->mac); > =09=09break; > =20 > =09default: > diff --git a/flow.h b/flow.h > index cac618a..916951b 100644 > --- a/flow.h > +++ b/flow.h > @@ -143,12 +143,14 @@ extern const uint8_t flow_proto[]; > * @oaddr:=09Our address (local address from passt's PoV) > * @eport:=09Endpoint port > * @oport:=09Our port > + * @mac:=09MAC address of remote endpoint > */ > struct flowside { > =09union inany_addr=09oaddr; > =09union inany_addr=09eaddr; > =09in_port_t=09=09oport; > =09in_port_t=09=09eport; > +=09unsigned char =09=09mac[6]; We'll never have two MAC addresses that are not c->our_tap_mac in a single flow, right? If that's the case, shouldn't we move this to flow_common, so that we have just one instance, reflecting our usage? > }; > =20 > /** --=20 Stefano