]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-route.h
Merge pull request #30513 from rpigott/resolved-ede
[thirdparty/systemd.git] / src / network / networkd-route.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
fc2f9534
LP
2#pragma once
3
e2263711
YW
4#include <inttypes.h>
5#include <stdbool.h>
a2106925 6
e2263711 7#include "sd-netlink.h"
fc2f9534 8
e2263711
YW
9#include "conf-parser.h"
10#include "in-addr-util.h"
11#include "networkd-link.h"
fcbf4cb7 12#include "networkd-util.h"
fc2f9534 13
e2263711
YW
14typedef struct Manager Manager;
15typedef struct Network Network;
76c5a0f2 16typedef struct Request Request;
80d62d4f
YW
17typedef struct Route Route;
18typedef int (*route_netlink_handler_t)(
19 sd_netlink *rtnl,
20 sd_netlink_message *m,
21 Request *req,
22 Link *link,
23 Route *route);
e2263711 24
80d62d4f 25struct Route {
1c8e710c 26 Link *link;
ad208fac 27 Manager *manager;
3b6a3bde 28 Network *network;
307fe3cd 29 ConfigSection *section;
3b6a3bde
YW
30 NetworkConfigSource source;
31 NetworkConfigState state;
32 union in_addr_union provider; /* DHCP server or router address */
1c8e710c 33
fc2f9534 34 int family;
6dd53981 35 int gw_family;
f9bb3338 36 uint32_t gw_weight;
09f5dfad 37 int quickack;
633c7258 38 int fast_open_no_cookie;
09f5dfad 39
fc2f9534
LP
40 unsigned char dst_prefixlen;
41 unsigned char src_prefixlen;
42 unsigned char scope;
fc2f9534 43 unsigned char protocol; /* RTPROT_* */
983226f3 44 unsigned char type; /* RTN_* */
bb7ae737 45 unsigned char tos;
86655331 46 uint32_t priority; /* note that ip(8) calls this 'metric' */
c953b24c 47 uint32_t table;
d6fceaf1 48 uint32_t mtu;
323d9329
SS
49 uint32_t initcwnd;
50 uint32_t initrwnd;
007cac09 51 uint32_t advmss;
f141b2c0 52 uint32_t hop_limit;
dc7c21f0 53 char *tcp_congestion_control_algo;
3b015d40
TG
54 unsigned char pref;
55 unsigned flags;
17f8d8f9 56 int gateway_onlink; /* Only used in conf parser and route_section_verify(). */
324e3422 57 uint32_t nexthop_id;
1412d4a4 58 usec_t tcp_rto_usec;
c27abcf4
YW
59
60 bool scope_set:1;
61 bool table_set:1;
62 bool priority_set:1;
63 bool protocol_set:1;
64 bool pref_set:1;
65 bool gateway_from_dhcp_or_ra:1;
fc2f9534 66
2ce40956
TG
67 union in_addr_union gw;
68 union in_addr_union dst;
69 union in_addr_union src;
70 union in_addr_union prefsrc;
6ff5cc6b 71 OrderedSet *multipath_routes;
fc2f9534 72
91fc5135
YW
73 /* This is an absolute point in time, and NOT a timespan/duration.
74 * Must be specified with clock_boottime_or_monotonic(). */
75 usec_t lifetime_usec;
76 /* Used when kernel does not support RTA_EXPIRES attribute. */
f833694d 77 sd_event_source *expire;
80d62d4f 78};
fc2f9534 79
28870a9d 80extern const struct hash_ops route_hash_ops;
01aaa3df 81
ed9e361a 82int route_new(Route **ret);
169948e9 83Route *route_free(Route *route);
307fe3cd 84DEFINE_SECTION_CLEANUP_FUNCTIONS(Route, route_free);
c0bd9eb1 85int route_dup(const Route *src, Route **ret);
74154c2e 86
5a07fa9d 87int route_configure_handler_internal(sd_netlink *rtnl, sd_netlink_message *m, Link *link, const char *error_msg);
3b6a3bde 88int route_remove(Route *route);
d4b76314 89int route_remove_and_drop(Route *route);
fc2f9534 90
3b6a3bde 91int route_get(Manager *manager, Link *link, const Route *in, Route **ret);
884a63d7 92
a0e99a37 93int link_drop_managed_routes(Link *link);
779804dd 94int link_drop_foreign_routes(Link *link);
b4564f4e 95void link_foreignize_routes(Link *link);
141318f7 96
95eb38c8 97void route_cancel_request(Route *route, Link *link);
76c5a0f2
YW
98int link_request_route(
99 Link *link,
100 Route *route,
101 bool consume_object,
102 unsigned *message_counter,
80d62d4f 103 route_netlink_handler_t netlink_handler,
76c5a0f2
YW
104 Request **ret);
105int link_request_static_routes(Link *link, bool only_ipv4);
76c5a0f2 106
4468f01b
YW
107int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
108
fa7cd711 109int network_add_ipv4ll_route(Network *network);
5d5003ab 110int network_add_default_route_on_device(Network *network);
13ffa39f 111void network_drop_invalid_routes(Network *network);
fa7cd711 112
3b6a3bde 113DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(Route, route);
2ccada8d 114void link_mark_routes(Link *link, NetworkConfigSource source);
3b6a3bde 115
a2106925
LP
116CONFIG_PARSER_PROTOTYPE(config_parse_gateway);
117CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src);
118CONFIG_PARSER_PROTOTYPE(config_parse_destination);
119CONFIG_PARSER_PROTOTYPE(config_parse_route_priority);
120CONFIG_PARSER_PROTOTYPE(config_parse_route_scope);
121CONFIG_PARSER_PROTOTYPE(config_parse_route_table);
d96edb2c 122CONFIG_PARSER_PROTOTYPE(config_parse_route_boolean);
a2106925
LP
123CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference);
124CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol);
125CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
cb35a0d4 126CONFIG_PARSER_PROTOTYPE(config_parse_route_tcp_window);
88c06423 127CONFIG_PARSER_PROTOTYPE(config_parse_route_hop_limit);
a2106925 128CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
1412d4a4 129CONFIG_PARSER_PROTOTYPE(config_parse_route_tcp_rto);
cea79e66 130CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);
6ff5cc6b 131CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route);
dc7c21f0 132CONFIG_PARSER_PROTOTYPE(config_parse_tcp_congestion);
007cac09 133CONFIG_PARSER_PROTOTYPE(config_parse_tcp_advmss);
324e3422 134CONFIG_PARSER_PROTOTYPE(config_parse_route_nexthop);