summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/virtio.c
diff options
context:
space:
mode:
authorDave Voutila <dv@cvs.openbsd.org>2023-07-13 18:32:00 +0000
committerDave Voutila <dv@cvs.openbsd.org>2023-07-13 18:32:00 +0000
commit16304a8cb4765f7a21f945cca1e542d0862d12fa (patch)
treebd7cd35510bdb7eb306e38b2c70ec94c004fd178 /usr.sbin/vmd/virtio.c
parenta21908be871bf90d19d64abdea46e78908e00300 (diff)
vmd(8): pull validation into local prefix parser.
Validation for local prefixes, both inet and inet6, was scattered around. To make it even more confusing, vmd was using generic address parsing logic from prior network daemons. vmd doesn't need to parse addresses other than when parsing the local prefix settings in vm.conf and no runtime parsing is needed. This change merges parsing and validation based on vmd's specific needs for local prefixes (e.g. reserving enough bits for vm id and network interface id encoding in an ipv4 address). In addition, it simplifies the struct from a generic address struct to one focused on just storing the v4 and v6 prefixes and masks. This cleans up an unused TAILQ struct member that isn't used by vmd and was leftover copy-pasta from those prior daemons. The address parsing that vmd uses is also updated to using the latest logic in bgpd(8). ok mlarkin@
Diffstat (limited to 'usr.sbin/vmd/virtio.c')
-rw-r--r--usr.sbin/vmd/virtio.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/vmd/virtio.c b/usr.sbin/vmd/virtio.c
index d29b9e7b883..6167a7764cb 100644
--- a/usr.sbin/vmd/virtio.c
+++ b/usr.sbin/vmd/virtio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: virtio.c,v 1.103 2023/05/13 23:15:28 dv Exp $ */
+/* $OpenBSD: virtio.c,v 1.104 2023/07/13 18:31:59 dv Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -591,7 +591,9 @@ virtio_init(struct vmd_vm *vm, int child_cdrom,
vmc->vmc_ifflags[i] & VMIFF_LOCAL ? 1 : 0;
if (i == 0 && vmc->vmc_bootdevice & VMBOOTDEV_NET)
dev->vionet.pxeboot = 1;
-
+ memcpy(&dev->vionet.local_prefix,
+ &env->vmd_cfg.cfg_localprefix,
+ sizeof(dev->vionet.local_prefix));
log_debug("%s: vm \"%s\" vio%u lladdr %s%s%s%s",
__func__, vcp->vcp_name, i,
ether_ntoa((void *)dev->vionet.mac),