diff mbox

[net] vxlan: correctly validate VXLAN ID against VXLAN_VID_MASK

Message ID 3ea499d5a3564fc7074665962b1a10cccd900e59.1487854674.git.mschiffer@universe-factory.net
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Matthias Schiffer Feb. 23, 2017, 12:59 p.m. UTC
The incorrect check caused an off-by-one error: the maximum VID 0xffffff
was unusable.

Fixes: d342894c5d2f ("vxlan: virtual extensible lan")
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
 drivers/net/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiri Benc Feb. 23, 2017, 3:34 p.m. UTC | #1
On Thu, 23 Feb 2017 13:59:02 +0100, Matthias Schiffer wrote:
> The incorrect check caused an off-by-one error: the maximum VID 0xffffff
> was unusable.
> 
> Fixes: d342894c5d2f ("vxlan: virtual extensible lan")
> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
> ---
>  drivers/net/vxlan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
> index 556953f53437..f89428fb7389 100644
> --- a/drivers/net/vxlan.c
> +++ b/drivers/net/vxlan.c
> @@ -2675,7 +2675,7 @@ static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[])
>  
>  	if (data[IFLA_VXLAN_ID]) {
>  		__u32 id = nla_get_u32(data[IFLA_VXLAN_ID]);
> -		if (id >= VXLAN_VID_MASK)
> +		if (id & ~VXLAN_VID_MASK)
>  			return -ERANGE;
>  	}
>  

"if (id >= VXLAN_N_VID)" would be cleaner and the meaning more obvious.

Thanks,

 Jiri
diff mbox

Patch

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 556953f53437..f89428fb7389 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2675,7 +2675,7 @@  static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[])
 
 	if (data[IFLA_VXLAN_ID]) {
 		__u32 id = nla_get_u32(data[IFLA_VXLAN_ID]);
-		if (id >= VXLAN_VID_MASK)
+		if (id & ~VXLAN_VID_MASK)
 			return -ERANGE;
 	}