diff options
| author | Stefano Brivio <sbrivio@redhat.com> | 2026-12-01 02:23:45 +0100 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-12-02 22:59:29 +0100 |
| commit | 8ce30019e739080a5a8292d567b8e48631f2f6fa (patch) | |
| tree | 0e01b774812da30b0af219662c5675690add8df7 | |
| parent | 6569a6f6c94e656a04f77132f853666550b744c7 (diff) | |
| download | passt-8ce30019e739080a5a8292d567b8e48631f2f6fa.tar passt-8ce30019e739080a5a8292d567b8e48631f2f6fa.tar.gz passt-8ce30019e739080a5a8292d567b8e48631f2f6fa.tar.bz2 passt-8ce30019e739080a5a8292d567b8e48631f2f6fa.tar.lz passt-8ce30019e739080a5a8292d567b8e48631f2f6fa.tar.xz passt-8ce30019e739080a5a8292d567b8e48631f2f6fa.tar.zst passt-8ce30019e739080a5a8292d567b8e48631f2f6fa.zip | |
icmp, tcp, udp: Change Layer-4 protocol handlers to return unsigned
...to avoid embarrassing mistakes like the one fixed by the previous
commit: they are always supposed to return a count of consumed
packets, and handle protocol errors themselves.
Note that, strictly speaking, those should all return size_t instead
of unsigned int, but changing tcp_tap_handler() to return size_t
triggers something that looks like a false positive in Coverity Scan
which I still need to investigate. Just fix the signedness for the
moment being.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | icmp.c | 7 | ||||
| -rw-r--r-- | icmp.h | 7 | ||||
| -rw-r--r-- | tcp.c | 7 | ||||
| -rw-r--r-- | tcp.h | 7 | ||||
| -rw-r--r-- | udp.c | 8 | ||||
| -rw-r--r-- | udp.h | 8 |
6 files changed, 24 insertions, 20 deletions
@@ -249,9 +249,10 @@ cancel: * * Return: count of consumed packets (always 1, even if malformed) */ -int icmp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, - const void *saddr, const void *daddr, - struct iov_tail *data, const struct timespec *now) +unsigned int icmp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, + const void *saddr, const void *daddr, + struct iov_tail *data, + const struct timespec *now) { struct iovec iov[MAX_IOV_ICMP]; struct icmp_ping_flow *pingf; @@ -15,9 +15,10 @@ struct icmp_ping_flow; void icmp_sock_handler(const struct ctx *c, union epoll_ref ref, const struct timespec *now); -int icmp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, - const void *saddr, const void *daddr, - struct iov_tail *data, const struct timespec *now); +unsigned int icmp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, + const void *saddr, const void *daddr, + struct iov_tail *data, + const struct timespec *now); void icmp_init(void); @@ -2313,9 +2313,10 @@ static void tcp_rst_no_conn(const struct ctx *c, int af, * * Return: count of consumed packets */ -int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, - const void *saddr, const void *daddr, uint32_t flow_lbl, - const struct pool *p, int idx, const struct timespec *now) +unsigned int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, + const void *saddr, const void *daddr, + uint32_t flow_lbl, const struct pool *p, int idx, + const struct timespec *now) { struct tcp_tap_conn *conn; struct tcphdr th_storage; @@ -24,9 +24,10 @@ void tcp_listen_handler(const struct ctx *c, union epoll_ref ref, const struct timespec *now); void tcp_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t events, const struct timespec *now); -int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, - const void *saddr, const void *daddr, uint32_t flow_lbl, - const struct pool *p, int idx, const struct timespec *now); +unsigned int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, + const void *saddr, const void *daddr, + uint32_t flow_lbl, const struct pool *p, int idx, + const struct timespec *now); int tcp_init(struct ctx *c); void tcp_defer_handler(struct ctx *c, const struct timespec *now); @@ -1016,10 +1016,10 @@ fail: * * #syscalls sendmmsg */ -int udp_tap_handler(const struct ctx *c, uint8_t pif, - sa_family_t af, const void *saddr, const void *daddr, - uint8_t ttl, const struct pool *p, int idx, - const struct timespec *now) +unsigned int udp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, + const void *saddr, const void *daddr, uint8_t ttl, + const struct pool *p, int idx, + const struct timespec *now) { const struct flowside *toside; struct mmsghdr mm[UIO_MAXIOV]; @@ -15,10 +15,10 @@ void udp_listen_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t events, const struct timespec *now); void udp_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t events, const struct timespec *now); -int udp_tap_handler(const struct ctx *c, uint8_t pif, - sa_family_t af, const void *saddr, const void *daddr, - uint8_t ttl, const struct pool *p, int idx, - const struct timespec *now); +unsigned int udp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, + const void *saddr, const void *daddr, uint8_t ttl, + const struct pool *p, int idx, + const struct timespec *now); int udp_init(struct ctx *c); void udp_update_l2_buf(const unsigned char *eth_d); |
