From b793850d2ffb85efffae65886915da78fcf24e12 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 29 Mar 2025 13:03:39 +0100 Subject: [PATCH] Add route_protocol option To be able to distinguish routes from several running l2tpns instances. --- docs/html/manual.html | 18 ++++++++++++------ docs/src/html/manual.md | 19 +++++++++++++------ etc/startup-config.default | 3 +++ l2tpns.c | 10 +++++++--- l2tpns.h | 5 ++--- 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/docs/html/manual.html b/docs/html/manual.html index 85f6716..5efeda9 100644 --- a/docs/html/manual.html +++ b/docs/html/manual.html @@ -232,6 +232,18 @@ otherwise the primary address of the machine.

Address to send to clients as the default gateway.

+
route_protocol (short)
+
+

Protocol number to record when adding a route (see +/usr/share/iproute2/rt_protos). This allows to separate +routes added by several l2tpns instances. The default is 42.

+
+
ipv6_prefix (ipv6 address)
+
+

Enable negotiation of IPv6. This forms the the first 64 bits of the +client allocated address. The remaining 64 come from the allocated IPv4 +address and 4 bytes of 0s.

+
send_garp (boolean)

Determines whether or not to send a gratuitous ARP for the @@ -330,12 +342,6 @@ from the master.

Determines the minimum number of up to date slaves required before the master will drop routes (default: 1).

-
ipv6_prefix (ipv6 address)
-
-

Enable negotiation of IPv6. This forms the the first 64 bits of the -client allocated address. The remaining 64 come from the allocated IPv4 -address and 4 bytes of 0s.

-

BGP

BGP routing configuration is entered by the command: router bgp as diff --git a/docs/src/html/manual.md b/docs/src/html/manual.md index db46bc2..e942fb2 100644 --- a/docs/src/html/manual.md +++ b/docs/src/html/manual.md @@ -253,6 +253,19 @@ should be set by a line like: set configstring \"value\" set ipaddress : Address to send to clients as the default gateway. +`route_protocol` (short) + +: Protocol number to record when adding a route + (see `/usr/share/iproute2/rt_protos`). This allows to separate routes added + by several l2tpns instances. + The default is 42. + +`ipv6_prefix` (ipv6 address) + +: Enable negotiation of IPv6. This forms the the first 64 bits of the + client allocated address. The remaining 64 come from the allocated + IPv4 address and 4 bytes of 0s. + `send_garp` (boolean) : Determines whether or not to send a gratuitous ARP for the @@ -349,12 +362,6 @@ should be set by a line like: set configstring \"value\" set ipaddress : Determines the minimum number of up to date slaves required before the master will drop routes (default: 1). -`ipv6_prefix` (ipv6 address) - -: Enable negotiation of IPv6. This forms the the first 64 bits of the - client allocated address. The remaining 64 come from the allocated - IPv4 address and 4 bytes of 0s. - ### BGP {#config-startup-bgp} BGP routing configuration is entered by the command: router bgp as where diff --git a/etc/startup-config.default b/etc/startup-config.default index d6a75c1..77d41bf 100644 --- a/etc/startup-config.default +++ b/etc/startup-config.default @@ -122,6 +122,9 @@ set cli_bind_address 127.0.0.1 #set nexthop 10.0.1.1 #set nexthop6 2001:db8::1 +# Route protocol number to use +#set route_protocol 42 + # Time between last packet sent and LCP ECHO generation (default 10 seconds) #set echo_timeout 10 # Drop sessions who have not responded within idle_echo_timeout seconds (default 240 seconds) diff --git a/l2tpns.c b/l2tpns.c index 4c47734..36f3f7d 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -176,6 +176,8 @@ config_descriptt config_values[] = { CONFIG("guest_account", guest_user, STRING), CONFIG("bind_address", bind_address, IPv4), CONFIG("peer_address", peer_address, IPv4), + CONFIG("ipv6_prefix", ipv6_prefix, IPv6), + CONFIG("route_protocol", route_protocol, SHORT), CONFIG("send_garp", send_garp, BOOL), CONFIG("throttle_speed", rl_rate, UNSIGNED_LONG), CONFIG("throttle_buckets", num_tbfs, INT), @@ -194,7 +196,6 @@ config_descriptt config_values[] = { CONFIG("cluster_hb_interval", cluster_hb_interval, INT), CONFIG("cluster_hb_timeout", cluster_hb_timeout, INT), CONFIG("cluster_master_min_adv", cluster_master_min_adv, INT), - CONFIG("ipv6_prefix", ipv6_prefix, IPv6), CONFIG("cli_bind_address", cli_bind_address, IPv4), CONFIG("hostname", hostname, STRING), #ifdef BGP @@ -1571,7 +1572,7 @@ static void routeset(sessionidt s, in_addr_t ip, int prefixlen, in_addr_t gw, in req.rt.rtm_family = AF_INET; req.rt.rtm_dst_len = prefixlen; req.rt.rtm_table = RT_TABLE_MAIN; - req.rt.rtm_protocol = 42; + req.rt.rtm_protocol = config->route_protocol; req.rt.rtm_scope = RT_SCOPE_LINK; req.rt.rtm_type = RTN_UNICAST; @@ -1698,7 +1699,7 @@ void route6set(sessionidt s, struct in6_addr ip, int prefixlen, int add) req.rt.rtm_family = AF_INET6; req.rt.rtm_dst_len = prefixlen; req.rt.rtm_table = RT_TABLE_MAIN; - req.rt.rtm_protocol = 42; + req.rt.rtm_protocol = config->route_protocol; req.rt.rtm_scope = RT_SCOPE_LINK; req.rt.rtm_type = RTN_UNICAST; @@ -7513,6 +7514,9 @@ static void update_config() } } + if (!config->route_protocol) + config->route_protocol = 42; + if (!*config->pppoe_ac_name) strncpy(config->pppoe_ac_name, DEFAULT_PPPOE_AC_NAME, sizeof(config->pppoe_ac_name) - 1); diff --git a/l2tpns.h b/l2tpns.h index 4cfb2fc..261f71e 100644 --- a/l2tpns.h +++ b/l2tpns.h @@ -783,6 +783,8 @@ typedef struct int account_all_origin; // Accouting all origin (LAC data + Remote LNS Data + PPPOE data) in_addr_t bind_address; in_addr_t peer_address; + struct in6_addr ipv6_prefix; // Our IPv6 network pool. + uint16_t route_protocol; // Route protocol number to use int send_garp; // Set to true to garp for vip address on startup int dump_speed; @@ -822,9 +824,6 @@ typedef struct int cluster_hb_timeout; // How many missed heartbeats trigger an election. uint64_t cluster_table_version; // # state changes processed by cluster - struct in6_addr ipv6_prefix; // Our IPv6 network pool. - - int cluster_master_min_adv; // Master advertises routes while the number of up to date // slaves is less than this value. in_addr_t cli_bind_address; // bind address for CLI