From: David Marchand <david.marchand@redhat.com>
To: Kirill Rybalchenko <kirill.rybalchenko@intel.com>,
Vanshika Shukla <vanshika.shukla@nxp.com>
Cc: dev <dev@dpdk.org>
Subject: Re: [PATCH] examples/ptpclient: fix delay request message
Date: Wed, 17 Nov 2021 08:43:50 +0100 [thread overview]
Message-ID: <CAJFAV8wKbBqBfFa_=YJs_BxyVD8YapQWk0CF4hHZFtO6Rmi0Uw@mail.gmail.com> (raw)
In-Reply-To: <20211117061853.20979-1-vanshika.shukla@nxp.com>
Hello,
On Wed, Nov 17, 2021 at 7:19 AM <vanshika.shukla@nxp.com> wrote:
>
> From: Vanshika Shukla <vanshika.shukla@nxp.com>
>
> The size of delay request message sent out by the DPDK
> ptpclient application was observed to have extra length
> than expected. Due to this, bad messages were observed
> on the master side and delay response was not received.
>
> This patch fixes this bug.
We need a Fixes: line and it is likely a candidate for backport.
>
> Signed-off-by: Vanshika Shukla <vanshika.shukla@nxp.com>
> ---
> examples/ptpclient/ptpclient.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
> index 4f32ade7fb..1eb813ab01 100644
> --- a/examples/ptpclient/ptpclient.c
> +++ b/examples/ptpclient/ptpclient.c
> @@ -422,7 +422,7 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
>
> created_pkt = rte_pktmbuf_alloc(mbuf_pool);
> pkt_size = sizeof(struct rte_ether_hdr) +
> - sizeof(struct ptp_message);
> + sizeof(struct delay_req_msg);
> created_pkt->data_len = pkt_size;
> created_pkt->pkt_len = pkt_size;
This example code is in a bad shape.
Directly updating mbuf fields without caring for available data size
is a bad practice, plus there is no check on available size in
allocated buffer.
It should be like (untested):
created_pkt = rte_pktmbuf_alloc(mbuf_pool);
pkt_size = sizeof(struct rte_ether_hdr) +
- sizeof(struct ptp_message);
- created_pkt->data_len = pkt_size;
- created_pkt->pkt_len = pkt_size;
+ sizeof(struct delay_req_msg);
+ if (rte_pktmbuf_append(created_pkt, pkt_size) == NULL) {
+ rte_pktmbuf_free(created_pkt);
+ return;
+ }
+
After this, the rest of the code uses a struct ptp_msg pointer.
It should use a pointer with the right type.
Something like:
+ struct delay_req_msg *req_msg;
...
- ptp_msg = (struct ptp_message *)
- (rte_pktmbuf_mtod(created_pkt, char *) +
- sizeof(struct rte_ether_hdr));
+ req_msg = rte_pktmbuf_mtod_offset(created_pkt,
+ struct delay_req_msg *, sizeof(struct rte_ether_hdr));
etc...
--
David Marchand
next prev parent reply other threads:[~2021-11-17 7:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-17 6:18 vanshika.shukla
2021-11-17 7:43 ` David Marchand [this message]
2021-11-22 7:31 ` [PATCH v2] " vanshika.shukla
2021-11-23 17:39 ` Nipun Gupta
2021-11-24 13:48 ` David Marchand
2021-11-24 13:52 ` 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='CAJFAV8wKbBqBfFa_=YJs_BxyVD8YapQWk0CF4hHZFtO6Rmi0Uw@mail.gmail.com' \
--to=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=kirill.rybalchenko@intel.com \
--cc=vanshika.shukla@nxp.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).