On Wed, 27 Nov 2024 23:21:33 +0000 Jordan Rife wrote: > The second command fails with "Invalid argument" (EINVAL) on the > unpatched kernel. This simplifies things, as there's no need for > clients to explicitly probe to see if this attribute is supported. I > will do the following: > > 1. Revert WG_GENL_VERSION back to 1. > 2. Add a check for new flags similar to the one you mentioned for > WGPEER_A_FLAGS. > > if (attrs[WGPEER_A_FLAGS]) > flags = nla_get_u32(attrs[WGPEER_A_FLAGS]); > ret = -EOPNOTSUPP; > if (flags & ~__WGPEER_F_ALL) > goto out; > > This should be sufficient. We might want to consider how best to bubble > this error up to users. In the case of wg, "Invalid argument" may not be > very helpful in determining where you went wrong. We could always detect > when EINVAL is returned in response to an operation that sets > WGALLOWEDIP_A_FLAGS and print something more helpful like "Operation not > supported on this kernel". However, these are details that can be worked > out. Better still use NLA_POLICY_MASK() so that nla_parse_nested() can perform the validation and attach a machine readable info about the failure.