diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-05-21 11:14:53 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-05-21 11:14:53 +0200 |
commit | 9311ceb8b6fe7064cffca3efda051ef1e1801642 (patch) | |
tree | 6ffceb50e313b00305eedfb53341ed37a484b5fd /util.c | |
parent | 5fd6db7751c4fd20a4a2415fdda8b09b5ce524f9 (diff) | |
download | passt-9311ceb8b6fe7064cffca3efda051ef1e1801642.tar passt-9311ceb8b6fe7064cffca3efda051ef1e1801642.tar.gz passt-9311ceb8b6fe7064cffca3efda051ef1e1801642.tar.bz2 passt-9311ceb8b6fe7064cffca3efda051ef1e1801642.tar.lz passt-9311ceb8b6fe7064cffca3efda051ef1e1801642.tar.xz passt-9311ceb8b6fe7064cffca3efda051ef1e1801642.tar.zst passt-9311ceb8b6fe7064cffca3efda051ef1e1801642.zip |
icmp: Implement lazy bind for ping sockets
It turns out that binding ICMP/ICMPv6 echo sockets takes a long
time. Instead of binding all of them (one for each possible echo
identification number, that is, 2^17) at start-up, bind them as
ICMP/ICMPv6 packets are sent by the guest.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -17,7 +17,6 @@ #include <arpa/inet.h> #include <net/ethernet.h> #include <net/if.h> -#include <netinet/ip.h> #include <netinet/tcp.h> #include <netinet/udp.h> #include <sys/epoll.h> @@ -207,6 +206,9 @@ int sock_l4(struct ctx *c, int af, uint16_t proto, uint16_t port) if (proto == IPPROTO_UDP && PORT_IS_EPHEMERAL(port)) goto epoll_add; + if (proto == IPPROTO_ICMP || proto == IPPROTO_ICMPV6) + goto epoll_add; + if (bind(fd, sa, sl) < 0) { /* We'll fail to bind to low ports if we don't have enough * capabilities, and we'll fail to bind on already bound ports, |