Skip to content

Commit

Permalink
selftests: net: ip_defrag: ignore EPERM
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thadeu Lima de Souza Cascardo authored and davem330 committed Jun 2, 2020
1 parent e8224bf commit 065fcfd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/testing/selftests/net/ip_defrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down Expand Up @@ -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++;
}
Expand Down

0 comments on commit 065fcfd

Please sign in to comment.