diff options
| author | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-10-06 02:24:50 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-10-06 02:24:50 +0300 |
| commit | b8a3c54aa34434312aa0053686ec37a133fb54e6 (patch) | |
| tree | 4dca27724df4224c23fde20ac7ae4502879f5dad /accel-pppd/include | |
| parent | d33028de8b8b520dfde12d9d9d01f4cd576f23b3 (diff) | |
| parent | 2823a07df0c88e9d98472b9248f2e9c3179f6920 (diff) | |
| download | accel-ppp-b8a3c54aa34434312aa0053686ec37a133fb54e6.tar.gz accel-ppp-b8a3c54aa34434312aa0053686ec37a133fb54e6.zip | |
Merge pull request #356 from nuclearcat/ipv6-dns-review-fixes
IPv6 DNS fixes
Diffstat (limited to 'accel-pppd/include')
| -rw-r--r-- | accel-pppd/include/ap_session.h | 8 | ||||
| -rw-r--r-- | accel-pppd/include/ipv6_dns.h | 46 |
2 files changed, 24 insertions, 30 deletions
diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h index a0733986..3bc8360b 100644 --- a/accel-pppd/include/ap_session.h +++ b/accel-pppd/include/ap_session.h @@ -41,6 +41,7 @@ struct ap_session; struct backup_data; struct rtnl_link_stats; +struct ipv6_dns_t; struct ap_ctrl { struct triton_context_t *ctx; @@ -87,10 +88,9 @@ struct ap_session struct ipv6db_prefix_t *ipv6_dp; /* Per session IPv6 DNS servers, NULL when none were assigned and the globally configured ones ([ipv6-dns]) should be advertised instead. - Only addr_list, and only the addr member of its entries, is - meaningful here. Owned by whoever sets it, currently the radius - module from the DNS-Server-IPv6-Address attribute (RFC 6911) */ - struct ipv6db_item_t *ipv6_dns; + Owned by whoever sets it, currently the radius module from the + DNS-Server-IPv6-Address attribute (RFC 6911) */ + struct ipv6_dns_t *ipv6_dns; char *ipv4_pool_name; char *ipv6_pool_name; char *dpv6_pool_name; diff --git a/accel-pppd/include/ipv6_dns.h b/accel-pppd/include/ipv6_dns.h index b604d006..e82812ce 100644 --- a/accel-pppd/include/ipv6_dns.h +++ b/accel-pppd/include/ipv6_dns.h @@ -3,10 +3,18 @@ #include <netinet/in.h> -#include "list.h" -#include "ipdb.h" #include "ap_session.h" +#define IPV6_DNS_INITIAL_CAPACITY 4 + +struct ipv6_dns_t { + struct in6_addr *addr; + unsigned int count; + unsigned int capacity; +}; + +int ipv6_dns_reserve(struct ipv6_dns_t *dns, unsigned int count); + /* * Pick the IPv6 DNS servers to advertise to a session. * @@ -15,34 +23,20 @@ * precedence. Sessions without any fall back to the globally configured ones, * which is what every session got before per session servers existed. * - * Up to 'max' addresses are written to 'dns', the number written is returned. - * Callers advertise nothing when that is 0. + * The selected array is returned and its length is written to 'count'. + * Callers advertise nothing when the returned count is 0. */ -static inline int ipv6_dns_get(const struct ap_session *ses, - const struct in6_addr *conf_dns, int conf_dns_count, - struct in6_addr *dns, int max) +static inline const struct in6_addr *ipv6_dns_get(const struct ap_session *ses, + const struct in6_addr *conf_dns, + int conf_dns_count, int *count) { - struct ipv6db_addr_t *a; - int count = 0; - - if (ses && ses->ipv6_dns) { - list_for_each_entry(a, &ses->ipv6_dns->addr_list, entry) { - if (count == max) - break; - dns[count++] = a->addr; - } - - /* An empty list means "nothing assigned", not "no DNS at all" */ - if (count) - return count; - } - - while (count < conf_dns_count && count < max) { - dns[count] = conf_dns[count]; - count++; + if (ses && ses->ipv6_dns && ses->ipv6_dns->count) { + *count = ses->ipv6_dns->count; + return ses->ipv6_dns->addr; } - return count; + *count = conf_dns_count; + return conf_dns; } #endif |
