diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2022-07-22 15:31:18 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-07-30 22:14:07 +0200 |
commit | 16f5586bb811dd344c3bbeadc88f30568986adbc (patch) | |
tree | 5ddf4027edb4867adb94dcd62870d9d9a6f3ac49 /tap.c | |
parent | 5e12d23acbda8871848c6221a4f14e5b7daff66f (diff) | |
download | passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar.gz passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar.bz2 passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar.lz passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar.xz passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar.zst passt-16f5586bb811dd344c3bbeadc88f30568986adbc.zip |
Make substructures for IPv4 and IPv6 specific context information
The context structure contains a batch of fields specific to IPv4 and to
IPv6 connectivity. Split those out into a sub-structure.
This allows the conf_ip4() and conf_ip6() functions, which take the
entire context but touch very little of it, to be given more specific
parameters, making it clearer what it affects without stepping through the
code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tap.c')
-rw-r--r-- | tap.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -130,7 +130,7 @@ void tap_ip_send(const struct ctx *c, const struct in6_addr *src, uint8_t proto, iph->frag_off = 0; iph->ttl = 255; iph->protocol = proto; - iph->daddr = c->addr4_seen; + iph->daddr = c->ip4.addr_seen; memcpy(&iph->saddr, &src->s6_addr[12], 4); iph->check = 0; @@ -165,9 +165,9 @@ void tap_ip_send(const struct ctx *c, const struct in6_addr *src, uint8_t proto, ip6h->saddr = *src; if (IN6_IS_ADDR_LINKLOCAL(src)) - ip6h->daddr = c->addr6_ll_seen; + ip6h->daddr = c->ip6.addr_ll_seen; else - ip6h->daddr = c->addr6_seen; + ip6h->daddr = c->ip6.addr_seen; memcpy(data, in, len); @@ -354,9 +354,9 @@ resume: l4_len = l3_len - hlen; - if (iph->saddr && c->addr4_seen != iph->saddr) { - c->addr4_seen = iph->saddr; - proto_update_l2_buf(NULL, NULL, &c->addr4_seen); + if (iph->saddr && c->ip4.addr_seen != iph->saddr) { + c->ip4.addr_seen = iph->saddr; + proto_update_l2_buf(NULL, NULL, &c->ip4.addr_seen); } l4h = packet_get(in, i, sizeof(*eh) + hlen, l4_len, NULL); @@ -504,13 +504,13 @@ resume: continue; if (IN6_IS_ADDR_LINKLOCAL(saddr)) { - c->addr6_ll_seen = *saddr; + c->ip6.addr_ll_seen = *saddr; - if (IN6_IS_ADDR_UNSPECIFIED(&c->addr6_seen)) { - c->addr6_seen = *saddr; + if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_seen)) { + c->ip6.addr_seen = *saddr; } } else { - c->addr6_seen = *saddr; + c->ip6.addr_seen = *saddr; } if (proto == IPPROTO_ICMPV6) { @@ -545,7 +545,7 @@ resume: continue; } - *saddr = c->addr6; + *saddr = c->ip6.addr; if (proto != IPPROTO_TCP && proto != IPPROTO_UDP) { tap_packet_debug(NULL, ip6h, NULL, proto, NULL, 1); |