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
---
conf.c | 7 ++-----
passt.h | 6 ------
tap.c | 9 ++++-----
3 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/conf.c b/conf.c
index ac8facc8..1c0c1786 100644
--- a/conf.c
+++ b/conf.c
@@ -1598,13 +1598,10 @@ void conf(struct ctx *c, int argc, char **argv)
/* Legacy behaviour: replace existing address if any */
fwd_set_addr(c, &addr, CONF_ADDR_USER, prefix_len);
- if (inany_v4(&addr)) {
+ if (inany_v4(&addr))
c->ip4.no_copy_addrs = true;
- c->ip4.addr_fixed = true;
- } else {
+ else
c->ip6.no_copy_addrs = true;
- c->ip6.addr_fixed = true;
- }
break;
}
case 'n': {
diff --git a/passt.h b/passt.h
index cafa35ea..11ccff05 100644
--- a/passt.h
+++ b/passt.h
@@ -100,8 +100,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 */
@@ -121,7 +119,6 @@ struct ip4_ctx {
bool no_copy_routes;
bool no_copy_addrs;
- bool addr_fixed;
};
/**
@@ -141,8 +138,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 */
@@ -163,7 +158,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 12630f58..573a3f10 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, CONF_ADDR_USER, 0) &&
iph->saddr && c->ip4.addr_seen.s_addr != iph->saddr)
c->ip4.addr_seen.s_addr = iph->saddr;
@@ -1000,18 +1000,17 @@ 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, CONF_ADDR_USER, 0) &&
IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_seen)) {
c->ip6.addr_seen = *saddr;
}
- if (!c->ip6.addr_fixed &&
- !fwd_get_addr(c, AF_INET6, CONF_ADDR_ANY, 0)) {
+ if (!fwd_get_addr(c, AF_INET6, CONF_ADDR_USER, 0)) {
union inany_addr addr = { .a6 = *saddr };
fwd_set_addr(c, &addr, CONF_ADDR_LINKLOCAL, 64);
}
- } else if (!c->ip6.addr_fixed &&
+ } else if (!fwd_get_addr(c, AF_INET6, CONF_ADDR_USER, 0) &&
!IN6_IS_ADDR_UNSPECIFIED(saddr)) {
c->ip6.addr_seen = *saddr;
}
--
2.52.0