2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2015-08-27 13:59:06 +02:00
|
|
|
#pragma once
|
|
|
|
|
2020-10-02 03:55:06 +02:00
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
2018-05-22 13:10:17 +02:00
|
|
|
|
2020-10-02 03:55:06 +02:00
|
|
|
#include "sd-netlink.h"
|
2015-08-27 13:59:06 +02:00
|
|
|
|
2020-10-02 03:55:06 +02:00
|
|
|
#include "conf-parser.h"
|
|
|
|
#include "in-addr-util.h"
|
|
|
|
#include "networkd-link.h"
|
2019-03-01 05:27:47 +01:00
|
|
|
#include "networkd-util.h"
|
2015-08-27 13:59:06 +02:00
|
|
|
|
2020-10-02 03:55:06 +02:00
|
|
|
typedef struct Manager Manager;
|
|
|
|
typedef struct Network Network;
|
|
|
|
|
|
|
|
typedef struct Route {
|
2015-08-27 13:59:06 +02:00
|
|
|
Network *network;
|
2017-02-15 05:30:35 +01:00
|
|
|
NetworkConfigSection *section;
|
2015-08-27 13:59:06 +02:00
|
|
|
|
2015-10-25 14:46:21 +01:00
|
|
|
Link *link;
|
2020-10-07 02:41:52 +02:00
|
|
|
Manager *manager;
|
2015-10-25 14:46:21 +01:00
|
|
|
|
2015-08-27 13:59:06 +02:00
|
|
|
int family;
|
2020-10-07 03:04:13 +02:00
|
|
|
int gw_family;
|
2020-10-07 07:25:11 +02:00
|
|
|
uint32_t gw_weight;
|
2018-01-20 00:49:15 +01:00
|
|
|
int quickack;
|
2019-05-13 13:15:33 +02:00
|
|
|
int fast_open_no_cookie;
|
2019-05-16 11:49:08 +02:00
|
|
|
int ttl_propagate;
|
2018-01-20 00:49:15 +01:00
|
|
|
|
2015-08-27 13:59:06 +02:00
|
|
|
unsigned char dst_prefixlen;
|
|
|
|
unsigned char src_prefixlen;
|
|
|
|
unsigned char scope;
|
|
|
|
unsigned char protocol; /* RTPROT_* */
|
2017-09-19 16:28:26 +02:00
|
|
|
unsigned char type; /* RTN_* */
|
2015-10-03 18:40:28 +02:00
|
|
|
unsigned char tos;
|
2015-10-26 17:04:57 +01:00
|
|
|
uint32_t priority; /* note that ip(8) calls this 'metric' */
|
2016-05-03 19:48:21 +02:00
|
|
|
uint32_t table;
|
2016-11-23 22:32:19 +01:00
|
|
|
uint32_t mtu;
|
2017-12-29 15:18:05 +01:00
|
|
|
uint32_t initcwnd;
|
|
|
|
uint32_t initrwnd;
|
networkd: ndisc - handle router advertisement in userspace
Router Discovery is a core part of IPv6, which by default is handled by the kernel.
However, the kernel implementation is meant as a fall-back, and to fully support
the protocol a userspace implementation is desired.
The protocol essentially listens for Router Advertisement packets from routers
on the local link and use these to configure the client automatically. The four
main pieces of information are: what kind (if any) of DHCPv6 configuration should
be performed; a default gateway; the prefixes that should be considered to be on
the local link; and the prefixes with which we can preform SLAAC in order to pick
a global IPv6 address.
A lot of additional information is also available, which we do not yet fully
support, but which will eventually allow us to avoid the need for DHCPv6 in the
common case.
Short-term, the reason for wanting this is in userspace was the desire to fully
track all the addresses on links we manage, and that is not possible for addresses
managed by the kernel (as the kernel does not expose to us the fact that it
manages these addresses). Moreover, we would like to support stable privacy
addresses, which will soon be mandated and the legacy MAC-based global addresses
deprecated, to do this well we need to handle the generation in userspace. Lastly,
more long-term we wish to support more RA options than what the kernel exposes.
2015-11-03 13:02:16 +01:00
|
|
|
unsigned char pref;
|
|
|
|
unsigned flags;
|
2019-02-28 02:10:38 +01:00
|
|
|
int gateway_onlink;
|
2020-10-12 08:52:02 +02:00
|
|
|
|
|
|
|
bool scope_set:1;
|
|
|
|
bool table_set:1;
|
|
|
|
bool priority_set:1;
|
|
|
|
bool protocol_set:1;
|
|
|
|
bool pref_set:1;
|
|
|
|
bool gateway_from_dhcp_or_ra:1;
|
2015-08-27 13:59:06 +02:00
|
|
|
|
2015-10-25 15:09:40 +01:00
|
|
|
union in_addr_union gw;
|
|
|
|
union in_addr_union dst;
|
|
|
|
union in_addr_union src;
|
|
|
|
union in_addr_union prefsrc;
|
2019-11-28 16:36:02 +01:00
|
|
|
OrderedSet *multipath_routes;
|
2015-08-27 13:59:06 +02:00
|
|
|
|
2015-10-26 12:29:37 +01:00
|
|
|
usec_t lifetime;
|
|
|
|
sd_event_source *expire;
|
2020-10-02 03:55:06 +02:00
|
|
|
} Route;
|
2015-08-27 13:59:06 +02:00
|
|
|
|
2020-09-04 03:56:03 +02:00
|
|
|
void route_hash_func(const Route *route, struct siphash *state);
|
|
|
|
int route_compare_func(const Route *a, const Route *b);
|
2019-09-09 17:17:28 +02:00
|
|
|
extern const struct hash_ops route_hash_ops;
|
2019-07-16 18:47:52 +02:00
|
|
|
|
2015-10-09 23:43:52 +02:00
|
|
|
int route_new(Route **ret);
|
2020-10-02 02:31:29 +02:00
|
|
|
Route *route_free(Route *route);
|
2020-10-02 03:16:25 +02:00
|
|
|
DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free);
|
|
|
|
|
2020-10-07 04:01:02 +02:00
|
|
|
int route_configure(const Route *route, Link *link, link_netlink_message_handler_t callback, Route **ret);
|
|
|
|
int route_remove(const Route *route, Manager *manager, Link *link, link_netlink_message_handler_t callback);
|
2015-08-27 13:59:06 +02:00
|
|
|
|
2020-10-02 02:27:28 +02:00
|
|
|
int link_set_routes(Link *link);
|
2020-10-02 02:40:31 +02:00
|
|
|
int link_drop_routes(Link *link);
|
2020-10-02 02:38:31 +02:00
|
|
|
int link_drop_foreign_routes(Link *link);
|
2020-10-02 02:27:28 +02:00
|
|
|
|
2020-10-07 04:01:02 +02:00
|
|
|
uint32_t link_get_dhcp_route_table(const Link *link);
|
|
|
|
uint32_t link_get_ipv6_accept_ra_route_table(const Link *link);
|
2020-10-02 08:48:01 +02:00
|
|
|
|
2020-10-02 02:29:07 +02:00
|
|
|
int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
|
|
|
|
|
2019-03-05 02:51:57 +01:00
|
|
|
int network_add_ipv4ll_route(Network *network);
|
2019-05-14 09:43:14 +02:00
|
|
|
int network_add_default_route_on_device(Network *network);
|
2020-10-06 20:21:59 +02:00
|
|
|
void network_drop_invalid_routes(Network *network);
|
2019-03-05 02:51:57 +01:00
|
|
|
|
2018-05-22 13:10:17 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_gateway);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_destination);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_priority);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_scope);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_table);
|
2020-07-16 07:48:08 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_boolean);
|
2018-05-22 13:10:17 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
|
2018-05-21 13:33:36 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);
|
2019-11-28 16:36:02 +01:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route);
|