From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] net: ifup: check for ctrl+c during ifup
Date: Wed, 26 Jul 2023 12:08:11 +0200 [thread overview]
Message-ID: <20230726100811.GI18491@pengutronix.de> (raw)
In-Reply-To: <20230721110744.3699054-1-a.fatoum@pengutronix.de>
On Fri, Jul 21, 2023 at 01:07:43PM +0200, Ahmad Fatoum wrote:
> When global.net.server is set, barebox will attempt to bring up all
> interfaces on ifup -a1 to see which interface can resolve it.
>
> That can take a while and there's no way to abort that, so stick in a
> ctrlc(), so user can change their mind (and e.g. remove
> global.net.server, so ifup -a1 takes first interface that has link up).
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> net/ifup.c | 24 ++++++++++++++++--------
> 1 file changed, 16 insertions(+), 8 deletions(-)
>
Applied, thanks
Sascha
> diff --git a/net/ifup.c b/net/ifup.c
> index 64298b44ebf3..993d2a115fda 100644
> --- a/net/ifup.c
> +++ b/net/ifup.c
> @@ -276,7 +276,7 @@ static bool ifup_edev_need_conf(struct eth_device *edev)
> edev->global_mode != ETH_MODE_DISABLED;
> }
>
> -static void __ifup_all_parallel(unsigned flags)
> +static int __ifup_all_parallel(unsigned flags)
> {
> struct eth_device *edev;
> unsigned netdev_count = 0;
> @@ -292,6 +292,9 @@ static void __ifup_all_parallel(unsigned flags)
> start = get_time_ns();
> while (netdev_count && !is_timeout(start, PHY_AN_TIMEOUT * SECOND)) {
> for_each_netdev(edev) {
> + if (ctrlc())
> + return -EINTR;
> +
> if (!ifup_edev_need_conf(edev))
> continue;
>
> @@ -306,21 +309,28 @@ static void __ifup_all_parallel(unsigned flags)
> netdev_count--;
>
> if ((flags & IFUP_FLAG_UNTIL_NET_SERVER) && net_get_server())
> - return;
> + return 0;
> }
> }
> +
> + return 0;
> }
>
> -static void __ifup_all_sequence(unsigned flags)
> +static int __ifup_all_sequence(unsigned flags)
> {
> struct eth_device *edev;
>
> for_each_netdev(edev) {
> + if (ctrlc())
> + return -EINTR;
> +
> ifup_edev(edev, flags);
>
> if ((flags & IFUP_FLAG_UNTIL_NET_SERVER) && net_get_server())
> - return;
> + return 0;
> }
> +
> + return 0;
> }
>
> int ifup_all(unsigned flags)
> @@ -358,11 +368,9 @@ int ifup_all(unsigned flags)
> flags &= ~IFUP_FLAG_UNTIL_NET_SERVER;
>
> if (flags & IFUP_FLAG_PARALLEL)
> - __ifup_all_parallel(flags);
> + return __ifup_all_parallel(flags);
> else
> - __ifup_all_sequence(flags);
> -
> - return 0;
> + return __ifup_all_sequence(flags);
> }
>
> void ifdown_all(void)
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2023-07-26 10:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-21 11:07 Ahmad Fatoum
2023-07-21 11:07 ` [PATCH 2/2] net: ifup: don't redo ifup -a1 if we have a gateway Ahmad Fatoum
2023-07-26 10:08 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230726100811.GI18491@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox