network/routing-policy-rule: manage all flags

Currently, only FIB_RULE_INVERT flag can be configurable, but for
simplicity and future extension, let's manage all flags.

No functional change, just refactoring.
This commit is contained in:
Yu Watanabe
2024-08-20 02:21:21 +09:00
parent 933448defe
commit 957d94c5bd
3 changed files with 7 additions and 11 deletions
+1 -1
View File
@@ -316,7 +316,7 @@ static int routing_policy_rule_append_json(RoutingPolicyRule *rule, sd_json_vari
SD_JSON_BUILD_PAIR_UNSIGNED("FirewallMask", rule->fwmask),
JSON_BUILD_PAIR_UNSIGNED_NON_ZERO("Table", rule->table),
JSON_BUILD_PAIR_STRING_NON_EMPTY("TableString", table),
SD_JSON_BUILD_PAIR_BOOLEAN("Invert", rule->invert_rule),
SD_JSON_BUILD_PAIR_BOOLEAN("Invert", FLAGS_SET(rule->flags, FIB_RULE_INVERT)),
SD_JSON_BUILD_PAIR_CONDITION(rule->suppress_prefixlen >= 0,
"SuppressPrefixLength", SD_JSON_BUILD_UNSIGNED(rule->suppress_prefixlen)),
SD_JSON_BUILD_PAIR_CONDITION(rule->suppress_ifgroup >= 0,
+5 -9
View File
@@ -524,11 +524,9 @@ static int routing_policy_rule_set_netlink_message(const RoutingPolicyRule *rule
return r;
}
if (rule->invert_rule) {
r = sd_rtnl_message_routing_policy_rule_set_flags(m, FIB_RULE_INVERT);
if (r < 0)
return r;
}
r = sd_rtnl_message_routing_policy_rule_set_flags(m, rule->flags);
if (r < 0)
return r;
if (rule->l3mdev) {
r = sd_netlink_message_append_u8(m, FRA_L3MDEV, 1);
@@ -929,13 +927,11 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Man
}
}
unsigned flags;
r = sd_rtnl_message_routing_policy_rule_get_flags(message, &flags);
r = sd_rtnl_message_routing_policy_rule_get_flags(message, &tmp->flags);
if (r < 0) {
log_warning_errno(r, "rtnl: received rule message without valid flag, ignoring: %m");
return 0;
}
tmp->invert_rule = flags & FIB_RULE_INVERT;
r = sd_netlink_message_read_u32(message, FRA_FWMARK, &tmp->fwmark);
if (r < 0 && r != -ENODATA) {
@@ -1487,7 +1483,7 @@ int config_parse_routing_policy_rule_invert(
return 0;
}
n->invert_rule = r;
SET_FLAG(n->flags, FIB_RULE_INVERT, r);
TAKE_PTR(n);
return 0;
+1 -1
View File
@@ -27,7 +27,7 @@ typedef struct RoutingPolicyRule {
uint8_t from_prefixlen;
uint8_t tos;
uint8_t type; /* a.k.a action */
bool invert_rule; /* used for flags */
uint32_t flags;
/* attributes */
union in_addr_union to; /* FRA_DST */