network: fix handling of routing policy rule fwmask
The firewall mask should be applied even if the mark is 0, to allow defining a value of e.g. 0/255. Fixes #36973
This commit is contained in:
committed by
Yu Watanabe
parent
49ff90c70d
commit
ec65c29e51
@@ -615,7 +615,7 @@ static int routing_policy_rule_set_netlink_message(const RoutingPolicyRule *rule
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (rule->fwmark > 0) {
|
||||
if (rule->fwmark > 0 || rule->fwmask > 0) {
|
||||
r = sd_netlink_message_append_u32(m, FRA_FWMARK, rule->fwmark);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -1315,14 +1315,12 @@ static int parse_fwmark_fwmask(const char *s, uint32_t *ret_fwmark, uint32_t *re
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (fwmark > 0) {
|
||||
if (slash) {
|
||||
r = safe_atou32(slash + 1, &fwmask);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else
|
||||
fwmask = UINT32_MAX;
|
||||
}
|
||||
if (slash) {
|
||||
r = safe_atou32(slash + 1, &fwmask);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else if (fwmark > 0)
|
||||
fwmask = UINT32_MAX;
|
||||
|
||||
*ret_fwmark = fwmark;
|
||||
*ret_fwmask = fwmask;
|
||||
|
||||
Reference in New Issue
Block a user