Fix setting route metric (aka priority)

This commit is contained in:
Samuel Thibault 2025-03-29 14:43:19 +01:00
parent 75144a546c
commit 43cbe0e4b2

View file

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