]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/routing-policy-rule: use int32_t for suppress_prefixlen
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 17 Aug 2024 11:13:12 +0000 (20:13 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 19 Aug 2024 17:21:21 +0000 (02:21 +0900)
The kernel parses FRA_SUPPRESS_PREFIXLEN as uint32_t, but internally
handled as signed integer and negative values as unset. Let's explicitly
specify the size of the variable.

No functional change, just refactoring.

src/basic/parse-util.c
src/basic/parse-util.h
src/network/networkd-routing-policy-rule.h

index 35d13eb38f6fc915843e8a4ca7fa4b7e60ed8fec..5ace2b9b11c2f455808a4dfafbe8c2df30fb991a 100644 (file)
@@ -714,7 +714,7 @@ int parse_ip_port_range(const char *s, uint16_t *low, uint16_t *high, bool allow
         return 0;
 }
 
-int parse_ip_prefix_length(const char *s, int *ret) {
+int parse_ip_prefix_length(const char *s, int32_t *ret) {
         unsigned l;
         int r;
 
@@ -725,7 +725,7 @@ int parse_ip_prefix_length(const char *s, int *ret) {
         if (l > 128)
                 return -ERANGE;
 
-        *ret = (int) l;
+        *ret = (int32_t) l;
 
         return 0;
 }
index c12988ef2049794b7ac69c095495b34a081ba3a5..e4ae48366c27b7bcc4abef9a295d2623203c5634 100644 (file)
@@ -141,7 +141,7 @@ int parse_nice(const char *p, int *ret);
 int parse_ip_port(const char *s, uint16_t *ret);
 int parse_ip_port_range(const char *s, uint16_t *low, uint16_t *high, bool allow_zero);
 
-int parse_ip_prefix_length(const char *s, int *ret);
+int parse_ip_prefix_length(const char *s, int32_t *ret);
 
 int parse_oom_score_adjust(const char *s, int *ret);
 
index 23aa041180c88fc33721b0c8ade67d87b8b51b51..fbde298f052dcd7d5ad9870720267ac55eb895de 100644 (file)
@@ -40,7 +40,7 @@ typedef struct RoutingPolicyRule {
         /* FRA_FLOW */
         /* FRA_TUN_ID */
         int32_t suppress_ifgroup; /* FRA_SUPPRESS_IFGROUP */
-        int suppress_prefixlen; /* FRA_SUPPRESS_PREFIXLEN */
+        int32_t suppress_prefixlen; /* FRA_SUPPRESS_PREFIXLEN */
         uint32_t table; /* FRA_TABLE, also used in struct fib_rule_hdr */
         uint32_t fwmask; /* FRA_FWMASK */
         char *oif; /* FRA_OIFNAME */