]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/network/networkd-ndisc.c
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / src / network / networkd-ndisc.c
index 84625f7fa923da770af1e6203f3681b8ecfa3520..c3053c007b8cf7e82f0d6f0b911e7265762b0f3f 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "sd-ndisc.h"
 
+#include "missing_network.h"
 #include "networkd-ndisc.h"
 #include "networkd-route.h"
 #include "strv.h"
@@ -102,7 +103,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
                 return log_link_error_errno(link, r, "Could not allocate route: %m");
 
         route->family = AF_INET6;
-        route->table = link->network->ipv6_accept_ra_route_table;
+        route->table = link_get_ipv6_accept_ra_route_table(link);
         route->priority = link->network->dhcp_route_metric;
         route->protocol = RTPROT_RA;
         route->pref = preference;
@@ -237,7 +238,7 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) {
                 return log_link_error_errno(link, r, "Could not allocate route: %m");
 
         route->family = AF_INET6;
-        route->table = link->network->ipv6_accept_ra_route_table;
+        route->table = link_get_ipv6_accept_ra_route_table(link);
         route->priority = link->network->dhcp_route_metric;
         route->protocol = RTPROT_RA;
         route->flags = RTM_F_PREFIX;
@@ -298,7 +299,7 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
                 return log_link_error_errno(link, r, "Could not allocate route: %m");
 
         route->family = AF_INET6;
-        route->table = link->network->ipv6_accept_ra_route_table;
+        route->table = link_get_ipv6_accept_ra_route_table(link);
         route->protocol = RTPROT_RA;
         route->pref = preference;
         route->gw.in6 = gateway;
@@ -321,22 +322,15 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
         return 0;
 }
 
-static void ndisc_rdnss_hash_func(const void *p, struct siphash *state) {
-        const NDiscRDNSS *x = p;
-
+static void ndisc_rdnss_hash_func(const NDiscRDNSS *x, struct siphash *state) {
         siphash24_compress(&x->address, sizeof(x->address), state);
 }
 
-static int ndisc_rdnss_compare_func(const void *_a, const void *_b) {
-        const NDiscRDNSS *a = _a, *b = _b;
-
+static int ndisc_rdnss_compare_func(const NDiscRDNSS *a, const NDiscRDNSS *b) {
         return memcmp(&a->address, &b->address, sizeof(a->address));
 }
 
-static const struct hash_ops ndisc_rdnss_hash_ops = {
-        .hash = ndisc_rdnss_hash_func,
-        .compare = ndisc_rdnss_compare_func
-};
+DEFINE_PRIVATE_HASH_OPS(ndisc_rdnss_hash_ops, NDiscRDNSS, ndisc_rdnss_hash_func, ndisc_rdnss_compare_func);
 
 static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
         uint32_t lifetime;
@@ -410,22 +404,15 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
         return 0;
 }
 
-static void ndisc_dnssl_hash_func(const void *p, struct siphash *state) {
-        const NDiscDNSSL *x = p;
-
+static void ndisc_dnssl_hash_func(const NDiscDNSSL *x, struct siphash *state) {
         siphash24_compress(NDISC_DNSSL_DOMAIN(x), strlen(NDISC_DNSSL_DOMAIN(x)), state);
 }
 
-static int ndisc_dnssl_compare_func(const void *_a, const void *_b) {
-        const NDiscDNSSL *a = _a, *b = _b;
-
+static int ndisc_dnssl_compare_func(const NDiscDNSSL *a, const NDiscDNSSL *b) {
         return strcmp(NDISC_DNSSL_DOMAIN(a), NDISC_DNSSL_DOMAIN(b));
 }
 
-static const struct hash_ops ndisc_dnssl_hash_ops = {
-        .hash = ndisc_dnssl_hash_func,
-        .compare = ndisc_dnssl_compare_func
-};
+DEFINE_PRIVATE_HASH_OPS(ndisc_dnssl_hash_ops, NDiscDNSSL, ndisc_dnssl_hash_func, ndisc_dnssl_compare_func);
 
 static void ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
         _cleanup_strv_free_ char **l = NULL;
@@ -540,10 +527,13 @@ static void ndisc_router_process_options(Link *link, sd_ndisc_router *rt) {
                                 return;
                         }
 
-                        if (flags & ND_OPT_PI_FLAG_ONLINK)
-                                (void) ndisc_router_process_onlink_prefix(link, rt);
-                        if (flags & ND_OPT_PI_FLAG_AUTO)
-                                (void) ndisc_router_process_autonomous_prefix(link, rt);
+                        if (link->network->ipv6_accept_ra_use_onlink_prefix)
+                                if (flags & ND_OPT_PI_FLAG_ONLINK)
+                                        (void) ndisc_router_process_onlink_prefix(link, rt);
+
+                        if (link->network->ipv6_accept_ra_use_autonomous_prefix)
+                                if (flags & ND_OPT_PI_FLAG_AUTO)
+                                        (void) ndisc_router_process_autonomous_prefix(link, rt);
 
                         break;
                 }