[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 06/15] plat/tap: Add tap to bridge
The patch implements the interface necessary to add a tap device to the bridge Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx> --- plat/drivers/tap/tap.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ plat/linuxu/tap_io.c | 1 + 2 files changed, 61 insertions(+) diff --git a/plat/drivers/tap/tap.c b/plat/drivers/tap/tap.c index cfee936..54b43ff 100644 --- a/plat/drivers/tap/tap.c +++ b/plat/drivers/tap/tap.c @@ -168,12 +168,65 @@ static int tap_netdev_rxq_info_get(struct uk_netdev *dev, __u16 queue_id, static int tap_netdev_txq_info_get(struct uk_netdev *dev, __u16 queue_id, struct uk_netdev_queue_info *qinfo); static int tap_device_create(struct tap_net_dev *tdev, __u32 feature_flags); +static int tap_dev_br_add(struct tap_net_dev *tdev); static int tap_mac_generate(__u8 *addr, int len, int dev_id); +static int tap_dev_index_get(struct tap_net_dev *tdev); /** * Local function definitions */ +static int tap_dev_index_get(struct tap_net_dev *tdev) +{ + int rc = 0; + struct uk_ifreq ifrq = {0}; + + snprintf(ifrq.ifr_name, sizeof(ifrq.ifr_name), "%s", + tdev->name); + + rc = tap_netif_configure(tdev->ctrl_sock, UK_SIOCGIFINDEX, &ifrq); + if (rc < 0) { + uk_pr_err(DRIVER_NAME": Failed to fetch the index\n"); + goto exit; + } + + rc = ifrq.ifr_ifindex; +exit: + return rc; + +} + +static int tap_dev_br_add(struct tap_net_dev *tdev) +{ + int rc = -EINVAL; + struct uk_ifreq ifrq = {0}; + + if (!tap_drv.bridge_ifs[tdev->tid]) + goto exit; + + /** + * Get the bridge name. + */ + snprintf(ifrq.ifr_name, sizeof(ifrq.ifr_name), "%s", + tap_drv.bridge_ifs[tdev->tid]); + + rc = tap_dev_index_get(tdev); + if (rc < 0) + return rc; + + ifrq.ifr_ifindex = rc; + rc = tap_netif_configure(tdev->ctrl_sock, UK_SIOCBRADDIF, &ifrq); + if (rc < 0) { + uk_pr_err(DRIVER_NAME": Failed to add the interface %s to bridge %s\n", + tdev->name, tap_drv.bridge_ifs[tdev->tid]); + goto exit; + } + rc = 0; + +exit: + return rc; +} + static int tap_netdev_recv(struct uk_netdev *dev, struct uk_netdev_rx_queue *queue, struct uk_netbuf **pkt) @@ -401,6 +454,13 @@ static int tap_netdev_configure(struct uk_netdev *n, goto close_ctrl_sock; } + rc = tap_dev_br_add(tdev); + if (rc < 0) { + uk_pr_err(DRIVER_NAME": Failed to add the bridge interface\n"); + goto close_ctrl_sock; + } + uk_pr_info("Tap descriptor %d\n", tdev->tap_fd); + /* Initialize the tx/rx queues */ UK_TAILQ_INIT(&tdev->rxqs); tdev->rxq_cnt = 0; diff --git a/plat/linuxu/tap_io.c b/plat/linuxu/tap_io.c index 60f1fcc..e963877 100644 --- a/plat/linuxu/tap_io.c +++ b/plat/linuxu/tap_io.c @@ -85,6 +85,7 @@ int tap_netif_configure(int fd, __u32 request, void *arg) case UK_SIOCSIFMTU: case UK_SIOCSIFTXQLEN: case UK_SIOCGIFTXQLEN: + case UK_SIOCBRADDIF: break; default: rc = -EINVAL; -- 2.7.4 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |