DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: David Marchand <david.marchand@redhat.com>,
	dev@dpdk.org, roy.fan.zhang@intel.com,
	Chenbo Xia <chenbo.xia@intel.com>,
	Christophe Fontaine <cfontain@redhat.com>
Subject: Re: [PATCH v2] vhost: fix external message handlers
Date: Tue, 8 Mar 2022 11:44:37 +0100	[thread overview]
Message-ID: <0272a7ca-aac5-b029-061a-3910d6f49548@redhat.com> (raw)
In-Reply-To: <20220308094422.25685-1-david.marchand@redhat.com>



On 3/8/22 10:44, David Marchand wrote:
> Following a rework, external message handlers were receiving a pointer
> to a vhost_user message (as stated in the API), but lost the ability to
> interact with fds attached to the message.
> Restore the original layout and put a build check and reminders.
> 
> Bugzilla ID: 953
> Fixes: 5e0099dc709e ("vhost: remove payload size limitation")
> 
> Reported-by: Fan Zhang <roy.fan.zhang@intel.com>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> Changes since v1:
> - fixed build with clang,
> 
> ---
>   lib/vhost/vhost_user.c | 8 ++++----
>   lib/vhost/vhost_user.h | 7 +++++--
>   2 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 723c6890c3..589b950458 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -3023,8 +3023,8 @@ vhost_user_msg_handler(int vid, int fd)
>   
>   	handled = false;
>   	if (dev->extern_ops.pre_msg_handle) {
> -		ret = (*dev->extern_ops.pre_msg_handle)(dev->vid,
> -				(void *)&ctx.msg);
> +		RTE_BUILD_BUG_ON(offsetof(struct vhu_msg_context, msg) != 0);
> +		ret = (*dev->extern_ops.pre_msg_handle)(dev->vid, &ctx);
>   		switch (ret) {
>   		case RTE_VHOST_MSG_RESULT_REPLY:
>   			send_vhost_reply(dev, fd, &ctx);
> @@ -3069,8 +3069,8 @@ vhost_user_msg_handler(int vid, int fd)
>   skip_to_post_handle:
>   	if (ret != RTE_VHOST_MSG_RESULT_ERR &&
>   			dev->extern_ops.post_msg_handle) {
> -		ret = (*dev->extern_ops.post_msg_handle)(dev->vid,
> -				(void *)&ctx.msg);
> +		RTE_BUILD_BUG_ON(offsetof(struct vhu_msg_context, msg) != 0);
> +		ret = (*dev->extern_ops.post_msg_handle)(dev->vid, &ctx);
>   		switch (ret) {
>   		case RTE_VHOST_MSG_RESULT_REPLY:
>   			send_vhost_reply(dev, fd, &ctx);
> diff --git a/lib/vhost/vhost_user.h b/lib/vhost/vhost_user.h
> index be53669f3b..c946cc2ef4 100644
> --- a/lib/vhost/vhost_user.h
> +++ b/lib/vhost/vhost_user.h
> @@ -152,10 +152,13 @@ typedef struct VhostUserMsg {
>   	/* Nothing should be added after the payload */
>   } __rte_packed VhostUserMsg;
>   
> -struct vhu_msg_context {
> +/* Note: this structure and VhostUserMsg can't be changed carelessly as
> + * external message handlers rely on them.
> + */
> +struct __rte_packed vhu_msg_context {
> +	VhostUserMsg msg;
>   	int fds[VHOST_MEMORY_MAX_NREGIONS];
>   	int fd_num;
> -	VhostUserMsg msg;
>   };
>   
>   #define VHOST_USER_HDR_SIZE offsetof(VhostUserMsg, payload.u64)

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime


  reply	other threads:[~2022-03-08 10:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 18:11 [PATCH] " David Marchand
2022-03-08  8:34 ` Maxime Coquelin
2022-03-08  8:37   ` David Marchand
2022-03-08  8:39     ` Maxime Coquelin
2022-03-08  9:44 ` [PATCH v2] " David Marchand
2022-03-08 10:44   ` Maxime Coquelin [this message]
2022-03-08 14:04     ` Poczatek, Jakub
2022-03-08 14:47   ` Christophe Fontaine
2022-03-08 15:06   ` David Marchand

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=0272a7ca-aac5-b029-061a-3910d6f49548@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=cfontain@redhat.com \
    --cc=chenbo.xia@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=roy.fan.zhang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).