[dpdk-dev] [PATCH 4/4] net/tap: set MTU on the remote

Pascal Mazon pascal.mazon at 6wind.com
Fri Mar 3 13:27:41 CET 2017


Signed-off-by: Pascal Mazon <pascal.mazon at 6wind.com>
---
 drivers/net/tap/rte_eth_tap.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 98b466aba223..141fc7944a5f 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -823,9 +823,8 @@ tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused,
 }
 
 static int
-tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+tap_netdev_mtu_set(const char *iface, uint16_t mtu)
 {
-	struct pmd_internals *pmd = dev->data->dev_private;
 	struct ifreq ifr;
 	int err, s;
 
@@ -833,15 +832,15 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 	if (s < 0) {
 		RTE_LOG(ERR, PMD,
 			"Unable to get a socket for %s to set flags: %s\n",
-			pmd->name, strerror(errno));
+			iface, strerror(errno));
 		return -1;
 	}
 	memset(&ifr, 0, sizeof(ifr));
-	strncpy(ifr.ifr_name, pmd->name, IFNAMSIZ);
+	strncpy(ifr.ifr_name, iface, IFNAMSIZ);
 	err = ioctl(s, SIOCGIFMTU, &ifr);
 	if (err < 0) {
 		RTE_LOG(WARNING, PMD, "Unable to get %s device MTU: %s\n",
-			pmd->name, strerror(errno));
+			iface, strerror(errno));
 		close(s);
 		return -1;
 	}
@@ -849,11 +848,29 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 	err = ioctl(s, SIOCSIFMTU, &ifr);
 	if (err < 0) {
 		RTE_LOG(WARNING, PMD, "Unable to set %s mtu %d: %s\n",
-			pmd->name, mtu, strerror(errno));
+			iface, mtu, strerror(errno));
 		close(s);
 		return -1;
 	}
 	close(s);
+	return 0;
+}
+
+static int
+tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct pmd_internals *pmd = dev->data->dev_private;
+	int err;
+
+	/* First try to set mtu on the remote */
+	if (pmd->remote_if_index) {
+		err = tap_netdev_mtu_set(pmd->remote_iface, mtu);
+		if (err < 0)
+			return err;
+	}
+	err = tap_netdev_mtu_set(pmd->name, mtu);
+	if (err < 0)
+		return err;
 	dev->data->mtu = mtu;
 	return 0;
 }
-- 
2.8.0.rc0



More information about the dev mailing list