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=Ph3Cv6N0; 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 5AA9F5A0008 for ; Mon, 07 Apr 2025 23:49:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744062564; 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=h/YMmc0wxosM/0BVKnyD3QHw0W4pxgUEcuwrr6bE1/Q=; b=Ph3Cv6N09uG/XNulXObCoq1/fshjA9dfGla1xEFmT3fWxX6yJvJQU3WQna3YwjVj5cRO/d nCNbf8I8lwDbEQXZOEBnmwYLIjbBFkGow7QT4GWqgz+IFw+O7BWWsfMhZZc7HpbRau71xa lTdwlERE/F36FG4tVlnkA6/QUlRSzbo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-422-HyQc3ly5M-asquYcwW68eQ-1; Mon, 07 Apr 2025 17:49:22 -0400 X-MC-Unique: HyQc3ly5M-asquYcwW68eQ-1 X-Mimecast-MFC-AGG-ID: HyQc3ly5M-asquYcwW68eQ_1744062561 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-39135d31ca4so2588321f8f.1 for ; Mon, 07 Apr 2025 14:49:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744062561; x=1744667361; 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=h/YMmc0wxosM/0BVKnyD3QHw0W4pxgUEcuwrr6bE1/Q=; b=WgUehsKu3voNXXw4HQSrEi3pYCnPPlWvdtMMfkqBoCGZ8glSNBRVq1hbhGQ+1vSak/ Vbm89NsMZVT3DgIVN0qmVqqa24YGcVakE4yQHjSRCNHdk2VsmyAGTSR2Zq/XUnUfgR/x L4UheA/OS2h/X4lqoPUSeN38Tsc2kQXsMJOC3upJqSZrxMrx0Rw5ovWVj9l3ypM+vhUI d/kTKzM4+jd4RmXnIlXATgVNLcwH7Z4kqPJFwOyI8DxyQzs71ysZdKpn+N9OG8DJqloo 3VSVlWe0ZaihvoouGcn/sUl46f1cRdcTfwEsiYwh27hqcS4AfPp/9ZeYQSPDwwCz43i3 i4hA== X-Gm-Message-State: AOJu0Yyerq2SCnvJdvSP0TESjwmrc1Npx7O9CqSyxrmTXa5s2wN7I0De IAt2WeW4HNOpHDPS/4gVntzNYTlI4CFkouiQ+MF7lrSCXLWrH/ZrTTHSre2xu8L4I1I7A2JJSap sC0sC8AUvXLVA3nHa6zgO1hgBVqZomgU0fjRrgUriP5AM6R3zjvKI3G2R0A== X-Gm-Gg: ASbGncu6eqb6X+dTE4IfOfRVd4U9qv7sF51QizfvgUqLM+Onuj3cZDnjwEFX/AG+SoB mzsn2x4desSBGxQwY8oHYzbI2BopjkQWXOZu4u29kyK6qgFIp38+CQYyEVArLAdLenEUlfsPIhe JWZ/HAE564BEmOE+v9mp9nV6I5LKmmGM82eoSO1NVJ817CESjSNRIEZwIZx5YZ83EIIE6tpCZvs JapLznDkdOGnHkpUydM/HCvNShu0T85npIRNjMWPhasXlX9PQ2c7p6OFJTJ2/mTWAuA/QRDXjse Zm414nJif72GVC8R9ktNWnYQzzzZvLi38l9+1iSoArrw X-Received: by 2002:a05:6000:1864:b0:39a:c9ae:a198 with SMTP id ffacd0b85a97d-39d820a3e29mr876428f8f.1.1744062561360; Mon, 07 Apr 2025 14:49:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGHQxXhXVcq/BkKDtVLkchI5c4HSfYujDGl4GIo5us6QfOLaqVd+4L4N76GcFmT+kPCFMjtQ== X-Received: by 2002:a05:6000:1864:b0:39a:c9ae:a198 with SMTP id ffacd0b85a97d-39d820a3e29mr876418f8f.1.1744062561018; Mon, 07 Apr 2025 14:49:21 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c301a9bcfsm13430718f8f.33.2025.04.07.14.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 14:49:20 -0700 (PDT) Date: Mon, 7 Apr 2025 23:49:18 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 03/12] udp: Polish udp_vu_sock_info() and remove from vu specific code Message-ID: <20250407234918.1b53503e@elisabeth> In-Reply-To: <20250404101542.3729316-4-david@gibson.dropbear.id.au> References: <20250404101542.3729316-1-david@gibson.dropbear.id.au> <20250404101542.3729316-4-david@gibson.dropbear.id.au> 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: ma8Sh2oHW90SfgM9rZSBPg6zAuDGY1Nmq6_Wf_is0Bc_1744062561 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: BVUCJFOUDMCGVL374DVN7TUXS655U3R2 X-Message-ID-Hash: BVUCJFOUDMCGVL374DVN7TUXS655U3R2 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 Fri, 4 Apr 2025 21:15:33 +1100 David Gibson wrote: > udp_vu_sock_info() uses MSG_PEEK to look ahead at the next datagram to be > received and gets its source address. Currently we only use it in the > vhost-user path, but there's nothing inherently vhost-user specific about > it. We have upcoming uses for it elsewhere so rename and move to udp.c. > > While we're there, polish its error reporting a litle. > > Signed-off-by: David Gibson > --- > udp.c | 25 +++++++++++++++++++++++++ > udp_internal.h | 1 + > udp_vu.c | 19 +------------------ > 3 files changed, 27 insertions(+), 18 deletions(-) > > diff --git a/udp.c b/udp.c > index 8125cfcb..6b72c30f 100644 > --- a/udp.c > +++ b/udp.c > @@ -629,6 +629,31 @@ static int udp_sock_errs(const struct ctx *c, union epoll_ref ref) > return n_err; > } > > +/** > + * udp_peek_addr() - Get source address for next packet > + * @s: Socket to get information from > + * @src: Socket address (output) > + * > + * Return: 0 on success, -1 otherwise > + */ > +int udp_peek_addr(int s, union sockaddr_inany *src) > +{ > + struct msghdr msg = { > + .msg_name = src, > + .msg_namelen = sizeof(*src), > + }; > + int rc; > + > + rc = recvmsg(s, &msg, MSG_PEEK | MSG_DONTWAIT); > + if (rc < 0) { > + if (errno != EAGAIN && errno != EWOULDBLOCK) > + warn_perror("Error peeking at socket address"); > + return rc; > + } > + return 0; > +} > + > + > /** Excess newline. Fixed on merge. > * udp_sock_recv() - Receive datagrams from a socket > * @c: Execution context -- Stefano