2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2015-08-27 13:59:06 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-05-22 13:10:17 +02:00
|
|
|
#include "conf-parser.h"
|
|
|
|
|
2015-08-27 13:59:06 +02:00
|
|
|
typedef struct Route Route;
|
2017-02-15 05:30:35 +01:00
|
|
|
typedef struct NetworkConfigSection NetworkConfigSection;
|
2015-08-27 13:59:06 +02:00
|
|
|
|
|
|
|
#include "networkd-network.h"
|
|
|
|
|
|
|
|
struct Route {
|
|
|
|
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;
|
|
|
|
|
2015-08-27 13:59:06 +02:00
|
|
|
int family;
|
2018-01-20 00:49:15 +01:00
|
|
|
int quickack;
|
|
|
|
|
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;
|
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;
|
2015-08-27 13:59:06 +02:00
|
|
|
|
2015-10-26 12:29:37 +01:00
|
|
|
usec_t lifetime;
|
|
|
|
sd_event_source *expire;
|
|
|
|
|
2015-08-27 13:59:06 +02:00
|
|
|
LIST_FIELDS(Route, routes);
|
|
|
|
};
|
|
|
|
|
2017-02-15 05:30:35 +01:00
|
|
|
int route_new_static(Network *network, const char *filename, unsigned section_line, Route **ret);
|
2015-10-09 23:43:52 +02:00
|
|
|
int route_new(Route **ret);
|
2015-08-27 13:59:06 +02:00
|
|
|
void route_free(Route *route);
|
2018-11-28 21:06:52 +01:00
|
|
|
int route_configure(Route *route, Link *link, link_netlink_message_handler_t callback);
|
|
|
|
int route_remove(Route *route, Link *link, link_netlink_message_handler_t callback);
|
2015-08-27 13:59:06 +02:00
|
|
|
|
2017-06-06 18:02:31 +02:00
|
|
|
int route_get(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
|
|
|
|
int route_add(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
|
|
|
|
int route_add_foreign(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
|
2017-11-27 13:08:37 +01:00
|
|
|
void route_update(Route *route, const union in_addr_union *src, unsigned char src_prefixlen, const union in_addr_union *gw, const union in_addr_union *prefsrc, unsigned char scope, unsigned char protocol, unsigned char type);
|
2018-11-06 13:28:12 +01:00
|
|
|
bool route_equal(Route *r1, Route *r2);
|
2015-10-25 14:46:21 +01:00
|
|
|
|
2015-10-26 12:29:37 +01:00
|
|
|
int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata);
|
|
|
|
|
2015-08-27 13:59:06 +02:00
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free);
|
|
|
|
|
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);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_gateway_onlink);
|
|
|
|
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);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_quickack);
|
2018-05-21 13:33:36 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);
|