Skip to content

Commit

Permalink
Add route lifetime from Router Advertisement
Browse files Browse the repository at this point in the history
Sends route lifetime to NETLINK RTA_EXPIRES

Partially addresses NetworkConfiguration#428
  • Loading branch information
ColinMcInnes committed Jan 8, 2025
1 parent 2568932 commit 14508ef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/if-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,10 @@ if_route(unsigned char cmd, const struct rt *rt)
if (!sa_is_loopback(&rt->rt_gateway))
add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, rt->rt_ifp->index);

/* add route lifetime */
logdebugx("Sending RTA_EXPIRES %d", rt->rt_expires);
add_attr_32(&nlm.hdr, sizeof(nlm), RTA_EXPIRES, rt->rt_expires);

if (rt->rt_metric != 0)
add_attr_32(&nlm.hdr, sizeof(nlm), RTA_PRIORITY,
rt->rt_metric);
Expand Down
2 changes: 2 additions & 0 deletions src/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -2370,6 +2370,8 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx)
#ifdef HAVE_ROUTE_PREF
rt->rt_pref = ipv6nd_rtpref(rap->flags);
#endif
rt->rt_expires = rap->lifetime;

rt_proto_add(routes, rt);
}
return 0;
Expand Down
1 change: 1 addition & 0 deletions src/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct rt {
#define RTDF_GATELINK 0x40 /* Gateway is on link */
size_t rt_order;
rb_node_t rt_tree;
int rt_expires; /* current lifetime of route */
};

extern const rb_tree_ops_t rt_compare_list_ops;
Expand Down

0 comments on commit 14508ef

Please sign in to comment.