summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-10-28 08:54:51 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-12-29 08:03:26 +0100
commit1e5fd3216a8c73b636ad61e6ebee0c161b6c2063 (patch)
treeb8bb91ad48bc7d66ed06a278c8c62ea164760ae7 /src
parentMerge pull request #18048 from poettering/timesync-man-more (diff)
downloadsystemd-1e5fd3216a8c73b636ad61e6ebee0c161b6c2063.tar.xz
systemd-1e5fd3216a8c73b636ad61e6ebee0c161b6c2063.zip
network: set FRA_PROTOCOL to RTPROT_STATIC by default
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-routing-policy-rule.c36
-rw-r--r--src/network/networkd-routing-policy-rule.h3
2 files changed, 29 insertions, 10 deletions
diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c
index 8c9565bda9..4ede16e581 100644
--- a/src/network/networkd-routing-policy-rule.c
+++ b/src/network/networkd-routing-policy-rule.c
@@ -66,6 +66,7 @@ static int routing_policy_rule_new(RoutingPolicyRule **ret) {
.uid_range.start = UID_INVALID,
.uid_range.end = UID_INVALID,
.suppress_prefixlen = -1,
+ .protocol = RTPROT_UNSPEC,
.type = FR_ACT_TO_TBL,
};
@@ -99,6 +100,7 @@ static int routing_policy_rule_new_static(Network *network, const char *filename
rule->network = network;
rule->section = TAKE_PTR(n);
+ rule->protocol = RTPROT_STATIC;
r = hashmap_ensure_allocated(&network->rules_by_section, &network_config_hash_ops);
if (r < 0)
@@ -144,6 +146,7 @@ static int routing_policy_rule_copy(RoutingPolicyRule *dest, RoutingPolicyRule *
dest->table = src->table;
dest->iif = TAKE_PTR(iif);
dest->oif = TAKE_PTR(oif);
+ dest->ipproto = src->ipproto;
dest->protocol = src->protocol;
dest->sport = src->sport;
dest->dport = src->dport;
@@ -177,6 +180,7 @@ static void routing_policy_rule_hash_func(const RoutingPolicyRule *rule, struct
siphash24_compress(&rule->table, sizeof(rule->table), state);
siphash24_compress(&rule->suppress_prefixlen, sizeof(rule->suppress_prefixlen), state);
+ siphash24_compress(&rule->ipproto, sizeof(rule->ipproto), state);
siphash24_compress(&rule->protocol, sizeof(rule->protocol), state);
siphash24_compress(&rule->sport, sizeof(rule->sport), state);
siphash24_compress(&rule->dport, sizeof(rule->dport), state);
@@ -250,6 +254,10 @@ static int routing_policy_rule_compare_func(const RoutingPolicyRule *a, const Ro
if (r != 0)
return r;
+ r = CMP(a->ipproto, b->ipproto);
+ if (r != 0)
+ return r;
+
r = CMP(a->protocol, b->protocol);
if (r != 0)
return r;
@@ -458,10 +466,14 @@ static int routing_policy_rule_set_netlink_message(RoutingPolicyRule *rule, sd_n
return log_link_error_errno(link, r, "Could not append FRA_OIFNAME attribute: %m");
}
- r = sd_netlink_message_append_u8(m, FRA_IP_PROTO, rule->protocol);
+ r = sd_netlink_message_append_u8(m, FRA_IP_PROTO, rule->ipproto);
if (r < 0)
return log_link_error_errno(link, r, "Could not append FRA_IP_PROTO attribute: %m");
+ r = sd_netlink_message_append_u8(m, FRA_PROTOCOL, rule->protocol);
+ if (r < 0)
+ return log_link_error_errno(link, r, "Could not append FRA_PROTOCOL attribute: %m");
+
if (rule->sport.start != 0 || rule->sport.end != 0) {
r = sd_netlink_message_append_data(m, FRA_SPORT_RANGE, &rule->sport, sizeof(rule->sport));
if (r < 0)
@@ -852,12 +864,18 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Man
if (r < 0)
return log_oom();
- r = sd_netlink_message_read_u8(message, FRA_IP_PROTO, &tmp->protocol);
+ r = sd_netlink_message_read_u8(message, FRA_IP_PROTO, &tmp->ipproto);
if (r < 0 && r != -ENODATA) {
log_warning_errno(r, "rtnl: could not get FRA_IP_PROTO attribute, ignoring: %m");
return 0;
}
+ r = sd_netlink_message_read_u8(message, FRA_PROTOCOL, &tmp->protocol);
+ if (r < 0 && r != -ENODATA) {
+ log_warning_errno(r, "rtnl: could not get FRA_PROTOCOL attribute, ignoring: %m");
+ return 0;
+ }
+
r = sd_netlink_message_read(message, FRA_SPORT_RANGE, sizeof(tmp->sport), &tmp->sport);
if (r < 0 && r != -ENODATA) {
log_warning_errno(r, "rtnl: could not get FRA_SPORT_RANGE attribute, ignoring: %m");
@@ -1271,7 +1289,7 @@ int config_parse_routing_policy_rule_ip_protocol(
return 0;
}
- n->protocol = r;
+ n->ipproto = r;
n = NULL;
@@ -1599,10 +1617,10 @@ int routing_policy_serialize_rules(Set *rules, FILE *f) {
space = true;
}
- if (rule->protocol != 0) {
- fprintf(f, "%sprotocol=%hhu",
+ if (rule->ipproto != 0) {
+ fprintf(f, "%sipproto=%hhu",
space ? " " : "",
- rule->protocol);
+ rule->ipproto);
space = true;
}
@@ -1777,10 +1795,10 @@ int routing_policy_load_rules(const char *state_file, Set **rules) {
if (free_and_strdup(&rule->oif, b) < 0)
return log_oom();
- } else if (streq(a, "protocol")) {
- r = safe_atou8(b, &rule->protocol);
+ } else if (streq(a, "ipproto")) {
+ r = safe_atou8(b, &rule->ipproto);
if (r < 0) {
- log_warning_errno(r, "Failed to parse RPDB rule protocol, ignoring: %s", b);
+ log_warning_errno(r, "Failed to parse RPDB rule IP protocol, ignoring: %s", b);
continue;
}
} else if (streq(a, "sourceport")) {
diff --git a/src/network/networkd-routing-policy-rule.h b/src/network/networkd-routing-policy-rule.h
index 1b574452e2..3786eee34b 100644
--- a/src/network/networkd-routing-policy-rule.h
+++ b/src/network/networkd-routing-policy-rule.h
@@ -24,7 +24,8 @@ typedef struct RoutingPolicyRule {
uint8_t tos;
uint8_t type;
- uint8_t protocol;
+ uint8_t ipproto; /* FRA_IP_PROTO */
+ uint8_t protocol; /* FRA_PROTOCOL */
uint8_t to_prefixlen;
uint8_t from_prefixlen;