aboutgitcodebugslistschat
path: root/icmp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-08-11 15:12:21 +1000
committerStefano Brivio <sbrivio@redhat.com>2023-08-13 17:29:51 +0200
commit34016444534120f2fa5a049675815843d041bc16 (patch)
tree2b61ca5998e756c0b8b8b316171941619bc01dcb /icmp.c
parente26282b67d013f775eacd8603fa5ec1397dec714 (diff)
downloadpasst-34016444534120f2fa5a049675815843d041bc16.tar
passt-34016444534120f2fa5a049675815843d041bc16.tar.gz
passt-34016444534120f2fa5a049675815843d041bc16.tar.bz2
passt-34016444534120f2fa5a049675815843d041bc16.tar.lz
passt-34016444534120f2fa5a049675815843d041bc16.tar.xz
passt-34016444534120f2fa5a049675815843d041bc16.tar.zst
passt-34016444534120f2fa5a049675815843d041bc16.zip
epoll: Generalize epoll_ref to cover things other than sockets
The epoll_ref type includes fields for the IP protocol of a socket, and the socket fd. However, we already have a few things in the epoll which aren't protocol sockets, and we may have more in future. Rename these fields to an abstract "fd type" and file descriptor for more generality. Similarly, rather than using existing IP protocol numbers for the type, introduce our own number space. For now these just correspond to the supported protocols, but we'll expand on that in future. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'icmp.c')
-rw-r--r--icmp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/icmp.c b/icmp.c
index 676fa64..a4b6a47 100644
--- a/icmp.c
+++ b/icmp.c
@@ -79,7 +79,7 @@ void icmp_sock_handler(const struct ctx *c, union epoll_ref ref,
(void)events;
(void)now;
- n = recvfrom(ref.s, buf, sizeof(buf), 0, (struct sockaddr *)&sr, &sl);
+ n = recvfrom(ref.fd, buf, sizeof(buf), 0, (struct sockaddr *)&sr, &sl);
if (n < 0)
return;
@@ -182,7 +182,7 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
bind_if, id, iref.u32);
if (s < 0)
goto fail_sock;
- if (s > SOCKET_MAX) {
+ if (s > FD_REF_MAX) {
close(s);
return 1;
}
@@ -236,7 +236,7 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
bind_if, id, iref.u32);
if (s < 0)
goto fail_sock;
- if (s > SOCKET_MAX) {
+ if (s > FD_REF_MAX) {
close(s);
return 1;
}