[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200730162030.0b5749a8@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date: Thu, 30 Jul 2020 16:20:30 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Martin Varghese <martinvarghesenokia@...il.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, jbenc@...hat.com,
gnault@...hat.com, Martin Varghese <martin.varghese@...ia.com>
Subject: Re: [PATCH net] bareudp: Disallow udp port 0.
On Thu, 30 Jul 2020 22:33:51 +0530 Martin Varghese wrote:
> From: Martin Varghese <martin.varghese@...ia.com>
>
> Kernel does not support udp destination port 0 on wire. Hence
> bareudp device with udp destination port 0 must be disallowed.
>
> Fixes: 571912c69f0e ("net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS, IP, NSH etc.")
> Signed-off-by: Martin Varghese <martin.varghese@...ia.com>
> ---
> drivers/net/bareudp.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
> index 88e7900853db..08b195d32cbe 100644
> --- a/drivers/net/bareudp.c
> +++ b/drivers/net/bareudp.c
> @@ -578,8 +578,13 @@ static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf,
> return -EINVAL;
> }
>
> - if (data[IFLA_BAREUDP_PORT])
> + if (data[IFLA_BAREUDP_PORT]) {
> conf->port = nla_get_u16(data[IFLA_BAREUDP_PORT]);
> + if (!conf->port) {
> + NL_SET_ERR_MSG(extack, "udp port 0 not supported");
> + return -EINVAL;
> + }
> + }
Please use one of the NLA_POLICY_**-ies, probably NLA_POLICY_MIN() ?
That's better for documenting, exporting for user space, and will also
point the user space to the attribute in exack automatically.
Powered by blists - more mailing lists