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

[Minios-devel] [UNIKRAFT/LWIP PATCH 1/3] Try to get IP address from device


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Mon, 1 Apr 2019 16:41:29 +0300
  • Cc: felipe.huici@xxxxxxxxx, Florian.Schmidt@xxxxxxxxx, simon.kuenzer@xxxxxxxxx, yuri.volchkov@xxxxxxxxx, sharan.santhanam@xxxxxxxxx
  • Delivery-date: Mon, 01 Apr 2019 13:41:47 +0000
  • Ironport-phdr: 9a23:NFawthaCwjaaeO8eGJ8FOET/LSx+4OfEezUN459isYplN5qZpsy9ZR7h7PlgxGXEQZ/co6odzbaP6+axBSdevd6oizMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpTEdFQ/iOgVrO+/7BpDdj9it1+C15pbffxhEiCCybL9vMBm6twHcu8YZjYZjJas61wfErGZPd+lK321jOEidnwz75se+/Z5j9zpftvc8/MNeUqv0Yro1Q6VAADspL2466svrtQLeTQSU/XsTTn8WkhtTDAfb6hzxQ4r8vTH7tup53ymaINH2QLUpUjms86tnVBnlgzoBOjUk8m/Yl9Zwgbpbrhy/uhJxzY3aboaXO/pwZa7RYc8WSHBdUstLSyBNHoWxZJYPAeobOuZYqpHwqkUJrRulGQmsBeXvwSJOiH/rxa06zvkqHAba0wwnBNIOrHXUrNPvOKcWTOC11LTIwC7fYPNNwzv98JXIfQs7rfGWWrJ9aMzcwlQsGQPdllictIPoMy6P2ukOs2WX9fRsWfythmI9pQx9uiWjy8gxhoXThY8YykrI+Tt3zYs7P9G0VUF2bcCiHZBNrS+VLZF2TdknQ2xwvSY6zaAJtoCjcSgRzZQn2wbfa/uac4iU+h7jVPieITN/hH99ZrK/ggy98UmkyuHmSsa0y0xGrjJYktbXrHwNzRvT5tCGSvt74EihxS6C2x3c5+1ZO0w5lqrWJ4Q/zrIulJcfq0rOEjfzmErsja+Wcksk+vKv6+TierjpupicN5RoigH/NKQigMi/AfkgMggTRGWU5f+82Kf7/U3kW7pGlOc2kq7BvJDAOcsbvrK5AxNS0os77ha/DjGm0NUfnXkcNV5KZQyIj5b3NFHKO/34Cfa/g0+wkDdw3fzHMaPuApPXInjEirfhcq5361RAxwor0dBf+5VUB6kBLvL3XU/xrt3YAQU/MwCu3ujoFNV91oYfWW2SHq+UK6XSvkGU6eIrOeaDf5UZtyjgK/I9/f7hkWc5mUMBfamuxZYXZm63HvBnI0WBf3XgmNcBEXoLvgUiTeznk1uCXiBPaHa2Ra0z/Ss3B5y7DY3bXICinKSB3DunHp1Rfm1GEVCMHm3yd4qeXfcAcjmSLdVnkjwYVbiuUYkh2gurtALhzbpoMPbb+ikCup34ztR6+fDTnwko9TNoF8Sdz32NT2Zsk2MTRj822ad/oUpnxleAzKh3nfpYFN1N6PNTSQo6M4DTwPB+C9/oQQ3NZMmGSEu+SNW8HT4xVs4xw8MJY0tlG9SikwrD3yuwD78LkLyLAIA78qLf33j2OcZw0HDG27c9gFkiWMRALneqibBi91ubO4mclkSflqGxMKgRwiPJ3GOC1naV+lFVVkh3S6qWc2oYYx79qs/l50WKa6K2FPxzOQxa1c+EbK9XcsDBhk4AXOrpfs7ZNTHi01ysDAqFk+vfJLHhfH8QiX3Q
  • Ironport-sdr: YaRN9H0ZV4SML+mrEAwRcVVzWMv0eqO01LsU03hrq/0gFn03KKWc97u4jt1Ii+YMUuw0OHT2BX pmnoGyrad7BQ==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

