Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145790054
D50446.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D50446.diff
View Options
diff --git a/sys/dev/wg/if_wg.c b/sys/dev/wg/if_wg.c
--- a/sys/dev/wg/if_wg.c
+++ b/sys/dev/wg/if_wg.c
@@ -2461,8 +2461,12 @@
aipl = nvlist_get_nvlist_array(nvl, "allowed-ips", &allowedip_count);
for (size_t idx = 0; idx < allowedip_count; idx++) {
+ sa_family_t ipaf;
+
if (!nvlist_exists_number(aipl[idx], "cidr"))
continue;
+
+ ipaf = AF_UNSPEC;
cidr = nvlist_get_number(aipl[idx], "cidr");
if (nvlist_exists_binary(aipl[idx], "ipv4")) {
addr = nvlist_get_binary(aipl[idx], "ipv4", &size);
@@ -2470,19 +2474,23 @@
err = EINVAL;
goto out;
}
- if ((err = wg_aip_add(sc, peer, AF_INET, addr, cidr)) != 0)
- goto out;
+
+ ipaf = AF_INET;
} else if (nvlist_exists_binary(aipl[idx], "ipv6")) {
addr = nvlist_get_binary(aipl[idx], "ipv6", &size);
if (addr == NULL || cidr > 128 || size != sizeof(struct in6_addr)) {
err = EINVAL;
goto out;
}
- if ((err = wg_aip_add(sc, peer, AF_INET6, addr, cidr)) != 0)
- goto out;
+
+ ipaf = AF_INET6;
} else {
continue;
}
+
+ MPASS(ipaf != AF_UNSPEC);
+ if ((err = wg_aip_add(sc, peer, ipaf, addr, cidr)) != 0)
+ goto out;
}
}
if (remote != NULL)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Feb 25, 12:58 PM (1 m, 21 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28988426
Default Alt Text
D50446.diff (1 KB)
Attached To
Mode
D50446: kern: wg: refactor out some repetitive bits in allowed-ip config
Attached
Detach File
Event Timeline
Log In to Comment