]> xenbits.xensource.com Git - unikraft/libs/lwip.git/commitdiff
Probe network device features
authorSimon Kuenzer <simon.kuenzer@neclab.eu>
Tue, 12 Oct 2021 15:19:03 +0000 (17:19 +0200)
committerUnikraft <monkey@unikraft.io>
Mon, 28 Mar 2022 18:33:46 +0000 (18:33 +0000)
Latest lib/uknetdev updates make it necessary that new network
interfaces need to be probed for feature negotiation before the
interface can be used.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #10

init.c

diff --git a/init.c b/init.c
index 5502bd3ac0d8973e22ef0ceca4569121665d5819..584c0a545cac606b26dee2a8c8a7f25964456448 100644 (file)
--- a/init.c
+++ b/init.c
@@ -138,6 +138,7 @@ static int liblwip_init(void)
        const char  __maybe_unused *strcfg;
        uint16_t  __maybe_unused int16cfg;
        int is_first_nf;
+       int ret;
 #if LWIP_IPV4
        ip4_addr_t ip4;
        ip4_addr_t *ip4_arg;
@@ -174,12 +175,25 @@ static int liblwip_init(void)
                dev = uk_netdev_get(devid);
                if (!dev)
                        continue;
-               if (uk_netdev_state_get(dev) != UK_NETDEV_UNCONFIGURED) {
+               if (uk_netdev_state_get(dev) != UK_NETDEV_UNCONFIGURED
+                   && uk_netdev_state_get(dev) != UK_NETDEV_UNPROBED) {
                        uk_pr_info("Skipping to add network device %u to lwIP: Not in unconfigured state\n",
                                    devid);
                        continue;
                }
 
+               if (uk_netdev_state_get(dev) == UK_NETDEV_UNPROBED) {
+                       ret = uk_netdev_probe(dev);
+                       if (ret < 0) {
+                               uk_pr_err("Failed to probe features of network device %u: %d; skipping device...\n",
+                                         devid, ret);
+                               continue;
+                       }
+               }
+
+               /* Here, the device has to be in unconfigured state */
+               UK_ASSERT(uk_netdev_state_get(dev) == UK_NETDEV_UNCONFIGURED);
+
                uk_pr_info("Attach network device %u to lwIP...\n",
                           devid);