This series lets passt and pasta handle more than one IPv4 and IPv6 address per guest, building on the unified address array already upstream: - addr_fixed is replaced by the CONF_ADDR_USER flag - guest accessibility checks and ARP filtering consider all configured addresses, not only the first one of each family - -a/--address can be given multiple times; the first address of each family is still the one handed out via DHCP and DHCPv6/NDP - in pasta, all addresses of the template interface are read at startup, and copied to the namespace with --config-net Tested with pasta in a namespace without connectivity, both with multiple -a options and --config-net (all addresses and routes set up, echo requests from every address answered), and with the plain local mode defaults. ---- v2: -Using inany_addr instead of protocol specific addresses as entry address field. v3: -Merging into one array, directly in struct ctx -Changed prefix_len and flags fields in struct inany_addr_entry to uint8_t, since that makes the struct directly migratable v4: -Updated according to changes in previous commits -Updated according to feedback from David G. -Squashed IP4_MASK macro commit into this one v6: -Renamed and moved some definitions -Introduced fwd_set_addr() and fwd_get_addr() already in this commit -Eliminated first_v4/v6() functions, replaced with fwd_get_addr() -Some other changes as suggested by David G. -I kept the flag CONF_ADDR_LINKLOCAL, since it will be needed later in an address selection function. v7: -Introduced CONF_ADDR_GENERATED flag -Other fixes based on feedback from David and Stefano. -I changed signature of inany_prefix_len(), but I did not change its semantics, since the premise of David's comment is wrong: the caller does *not* explicitly know he is dealing with an IPv4 address. In fact, there are examples later in this series where it may be an IPv6 address, and the caller just trusts he gets the return value in the appropriate format. -Intoduced the inverse of inany_prefix_len(), called inany_prefix_len6() which always returns the prefix in IPv6 or mapped IPv4 format. The name of the function isn't great, but any alternative I came up with became too long to be practical. v8: -Added inany_prefix_v4() (David G.) to extract IPv4 address and prefix length simultaneously, replacing inany_prefix_len(). -Removed both inany_prefix_len() and inany_prefix_len6() auto-detecting functions. Prefix length attached to an inany is now always stored in IPv6 format (96-128 for IPv4-mapped). -fwd_set_addr() now requires prefix_len in IPv6 format; callers updated to pass prefix_len + 96 for IPv4 addresses. -Fixed -n option to store prefix_len in IPv6 format. -Fixed addr_seen regression: when address was set via -a, addr_seen was not initialised in conf_ip4(). -Replaced assert() with graceful no-op in dhcp.c and ndp.c when no address is configured (David G.). -Note: addr_seen is still initialised both at conf_ip*() time and at DHCP/DHCPv6 send time (David's concern). This inconsistency will be addressed in a follow-up. -Introduced a new CONF_ADDR_ANY macro tobe used for address selection, as suggested by Stefano. -Deferred introduction of an explicit scope field (replacing CONF_ADDR_LINKLOCAL flag) to a later commit or series. v9: -Posting without first commit in previous version, since that one has already been applied upstream. -Posted with only the next 5 commits in the previous version of the series, to make it more manageable. This was suggested by David Gibson. Jon Maloy (5): tap, conf: Replace addr_fixed with CONF_ADDR_USER flag check fwd: Unify guest accessibility checks with unified address array arp: Check all configured addresses in ARP filtering conf: Allow multiple -a/--address options per address family netlink, conf: Read all addresses from template interface at startup Jon Maloy (5): tap, conf: Replace addr_fixed with CONF_ADDR_USER flag check fwd: Unify guest accessibility checks with unified address array arp: Check all configured addresses in ARP filtering conf: Allow multiple -a/--address options per address family netlink, conf: Read all addresses from template interface at startup arp.c | 16 +++++----- conf.c | 63 +++++++++++++++++---------------------- fwd.c | 80 +++++++++++++------------------------------------- netlink.c | 88 ++++++++++++++++++++++++++++++++++++++++--------------- netlink.h | 3 +- passt.1 | 18 +++++------- passt.h | 6 ---- pasta.c | 27 +++++++++-------- tap.c | 6 ++-- 9 files changed, 145 insertions(+), 162 deletions(-) -- 2.56.1