Skip to content

Commit

Permalink
linux: ignore source-based routes (#372)
Browse files Browse the repository at this point in the history
Since source-based routes aren't used by dhcpcd, it's best if they
are ignored so that they aren't confused with default routes.
  • Loading branch information
sshambar authored Oct 29, 2024
1 parent c4c757f commit fa4e1dd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/if-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,27 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct nlmsghdr *nlm)
case RTA_DST:
sa = &rt->rt_dest;
break;
case RTA_SRC:
{
union sa_ss ssa;
struct sockaddr *psa = (struct sockaddr *)&ssa;
socklen_t salen;

psa->sa_family = rtm->rtm_family;
salen = sa_addrlen(psa);
memcpy((char *)psa + sa_addroffset(psa),
RTA_DATA(rta), MIN(salen, RTA_PAYLOAD(rta)));
/* if ip-route "from" address is not unspecified,
route is source-based, eg:
<dest-net> from <source-net> via ... dev ...
ignore the route as may otherwise appear to overlap
with routes set/removed by dhcpcd */
if (!sa_is_unspecified(psa)) {
errno = ENOTSUP;
return -1;
}
break;
}
case RTA_GATEWAY:
sa = &rt->rt_gateway;
break;
Expand Down

0 comments on commit fa4e1dd

Please sign in to comment.