The data_size in eth_dev_mtu_set() is calculated as:
  tp_frame_size - TPACKET2_HDRLEN

Since TPACKET2_HDRLEN is defined as:
  TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll)

it includes sizeof(struct sockaddr_ll), but the actual packet data
in the TPACKET ring starts at TPACKET_ALIGN(sizeof(struct tpacket2_hdr)).
The sockaddr_ll does not consume frame data space. This makes the
current formula 20 bytes too restrictive, matching neither the
RX queue setup nor the TX queue init path, which both correctly use:
  tp_frame_size - TPACKET2_HDRLEN + sizeof(struct sockaddr_ll)

Fix the calculation to be consistent and accept all valid MTU values.

Fixes: 8020573894a8 ("net/af_packet: fix setting MTU decrements sockaddr twice")
Cc: [email protected]

Signed-off-by: Xavier Guillaume <[email protected]>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c 
b/drivers/net/af_packet/rte_eth_af_packet.c
index c0ba3381ea..bfa68297a6 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -612,7 +612,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;
+                                TPACKET2_HDRLEN + sizeof(struct sockaddr_ll);
 
        if (mtu > data_size)
                return -EINVAL;
-- 
2.34.1

Reply via email to