From 43cbe0e4b2a60b4e23b1f3a16c8258d1575aab04 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 29 Mar 2025 14:43:19 +0100 Subject: [PATCH] Fix setting route metric (aka priority) --- l2tpns.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/l2tpns.c b/l2tpns.c index 3f16c73..4c47734 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -1545,6 +1545,7 @@ static void routeset(sessionidt s, in_addr_t ip, int prefixlen, in_addr_t gw, in struct rtmsg rt; char buf[32]; } req; + int metric; int i; in_addr_t n_ip; @@ -1583,6 +1584,8 @@ 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; + 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", fmtaddr(htonl(ip), 0), prefixlen, @@ -1703,7 +1706,7 @@ void route6set(sessionidt s, struct in6_addr ip, int prefixlen, int add) rtnetlink_addattr(&req.nh, RTA_OIF, &idx, sizeof(idx)); rtnetlink_addattr(&req.nh, RTA_DST, &ip, sizeof(ip)); metric = 1; - rtnetlink_addattr(&req.nh, RTA_METRICS, &metric, sizeof(metric)); + rtnetlink_addattr(&req.nh, RTA_PRIORITY, &metric, sizeof(metric)); LOG(1, s, session[s].tunnel, "Route %s %s/%d\n", add ? "add" : "del",