IP addresses for netfront devices on Xen may be configured using
Xenstore. Therefore we should first try to get IP address from device
before taking it from elsewhere.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 init.c | 47 +++++++++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/init.c b/init.c
index a5854b8..58fb173 100644
--- a/init.c
+++ b/init.c
@@ -38,11 +38,13 @@
 #include "lwip/tcpip.h"
 #include "lwip/init.h"
 #include "lwip/dhcp.h"
+#include "lwip/inet.h"
 #if CONFIG_LWIP_NOTHREADS
 #include "lwip/timeouts.h"
 #else /* CONFIG_LWIP_NOTHREADS */
 #include <uk/semaphore.h>
 #endif /* CONFIG_LWIP_NOTHREADS */
+#include <uk/netdev_core.h>
 #include "netif/uknetdev.h"
 
 #if LWIP_NETIF_EXT_STATUS_CALLBACK && CONFIG_LWIP_NETIF_STATUS_PRINT
@@ -138,11 +140,11 @@ int liblwip_init(void)
        uint16_t  __maybe_unused int16cfg;
        int is_first_nf;
 #if LWIP_IPV4
-       ip4_addr_t __maybe_unused ip4;
+       ip4_addr_t ip4;
        ip4_addr_t *ip4_arg;
-       ip4_addr_t __maybe_unused mask4;
+       ip4_addr_t mask4;
        ip4_addr_t *mask4_arg;
-       ip4_addr_t __maybe_unused gw4;
+       ip4_addr_t gw4;
        ip4_addr_t *gw4_arg;
 #endif /* LWIP_IPV4 */
 #endif /* CONFIG_LWIP_UKNETDEV && CONFIG_LWIP_AUTOIFACE */
@@ -186,23 +188,28 @@ int liblwip_init(void)
                mask4_arg = NULL;
                gw4_arg   = NULL;
 
-               /*
-                * TODO: Try to get device configuration from
-                * netdev's econf interface:
-                *
-                * UK_NETDEV_IPV4_ADDR_NINT16;
-                * UK_NETDEV_IPV4_ADDR_STR;
-                * UK_NETDEV_IPV4_MASK_NINT16;
-                * UK_NETDEV_IPV4_MASK_STR;
-                * UK_NETDEV_IPV4_GW_NINT16;
-                * UK_NETDEV_IPV4_GW_STR;
-                *
-                * When successfully done, set
-                *  ip_arg = &ip;
-                *  mask_arg = &mask;
-                *  gw_arg = &gw;
-                */
-
+               strcfg = uk_netdev_einfo_get(dev, UK_NETDEV_IPV4_ADDR_STR);
+               if (!strcfg)
+                       goto no_conf;
+               if (ip4addr_aton(strcfg, &ip4) != 1)
+                       goto no_conf;
+
+               strcfg = uk_netdev_einfo_get(dev, UK_NETDEV_IPV4_MASK_STR);
+               if (!strcfg)
+                       goto no_conf;
+               if (ip4addr_aton(strcfg, &mask4) != 1)
+                       goto no_conf;
+
+               strcfg = uk_netdev_einfo_get(dev, UK_NETDEV_IPV4_GW_STR);
+               if (!strcfg)
+                       goto no_conf;
+               if (ip4addr_aton(strcfg, &gw4) != 1)
+                       goto no_conf;
+
+               ip4_arg = &ip4;
+               mask4_arg = &mask4;
+               gw4_arg = &gw4;
+no_conf:
                nf = uknetdev_addif(dev, ip4_arg, mask4_arg, gw4_arg);
 #else /* LWIP_IPV4 */
                /*
-- 
2.11.0


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

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