aboutgitcodebugslistschat
path: root/icmp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-08-22 15:29:53 +1000
committerStefano Brivio <sbrivio@redhat.com>2023-08-22 12:15:21 +0200
commitcee4a2da48ba2518b1b5f7a05f0c26381272fb91 (patch)
treeeb7bc50d3d6ef1eefcd34f2edd8834b667507eae /icmp.c
parent673bde1f213381fedd0d53946cfa35df9144075a (diff)
downloadpasst-cee4a2da48ba2518b1b5f7a05f0c26381272fb91.tar
passt-cee4a2da48ba2518b1b5f7a05f0c26381272fb91.tar.gz
passt-cee4a2da48ba2518b1b5f7a05f0c26381272fb91.tar.bz2
passt-cee4a2da48ba2518b1b5f7a05f0c26381272fb91.tar.lz
passt-cee4a2da48ba2518b1b5f7a05f0c26381272fb91.tar.xz
passt-cee4a2da48ba2518b1b5f7a05f0c26381272fb91.tar.zst
passt-cee4a2da48ba2518b1b5f7a05f0c26381272fb91.zip
tap: Pass source address to protocol handler functions
The tap code passes the IPv4 or IPv6 destination address of packets it receives to the protocol specific code. Currently that protocol code doesn't use the source address, but we want it to in future. So, in preparation, pass the IPv4/IPv6 source address of tap packets to those functions as well. 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.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/icmp.c b/icmp.c
index b676a1a..f2cc4d6 100644
--- a/icmp.c
+++ b/icmp.c
@@ -154,17 +154,21 @@ void icmpv6_sock_handler(const struct ctx *c, union epoll_ref ref)
* icmp_tap_handler() - Handle packets from tap
* @c: Execution context
* @af: Address family, AF_INET or AF_INET6
- * @addr: Destination address
+ * @saddr: Source address
+ * @daddr: Destination address
* @p: Packet pool, single packet with ICMP/ICMPv6 header
* @now: Current timestamp
*
* Return: count of consumed packets (always 1, even if malformed)
*/
-int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
+int icmp_tap_handler(const struct ctx *c, int af,
+ const void *saddr, const void *daddr,
const struct pool *p, const struct timespec *now)
{
size_t plen;
+ (void)saddr;
+
if (af == AF_INET) {
struct sockaddr_in sa = {
.sin_family = AF_INET,
@@ -210,7 +214,7 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
icmp_id_map[V4][id].ts = now->tv_sec;
bitmap_set(icmp_act[V4], id);
- sa.sin_addr = *(struct in_addr *)addr;
+ sa.sin_addr = *(struct in_addr *)daddr;
if (sendto(s, ih, sizeof(*ih) + plen, MSG_NOSIGNAL,
(struct sockaddr *)&sa, sizeof(sa)) < 0) {
debug("ICMP: failed to relay request to socket");
@@ -264,7 +268,7 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
icmp_id_map[V6][id].ts = now->tv_sec;
bitmap_set(icmp_act[V6], id);
- sa.sin6_addr = *(struct in6_addr *)addr;
+ sa.sin6_addr = *(struct in6_addr *)daddr;
if (sendto(s, ih, sizeof(*ih) + plen, MSG_NOSIGNAL,
(struct sockaddr *)&sa, sizeof(sa)) < 1) {
debug("ICMPv6: failed to relay request to socket");