Thomas Huth, on Wed 17 Feb 2016 12:59:04 +0100, wrote:
> The IPv4 code seems to have a sanity check that the vhost address is
> within the same net as specified with the "net=" parameter... maybe the
> IPv6 part should have that, too? Or use the prefix from "ip6-net=" here
> if ip6-host has not been specified manually?
I'd say the latter indeed. I have reworked this part of the code, and
then the implementation matches the documentation :)
@@ -235,6 +242,52 @@ static int net_slirp_init(NetClientState *peer, const char
*model,
}
#endif
+
+ if (!vprefix6) {
+ vprefix6 = "fec0::";
+ }
+ if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) {
+ return -1;
+ }
+
+ if (!vprefix6_len) {
+ vprefix6_len = 64;
+ }
+ if (vprefix6_len < 0 || vprefix6_len > 128) {
+ return -1;
+ }
+
+ if (vhost6) {
+ if (!inet_pton(AF_INET6, vhost6, &ip6_host)) {
+ return -1;
+ }
+ if (!in6_equal_net(&ip6_prefix, &ip6_host, vprefix6_len)) {
+ return -1;
+ }
+ } else {
+ if (vprefix6_len > 126) {
+ return -1;
+ }
+ ip6_host = ip6_prefix;
+ ip6_host.s6_addr[15] |= 2;
+ }
+
+ if (vnameserver6) {
+ if (!inet_pton(AF_INET6, vnameserver6, &ip6_dns)) {
+ return -1;
+ }
+ if (!in6_equal_net(&ip6_prefix, &ip6_dns, vprefix6_len)) {
+ return -1;
+ }
+ } else {
+ if (vprefix6_len > 126) {
+ return -1;
+ }
+ ip6_dns = ip6_prefix;
+ ip6_dns.s6_addr[15] |= 3;
+ }
+
+
nc = qemu_new_net_client(&net_slirp_info, peer, model, name);
snprintf(nc->info_str, sizeof(nc->info_str),