Apart from the one inline comment, looks good to me. IMO it's not too restrictive, since IPv4 network/broadcast addresses shouldn't really be used (and probably introduce subtle breakages) outside of /31 prefixes anyway.
On Tue Apr 29, 2025 at 4:09 PM CEST, Michael Köppl wrote: > Add checks for valid subnet mask (greater than /0 and at most /32 for > IPv4). In addition, check if the address entered by the user is valid > within the given subnet, i.e. not a network address or broadcast > address. /31 is considered an exception in accordance with RFC3021 [0], > considering any of the 2 available addresses to be valid host addresses. > > [0] https://datatracker.ietf.org/doc/html/rfc3021 > > Signed-off-by: Michael Köppl <m.koe...@proxmox.com> > --- > [..] > diff --git a/proxmox-installer-common/src/utils.rs > b/proxmox-installer-common/src/utils.rs > index 1fe6a74..fea98db 100644 > --- a/proxmox-installer-common/src/utils.rs > +++ b/proxmox-installer-common/src/utils.rs > [..] > @@ -133,6 +137,43 @@ fn mask_limit(addr: &IpAddr) -> usize { > if addr.is_ipv4() { 32 } else { 128 } > } > > +fn check_mask_limit(addr: &IpAddr, mask: usize) -> Result<(), > CidrAddressParseError> { > + return if mask > mask_limit(&addr) { > + Err(CidrAddressParseError::InvalidMask( > + "mask cannot be greater than 32".into(), s/32/mask_limit(&addr)/g > + )) > + } else { > + Ok(()) > + }; > +} _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel