diff mbox series

[net-next] erspan: Check IFLA_GRE_ERSPAN_VER is set.

Message ID 1589304983-100626-1-git-send-email-u9012063@gmail.com
State Accepted
Delegated to: David Miller
Headers show
Series [net-next] erspan: Check IFLA_GRE_ERSPAN_VER is set. | expand

Commit Message

William Tu May 12, 2020, 5:36 p.m. UTC
Add a check to make sure the IFLA_GRE_ERSPAN_VER is provided by users.

Fixes: f989d546a2d5 ("erspan: Add type I version 0 support.")
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: William Tu <u9012063@gmail.com>
---
 net/ipv4/ip_gre.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Eric Dumazet May 12, 2020, 6:50 p.m. UTC | #1
On 5/12/20 10:36 AM, William Tu wrote:
> Add a check to make sure the IFLA_GRE_ERSPAN_VER is provided by users.
> 
> Fixes: f989d546a2d5 ("erspan: Add type I version 0 support.")
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: William Tu <u9012063@gmail.com>
> ---

Reviewed-by: Eric Dumazet <edumazet@google.com>

Thanks.
David Miller May 12, 2020, 8:11 p.m. UTC | #2
From: William Tu <u9012063@gmail.com>
Date: Tue, 12 May 2020 10:36:23 -0700

> Add a check to make sure the IFLA_GRE_ERSPAN_VER is provided by users.
> 
> Fixes: f989d546a2d5 ("erspan: Add type I version 0 support.")
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: William Tu <u9012063@gmail.com>

Applied, thanks.
diff mbox series

Patch

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index e29cd48674d7..0ce9b91ff55c 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1087,7 +1087,8 @@  static int erspan_validate(struct nlattr *tb[], struct nlattr *data[],
 	if (ret)
 		return ret;
 
-	if (nla_get_u8(data[IFLA_GRE_ERSPAN_VER]) == 0)
+	if (data[IFLA_GRE_ERSPAN_VER] &&
+	    nla_get_u8(data[IFLA_GRE_ERSPAN_VER]) == 0)
 		return 0;
 
 	/* ERSPAN type II/III should only have GRE sequence and key flag */