From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F067CA0C41; Wed, 17 Nov 2021 08:44:05 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B726A4068C; Wed, 17 Nov 2021 08:44:05 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id B27B940040 for ; Wed, 17 Nov 2021 08:44:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637135044; 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: in-reply-to:in-reply-to:references:references; bh=1ezURpqzUZJ76rH7Tl2HHPzY1/nycZL4BtXs4Leq61w=; b=jDh2RuI6qVki3daEkAyUh5eC+Rohhn/W81XraRmhJ/hLjXbfki11B8zhoDJUaLo1hVjFnK I2zeLWEY1Mu+OU8213zUVQZ1X3qEkWCV/rXc2ihsLrZIVa+okcPD3FWNRANxU554EhoWxp ET49CcPvlAEg/vQ6JHk1+9djYPWtAXw= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-413-3l0KhlZ6Pleky7wN6vFCwA-1; Wed, 17 Nov 2021 02:44:02 -0500 X-MC-Unique: 3l0KhlZ6Pleky7wN6vFCwA-1 Received: by mail-lf1-f70.google.com with SMTP id x7-20020a056512130700b003fd1a7424a8so925535lfu.5 for ; Tue, 16 Nov 2021 23:44:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1ezURpqzUZJ76rH7Tl2HHPzY1/nycZL4BtXs4Leq61w=; b=TxZH+f1CIaIF/rRY19N3c8W6ZIioWgJAJVhdaNkAwpF870idRQ6bbxMJOY0NMpMfmj v0A28HWATUMPcyVadcNlnYgLFpdRlHyETwKfQrWJeh+2z2WnlWFpdRbQXa0A/I6v3esx j7tlSzrBIAembUISz/jUL6eCPbDLtxtngXTik4ovf1zi7vwB0bzF93coDq0ceut/jAVv 7flHBPYKACY+yWhTCvFbTr2nh6W1A4fvx/dIDHpwmq4UT3DxU0xc7wOJKnjL7Z9UMS5W Mtpsb7/yIrhtNepq+Z+ObN60guOaLamMFqXffPtf2LXQT+b8qE+N7SIjdb3yx+GqyEvC zlyA== X-Gm-Message-State: AOAM532rmeHA+qNyZrEG7EieLJpJBudVqAtXzmqIjw42GvaRtTtllzu3 /4+r7y2UFj2+OtJ5bFIf/tRGO/R4CGYtGXb8dDKSUiz//dZg0lfJ/zVmbRWwKSWtDHv/bMDe1kW 9zWJTI9BCoUC7SpdL9kQ= X-Received: by 2002:a2e:83c6:: with SMTP id s6mr5869130ljh.477.1637135041433; Tue, 16 Nov 2021 23:44:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJybsgfI9mR7/DaQacI2fDLey2aCzXUJ7HnqdGoGTqSmNV4zcmIKedtWlQpO4mAB0QGZMVEnaZ76kLhqgRIV1R8= X-Received: by 2002:a2e:83c6:: with SMTP id s6mr5869111ljh.477.1637135041238; Tue, 16 Nov 2021 23:44:01 -0800 (PST) MIME-Version: 1.0 References: <20211117061853.20979-1-vanshika.shukla@nxp.com> In-Reply-To: <20211117061853.20979-1-vanshika.shukla@nxp.com> From: David Marchand Date: Wed, 17 Nov 2021 08:43:50 +0100 Message-ID: Subject: Re: [PATCH] examples/ptpclient: fix delay request message To: Kirill Rybalchenko , Vanshika Shukla Cc: dev Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hello, On Wed, Nov 17, 2021 at 7:19 AM wrote: > > From: Vanshika Shukla > > 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 > --- > 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