[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT/LIBLWIP PATCH v3 13/16] plat/tap: Start a tap device
The patch implements the function to start the tap device Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx> --- plat/drivers/tap/tap.c | 21 +++++++++++++++++++-- plat/linuxu/tap_io.c | 12 ++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/plat/drivers/tap/tap.c b/plat/drivers/tap/tap.c index 2667fd10..b7037b64 100644 --- a/plat/drivers/tap/tap.c +++ b/plat/drivers/tap/tap.c @@ -430,10 +430,27 @@ err_exit: static int tap_netdev_start(struct uk_netdev *n) { - int rc = -EINVAL; + int rc = 0; + struct tap_net_dev *tdev = NULL; + struct uk_ifreq ifrq = {0}; UK_ASSERT(n); - return rc; + tdev = to_tapnetdev(n); + /* Set the name of the device */ + snprintf(ifrq.ifr_name, sizeof(ifrq.ifr_name), "%s", tdev->name); + + ifrq.ifr_flags = UK_IFF_UP | UK_IFF_PROMISC; + + /* Set the status of the device */ + rc = tap_netif_configure(tdev->ctrl_sock, UK_SIOCSIFFLAGS, &ifrq); + if (rc < 0) { + uk_pr_err(DRIVER_NAME": Failed(%d) to set the flags of if: %s\n", + rc, tdev->name); + return rc; + } + tdev->promisc = 1; + + return 0; } static void tap_netdev_info_get(struct uk_netdev *dev __unused, diff --git a/plat/linuxu/tap_io.c b/plat/linuxu/tap_io.c index 4828639d..8c44281c 100644 --- a/plat/linuxu/tap_io.c +++ b/plat/linuxu/tap_io.c @@ -64,8 +64,20 @@ int tap_netif_configure(int fd, __u32 request, void *arg) { int rc; struct uk_ifreq *usr_ifr = (struct uk_ifreq *) arg; + struct uk_ifreq ifr = {0}; switch (request) { + case UK_SIOCSIFFLAGS: + snprintf(ifr.ifr_name, IFNAMSIZ, "%s", usr_ifr->ifr_name); + rc = sys_ioctl(fd, UK_SIOCGIFFLAGS, &ifr); + /* fetch current flags to leave other flags untouched */ + if (rc < 0) { + uk_pr_err("Failed to read flags %d\n", rc); + goto exit_error; + } + usr_ifr->ifr_flags |= ifr.ifr_flags; + break; + case UK_SIOCGIFFLAGS: case UK_SIOCGIFINDEX: case UK_SIOCGIFHWADDR: case UK_SIOCSIFHWADDR: -- 2.20.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |