Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: net: ip_defrag: ignore EPERM

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>

authored by

Thadeu Lima de Souza Cascardo and committed by
David S. Miller
065fcfd4 e8224bfe

+4 -4
+4 -4
tools/testing/selftests/net/ip_defrag.c
··· 192 192 } 193 193 194 194 res = sendto(fd_raw, ip_frame, frag_len, 0, addr, alen); 195 - if (res < 0) 195 + if (res < 0 && errno != EPERM) 196 196 error(1, errno, "send_fragment"); 197 - if (res != frag_len) 197 + if (res >= 0 && res != frag_len) 198 198 error(1, 0, "send_fragment: %d vs %d", res, frag_len); 199 199 200 200 frag_counter++; ··· 313 313 iphdr->ip_len = htons(frag_len); 314 314 } 315 315 res = sendto(fd_raw, ip_frame, frag_len, 0, addr, alen); 316 - if (res < 0) 316 + if (res < 0 && errno != EPERM) 317 317 error(1, errno, "sendto overlap: %d", frag_len); 318 - if (res != frag_len) 318 + if (res >= 0 && res != frag_len) 319 319 error(1, 0, "sendto overlap: %d vs %d", (int)res, frag_len); 320 320 frag_counter++; 321 321 }