From 4cd753e65c591732b84c455b8eb9af44d09155cd Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 18 Jul 2024 15:26:42 +1000 Subject: icmp: Manage outbound socket address via flow table For now when we forward a ping to the host we leave the host side forwarding address and port blank since we don't necessarily know what source address and id will be used by the kernel. When the outbound address option is active, though, we do know the address at least, so we can record it in the flowside. Having done that, use it as the primary source of truth, binding the outgoing socket based on the information in there. This allows the possibility of more complex rules for what outbound address and/or id we use in future. To implement this we create a new helper which sets up a new socket based on information in a flowside, which will also have future uses. It behaves slightly differently from the existing ICMP code, in that it doesn't bind to a specific interface if given a loopback address. This is logically correct - the loopback address means we need to operate through the host's loopback interface, not ifname_out. We didn't need it in ICMP because ICMP will never generate a loopback address at this point, however we intend to change that in future. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- flow.c | 1 - 1 file changed, 1 deletion(-) (limited to 'flow.c') diff --git a/flow.c b/flow.c index 6ba8a62..c4f1236 100644 --- a/flow.c +++ b/flow.c @@ -194,7 +194,6 @@ static int flowside_sock_splice(void *arg) * Return: socket fd of protocol @proto bound to the forwarding address and port * from @tgt (if specified). */ -/* cppcheck-suppress unusedFunction */ int flowside_sock_l4(const struct ctx *c, enum epoll_type type, uint8_t pif, const struct flowside *tgt, uint32_t data) { -- cgit v1.2.3