[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT PATCH v2 07/15] plat/tap: Get/Set MTU



The patch implements mtu get and set functions.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
 plat/drivers/tap/tap.c | 28 +++++++++++++++++++++++++---
 plat/linuxu/tap_io.c   |  2 ++
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/plat/drivers/tap/tap.c b/plat/drivers/tap/tap.c
index d5e1c42..1345475 100644
--- a/plat/drivers/tap/tap.c
+++ b/plat/drivers/tap/tap.c
@@ -327,15 +327,37 @@ static unsigned int tap_netdev_promisc_get(struct 
uk_netdev *n)
 
 static __u16 tap_netdev_mtu_get(struct uk_netdev *n)
 {
+       int rc = 0;
+       struct tap_net_dev *tdev;
+       struct uk_ifreq ifrq = {0};
+
        UK_ASSERT(n);
-       return 0;
+       tdev = to_tapnetdev(n);
+       snprintf(ifrq.ifr_name, sizeof(ifrq.ifr_name), "%s", tdev->name);
+
+       rc = tap_netif_configure(tdev->ctrl_sock, UK_SIOCGIFMTU, &ifrq);
+       if (rc < 0) {
+               uk_pr_err(DRIVER_NAME": Failed(%d) to get the mtu\n", rc);
+               return rc;
+       }
+
+       return ifrq.ifr_mtu;
 }
 
-static int tap_netdev_mtu_set(struct uk_netdev *n,  __u16 mtu __unused)
+static int tap_netdev_mtu_set(struct uk_netdev *n,  __u16 mtu)
 {
-       int rc = -EINVAL;
+       int rc = 0;
+       struct tap_net_dev *tdev;
+       struct uk_ifreq ifrq = {0};
 
        UK_ASSERT(n);
+       tdev = to_tapnetdev(n);
+       snprintf(ifrq.ifr_name, sizeof(ifrq.ifr_name), "%s", tdev->name);
+
+       ifrq.ifr_mtu = mtu;
+       rc = tap_netif_configure(tdev->ctrl_sock, UK_SIOCSIFMTU, &ifrq);
+       if (rc < 0)
+               uk_pr_err(DRIVER_NAME": Failed(%d) to set the mtu\n", rc);
 
        return rc;
 }
diff --git a/plat/linuxu/tap_io.c b/plat/linuxu/tap_io.c
index de8b3db..9a1085c 100644
--- a/plat/linuxu/tap_io.c
+++ b/plat/linuxu/tap_io.c
@@ -70,6 +70,8 @@ int tap_netif_configure(int fd, __u32 request, void *arg)
        case UK_SIOCGIFINDEX:
        case UK_SIOCGIFHWADDR:
        case UK_SIOCSIFHWADDR:
+       case UK_SIOCSIFMTU:
+       case UK_SIOCGIFMTU:
        case UK_SIOCBRADDIF:
                break;
        default:
-- 
2.7.4




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.