aboutgitcodebugslistschat
diff options
context:
space:
mode:
-rw-r--r--conf.c2
-rw-r--r--passt.h6
-rw-r--r--tap.c9
3 files changed, 14 insertions, 3 deletions
diff --git a/conf.c b/conf.c
index cd05adf..4755a9f 100644
--- a/conf.c
+++ b/conf.c
@@ -1583,10 +1583,12 @@ void conf(struct ctx *c, int argc, char **argv)
if (inany_v4(&addr)) {
c->ip4.addr = *inany_v4(&addr);
c->ip4.prefix_len = prefix_len - 96;
+ c->ip4.addr_fixed = true;
if (c->mode == MODE_PASTA)
c->ip4.no_copy_addrs = true;
} else {
c->ip6.addr = addr.a6;
+ c->ip6.addr_fixed = true;
if (c->mode == MODE_PASTA)
c->ip6.no_copy_addrs = true;
}
diff --git a/passt.h b/passt.h
index 3a07294..16506dc 100644
--- a/passt.h
+++ b/passt.h
@@ -82,6 +82,8 @@ enum passt_modes {
* @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 */
@@ -103,6 +105,7 @@ struct ip4_ctx {
bool no_copy_routes;
bool no_copy_addrs;
+ bool addr_fixed;
};
/**
@@ -123,6 +126,8 @@ 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 */
@@ -144,6 +149,7 @@ struct ip6_ctx {
bool no_copy_routes;
bool no_copy_addrs;
+ bool addr_fixed;
};
#include <netinet/if_ether.h>
diff --git a/tap.c b/tap.c
index 6ed7f8d..6d93c7c 100644
--- a/tap.c
+++ b/tap.c
@@ -771,7 +771,8 @@ resume:
continue;
}
- if (iph->saddr && c->ip4.addr_seen.s_addr != iph->saddr)
+ if (!c->ip4.addr_fixed &&
+ iph->saddr && c->ip4.addr_seen.s_addr != iph->saddr)
c->ip4.addr_seen.s_addr = iph->saddr;
if (!iov_drop_header(&data, hlen))
@@ -1014,13 +1015,15 @@ resume:
if (IN6_IS_ADDR_LINKLOCAL(saddr)) {
c->ip6.addr_ll_seen = *saddr;
- if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_seen)) {
+ if (!c->ip6.addr_fixed &&
+ IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_seen)) {
c->ip6.addr_seen = *saddr;
}
if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr))
c->ip6.addr = *saddr;
- } else if (!IN6_IS_ADDR_UNSPECIFIED(saddr)){
+ } else if (!c->ip6.addr_fixed &&
+ !IN6_IS_ADDR_UNSPECIFIED(saddr)) {
c->ip6.addr_seen = *saddr;
}