aboutgitcodebugslistschat
path: root/icmp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-05-21 15:57:03 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-05-22 23:20:52 +0200
commit7a832a8a0edbdd5a705c1fe03fca0790a535ab11 (patch)
tree408f32fadc34b75ea9e7e166a5ba91880a4a1d73 /icmp.c
parent1a20370b364ada675882e6a70d05b6e81418d64f (diff)
downloadpasst-7a832a8a0edbdd5a705c1fe03fca0790a535ab11.tar
passt-7a832a8a0edbdd5a705c1fe03fca0790a535ab11.tar.gz
passt-7a832a8a0edbdd5a705c1fe03fca0790a535ab11.tar.bz2
passt-7a832a8a0edbdd5a705c1fe03fca0790a535ab11.tar.lz
passt-7a832a8a0edbdd5a705c1fe03fca0790a535ab11.tar.xz
passt-7a832a8a0edbdd5a705c1fe03fca0790a535ab11.tar.zst
passt-7a832a8a0edbdd5a705c1fe03fca0790a535ab11.zip
flow: Properly type callbacks to protocol specific handlers
The flow dispatches deferred and timer handling for flows centrally, but needs to call into protocol specific code for the handling of individual flows. Currently this passes a general union flow *. It makes more sense to pass the specific relevant flow type structure. That brings the check on the flow type adjacent to casting to the union variant which it tags. Arguably, this is a slight abstraction violation since it involves the generic flow code using protocol specific types. It's already calling into protocol specific functions, so I don't think this really makes any difference. 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, 2 insertions, 4 deletions
diff --git a/icmp.c b/icmp.c
index 1c5cf84..eb559c1 100644
--- a/icmp.c
+++ b/icmp.c
@@ -289,16 +289,14 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af,
/**
* icmp_ping_timer() - Handler for timed events related to a given flow
* @c: Execution context
- * @flow: flow table entry to check for timeout
+ * @pingf: Ping flow to check for timeout
* @now: Current timestamp
*
* Return: true if the flow is ready to free, false otherwise
*/
-bool icmp_ping_timer(const struct ctx *c, union flow *flow,
+bool icmp_ping_timer(const struct ctx *c, const struct icmp_ping_flow *pingf,
const struct timespec *now)
{
- const struct icmp_ping_flow *pingf = &flow->ping;
-
if (now->tv_sec - pingf->ts <= ICMP_ECHO_TIMEOUT)
return false;