From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Daniel Glöckner" <dg@emlix.com>
Cc: Barebox List <barebox@lists.infradead.org>,
Edmund Henniges <eh@emlix.com>
Subject: Re: [PATCH 17/21] fastboot net: implement fastboot over UDP
Date: Thu, 13 Aug 2020 12:38:45 +0200 [thread overview]
Message-ID: <20200813103845.GA19745@pengutronix.de> (raw)
In-Reply-To: <70810c58-b4f1-945d-fffa-c79083a03c48@emlix.com>
Hi Daniel,
On Mon, Jun 29, 2020 at 09:50:51PM +0200, Daniel Glöckner wrote:
> Hello Sascha,
>
> Am 19.06.20 um 09:44 schrieb Sascha Hauer:
> > +struct fastboot_net {
> > + struct fastboot fastboot;
> > +
> > + struct net_connection *net_con;
> > + struct fastboot_header response_header;
> > + struct poller_struct poller;
> > + struct work_queue wq;
> > + u64 host_waits_since;
> > + u64 last_download_pkt;
> > + bool sequence_number_seen;
> > + bool active_download;
> > + bool reinit;
> > + bool send_keep_alive;
> > + enum may_send may_send;
> > +
> > + IPaddr_t host_addr;
> > + u16 host_port;
> > + u8 host_mac[ETH_ALEN];
> > + u16 sequence_number;
> > + u16 last_payload_len;
> > + uchar last_payload[FASTBOOT_MAX_CMD_LEN + sizeof(struct fastboot_header)];
>
> This is not FASTBOOT_MAX_CMD_LEN. It's the 64 that is strewn around in
> fastboot_tx_print. Adding a new constant FASTBOOT_MAX_MSG_LEN would be
> correct.
There's no check that the packet copied into last_payload has this
maximum size. I switched to storing the packet in an allocated buffer,
with this the define is not needed anymore.
> > + net_write_ip(&fbn->net_con->ip->daddr, fbn->host_addr);
> > + fbn->net_con->udp->uh_dport = fbn->host_port;
> > + net_udp_send(fbn->net_con, fbn->last_payload_len);
> > +
> > + fbn->may_send = MAY_NOT_SEND;
>
> You moved that line below net_udp_send. Is there any risk that
>
> 1. our work queue executes a command which calls fastboot_tx_print
> 2. the net_udp_send caused by that fastboot_tx_print sleeps
> 3. our poller is executed and decides to send a message because
> may_send is still MAY_SEND_MESSAGE
Ok, changed that.
> > + fbn->last_download_pkt = get_time_ns();
> > +}
>
> Although you added that last_download_pkt timeout check to the poller,
> there is still the risk that we will never close download_fd if
> fastboot_net_abort is called (f.ex. by the first fastboot_tx_print
> inside cb_download) before we open download_fd. In that case there
> is no poller to check for the timeout.
I was not able to provoke such a behaviour. It seems that
fastboot_abort() is called often enough that this doesn't happen. In
doubt it happens when the next fastboot session is initiated.
> > + if (fastboot_data_len >= FASTBOOT_MAX_CMD_LEN) {
>
> Still off-by-one. Replace >= with >
Ok, fixed.
> > + ret = poller_register(&fbn->poller, "fastboot");
> > + if (ret) {
> > + pr_err("Cannot register poller: %s\n", strerror(-ret));
> > + return;
>
> It is not obvious that a second FASTBOOT_INIT will _not_ cause this
> error because fastboot_net_abort unregistered the previous poller.
> I would at least add a comment to the fastboot_net_abort(fbn) line.
Added a comment.
> > +{
> > + struct fastboot_net *fbn = container_of(poller, struct fastboot_net,
> > + poller);
> > +
> > + if (fbn->active_download && is_timeout(fbn->last_download_pkt, 5 * SECOND)) {
>
> Should pollers prefer is_timeout_non_interruptible over is_timeout?
Since with the current approach we no longer execute pollers inside of
pollers this shouldn't make a difference.
Sascha
--
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 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-08-13 10:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 7:44 [PATCH v5 00/21] Slices and " Sascha Hauer
2020-06-19 7:44 ` [PATCH 01/21] Introduce slices Sascha Hauer
2020-06-19 7:44 ` [PATCH 02/21] Add workqueues Sascha Hauer
2020-06-19 7:44 ` [PATCH 03/21] ratp: Switch to workqueues Sascha Hauer
2020-06-19 7:44 ` [PATCH 04/21] net: Add a slice to struct eth_device Sascha Hauer
2020-06-19 7:44 ` [PATCH 05/21] net: mdiobus: Add slice Sascha Hauer
2020-06-19 7:44 ` [PATCH 06/21] usb: Add a slice to usb host controllers Sascha Hauer
2020-06-19 7:44 ` [PATCH 07/21] usbnet: Add slice Sascha Hauer
2020-06-19 7:44 ` [PATCH 08/21] net: Call net_poll() in a poller Sascha Hauer
2020-06-19 7:44 ` [PATCH 09/21] net: reply to ping requests Sascha Hauer
2020-06-19 7:44 ` [PATCH 10/21] usbnet: Be more friendly in the receive path Sascha Hauer
2020-06-19 7:44 ` [PATCH 11/21] defconfigs: update renamed fastboot options Sascha Hauer
2020-06-19 7:44 ` [PATCH 12/21] globalvar: Add helper for deprecated variable names Sascha Hauer
2020-06-19 7:44 ` [PATCH 13/21] fastboot: rename usbgadget.fastboot_* variables to fastboot.* Sascha Hauer
2020-06-19 7:44 ` [PATCH 14/21] fastboot: Warn when cb_download is called with file still open Sascha Hauer
2020-06-19 7:44 ` [PATCH 15/21] fastboot: Add fastboot_abort() Sascha Hauer
2020-06-19 7:44 ` [PATCH 16/21] fastboot: init list head in common Sascha Hauer
2020-06-19 7:44 ` [PATCH 17/21] fastboot net: implement fastboot over UDP Sascha Hauer
2020-06-29 19:50 ` Daniel Glöckner
2020-07-11 4:48 ` Sascha Hauer
2020-08-13 10:38 ` Sascha Hauer [this message]
2020-06-19 7:44 ` [PATCH 18/21] usb: fastboot: execute commands in command context Sascha Hauer
2020-06-19 7:44 ` [PATCH 19/21] Add WARN_ONCE() macro Sascha Hauer
2020-06-19 7:44 ` [PATCH 20/21] fs: Warn when filesystem operations are called from a poller Sascha Hauer
2020-06-19 7:44 ` [PATCH 21/21] Documentation: Add document for parallel execution in barebox Sascha Hauer
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=20200813103845.GA19745@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=dg@emlix.com \
--cc=eh@emlix.com \
/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