]> git.ipfire.org Git - thirdparty/systemd.git/blame_incremental - src/network/networkd-routing-policy-rule.h
man: improve Description= documentation (#38101)
[thirdparty/systemd.git] / src / network / networkd-routing-policy-rule.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2#pragma once
3
4#include <linux/fib_rules.h>
5
6#include "in-addr-prefix-util.h"
7#include "networkd-forward.h"
8#include "networkd-util.h"
9
10typedef struct RoutingPolicyRule {
11 Manager *manager;
12 Network *network;
13 ConfigSection *section;
14 NetworkConfigSource source;
15 NetworkConfigState state;
16
17 unsigned n_ref;
18
19 /* struct fib_rule_hdr */
20 AddressFamily address_family; /* Used when parsing Family= */
21 int family; /* Automatically determined by From=, To=, and Family= */
22 uint8_t tos;
23 uint8_t action;
24 uint32_t flags;
25
26 /* attributes */
27 struct in_addr_prefix to; /* FRA_DST */
28 struct in_addr_prefix from; /* FRA_SRC */
29 char *iif; /* FRA_IIFNAME */
30 uint32_t priority_goto; /* FRA_GOTO */
31 bool priority_set;
32 uint32_t priority; /* FRA_PRIORITY */
33 uint32_t fwmark; /* FRA_FWMARK */
34 uint32_t realms; /* FRA_FLOW (IPv4 only) */
35 uint64_t tunnel_id; /* FRA_TUN_ID */
36 int32_t suppress_ifgroup; /* FRA_SUPPRESS_IFGROUP */
37 int32_t suppress_prefixlen; /* FRA_SUPPRESS_PREFIXLEN */
38 uint32_t table; /* FRA_TABLE, also used in struct fib_rule_hdr */
39 uint32_t fwmask; /* FRA_FWMASK */
40 char *oif; /* FRA_OIFNAME */
41 bool l3mdev; /* FRA_L3MDEV */
42 struct fib_rule_uid_range uid_range; /* FRA_UID_RANGE */
43 uint8_t protocol; /* FRA_PROTOCOL */
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 */
47} RoutingPolicyRule;
48
49int fr_act_type_from_string(const char *s) _pure_;
50const char* fr_act_type_to_string(int t) _const_;
51
52RoutingPolicyRule* routing_policy_rule_ref(RoutingPolicyRule *rule);
53RoutingPolicyRule* routing_policy_rule_unref(RoutingPolicyRule *rule);
54
55void network_drop_invalid_routing_policy_rules(Network *network);
56
57int link_request_static_routing_policy_rules(Link *link);
58
59int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
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);
64}
65static inline int link_drop_static_routing_policy_rules(Link *link) {
66 return link_drop_routing_policy_rules(link, true);
67}
68
69DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(RoutingPolicyRule, routing_policy_rule);
70
71typedef enum RoutingPolicyRuleConfParserType {
72 ROUTING_POLICY_RULE_IIF,
73 ROUTING_POLICY_RULE_OIF,
74 ROUTING_POLICY_RULE_FAMILY,
75 ROUTING_POLICY_RULE_FWMARK,
76 ROUTING_POLICY_RULE_GOTO,
77 ROUTING_POLICY_RULE_INVERT,
78 ROUTING_POLICY_RULE_IP_PROTOCOL,
79 ROUTING_POLICY_RULE_L3MDEV,
80 ROUTING_POLICY_RULE_SPORT,
81 ROUTING_POLICY_RULE_DPORT,
82 ROUTING_POLICY_RULE_FROM,
83 ROUTING_POLICY_RULE_TO,
84 ROUTING_POLICY_RULE_PRIORITY,
85 ROUTING_POLICY_RULE_SUPPRESS_IFGROUP,
86 ROUTING_POLICY_RULE_SUPPRESS_PREFIXLEN,
87 ROUTING_POLICY_RULE_TABLE,
88 ROUTING_POLICY_RULE_TOS,
89 ROUTING_POLICY_RULE_ACTION,
90 ROUTING_POLICY_RULE_UID_RANGE,
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);