summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Lam <tiago.lam@intel.com>2018-11-20 10:26:29 +0000
committerFerruh Yigit <ferruh.yigit@intel.com>2018-12-21 16:22:41 +0100
commit8020573894a8504da3146af1854c8aca762539fd (patch)
tree2619f239387a773c728cedeb95d71cad343916e6
parentbcac5aa207f896c46963b2ac0a06bc09b1e912a5 (diff)
downloaddpdk-8020573894a8504da3146af1854c8aca762539fd.zip
dpdk-8020573894a8504da3146af1854c8aca762539fd.tar.gz
dpdk-8020573894a8504da3146af1854c8aca762539fd.tar.xz
net/af_packet: fix setting MTU decrements sockaddr twice
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 increments 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: cc68ac4847bc ("net/af_packet: support MTU change") Cc: stable@dpdk.org Signed-off-by: Tiago Lam <tiago.lam@intel.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
-rw-r--r--drivers/net/af_packet/rte_eth_af_packet.c3
1 files changed, 1 insertions, 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;