From: "Lam, Tiago" <tiago.lam@intel.com>
To: Kevin Traynor <ktraynor@redhat.com>, dev@dpdk.org
Cc: ferruh.yigit@intel.com, linville@tuxdriver.com
Subject: Re: [dpdk-dev] [PATCH v2 1/3] net/af_packet: set_mtu() decrements sockaddr twice
Date: Tue, 20 Nov 2018 10:45:37 +0000 [thread overview]
Message-ID: <99baa754-7176-b73e-403c-abd3762e698a@intel.com> (raw)
In-Reply-To: <4419c3e1-d94c-8cde-cf55-0e54a255b8c4@redhat.com>
On 20/11/2018 10:29, Kevin Traynor wrote:
> On 11/20/2018 10:26 AM, Tiago Lam wrote:
>> When setting the MTU, eth_dev_mtu_set() is called to validate the
>> provided MTU. As part of that, it calculates the useful area to store
>> data and compares it against the MTU, to guarantee that there's enough
>> space to store the data. It calculates that as:
>> "tp_frame_size - TPACKET2_HDRLEN - sizeof(struct sockaddr_ll)"
>>
>> However, the TPACKET2_HDRLEN macro already increaments sizeof(struct
>> sockaddr_ll) internally, meaning the useuful area of data above will
>> have sizeof(struct sockaddr_ll) decremented twice.
>>
>> Instead, the useful area of data should be calculated as:
>> "tp_frame_size - TPACKET2_HDRLEN"
>>
>> This makes sure that there's enough useful area to fit the provided MTU
>> after excluding tpacket2_hdr and sockaddr_ll.
>>
>> Fixes: cc68ac4 ("net/af_packet: support MTU change")
>>
>
> It should be for stable also?
Indeed, thanks for pointing that out. I've missed the Cc there, but it
should be backported - I can track it down to 17.02. I'll make sure I
add the Cc if a new iteration is needed.
Tiago.
>
>> Signed-off-by: Tiago Lam <tiago.lam@intel.com>
>> ---
>> drivers/net/af_packet/rte_eth_af_packet.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
>> index 95a98c6..264cfc0 100644
>> --- a/drivers/net/af_packet/rte_eth_af_packet.c
>> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
>> @@ -433,8 +433,7 @@ eth_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
>> int ret;
>> int s;
>> unsigned int data_size = internals->req.tp_frame_size -
>> - TPACKET2_HDRLEN -
>> - sizeof(struct sockaddr_ll);
>> + TPACKET2_HDRLEN;
>>
>> if (mtu > data_size)
>> return -EINVAL;
>>
>
next prev parent reply other threads:[~2018-11-20 10:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-20 9:54 [dpdk-dev] [PATCH " Tiago Lam
2018-11-20 9:54 ` [dpdk-dev] [PATCH 2/3] net/af_packet: Move parse and validation of iface Tiago Lam
2018-11-20 9:54 ` [dpdk-dev] [PATCH 3/3] net/af_packet: Get 'framesz' from the iface's MTU Tiago Lam
2018-11-20 10:26 ` [dpdk-dev] [PATCH v2 1/3] net/af_packet: set_mtu() decrements sockaddr twice Tiago Lam
2018-11-20 10:26 ` [dpdk-dev] [PATCH v2 2/3] net/af_packet: move parse and validation of iface Tiago Lam
2018-11-27 17:42 ` Ferruh Yigit
2018-11-20 10:26 ` [dpdk-dev] [PATCH v2 3/3] net/af_packet: get 'framesz' from the iface's MTU Tiago Lam
2018-11-27 17:43 ` Ferruh Yigit
2018-11-27 17:45 ` Ferruh Yigit
2018-11-28 13:12 ` Lam, Tiago
2018-11-28 13:33 ` Ferruh Yigit
2018-12-17 9:21 ` Lam, Tiago
2018-12-21 12:21 ` Ferruh Yigit
2019-02-18 18:01 ` Yigit, Ferruh
2019-03-19 13:16 ` Yigit, Ferruh
2019-03-19 13:16 ` Yigit, Ferruh
2018-11-20 10:29 ` [dpdk-dev] [PATCH v2 1/3] net/af_packet: set_mtu() decrements sockaddr twice Kevin Traynor
2018-11-20 10:45 ` Lam, Tiago [this message]
2018-11-27 17:42 ` Ferruh Yigit
2018-12-21 12:29 ` Ferruh Yigit
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=99baa754-7176-b73e-403c-abd3762e698a@intel.com \
--to=tiago.lam@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=ktraynor@redhat.com \
--cc=linville@tuxdriver.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).