[PATCH 12/13] tftp: allow to change tftp port

Sascha Hauer sha at pengutronix.de
Tue Aug 9 01:12:43 PDT 2022


On Mon, Jul 18, 2022 at 02:22:27PM +0200, Enrico Scholz wrote:
> useful e.g. when working with a local, non-privileged tftp server
> 
> Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
> ---
>  fs/tftp.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/tftp.c b/fs/tftp.c
> index 2c2ff081be51..400209c26023 100644
> --- a/fs/tftp.c
> +++ b/fs/tftp.c
> @@ -78,6 +78,7 @@
>  #define TFTP_ERR_RESEND	1
>  
>  static int g_tftp_window_size = TFTP_MAX_WINDOW_SIZE / 1;
> +static int g_tftp_port = TFTP_PORT;
>  
>  struct tftp_block {
>  	uint16_t id;
> @@ -600,7 +601,7 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
>  		goto out;
>  	}
>  
> -	priv->tftp_con = net_udp_new(tpriv->server, TFTP_PORT, tftp_handler,
> +	priv->tftp_con = net_udp_new(tpriv->server, g_tftp_port, tftp_handler,
>  			priv);
>  	if (IS_ERR(priv->tftp_con)) {
>  		ret = PTR_ERR(priv->tftp_con);
> @@ -944,6 +945,7 @@ static struct fs_driver_d tftp_driver = {
>  static int tftp_init(void)
>  {
>  	globalvar_add_simple_int("tftp.windowsize", &g_tftp_window_size, "%u");
> +	globalvar_add_simple_int("tftp.port", &g_tftp_port, "%u");

The port is connection specific. I think we should rather pass the port
through mount using -o, something like mount -o port=4711 <server>
<path>. Grep for "parseopt_hu" to see how this can be done.

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 |



More information about the barebox mailing list