]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: accept all values provided by kernel
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Nov 2021 13:50:35 +0000 (22:50 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 16 Nov 2021 23:31:24 +0000 (23:31 +0000)
Follow-up for af493fb742bece2cafcdbab9238c711ac9090c9f.

The kernel sends FRA_SUPPRESS_IFGROUP attribute with -1, that must be
handled by networkd.

For FRA_SUPPRESS_PREFIXLEN, we already handled -1, but ignored values
larger than 128. We should not configure rules with such a meaningless
value, but should manage such rules when received from kernel. It can
occur when created by other tools mistakenly. If networkd ignores them,
then networkd cannot remove them.

src/network/networkd-routing-policy-rule.c

index 1d0dff56ce274ab7660e778344a3ced2325a9b18..72ef39f4579bce004120f6f373fba25efe836391 100644 (file)
@@ -1061,14 +1061,8 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Man
                 log_warning_errno(r, "rtnl: could not get FRA_SUPPRESS_PREFIXLEN attribute, ignoring: %m");
                 return 0;
         }
-        if (r >= 0) {
-                /* kernel does not limit this value, but we do. */
-                if (suppress_prefixlen > 128) {
-                        log_warning("rtnl: received invalid FRA_SUPPRESS_PREFIXLEN attribute value %"PRIu32", ignoring.", suppress_prefixlen);
-                        return 0;
-                }
+        if (r >= 0)
                 tmp->suppress_prefixlen = (int32_t) suppress_prefixlen;
-        }
 
         uint32_t suppress_ifgroup;
         r = sd_netlink_message_read_u32(message, FRA_SUPPRESS_IFGROUP, &suppress_ifgroup);
@@ -1076,13 +1070,8 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Man
                 log_warning_errno(r, "rtnl: could not get FRA_SUPPRESS_IFGROUP attribute, ignoring: %m");
                 return 0;
         }
-        if (r >= 0) {
-                if (suppress_ifgroup > INT32_MAX) {
-                        log_warning("rtnl: received invalid FRA_SUPPRESS_IFGROUP attribute value %"PRIu32", ignoring.", suppress_ifgroup);
-                        return 0;
-                }
+        if (r >= 0)
                 tmp->suppress_ifgroup = (int32_t) suppress_ifgroup;
-        }
 
         if (adjust_protocol)
                 /* As .network files does not have setting to specify protocol, we can assume the