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

[UNIKRAFT PATCH v3 2/2] lib/uknetdev: Get the ipaddr, gw_addr and subnet



The user of uknetdev can pass the ipaddr, gw_addr and subnet as a
library argument. The library argument can be retrieved from the
network stack using uk_netdev_einfo_get function. The library
arguments are retrieved only if the driver does not support the
uk_netdev_einfo_get callback.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
 lib/uknetdev/netdev.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lib/uknetdev/netdev.c b/lib/uknetdev/netdev.c
index e0ee4427..23581f50 100644
--- a/lib/uknetdev/netdev.c
+++ b/lib/uknetdev/netdev.c
@@ -239,6 +239,28 @@ void uk_netdev_info_get(struct uk_netdev *dev,
                                      dev_info->max_tx_queues);
 }
 
+static const void *_netdev_einfo_get(struct uk_netdev *dev,
+                               enum uk_netdev_einfo_type einfo)
+{
+       switch (einfo) {
+       case UK_NETDEV_IPV4_ADDR_STR:
+               if (dev->_config->ipv4_addr)
+                       uk_pr_debug("ip_addr: %s\n", dev->_config->ipv4_addr);
+               return dev->_config->ipv4_addr;
+       case UK_NETDEV_IPV4_MASK_STR:
+               if (dev->_config->ipv4_net_mask)
+                       uk_pr_debug("netmask: %s\n", 
dev->_config->ipv4_net_mask);
+               return dev->_config->ipv4_net_mask;
+       case UK_NETDEV_IPV4_GW_STR:
+               if (dev->_config->ipv4_gw_addr)
+                       uk_pr_debug("Gateway: %s\n", 
dev->_config->ipv4_gw_addr);
+               return dev->_config->ipv4_gw_addr;
+       default:
+               uk_pr_warn("Option %d not yet supported\n", einfo);
+       }
+       return NULL;
+}
+
 const void *uk_netdev_einfo_get(struct uk_netdev *dev,
                                enum uk_netdev_einfo_type einfo)
 {
@@ -247,6 +269,8 @@ const void *uk_netdev_einfo_get(struct uk_netdev *dev,
 
        if (!dev->ops->einfo_get) {
                /* driver does not provide any extra configuration */
+               if (dev->_config)
+                       return _netdev_einfo_get(dev, einfo);
                return NULL;
        }
        return dev->ops->einfo_get(dev, einfo);
-- 
2.20.1




 


Rackspace

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