Add route_protocol option

To be able to distinguish routes from several running l2tpns instances.
This commit is contained in:
Samuel Thibault 2025-03-29 13:03:39 +01:00
parent 44b01d70c6
commit b793850d2f
5 changed files with 37 additions and 18 deletions

View file

@ -232,6 +232,18 @@ otherwise the primary address of the machine.</p>
<dd>
<p>Address to send to clients as the default gateway.</p>
</dd>
<dt><code>route_protocol</code> (short)</dt>
<dd>
<p>Protocol number to record when adding a route (see
<code>/usr/share/iproute2/rt_protos</code>). This allows to separate
routes added by several l2tpns instances. The default is 42.</p>
</dd>
<dt><code>ipv6_prefix</code> (ipv6 address)</dt>
<dd>
<p>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.</p>
</dd>
<dt><code>send_garp</code> (boolean)</dt>
<dd>
<p>Determines whether or not to send a gratuitous ARP for the
@ -330,12 +342,6 @@ from the master.</p>
<p>Determines the minimum number of up to date slaves required before
the master will drop routes (default: 1).</p>
</dd>
<dt><code>ipv6_prefix</code> (ipv6 address)</dt>
<dd>
<p>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.</p>
</dd>
</dl>
<h3 id="config-startup-bgp">BGP</h3>
<p>BGP routing configuration is entered by the command: router bgp as

View file

@ -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

View file

@ -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)

View file

@ -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);

View file

@ -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