From 16304a8cb4765f7a21f945cca1e542d0862d12fa Mon Sep 17 00:00:00 2001 From: Dave Voutila Date: Thu, 13 Jul 2023 18:32:00 +0000 Subject: 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@ --- usr.sbin/vmd/virtio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'usr.sbin/vmd/virtio.c') 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 @@ -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), -- cgit v1.2.3