]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-routing-policy-rule.h
network: make Reload bus method synchronous
[thirdparty/systemd.git] / src / network / networkd-routing-policy-rule.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <inttypes.h>
5 #include <linux/fib_rules.h>
6 #include <stdbool.h>
7
8 #include "conf-parser.h"
9 #include "in-addr-util.h"
10 #include "networkd-util.h"
11
12 typedef struct Link Link;
13 typedef struct Manager Manager;
14 typedef struct Network Network;
15
16 typedef struct RoutingPolicyRule {
17 Manager *manager;
18 Network *network;
19 ConfigSection *section;
20 NetworkConfigSource source;
21 NetworkConfigState state;
22
23 bool invert_rule;
24 bool priority_set;
25 bool l3mdev; /* FRA_L3MDEV */
26
27 uint8_t tos;
28 uint8_t type;
29 uint8_t ipproto; /* FRA_IP_PROTO */
30 uint8_t protocol; /* FRA_PROTOCOL */
31 uint8_t to_prefixlen;
32 uint8_t from_prefixlen;
33
34 uint32_t table;
35 uint32_t fwmark;
36 uint32_t fwmask;
37 uint32_t priority;
38
39 AddressFamily address_family; /* Specified by Family= */
40 int family; /* Automatically determined by From= or To= */
41
42 char *iif;
43 char *oif;
44
45 union in_addr_union to;
46 union in_addr_union from;
47
48 struct fib_rule_port_range sport;
49 struct fib_rule_port_range dport;
50 struct fib_rule_uid_range uid_range;
51
52 int suppress_prefixlen;
53 int32_t suppress_ifgroup;
54 } RoutingPolicyRule;
55
56 const char *fr_act_type_full_to_string(int t) _const_;
57
58 RoutingPolicyRule *routing_policy_rule_free(RoutingPolicyRule *rule);
59
60 void network_drop_invalid_routing_policy_rules(Network *network);
61
62 int link_request_static_routing_policy_rules(Link *link);
63
64 int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
65 int manager_drop_routing_policy_rules_internal(Manager *m, bool foreign, const Link *except);
66 static inline int manager_drop_foreign_routing_policy_rules(Manager *m) {
67 return manager_drop_routing_policy_rules_internal(m, true, NULL);
68 }
69 static inline int link_drop_managed_routing_policy_rules(Link *link) {
70 assert(link);
71 return manager_drop_routing_policy_rules_internal(link->manager, false, link);
72 }
73 void link_foreignize_routing_policy_rules(Link *link);
74
75 DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(RoutingPolicyRule, routing_policy_rule);
76
77 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_tos);
78 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_table);
79 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_fwmark_mask);
80 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_prefix);
81 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_priority);
82 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_device);
83 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_l3mdev);
84 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_port_range);
85 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_ip_protocol);
86 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_invert);
87 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_family);
88 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_uid_range);
89 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_suppress_prefixlen);
90 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_suppress_ifgroup);
91 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_type);