diff --git a/docs/html/manual.html b/docs/html/manual.html index 5efeda9..912a1ce 100644 --- a/docs/html/manual.html +++ b/docs/html/manual.html @@ -238,6 +238,12 @@ otherwise the primary address of the machine.

/usr/share/iproute2/rt_protos). This allows to separate routes added by several l2tpns instances. The default is 42.

+
route_metric (int)
+
+

Metric of the route. Routes with lower values are preferred. This +should not be changed during execution, since l2tpns would then not +recognize the routes it added itself. The default is 1.

+
ipv6_prefix (ipv6 address)

Enable negotiation of IPv6. This forms the the first 64 bits of the diff --git a/docs/src/html/manual.md b/docs/src/html/manual.md index e942fb2..41d0f36 100644 --- a/docs/src/html/manual.md +++ b/docs/src/html/manual.md @@ -260,6 +260,13 @@ should be set by a line like: set configstring \"value\" set ipaddress by several l2tpns instances. The default is 42. +`route_metric` (int) + +: Metric of the route. Routes with lower values are preferred. + This should not be changed during execution, since l2tpns would then + not recognize the routes it added itself. + The default is 1. + `ipv6_prefix` (ipv6 address) : Enable negotiation of IPv6. This forms the the first 64 bits of the diff --git a/etc/startup-config.default b/etc/startup-config.default index 77d41bf..75c2cec 100644 --- a/etc/startup-config.default +++ b/etc/startup-config.default @@ -122,6 +122,8 @@ set cli_bind_address 127.0.0.1 #set nexthop 10.0.1.1 #set nexthop6 2001:db8::1 +# Route metric (lower is preferred) +#set route_metric 1 # Route protocol number to use #set route_protocol 42 diff --git a/l2tpns.c b/l2tpns.c index 36f3f7d..8a788f2 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -178,6 +178,7 @@ config_descriptt config_values[] = { CONFIG("peer_address", peer_address, IPv4), CONFIG("ipv6_prefix", ipv6_prefix, IPv6), CONFIG("route_protocol", route_protocol, SHORT), + CONFIG("route_metric", route_metric, INT), CONFIG("send_garp", send_garp, BOOL), CONFIG("throttle_speed", rl_rate, UNSIGNED_LONG), CONFIG("throttle_buckets", num_tbfs, INT), @@ -1585,7 +1586,7 @@ static void routeset(sessionidt s, in_addr_t ip, int prefixlen, in_addr_t gw, in n_ip = htonl(gw); rtnetlink_addattr(&req.nh, RTA_GATEWAY, &n_ip, sizeof(n_ip)); } - metric = 1; + metric = config->route_metric; rtnetlink_addattr(&req.nh, RTA_PRIORITY, &metric, sizeof(metric)); LOG(1, s, session[s].tunnel, "Route %s %s/%d%s%s\n", add ? "add" : "del", @@ -1706,7 +1707,7 @@ void route6set(sessionidt s, struct in6_addr ip, int prefixlen, int add) int idx = session_if_idx(s); rtnetlink_addattr(&req.nh, RTA_OIF, &idx, sizeof(idx)); rtnetlink_addattr(&req.nh, RTA_DST, &ip, sizeof(ip)); - metric = 1; + metric = config->route_metric; rtnetlink_addattr(&req.nh, RTA_PRIORITY, &metric, sizeof(metric)); LOG(1, s, session[s].tunnel, "Route %s %s/%d\n", @@ -7516,6 +7517,8 @@ static void update_config() if (!config->route_protocol) config->route_protocol = 42; + if (!config->route_metric) + config->route_metric = 1; 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 261f71e..dd97491 100644 --- a/l2tpns.h +++ b/l2tpns.h @@ -785,6 +785,7 @@ typedef struct in_addr_t peer_address; struct in6_addr ipv6_prefix; // Our IPv6 network pool. uint16_t route_protocol; // Route protocol number to use + int route_metric; // Route metric int send_garp; // Set to true to garp for vip address on startup int dump_speed;