The addr_fixed boolean (per address family) was introduced to prevent
observed traffic from overwriting addr_seen when the user explicitly
set an address with -a/--address.
The unified address array already tracks this: fwd_set_addr() marks
user-provided addresses with CONF_ADDR_USER. We now replace all
addr_fixed checks with fwd_get_addr() lookups for CONF_ADDR_USER
and remove the now-redundant field from ip4_ctx and ip6_ctx.
Signed-off-by: Jon Maloy
---
v9: -Adapted to changes due to rebase
-Adapted to change in fwd_get_addr()
---
conf.c | 7 ++-----
passt.h | 6 ------
tap.c | 6 +++---
3 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/conf.c b/conf.c
index fd9f0771..27656271 100644
--- a/conf.c
+++ b/conf.c
@@ -1266,13 +1266,10 @@ static bool conf_addr(struct ctx *c, char *arg, uint8_t opt_n)
goto bad;
fwd_set_addr(c, &addr, CONF_ADDR_USER, prefix_len);
- if (a4) {
+ if (a4)
c->ip4.no_copy_addrs = true;
- c->ip4.addr_fixed = true;
- } else {
+ else
c->ip6.no_copy_addrs = true;
- c->ip6.addr_fixed = true;
- }
return is_prefix;
diff --git a/passt.h b/passt.h
index d4661d81..40d22bba 100644
--- a/passt.h
+++ b/passt.h
@@ -101,8 +101,6 @@ struct guest_addr {
* @ifname_out: Optional interface name to bind outbound sockets to
* @no_copy_routes: Don't copy all routes when configuring target namespace
* @no_copy_addrs: Don't copy all addresses when configuring namespace
- * @addr_fixed: Address was given explicitly (-a): don't update
- * addr_seen from traffic observed on tap
*/
struct ip4_ctx {
/* PIF_TAP addresses */
@@ -122,7 +120,6 @@ struct ip4_ctx {
bool no_copy_routes;
bool no_copy_addrs;
- bool addr_fixed;
};
/**
@@ -143,8 +140,6 @@ struct ip4_ctx {
* @ifname_out: Optional interface name to bind outbound sockets to
* @no_copy_routes: Don't copy all routes when configuring target namespace
* @no_copy_addrs: Don't copy all addresses when configuring namespace
- * @addr_fixed: Address was given explicitly (-a): don't update
- * addr_seen from traffic observed on tap
*/
struct ip6_ctx {
/* PIF_TAP addresses */
@@ -166,7 +161,6 @@ struct ip6_ctx {
bool no_copy_routes;
bool no_copy_addrs;
- bool addr_fixed;
};
#include
diff --git a/tap.c b/tap.c
index 100afc83..cc2dfbcc 100644
--- a/tap.c
+++ b/tap.c
@@ -756,7 +756,7 @@ resume:
continue;
}
- if (!c->ip4.addr_fixed &&
+ if (!fwd_get_addr(c, AF_INET, true, CONF_ADDR_USER) &&
iph->saddr && c->ip4.addr_seen.s_addr != iph->saddr)
c->ip4.addr_seen.s_addr = iph->saddr;
@@ -1000,7 +1000,7 @@ resume:
if (IN6_IS_ADDR_LINKLOCAL(saddr)) {
c->ip6.addr_ll_seen = *saddr;
- if (!c->ip6.addr_fixed &&
+ if (!fwd_get_addr(c, AF_INET6, true, CONF_ADDR_USER) &&
IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_seen)) {
c->ip6.addr_seen = *saddr;
}
@@ -1011,7 +1011,7 @@ resume:
fwd_set_addr(c, &addr, CONF_ADDR_GEN, 64);
}
- } else if (!c->ip6.addr_fixed &&
+ } else if (!fwd_get_addr(c, AF_INET6, true, CONF_ADDR_USER) &&
!IN6_IS_ADDR_UNSPECIFIED(saddr)) {
c->ip6.addr_seen = *saddr;
}
--
2.56.1