Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update route if acquired time changes #441

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx)
#endif
rt->rt_expires = lifetime_left(rinfo->lifetime,
&rinfo->acquired, &now);
rt->rt_updated = rinfo->acquired;

rt_proto_add(routes, rt);
}
Expand All @@ -2320,6 +2321,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx)
rt->rt_expires =
lifetime_left(addr->prefix_vltime,
&addr->acquired, &now);
rt->rt_updated = addr->acquired;

rt_proto_add(routes, rt);
}
Expand Down Expand Up @@ -2354,6 +2356,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx)
#endif
rt->rt_expires = lifetime_left(rap->lifetime,
&rap->acquired, &now);
rt->rt_updated = rap->acquired;

rt_proto_add(routes, rt);
}
Expand Down
19 changes: 14 additions & 5 deletions src/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ rt_desc(const char *cmd, const struct rt *rt)
ifname, cmd,
rt->rt_flags & RTF_REJECT ? " reject" : "",
dest, prefix, gateway);
logdebugx("route flags %d lifetime %d mtu %d",
rt->rt_flags, rt->rt_expires, rt->rt_mtu);
}

void
Expand Down Expand Up @@ -540,9 +542,12 @@ rt_add(rb_tree_t *kroutes, struct rt *nrt, struct rt *ort)
#endif
sa_cmp(&ort->rt_gateway, &nrt->rt_gateway) == 0)))
{
if (ort->rt_mtu == nrt->rt_mtu)
/* If expiry has not been renewed by RA, and MTU is unchanged, skip */
if (ort->rt_mtu != nrt->rt_mtu ||
ort->rt_updated.tv_sec != nrt->rt_updated.tv_sec)
change = true;
if (!change)
return true;
change = true;
kroute = true;
}
} else if (ort->rt_dflags & RTDF_FAKE &&
Expand All @@ -555,9 +560,12 @@ rt_add(rb_tree_t *kroutes, struct rt *nrt, struct rt *ort)
rt_cmp_netmask(ort, nrt) == 0 &&
sa_cmp(&ort->rt_gateway, &nrt->rt_gateway) == 0)
{
if (ort->rt_mtu == nrt->rt_mtu)
/* If expiry has not been renewed by RA, and MTU is unchanged, skip */
if (ort->rt_mtu != nrt->rt_mtu ||
ort->rt_updated.tv_sec != nrt->rt_updated.tv_sec)
change = true;
if (!change)
return true;
change = true;
}

#ifdef RTF_CLONING
Expand Down Expand Up @@ -678,7 +686,8 @@ rt_doroute(rb_tree_t *kroutes, struct rt *rt)
!rt_cmp(rt, or) ||
(rt->rt_ifa.sa_family != AF_UNSPEC &&
sa_cmp(&or->rt_ifa, &rt->rt_ifa) != 0) ||
or->rt_mtu != rt->rt_mtu)
or->rt_mtu != rt->rt_mtu ||
or->rt_updated.tv_sec != rt->rt_updated.tv_sec)
{
if (!rt_add(kroutes, rt, or))
return false;
Expand Down
1 change: 1 addition & 0 deletions src/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ struct rt {
size_t rt_order;
rb_node_t rt_tree;
uint32_t rt_expires; /* current lifetime of route */
struct timespec rt_updated; /* time route was last updated */
};

extern const rb_tree_ops_t rt_compare_list_ops;
Expand Down
Loading