]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
ipc: add stub for allowedips flags on other platforms
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 20 May 2025 20:12:39 +0000 (22:12 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 20 May 2025 20:12:39 +0000 (22:12 +0200)
On UAPI, just pass along the -. On other platforms, return an error and
add a TODO comment.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/ipc-freebsd.h
src/ipc-openbsd.h
src/ipc-uapi.h
src/ipc-windows.h

index 446f13cacac265d96a7176d1de479e7f1a0b12ff..58e5e71ce5cb4f4dff6b50cf9101a1926587bf99 100644 (file)
@@ -307,6 +307,11 @@ static int kernel_set_device(struct wgdevice *dev)
                        nvl_aips[j] = nvlist_create(0);
                        if (!nvl_aips[j])
                                goto err_peer;
+                       if (aip->flags) {
+                               //TODO: implement me
+                               ret = -EOPNOTSUPP;
+                               goto err_peer;
+                       }
                        nvlist_add_number(nvl_aips[j], "cidr", aip->cidr);
                        if (aip->family == AF_INET)
                                nvlist_add_binary(nvl_aips[j], "ipv4", &aip->ip4, sizeof(aip->ip4));
index 03fbdb5cb5380ef01adf95af2d5a72c9daf63440..6bb231ecce9e3c678c3ac5379239de76758eeef5 100644 (file)
@@ -252,6 +252,11 @@ static int kernel_set_device(struct wgdevice *dev)
                aip_count = 0;
                wg_aip = &wg_peer->p_aips[0];
                for_each_wgallowedip(peer, aip) {
+                       if (aip->flags) {
+                               //TODO: implement me
+                               errno = EOPNOTSUPP;
+                               goto out;
+                       }
                        wg_aip->a_af = aip->family;
                        wg_aip->a_cidr = aip->cidr;
 
index f582916ecc9f93c601739c3f92e4391e7543f00a..1d8a2710250a87aa6366b7022eb6913d72b3e0d4 100644 (file)
@@ -89,7 +89,7 @@ static int userspace_set_device(struct wgdevice *dev)
                                        continue;
                        } else
                                continue;
-                       fprintf(f, "allowed_ip=%s/%d\n", ip, allowedip->cidr);
+                       fprintf(f, "allowed_ip=%s%s/%d\n", (allowedip->flags & WGALLOWEDIP_REMOVE_ME) ? "-" : "", ip, allowedip->cidr);
                }
        }
        fprintf(f, "\n");
index d237fc9d67e48da09bb6a82612652cf81c5c3ce0..a71911e67354800d85dd07f9790b7bc891bf7b0f 100644 (file)
@@ -418,6 +418,12 @@ static int kernel_set_device(struct wgdevice *dev)
                aip_count = 0;
                wg_aip = (void *)wg_peer + sizeof(WG_IOCTL_PEER);
                for_each_wgallowedip(peer, aip) {
+                       if (aip->flags) {
+                               //TODO: implement me
+                               errno = EOPNOTSUPP;
+                               goto out;
+                       }
+
                        wg_aip->AddressFamily = aip->family;
                        wg_aip->Cidr = aip->cidr;