]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-routing-policy-rule.h
man: improve Description= documentation (#38101)
[thirdparty/systemd.git] / src / network / networkd-routing-policy-rule.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
bce67bbe
SS
2#pragma once
3
926062f0 4#include <linux/fib_rules.h>
bce67bbe 5
f8a31c90 6#include "in-addr-prefix-util.h"
baa3fadf 7#include "networkd-forward.h"
fcbf4cb7 8#include "networkd-util.h"
bce67bbe 9
ca183bf8 10typedef struct RoutingPolicyRule {
6964cf45 11 Manager *manager;
bce67bbe 12 Network *network;
307fe3cd 13 ConfigSection *section;
eb72fa3a
YW
14 NetworkConfigSource source;
15 NetworkConfigState state;
bce67bbe 16
6c72e80a
YW
17 unsigned n_ref;
18
0a3a3a2a 19 /* struct fib_rule_hdr */
f8a31c90
YW
20 AddressFamily address_family; /* Used when parsing Family= */
21 int family; /* Automatically determined by From=, To=, and Family= */
0a3a3a2a 22 uint8_t tos;
9b8cb789 23 uint8_t action;
957d94c5 24 uint32_t flags;
0a3a3a2a
YW
25
26 /* attributes */
f8a31c90
YW
27 struct in_addr_prefix to; /* FRA_DST */
28 struct in_addr_prefix from; /* FRA_SRC */
0a3a3a2a 29 char *iif; /* FRA_IIFNAME */
3ac8148e 30 uint32_t priority_goto; /* FRA_GOTO */
c4f7a347 31 bool priority_set;
0a3a3a2a
YW
32 uint32_t priority; /* FRA_PRIORITY */
33 uint32_t fwmark; /* FRA_FWMARK */
3ac8148e
YW
34 uint32_t realms; /* FRA_FLOW (IPv4 only) */
35 uint64_t tunnel_id; /* FRA_TUN_ID */
0a3a3a2a 36 int32_t suppress_ifgroup; /* FRA_SUPPRESS_IFGROUP */
933448de 37 int32_t suppress_prefixlen; /* FRA_SUPPRESS_PREFIXLEN */
0a3a3a2a
YW
38 uint32_t table; /* FRA_TABLE, also used in struct fib_rule_hdr */
39 uint32_t fwmask; /* FRA_FWMASK */
40 char *oif; /* FRA_OIFNAME */
4be1fc84 41 bool l3mdev; /* FRA_L3MDEV */
0a3a3a2a 42 struct fib_rule_uid_range uid_range; /* FRA_UID_RANGE */
1e5fd321 43 uint8_t protocol; /* FRA_PROTOCOL */
0a3a3a2a
YW
44 uint8_t ipproto; /* FRA_IP_PROTO */
45 struct fib_rule_port_range sport; /* FRA_SPORT_RANGE */
46 struct fib_rule_port_range dport; /* FRA_DPORT_RANGE */
ca183bf8 47} RoutingPolicyRule;
bce67bbe 48
ac1d8aa5
YW
49int fr_act_type_from_string(const char *s) _pure_;
50const char* fr_act_type_to_string(int t) _const_;
96515305 51
6c72e80a
YW
52RoutingPolicyRule* routing_policy_rule_ref(RoutingPolicyRule *rule);
53RoutingPolicyRule* routing_policy_rule_unref(RoutingPolicyRule *rule);
50a3682f 54
13ffa39f 55void network_drop_invalid_routing_policy_rules(Network *network);
bce67bbe 56
0e5ef6be 57int link_request_static_routing_policy_rules(Link *link);
c0ec4746 58
51a0dc4a 59int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
dd6d53a8
YW
60
61int link_drop_routing_policy_rules(Link *link, bool only_static);
62static inline int link_drop_unmanaged_routing_policy_rules(Link *link) {
63 return link_drop_routing_policy_rules(link, false);
0b81225e 64}
e09b7588 65static inline int link_drop_static_routing_policy_rules(Link *link) {
dd6d53a8 66 return link_drop_routing_policy_rules(link, true);
0b81225e 67}
51a0dc4a 68
eb72fa3a
YW
69DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(RoutingPolicyRule, routing_policy_rule);
70
7f66a94e
YW
71typedef enum RoutingPolicyRuleConfParserType {
72 ROUTING_POLICY_RULE_IIF,
73 ROUTING_POLICY_RULE_OIF,
74 ROUTING_POLICY_RULE_FAMILY,
605377e7
YW
75 ROUTING_POLICY_RULE_FWMARK,
76 ROUTING_POLICY_RULE_GOTO,
7f66a94e
YW
77 ROUTING_POLICY_RULE_INVERT,
78 ROUTING_POLICY_RULE_IP_PROTOCOL,
79 ROUTING_POLICY_RULE_L3MDEV,
605377e7
YW
80 ROUTING_POLICY_RULE_SPORT,
81 ROUTING_POLICY_RULE_DPORT,
f8a31c90
YW
82 ROUTING_POLICY_RULE_FROM,
83 ROUTING_POLICY_RULE_TO,
605377e7
YW
84 ROUTING_POLICY_RULE_PRIORITY,
85 ROUTING_POLICY_RULE_SUPPRESS_IFGROUP,
86 ROUTING_POLICY_RULE_SUPPRESS_PREFIXLEN,
87 ROUTING_POLICY_RULE_TABLE,
7f66a94e 88 ROUTING_POLICY_RULE_TOS,
9b8cb789 89 ROUTING_POLICY_RULE_ACTION,
605377e7 90 ROUTING_POLICY_RULE_UID_RANGE,
7f66a94e
YW
91 _ROUTING_POLICY_RULE_CONF_PARSER_MAX,
92 _ROUTING_POLICY_RULE_CONF_PARSER_INVALID = -EINVAL,
93} RoutingPolicyRuleConfParserType;
94
95CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule);