]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[cmdline] Add "--timeout" parameter to "ifconf" command
authorJoe Groocock <jgroocock@cloudflare.com>
Fri, 20 Sep 2019 12:41:29 +0000 (13:41 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 22 Jul 2020 11:44:51 +0000 (12:44 +0100)
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/hci/commands/ifmgmt_cmd.c
src/include/usr/ifmgmt.h
src/usr/autoboot.c
src/usr/ifmgmt.c

index c89af2e81ff2f3f729516314c245a2db0101050e..2e976d3fbb3791d61c52b0bd883b2f23c093531d 100644 (file)
@@ -193,6 +193,8 @@ static int ifstat_exec ( int argc, char **argv ) {
 
 /** "ifconf" options */
 struct ifconf_options {
+       /** Configuration timeout */
+       unsigned long timeout;
        /** Configurator */
        struct net_device_configurator *configurator;
 };
@@ -202,6 +204,9 @@ static struct option_descriptor ifconf_opts[] = {
        OPTION_DESC ( "configurator", 'c', required_argument,
                      struct ifconf_options, configurator,
                      parse_netdev_configurator ),
+       OPTION_DESC ( "timeout", 't', required_argument,
+                     struct ifconf_options, timeout,
+                     parse_timeout ),
 };
 
 /**
@@ -216,7 +221,8 @@ static int ifconf_payload ( struct net_device *netdev,
        int rc;
 
        /* Attempt configuration */
-       if ( ( rc = ifconf ( netdev, opts->configurator ) ) != 0 ) {
+       if ( ( rc = ifconf ( netdev, opts->configurator,
+                            opts->timeout ) ) != 0 ) {
 
                /* Close device on failure, to avoid memory exhaustion */
                netdev_close ( netdev );
index 5c386327b59350513088b7e6b291956ef3df2b08..52f88f9577a49e60d138e30115c94d085d43f41b 100644 (file)
@@ -14,7 +14,8 @@ struct net_device_configurator;
 
 extern int ifopen ( struct net_device *netdev );
 extern int ifconf ( struct net_device *netdev,
-                   struct net_device_configurator *configurator );
+                   struct net_device_configurator *configurator,
+                   unsigned long timeout );
 extern void ifclose ( struct net_device *netdev );
 extern void ifstat ( struct net_device *netdev );
 extern int iflinkwait ( struct net_device *netdev, unsigned long timeout );
index 106e0f87992ff920ff0290dd4c908fbdbedf9674..51b07e1256d70842219d2c4c62ed8a2bcc3924e3 100644 (file)
@@ -396,7 +396,7 @@ int netboot ( struct net_device *netdev ) {
        ifstat ( netdev );
 
        /* Configure device */
-       if ( ( rc = ifconf ( netdev, NULL ) ) != 0 )
+       if ( ( rc = ifconf ( netdev, NULL, 0 ) ) != 0 )
                goto err_dhcp;
        route();
 
index f367149f797772f503ddad0fa481d88c38b07669..f1172bafb3ca63e2d7ed01606d85b96bb0481afd 100644 (file)
@@ -264,10 +264,12 @@ static int ifconf_progress ( struct ifpoller *ifpoller ) {
  *
  * @v netdev           Network device
  * @v configurator     Network device configurator, or NULL to use all
+ * @v timeout          Timeout period, in ticks
  * @ret rc             Return status code
  */
 int ifconf ( struct net_device *netdev,
-            struct net_device_configurator *configurator ) {
+            struct net_device_configurator *configurator,
+            unsigned long timeout ) {
        int rc;
 
        /* Ensure device is open and link is up */
@@ -296,5 +298,5 @@ int ifconf ( struct net_device *netdev,
                 ( configurator ? configurator->name : "" ),
                 ( configurator ? "] " : "" ),
                 netdev->name, netdev->ll_protocol->ntoa ( netdev->ll_addr ) );
-       return ifpoller_wait ( netdev, configurator, 0, ifconf_progress );
+       return ifpoller_wait ( netdev, configurator, timeout, ifconf_progress );
 }