1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 #include <linux/fib_rules.h>
8 #include "conf-parser.h"
9 #include "in-addr-util.h"
10 #include "networkd-util.h"
12 typedef struct Link Link
;
13 typedef struct Manager Manager
;
14 typedef struct Network Network
;
16 typedef struct RoutingPolicyRule
{
19 ConfigSection
*section
;
20 NetworkConfigSource source
;
21 NetworkConfigState state
;
25 bool l3mdev
; /* FRA_L3MDEV */
29 uint8_t ipproto
; /* FRA_IP_PROTO */
30 uint8_t protocol
; /* FRA_PROTOCOL */
32 uint8_t from_prefixlen
;
39 AddressFamily address_family
; /* Specified by Family= */
40 int family
; /* Automatically determined by From= or To= */
45 union in_addr_union to
;
46 union in_addr_union from
;
48 struct fib_rule_port_range sport
;
49 struct fib_rule_port_range dport
;
50 struct fib_rule_uid_range uid_range
;
52 int suppress_prefixlen
;
53 int32_t suppress_ifgroup
;
56 const char *fr_act_type_full_to_string(int t
) _const_
;
58 RoutingPolicyRule
*routing_policy_rule_free(RoutingPolicyRule
*rule
);
60 void network_drop_invalid_routing_policy_rules(Network
*network
);
62 int link_request_static_routing_policy_rules(Link
*link
);
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
);
69 static inline int link_drop_managed_routing_policy_rules(Link
*link
) {
71 return manager_drop_routing_policy_rules_internal(link
->manager
, false, link
);
73 void link_foreignize_routing_policy_rules(Link
*link
);
75 DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(RoutingPolicyRule
, routing_policy_rule
);
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
);