From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Cindy Lu <lulu@redhat.com>
Cc: mst@redhat.com, jasowang@redhat.com, zhangckid@gmail.com,
lizhijian@fujitsu.com, jmarcin@redhat.com, qemu-devel@nongnu.org
Subject: Re: [RFC v4 3/5] io/channel-socket: tolerate AF_PACKET getpeername
Date: Wed, 8 Apr 2026 13:00:21 +0100 [thread overview]
Message-ID: <adZDVfElLkzTaBM_@redhat.com> (raw)
In-Reply-To: <20260407050818.2249570-4-lulu@redhat.com>
On Tue, Apr 07, 2026 at 01:05:50PM +0800, Cindy Lu wrote:
> When -chardev socket,fd=... is handed an AF_PACKET socket,
> getpeername() can fail with EOPNOTSUPP instead of ENOTCONN because
> packet sockets are not connection-oriented. qio_channel_socket_set_fd()
> currently treats that as fatal and refuses to wrap the fd, even though
> getsockname() and the local address are still valid.
>
> Treat EOPNOTSUPP the same way as ENOTCONN and leave remoteAddr empty.
> That keeps existing stream-socket behavior unchanged while allowing
> AF_PACKET fds to be adopted by QIOChannelSocket.
>
> Signed-off-by: Cindy Lu <lulu@redhat.com>
> ---
> io/channel-socket.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/io/channel-socket.c b/io/channel-socket.c
> index 3053b35ad8..2ed26aefa3 100644
> --- a/io/channel-socket.c
> +++ b/io/channel-socket.c
> @@ -115,7 +115,11 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc,
>
> if (getpeername(fd, (struct sockaddr *)&sioc->remoteAddr,
> &sioc->remoteAddrLen) < 0) {
> - if (errno == ENOTCONN) {
> + if (errno == ENOTCONN
> +#ifdef EOPNOTSUPP
> + || errno == EOPNOTSUPP
> +#endif
Why conditionalize it ? We use this unconditionally throughout
QEMU code AFAICS, even on Windows.
> + ) {
> memset(&sioc->remoteAddr, 0, sizeof(sioc->remoteAddr));
> sioc->remoteAddrLen = sizeof(sioc->remoteAddr);
> } else {
> --
> 2.52.0
>
>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
next prev parent reply other threads:[~2026-04-08 19:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 5:05 [RFC v4 0/5] net/filter: Add AF_PACKET support for vhost-net Cindy Lu
2026-04-07 5:05 ` [RFC v4 1/5] net/filter: allow filters on vhost netdevs Cindy Lu
2026-04-07 5:05 ` [RFC v4 2/5] chardev/socket: add AF_PACKET initialization Cindy Lu
2026-04-07 5:05 ` [RFC v4 3/5] io/channel-socket: tolerate AF_PACKET getpeername Cindy Lu
2026-04-08 12:00 ` Daniel P. Berrangé [this message]
2026-04-07 5:05 ` [RFC v4 4/5] chardev/socket: add AF_PACKET inject path Cindy Lu
2026-04-08 12:07 ` Daniel P. Berrangé
2026-04-07 5:05 ` [RFC v4 5/5] chardev/socket: add AF_PACKET capture path Cindy Lu
2026-04-08 12:13 ` Daniel P. Berrangé
2026-04-08 12:16 ` [RFC v4 0/5] net/filter: Add AF_PACKET support for vhost-net Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adZDVfElLkzTaBM_@redhat.com \
--to=berrange@redhat.com \
--cc=jasowang@redhat.com \
--cc=jmarcin@redhat.com \
--cc=lizhijian@fujitsu.com \
--cc=lulu@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhangckid@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.