[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT/LIBLWIP PATCH v3 07/16] plat/tap: Add tap to the bridge
The patch implements support to add the tap device to a user provided bridge. Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx> --- plat/drivers/tap/tap.c | 60 ++++++++++++++++++++++++++++++++++++++++++ plat/linuxu/tap_io.c | 2 ++ 2 files changed, 62 insertions(+) diff --git a/plat/drivers/tap/tap.c b/plat/drivers/tap/tap.c index 5e510759..6b059943 100644 --- a/plat/drivers/tap/tap.c +++ b/plat/drivers/tap/tap.c @@ -174,11 +174,64 @@ 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_mac_generate(__u8 *addr, __u8 dev_id); +static int tap_dev_br_add(struct tap_net_dev *tdev); +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) @@ -409,6 +462,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(%d) to add the bridge interface\n", + rc); + goto close_ctrl_sock; + } + /* 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 24094f2b..fe1f52a6 100644 --- a/plat/linuxu/tap_io.c +++ b/plat/linuxu/tap_io.c @@ -66,8 +66,10 @@ int tap_netif_configure(int fd, __u32 request, void *arg) struct uk_ifreq *usr_ifr = (struct uk_ifreq *) arg; switch (request) { + case UK_SIOCGIFINDEX: case UK_SIOCGIFHWADDR: case UK_SIOCSIFHWADDR: + case UK_SIOCBRADDIF: break; default: rc = -EINVAL; -- 2.20.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |