]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce route_by_kernel() helper function 20702/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Sep 2021 06:26:27 +0000 (15:26 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 10 Sep 2021 08:06:24 +0000 (17:06 +0900)
And drop "FIXME" from comment, as there is nothing we need to fix.

src/network/networkd-route.c

index a364ca45b79a66a5be7b27daed1d403307600999..c01f1ca14ae40175562e4c9e91ee5d930a3a2c79 100644 (file)
@@ -1187,6 +1187,24 @@ static int manager_drop_routes(Manager *manager, const Link *except) {
         return manager_drop_routes_internal(manager, false, except);
 }
 
+static bool route_by_kernel(const Route *route) {
+        assert(route);
+
+        if (route->protocol == RTPROT_KERNEL)
+                return true;
+
+        /* Do not touch multicast route added by kernel. See issue #6088.
+         * TODO: Why the kernel adds this route with protocol RTPROT_BOOT?
+         * https://tools.ietf.org/html/rfc4862#section-5.4 may explain why. */
+        if (route->protocol == RTPROT_BOOT &&
+            route->family == AF_INET6 &&
+            route->dst_prefixlen == 8 &&
+            in6_addr_equal(&route->dst.in6, & (struct in6_addr) {{{ 0xff,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 }}}))
+                return true;
+
+        return false;
+}
+
 int link_drop_foreign_routes(Link *link) {
         Route *route;
         int k, r = 0;
@@ -1196,16 +1214,7 @@ int link_drop_foreign_routes(Link *link) {
 
         SET_FOREACH(route, link->routes_foreign) {
                 /* do not touch routes managed by the kernel */
-                if (route->protocol == RTPROT_KERNEL)
-                        continue;
-
-                /* do not touch multicast route added by kernel */
-                /* FIXME: Why the kernel adds this route with protocol RTPROT_BOOT??? We need to investigate that.
-                 * https://tools.ietf.org/html/rfc4862#section-5.4 may explain why. */
-                if (route->protocol == RTPROT_BOOT &&
-                    route->family == AF_INET6 &&
-                    route->dst_prefixlen == 8 &&
-                    in_addr_equal(AF_INET6, &route->dst, &(union in_addr_union) { .in6 = {{{ 0xff,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 }}} }))
+                if (route_by_kernel(route))
                         continue;
 
                 if (route->protocol == RTPROT_STATIC && link->network &&