From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202512 header.b=N7Ie5me3; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 3CF055A0657 for ; Mon, 15 Dec 2025 11:08:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1765793302; bh=pSUh3SWmCYcrrlm9MUlZwSEydKIjMAlesceAM9fuJ2w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N7Ie5me3puv2V9jCdXjQuXclHxJ8uAn9/DjjQwzGsneH5WicBEeFYlFrXjeHJbjSc q0H0A1i/z7PvzU9jMLyf0wpOgo7/tSPFC0hNaYK2qLeKjAn1rmTZ8VrQ6cf7A0g+M7 3Ej/eq0/1ZyV7jB9pWsA5MFcxuT5EZAgiWC7zqlar6vxtjQIhPyHp8YdxfWasAKLmQ wHKIM/jHBoX/gQzcyypeMbQBTx/E/mMleZlejrZnDJre2wF+C7tnVT5g6LTIiVA0hP 2zgc6sWjXI2mGYdgdn353GsvCMA3XHjVrgn4Olkt3X4D/s+3eT8FuIqnfVvkKDF9Y9 hOGnVvGALxixQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dVG3V1g2wz4wCx; Mon, 15 Dec 2025 21:08:22 +1100 (AEDT) Date: Mon, 15 Dec 2025 20:40:18 +1100 From: David Gibson To: Jon Maloy Subject: Re: [RFC 01/12] ip: Introduce multi-address data structures for IPv4 and IPv6 Message-ID: References: <20251215015441.887736-1-jmaloy@redhat.com> <20251215015441.887736-2-jmaloy@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="PN/M7I6IZuD8ioTT" Content-Disposition: inline In-Reply-To: <20251215015441.887736-2-jmaloy@redhat.com> Message-ID-Hash: FZR4M5YFO2P3TIEQQK2ENBE6GT3QUCG5 X-Message-ID-Hash: FZR4M5YFO2P3TIEQQK2ENBE6GT3QUCG5 X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: sbrivio@redhat.com, dgibson@redhat.com, passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --PN/M7I6IZuD8ioTT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Dec 14, 2025 at 08:54:30PM -0500, Jon Maloy wrote: > As preparation for supporting multiple addresses per interface, we > replace the single addr/prefix_len fields with arrays. >=20 > - We add an ip4_addr_entry and an ip6_addr_entry struct containing > address and prefix length. >=20 > - We set the array sizes to IP4_MAX_ADDRS=3D8 and IP6_MAX_ADDRS=3D16, > respectively. >=20 > The only functional change is that the IPv6 prefix length now is > properly stored instead of being hardcoded to 64 even when set > via the -a option. >=20 > Signed-off-by: Jon Maloy > --- > arp.c | 4 +-- > conf.c | 97 +++++++++++++++++++++++++++++++++----------------------- > dhcp.c | 8 ++--- > dhcpv6.c | 6 ++-- > fwd.c | 12 +++---- > ip.h | 26 +++++++++++++++ > ndp.c | 6 ++-- > passt.h | 16 ++++++---- > pasta.c | 12 ++++--- > tap.c | 4 +-- > util.h | 1 + > 11 files changed, 122 insertions(+), 70 deletions(-) >=20 > diff --git a/arp.c b/arp.c > index bb042e9..7eaf517 100644 > --- a/arp.c > +++ b/arp.c > @@ -54,7 +54,7 @@ static bool ignore_arp(const struct ctx *c, > return true; > =20 > /* Don't resolve the guest's assigned address, either. */ > - if (!memcmp(am->tip, &c->ip4.addr, sizeof(am->tip))) > + if (!memcmp(am->tip, &c->ip4.addrs[0].addr, sizeof(am->tip))) > return true; > =20 > return false; > @@ -145,7 +145,7 @@ void arp_send_init_req(const struct ctx *c) > memcpy(req.am.sha, c->our_tap_mac, sizeof(req.am.sha)); > memcpy(req.am.sip, &c->ip4.our_tap_addr, sizeof(req.am.sip)); > memcpy(req.am.tha, MAC_BROADCAST, sizeof(req.am.tha)); > - memcpy(req.am.tip, &c->ip4.addr, sizeof(req.am.tip)); > + memcpy(req.am.tip, &c->ip4.addrs[0].addr, sizeof(req.am.tip)); > =20 > debug("Sending initial ARP request for guest MAC address"); > tap_send_single(c, &req, sizeof(req)); > diff --git a/conf.c b/conf.c > index fdc19e8..0e96f36 100644 > --- a/conf.c > +++ b/conf.c > @@ -694,10 +694,12 @@ static int conf_ip4_prefix(const char *arg) > * conf_ip4() - Verify or detect IPv4 support, get relevant addresses > * @ifi: Host interface to attempt (0 to determine one) > * @ip4: IPv4 context (will be written) > + * @permanent: Mark configured addresses as permanent > * > * Return: interface index for IPv4, or 0 on failure. > */ > -static unsigned int conf_ip4(unsigned int ifi, struct ip4_ctx *ip4) > +static unsigned int conf_ip4(unsigned int ifi, struct ip4_ctx *ip4, > + bool permanent) > { > if (!ifi) > ifi =3D nl_get_ext_if(nl_sock, AF_INET); > @@ -717,33 +719,38 @@ static unsigned int conf_ip4(unsigned int ifi, stru= ct ip4_ctx *ip4) > } > } > =20 > - if (IN4_IS_ADDR_UNSPECIFIED(&ip4->addr)) { > + if (!ip4->addr_count) { > int rc =3D nl_addr_get(nl_sock, ifi, AF_INET, > - &ip4->addr, &ip4->prefix_len, NULL); > + &ip4->addrs[0].addr, > + &ip4->addrs[0].prefix_len, NULL); > if (rc < 0) { > debug("Couldn't discover IPv4 address: %s", > strerror_(-rc)); > return 0; > } > + ip4->addrs[0].permanent =3D permanent; > + ip4->addr_count =3D 1; > } > =20 > - if (!ip4->prefix_len) { > - in_addr_t addr =3D ntohl(ip4->addr.s_addr); > - if (IN_CLASSA(addr)) > - ip4->prefix_len =3D (32 - IN_CLASSA_NSHIFT); > - else if (IN_CLASSB(addr)) > - ip4->prefix_len =3D (32 - IN_CLASSB_NSHIFT); > - else if (IN_CLASSC(addr)) > - ip4->prefix_len =3D (32 - IN_CLASSC_NSHIFT); > + /* Apply default prefix_len to first address if not set */ > + if (!ip4->addrs[0].prefix_len) { > + in_addr_t a =3D ntohl(ip4->addrs[0].addr.s_addr); > + > + if (IN_CLASSA(a)) > + ip4->addrs[0].prefix_len =3D 8; > + else if (IN_CLASSB(a)) > + ip4->addrs[0].prefix_len =3D 16; > + else if (IN_CLASSC(a)) > + ip4->addrs[0].prefix_len =3D 24; > else > - ip4->prefix_len =3D 32; > + ip4->addrs[0].prefix_len =3D 32; > } > =20 > - ip4->addr_seen =3D ip4->addr; > + ip4->addr_seen =3D ip4->addrs[0].addr; > =20 > ip4->our_tap_addr =3D ip4->guest_gw; > =20 > - if (IN4_IS_ADDR_UNSPECIFIED(&ip4->addr)) > + if (IN4_IS_ADDR_UNSPECIFIED(&ip4->addrs[0].addr)) > return 0; > =20 > return ifi; > @@ -755,9 +762,9 @@ static unsigned int conf_ip4(unsigned int ifi, struct= ip4_ctx *ip4) > */ > static void conf_ip4_local(struct ip4_ctx *ip4) > { > - ip4->addr_seen =3D ip4->addr =3D IP4_LL_GUEST_ADDR; > + ip4->addr_seen =3D ip4->addrs[0].addr =3D IP4_LL_GUEST_ADDR; > ip4->our_tap_addr =3D ip4->guest_gw =3D IP4_LL_GUEST_GW; > - ip4->prefix_len =3D IP4_LL_PREFIX_LEN; > + ip4->addrs[0].prefix_len =3D IP4_LL_PREFIX_LEN; > =20 > ip4->no_copy_addrs =3D ip4->no_copy_routes =3D true; > } > @@ -766,10 +773,12 @@ static void conf_ip4_local(struct ip4_ctx *ip4) > * conf_ip6() - Verify or detect IPv6 support, get relevant addresses > * @ifi: Host interface to attempt (0 to determine one) > * @ip6: IPv6 context (will be written) > + * @permanent: Mark discovered addresses as permanent > * > * Return: interface index for IPv6, or 0 on failure. > */ > -static unsigned int conf_ip6(unsigned int ifi, struct ip6_ctx *ip6) > +static unsigned int conf_ip6(unsigned int ifi, struct ip6_ctx *ip6, > + bool permanent) > { > int prefix_len =3D 0; > int rc; > @@ -792,19 +801,25 @@ static unsigned int conf_ip6(unsigned int ifi, stru= ct ip6_ctx *ip6) > } > =20 > rc =3D nl_addr_get(nl_sock, ifi, AF_INET6, > - IN6_IS_ADDR_UNSPECIFIED(&ip6->addr) ? &ip6->addr : NULL, > + ip6->addr_count ? NULL : &ip6->addrs[0].addr, > &prefix_len, &ip6->our_tap_ll); > if (rc < 0) { > debug("Couldn't discover IPv6 address: %s", strerror_(-rc)); > return 0; > } > =20 > - ip6->addr_seen =3D ip6->addr; > + if (!ip6->addr_count) { > + ip6->addrs[0].prefix_len =3D prefix_len ? prefix_len : 64; > + ip6->addrs[0].permanent =3D permanent; > + ip6->addr_count =3D 1; > + } > + > + ip6->addr_seen =3D ip6->addrs[0].addr; > =20 > if (IN6_IS_ADDR_LINKLOCAL(&ip6->guest_gw)) > ip6->our_tap_ll =3D ip6->guest_gw; > =20 > - if (IN6_IS_ADDR_UNSPECIFIED(&ip6->addr) || > + if (IN6_IS_ADDR_UNSPECIFIED(&ip6->addrs[0].addr) || > IN6_IS_ADDR_UNSPECIFIED(&ip6->our_tap_ll)) > return 0; > =20 > @@ -1149,11 +1164,13 @@ static void conf_print(const struct ctx *c) > if (!c->no_dhcp) { > uint32_t mask; > =20 > - mask =3D htonl(0xffffffff << (32 - c->ip4.prefix_len)); > + mask =3D htonl(0xffffffff << > + (32 - c->ip4.addrs[0].prefix_len)); > =20 > info("DHCP:"); > info(" assign: %s", > - inet_ntop(AF_INET, &c->ip4.addr, buf4, sizeof(buf4))); > + inet_ntop(AF_INET, &c->ip4.addrs[0].addr, > + buf4, sizeof(buf4))); > info(" mask: %s", > inet_ntop(AF_INET, &mask, buf4, sizeof(buf4))); > info(" router: %s", > @@ -1191,7 +1208,8 @@ static void conf_print(const struct ctx *c) > goto dns6; > =20 > info(" assign: %s", > - inet_ntop(AF_INET6, &c->ip6.addr, buf6, sizeof(buf6))); > + inet_ntop(AF_INET6, &c->ip6.addrs[0].addr, > + buf6, sizeof(buf6))); > info(" router: %s", > inet_ntop(AF_INET6, &c->ip6.guest_gw, buf6, sizeof(buf6))); > info(" our link-local: %s", > @@ -1812,22 +1830,23 @@ void conf(struct ctx *c, int argc, char **argv) > break; > } > case 'a': > - if (inet_pton(AF_INET6, optarg, &c->ip6.addr) && > - !IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr) && > - !IN6_IS_ADDR_LOOPBACK(&c->ip6.addr) && > - !IN6_IS_ADDR_V4MAPPED(&c->ip6.addr) && > - !IN6_IS_ADDR_V4COMPAT(&c->ip6.addr) && > - !IN6_IS_ADDR_MULTICAST(&c->ip6.addr)) { > + if (inet_pton(AF_INET6, optarg, > + &c->ip6.addrs[0].addr) && > + !IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addrs[0].addr) && > + !IN6_IS_ADDR_LOOPBACK(&c->ip6.addrs[0].addr) && > + !IN6_IS_ADDR_V4MAPPED(&c->ip6.addrs[0].addr) && > + !IN6_IS_ADDR_V4COMPAT(&c->ip6.addrs[0].addr) && > + !IN6_IS_ADDR_MULTICAST(&c->ip6.addrs[0].addr)) { > if (c->mode =3D=3D MODE_PASTA) > c->ip6.no_copy_addrs =3D true; > break; > } > =20 > - if (inet_pton(AF_INET, optarg, &c->ip4.addr) && > - !IN4_IS_ADDR_UNSPECIFIED(&c->ip4.addr) && > - !IN4_IS_ADDR_BROADCAST(&c->ip4.addr) && > - !IN4_IS_ADDR_LOOPBACK(&c->ip4.addr) && > - !IN4_IS_ADDR_MULTICAST(&c->ip4.addr)) { > + if (inet_pton(AF_INET, optarg, &c->ip4.addrs[0].addr) && > + !IN4_IS_ADDR_UNSPECIFIED(&c->ip4.addrs[0].addr) && > + !IN4_IS_ADDR_BROADCAST(&c->ip4.addrs[0].addr) && > + !IN4_IS_ADDR_LOOPBACK(&c->ip4.addrs[0].addr) && > + !IN4_IS_ADDR_MULTICAST(&c->ip4.addrs[0].addr)) { > if (c->mode =3D=3D MODE_PASTA) > c->ip4.no_copy_addrs =3D true; > break; > @@ -1836,8 +1855,8 @@ void conf(struct ctx *c, int argc, char **argv) > die("Invalid address: %s", optarg); > break; > case 'n': > - c->ip4.prefix_len =3D conf_ip4_prefix(optarg); > - if (c->ip4.prefix_len < 0) > + c->ip4.addrs[0].prefix_len =3D conf_ip4_prefix(optarg); > + if (c->ip4.addrs[0].prefix_len < 0) > die("Invalid netmask: %s", optarg); > =20 > break; > @@ -1984,9 +2003,9 @@ void conf(struct ctx *c, int argc, char **argv) > =20 > nl_sock_init(c, false); > if (!v6_only) > - c->ifi4 =3D conf_ip4(ifi4, &c->ip4); > + c->ifi4 =3D conf_ip4(ifi4, &c->ip4, c->pasta_conf_ns); > if (!v4_only) > - c->ifi6 =3D conf_ip6(ifi6, &c->ip6); > + c->ifi6 =3D conf_ip6(ifi6, &c->ip6, c->pasta_conf_ns); > =20 > if (c->ifi4 && c->mtu < IPV4_MIN_MTU) { > warn("MTU %"PRIu16" is too small for IPv4 (minimum %u)", > @@ -2125,7 +2144,7 @@ void conf(struct ctx *c, int argc, char **argv) > if (!c->ifi6) { > c->no_ndp =3D 1; > c->no_dhcpv6 =3D 1; > - } else if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr)) { > + } else if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addrs[0].addr)) { > c->no_dhcpv6 =3D 1; > } > =20 > diff --git a/dhcp.c b/dhcp.c > index 6b9c2e3..46ef8e3 100644 > --- a/dhcp.c > +++ b/dhcp.c > @@ -352,7 +352,7 @@ int dhcp(const struct ctx *c, struct iov_tail *data) > reply.secs =3D 0; > reply.flags =3D m->flags; > reply.ciaddr =3D m->ciaddr; > - reply.yiaddr =3D c->ip4.addr; > + reply.yiaddr =3D c->ip4.addrs[0].addr; > reply.siaddr =3D 0; > reply.giaddr =3D m->giaddr; > memcpy(&reply.chaddr, m->chaddr, sizeof(reply.chaddr)); > @@ -404,7 +404,7 @@ int dhcp(const struct ctx *c, struct iov_tail *data) > =20 > info(" from %s", eth_ntop(m->chaddr, macstr, sizeof(macstr))); > =20 > - mask.s_addr =3D htonl(0xffffffff << (32 - c->ip4.prefix_len)); > + mask.s_addr =3D htonl(0xffffffff << (32 - c->ip4.addrs[0].prefix_len)); > memcpy(opts[1].s, &mask, sizeof(mask)); > memcpy(opts[3].s, &c->ip4.guest_gw, sizeof(c->ip4.guest_gw)); > memcpy(opts[54].s, &c->ip4.our_tap_addr, sizeof(c->ip4.our_tap_addr)); > @@ -412,7 +412,7 @@ int dhcp(const struct ctx *c, struct iov_tail *data) > /* If the gateway is not on the assigned subnet, send an option 121 > * (Classless Static Routing) adding a dummy route to it. > */ > - if ((c->ip4.addr.s_addr & mask.s_addr) > + if ((c->ip4.addrs[0].addr.s_addr & mask.s_addr) > !=3D (c->ip4.guest_gw.s_addr & mask.s_addr)) { > /* a.b.c.d/32:0.0.0.0, 0:a.b.c.d */ > opts[121].slen =3D 14; > @@ -469,7 +469,7 @@ int dhcp(const struct ctx *c, struct iov_tail *data) > if (m->flags & FLAG_BROADCAST) > dst =3D in4addr_broadcast; > else > - dst =3D c->ip4.addr; > + dst =3D c->ip4.addrs[0].addr; > =20 > tap_udp4_send(c, c->ip4.our_tap_addr, 67, dst, 68, &reply, dlen); > =20 > diff --git a/dhcpv6.c b/dhcpv6.c > index e4df0db..7eae6a1 100644 > --- a/dhcpv6.c > +++ b/dhcpv6.c > @@ -625,7 +625,7 @@ int dhcpv6(struct ctx *c, struct iov_tail *data, > if (mh->type =3D=3D TYPE_CONFIRM && server_id) > return -1; > =20 > - if (dhcpv6_ia_notonlink(data, &c->ip6.addr)) { > + if (dhcpv6_ia_notonlink(data, &c->ip6.addrs[0].addr)) { > =20 > dhcpv6_send_ia_notonlink(c, data, &client_id_base, > ntohs(client_id->l), mh->xid); > @@ -679,7 +679,7 @@ int dhcpv6(struct ctx *c, struct iov_tail *data, > =20 > tap_udp6_send(c, src, 547, tap_ip6_daddr(c, src), 546, > mh->xid, &resp, n); > - c->ip6.addr_seen =3D c->ip6.addr; > + c->ip6.addr_seen =3D c->ip6.addrs[0].addr; > =20 > return 1; > } > @@ -703,5 +703,5 @@ void dhcpv6_init(const struct ctx *c) > memcpy(resp_not_on_link.server_id.duid_lladdr, > c->our_tap_mac, sizeof(c->our_tap_mac)); > =20 > - resp.ia_addr.addr =3D c->ip6.addr; > + resp.ia_addr.addr =3D c->ip6.addrs[0].addr; > } > diff --git a/fwd.c b/fwd.c > index 44a0e10..408af30 100644 > --- a/fwd.c > +++ b/fwd.c > @@ -516,7 +516,7 @@ static bool fwd_guest_accessible4(const struct ctx *c, > /* For IPv4, addr_seen is initialised to addr, so is always a valid > * address > */ > - if (IN4_ARE_ADDR_EQUAL(addr, &c->ip4.addr) || > + if (IN4_ARE_ADDR_EQUAL(addr, &c->ip4.addrs[0].addr) || > IN4_ARE_ADDR_EQUAL(addr, &c->ip4.addr_seen)) > return false; > =20 > @@ -537,7 +537,7 @@ static bool fwd_guest_accessible6(const struct ctx *c, > if (IN6_IS_ADDR_LOOPBACK(addr)) > return false; > =20 > - if (IN6_ARE_ADDR_EQUAL(addr, &c->ip6.addr)) > + if (IN6_ARE_ADDR_EQUAL(addr, &c->ip6.addrs[0].addr)) > return false; > =20 > /* For IPv6, addr_seen starts unspecified, because we don't know what LL > @@ -587,9 +587,9 @@ static void nat_outbound(const struct ctx *c, const u= nion inany_addr *addr, > else if (inany_equals6(addr, &c->ip6.map_host_loopback)) > *translated =3D inany_loopback6; > else if (inany_equals4(addr, &c->ip4.map_guest_addr)) > - *translated =3D inany_from_v4(c->ip4.addr); > + *translated =3D inany_from_v4(c->ip4.addrs[0].addr); > else if (inany_equals6(addr, &c->ip6.map_guest_addr)) > - translated->a6 =3D c->ip6.addr; > + translated->a6 =3D c->ip6.addrs[0].addr; > else > *translated =3D *addr; > } > @@ -710,10 +710,10 @@ bool nat_inbound(const struct ctx *c, const union i= nany_addr *addr, > inany_equals6(addr, &in6addr_loopback)) { > translated->a6 =3D c->ip6.map_host_loopback; > } else if (!IN4_IS_ADDR_UNSPECIFIED(&c->ip4.map_guest_addr) && > - inany_equals4(addr, &c->ip4.addr)) { > + inany_equals4(addr, &c->ip4.addrs[0].addr)) { > *translated =3D inany_from_v4(c->ip4.map_guest_addr); > } else if (!IN6_IS_ADDR_UNSPECIFIED(&c->ip6.map_guest_addr) && > - inany_equals6(addr, &c->ip6.addr)) { > + inany_equals6(addr, &c->ip6.addrs[0].addr)) { > translated->a6 =3D c->ip6.map_guest_addr; > } else if (fwd_guest_accessible(c, addr)) { > *translated =3D *addr; > diff --git a/ip.h b/ip.h > index 5830b92..748cb1f 100644 > --- a/ip.h > +++ b/ip.h > @@ -135,4 +135,30 @@ static const struct in_addr in4addr_broadcast =3D { = 0xffffffff }; > #define IPV6_MIN_MTU 1280 > #endif > =20 > +/* Maximum number of addresses per address family */ > +#define IP4_MAX_ADDRS 8 > +#define IP6_MAX_ADDRS 16 > + > +/** > + * struct ip4_addr_entry - IPv4 address with prefix length > + * @addr: IPv4 address > + * @prefix_len: Prefix length (netmask bits) > + */ > +struct ip4_addr_entry { > + struct in_addr addr; > + int prefix_len; > + int permanent; Might as well make these uint8_t and bool, respectively. There will be some padding, but the overall structure will still be smaller. Or, it might be worth considering replacing 'permanent' with a flags mask, in case we have future uses for it. > +}; > + > +/** > + * struct ip6_addr_entry - IPv6 address with prefix length > + * @addr: IPv6 address > + * @prefix_len: Prefix length > + */ > +struct ip6_addr_entry { > + struct in6_addr addr; > + int prefix_len; > + int permanent; Ditto. > +}; > + > #endif /* IP_H */ > diff --git a/ndp.c b/ndp.c > index eb9e313..868a234 100644 > --- a/ndp.c > +++ b/ndp.c > @@ -257,7 +257,7 @@ static void ndp_ra(const struct ctx *c, const struct = in6_addr *dst) > .valid_lifetime =3D ~0U, > .pref_lifetime =3D ~0U, > }, > - .prefix =3D c->ip6.addr, > + .prefix =3D c->ip6.addrs[0].addr, > .source_ll =3D { > .header =3D { > .type =3D OPT_SRC_L2_ADDR, > @@ -466,8 +466,8 @@ void ndp_send_init_req(const struct ctx *c) > .icmp6_solicited =3D 0, /* Reserved */ > .icmp6_override =3D 0, /* Reserved */ > }, > - .target_addr =3D c->ip6.addr > + .target_addr =3D c->ip6.addrs[0].addr > }; > debug("Sending initial NDP NS request for guest MAC address"); > - ndp_send(c, &c->ip6.addr, &ns, sizeof(ns)); > + ndp_send(c, &c->ip6.addrs[0].addr, &ns, sizeof(ns)); > } > diff --git a/passt.h b/passt.h > index 79d01dd..533f2cb 100644 > --- a/passt.h > +++ b/passt.h > @@ -66,9 +66,9 @@ enum passt_modes { > =20 > /** > * struct ip4_ctx - IPv4 execution context > - * @addr: IPv4 address assigned to guest > + * @addrs: IPv4 addresses assigned to guest > + * @addr_count: Number of addresses in addrs[] array > * @addr_seen: Latest IPv4 address seen as source from tap > - * @prefixlen: IPv4 prefix length (netmask) > * @guest_gw: IPv4 gateway as seen by the guest > * @map_host_loopback: Outbound connections to this address are NATted t= o the > * host's 127.0.0.1 > @@ -85,9 +85,10 @@ enum passt_modes { > */ > struct ip4_ctx { > /* PIF_TAP addresses */ > - struct in_addr addr; > + struct ip4_addr_entry addrs[IP4_MAX_ADDRS]; > + int addr_count; > + > struct in_addr addr_seen; > - int prefix_len; > struct in_addr guest_gw; > struct in_addr map_host_loopback; > struct in_addr map_guest_addr; > @@ -107,7 +108,8 @@ struct ip4_ctx { > =20 > /** > * struct ip6_ctx - IPv6 execution context > - * @addr: IPv6 address assigned to guest > + * @addrs: IPv6 addresses assigned to guest > + * @addr_count: Number of addresses in addrs[] array > * @addr_seen: Latest IPv6 global/site address seen as source from tap > * @addr_ll_seen: Latest IPv6 link-local address seen as source from tap > * @guest_gw: IPv6 gateway as seen by the guest > @@ -126,7 +128,9 @@ struct ip4_ctx { > */ > struct ip6_ctx { > /* PIF_TAP addresses */ > - struct in6_addr addr; > + struct ip6_addr_entry addrs[IP6_MAX_ADDRS]; > + int addr_count; > + > struct in6_addr addr_seen; > struct in6_addr addr_ll_seen; > struct in6_addr guest_gw; > diff --git a/pasta.c b/pasta.c > index 674b554..49b393c 100644 > --- a/pasta.c > +++ b/pasta.c > @@ -331,8 +331,8 @@ void pasta_ns_conf(struct ctx *c) > if (c->ip4.no_copy_addrs) { > rc =3D nl_addr_set(nl_sock_ns, c->pasta_ifi, > AF_INET, > - &c->ip4.addr, > - c->ip4.prefix_len); > + &c->ip4.addrs[0].addr, > + c->ip4.addrs[0].prefix_len); > } else { > rc =3D nl_addr_dup(nl_sock, c->ifi4, > nl_sock_ns, c->pasta_ifi, > @@ -378,10 +378,12 @@ void pasta_ns_conf(struct ctx *c) > 0, IFF_NOARP); > =20 > if (c->ip6.no_copy_addrs) { > - if (!IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr)) { > + struct in6_addr *a =3D &c->ip6.addrs[0].addr; > + > + if (!IN6_IS_ADDR_UNSPECIFIED(a)) { > rc =3D nl_addr_set(nl_sock_ns, > - c->pasta_ifi, AF_INET6, > - &c->ip6.addr, 64); > + c->pasta_ifi, > + AF_INET6, a, 64); > } > } else { > rc =3D nl_addr_dup(nl_sock, c->ifi6, > diff --git a/tap.c b/tap.c > index e3ea61c..0b96cc1 100644 > --- a/tap.c > +++ b/tap.c > @@ -951,8 +951,8 @@ resume: > c->ip6.addr_seen =3D *saddr; > } > =20 > - if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr)) > - c->ip6.addr =3D *saddr; > + if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addrs[0].addr)) > + c->ip6.addrs[0].addr =3D *saddr; > } else if (!IN6_IS_ADDR_UNSPECIFIED(saddr)){ > c->ip6.addr_seen =3D *saddr; > } > diff --git a/util.h b/util.h > index f7a941f..4273e0d 100644 > --- a/util.h > +++ b/util.h > @@ -401,4 +401,5 @@ static inline int wrap_getsockname(int sockfd, struct= sockaddr *addr, > #define PASST_MAXDNAME 254 /* 253 (RFC 1035) + 1 (the terminator) */ > void encode_domain_name(char *buf, const char *domain_name); > =20 > + > #endif /* UTIL_H */ > --=20 > 2.51.1 >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --PN/M7I6IZuD8ioTT Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmk/13QACgkQzQJF27ox 2GdI8w//SKlNO3vkj/VvqQBtgJR+ma2CpcgmM9ckIgfnc9kVemBXfWT+BumqznVt 45JptdhTiGRgPU26c7XSFuibwj5e9bO+Qkj2jMazLragXTIlbC9Cr9F7wlTz4cP2 nOOwv4zY7p/yMI3Q2Udy2LFHNBnX59ja9O1ARXTzxD8D9wbec8T4sw0wx+ibHLyU IPxrxGmZHnoLJYKkQjAXuHaSAph71CM3oW9Gb22mb6hv8ER7qVYwVRbq7v7xSZbT jI5quCFm2L4WmOOeIg/8aY1usyn9LZlR8us+amS2bV8LAgB5+6/8+sQVzEKhGUPe 70l+bnIFOp4JeHV+98WZ81IIqkSN5VFgmpEk9LU7+e4DziH4eYh9bTcXYz3Y4yqY 4wL1fREKwwKFgI08YeXYvjsVAig1iY9YNJP8oCV+KGVD9Sem3tFrbNz1qXC+Hcos EmNaT4tDvlEVuyUcckJGkawWIjSpZO8Sa+U4YmcVYXZ4FrP/jjIsFzPh8e+JBODN 8n/7GYFANOPKW0W8tS1nDH6gxKPHYJjEfUpjABqEXmSHkDT/k77SWui3eDLEkuGF 7xPa9XPkpdXOBBd3rYEyWIXbWAeyUuAEd4ecWxVnlgo+iFhmk0/uWAN8Nir+eeMJ s7MG6BEjmVyBtnvhWmka6eboNQ0D3iM3Bx/IyoPQ3+j5XInAJQU= =MvyA -----END PGP SIGNATURE----- --PN/M7I6IZuD8ioTT--