diff mbox series

[OEM-5.6,SRU,1/1] selftests: net: ip_defrag: ignore EPERM

Message ID 20201218025503.21207-2-po-hsu.lin@canonical.com
State Accepted
Headers show
Series selftests: net: ip_defrag: ignore EPERM | expand

Commit Message

Po-Hsu Lin Dec. 18, 2020, 2:55 a.m. UTC
From: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

BugLink: https://bugs.launchpad.net/bugs/1908498

When running with conntrack rules, the dropped overlap fragments may cause
EPERM to be returned to sendto. Instead of completely failing, just ignore
those errors and continue. If this causes packets with overlap fragments to
be dropped as expected, that is okay. And if it causes packets that are
expected to be received to be dropped, which should not happen, it will be
detected as failure.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 065fcfd49763ec71ae345bb5c5a74f961031e70e)
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
 tools/testing/selftests/net/ip_defrag.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Thadeu Lima de Souza Cascardo Dec. 18, 2020, 9:27 a.m. UTC | #1
On Fri, Dec 18, 2020 at 10:55:03AM +0800, Po-Hsu Lin wrote:
> From: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1908498
> 
> When running with conntrack rules, the dropped overlap fragments may cause
> EPERM to be returned to sendto. Instead of completely failing, just ignore
> those errors and continue. If this causes packets with overlap fragments to
> be dropped as expected, that is okay. And if it causes packets that are
> expected to be received to be dropped, which should not happen, it will be
> detected as failure.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> (cherry picked from commit 065fcfd49763ec71ae345bb5c5a74f961031e70e)
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

> ---
>  tools/testing/selftests/net/ip_defrag.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/ip_defrag.c b/tools/testing/selftests/net/ip_defrag.c
> index c0c9ecb..f9ed749 100644
> --- a/tools/testing/selftests/net/ip_defrag.c
> +++ b/tools/testing/selftests/net/ip_defrag.c
> @@ -192,9 +192,9 @@ static void send_fragment(int fd_raw, struct sockaddr *addr, socklen_t alen,
>  	}
>  
>  	res = sendto(fd_raw, ip_frame, frag_len, 0, addr, alen);
> -	if (res < 0)
> +	if (res < 0 && errno != EPERM)
>  		error(1, errno, "send_fragment");
> -	if (res != frag_len)
> +	if (res >= 0 && res != frag_len)
>  		error(1, 0, "send_fragment: %d vs %d", res, frag_len);
>  
>  	frag_counter++;
> @@ -313,9 +313,9 @@ static void send_udp_frags(int fd_raw, struct sockaddr *addr,
>  			iphdr->ip_len = htons(frag_len);
>  		}
>  		res = sendto(fd_raw, ip_frame, frag_len, 0, addr, alen);
> -		if (res < 0)
> +		if (res < 0 && errno != EPERM)
>  			error(1, errno, "sendto overlap: %d", frag_len);
> -		if (res != frag_len)
> +		if (res >= 0 && res != frag_len)
>  			error(1, 0, "sendto overlap: %d vs %d", (int)res, frag_len);
>  		frag_counter++;
>  	}
> -- 
> 2.7.4
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
AceLan Kao Dec. 28, 2020, 3:46 a.m. UTC | #2
applied to oem-5.6, thanks
Acked-By: AceLan Kao <acelan.kao@canonical.com>
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/ip_defrag.c b/tools/testing/selftests/net/ip_defrag.c
index c0c9ecb..f9ed749 100644
--- a/tools/testing/selftests/net/ip_defrag.c
+++ b/tools/testing/selftests/net/ip_defrag.c
@@ -192,9 +192,9 @@  static void send_fragment(int fd_raw, struct sockaddr *addr, socklen_t alen,
 	}
 
 	res = sendto(fd_raw, ip_frame, frag_len, 0, addr, alen);
-	if (res < 0)
+	if (res < 0 && errno != EPERM)
 		error(1, errno, "send_fragment");
-	if (res != frag_len)
+	if (res >= 0 && res != frag_len)
 		error(1, 0, "send_fragment: %d vs %d", res, frag_len);
 
 	frag_counter++;
@@ -313,9 +313,9 @@  static void send_udp_frags(int fd_raw, struct sockaddr *addr,
 			iphdr->ip_len = htons(frag_len);
 		}
 		res = sendto(fd_raw, ip_frame, frag_len, 0, addr, alen);
-		if (res < 0)
+		if (res < 0 && errno != EPERM)
 			error(1, errno, "sendto overlap: %d", frag_len);
-		if (res != frag_len)
+		if (res >= 0 && res != frag_len)
 			error(1, 0, "sendto overlap: %d vs %d", (int)res, frag_len);
 		frag_counter++;
 	}