From: Stefan Jumarea Date: Fri, 8 Sep 2023 12:37:04 +0000 (+0300) Subject: click.cc: Probe the network devices at init time X-Git-Tag: RELEASE-0.15.0~4 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=11cc35d3a750e5901a1f053621d787b2913f9a73;p=unikraft%2Flibs%2Fclick.git click.cc: Probe the network devices at init time In the early init step, probe the network device if it was not already probed or configured. Whithout this step, the `uk_netdev_configure` call will fail, since it expects the device state to be `UK_NETDEV_UNCONFIGURED`, not `UK_NETDEV_UNPROBED`. Signed-off-by: Stefan Jumarea Reviewed-by: Razvan Deaconescu Approved-by: Razvan Deaconescu Tested-by: Unikraft CI GitHub-Closes: #7 --- diff --git a/click.cc b/click.cc index 1ab0076..f72a32e 100644 --- a/click.cc +++ b/click.cc @@ -236,11 +236,28 @@ uk_netdev_early_init(ErrorHandler *errh) { struct uk_netdev *netdev; struct uk_netdev_conf netdev_conf; + int ret; netdev_conf.nb_rx_queues = 1; netdev_conf.nb_tx_queues = 1; for (unsigned int i = 0; i < uk_netdev_count(); ++i) { netdev = uk_netdev_get(i); + + if (!netdev) + continue; + if (uk_netdev_state_get(netdev) != UK_NETDEV_UNCONFIGURED && + uk_netdev_state_get(netdev) != UK_NETDEV_UNPROBED) { + uk_pr_info("Skipping to add network device %u to lwIP: Not in unconfigured state\n", i); + continue; + } + + if (uk_netdev_state_get(netdev) == UK_NETDEV_UNPROBED) { + ret = uk_netdev_probe(netdev); + if (ret < 0) { + uk_pr_err("Failed to probe network device %u %d", i, ret); + continue; + } + } uk_pr_info("netdev %d early init\n", i); if (uk_netdev_configure(netdev, &netdev_conf) < 0) return errh->error("Failed to configure device %d\n", i);