epoll: Split handling of ICMP and ICMPv6 sockets

We have different epoll type values for ICMP and ICMPv6 sockets, but they
both call the same handler function, icmp_sock_handler().  However that
function does essentially nothing in common for the two cases.  So, split
it into icmp_sock_handler() and icmpv6_sock_handler() and dispatch them
separately from the top level.

While we're there remove some parameters that the function was never using
anyway.  Also move the test for c->no_icmp into the functions, so that all
the logic specific to ICMP is within the handler, rather than in the top
level dispatch code.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson
2023-08-11 15:12:24 +10:00
committed by Stefano Brivio
parent d850caab66
commit 05f606ab0b
3 changed files with 79 additions and 65 deletions

View File

@@ -329,9 +329,10 @@ loop:
udp_sock_handler(&c, ref, eventmask, &now);
break;
case EPOLL_TYPE_ICMP:
icmp_sock_handler(&c, ref);
break;
case EPOLL_TYPE_ICMPV6:
if (!c.no_icmp)
icmp_sock_handler(&c, ref, eventmask, &now);
icmpv6_sock_handler(&c, ref);
break;
default:
/* Can't happen */