Skip to content

Commit

Permalink
route: check gw address to set scope (bnc#887586)
Browse files Browse the repository at this point in the history
Fixed guess scope helper to also check the if route gateway
address is specified, not only if it's family is unspec to
not set device routes with universe scope.
  • Loading branch information
mtomaschewski committed Jul 16, 2014
1 parent 73cb254 commit f930bcd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/route.c
Expand Up @@ -177,7 +177,10 @@ ni_route_create(unsigned int prefixlen, const ni_sockaddr_t *dest,
rp->family = af;
rp->prefixlen = prefixlen;
rp->destination = *dest;
rp->nh.gateway = *gw;
if (!ni_sockaddr_is_specified(gw))
rp->nh.gateway.ss_family = af;
else
rp->nh.gateway = *gw;
if (rp->destination.ss_family == AF_UNSPEC) {
memset(&rp->destination, 0, sizeof(rp->destination));
rp->destination.ss_family = af;
Expand Down Expand Up @@ -747,7 +750,7 @@ ni_route_guess_scope(ni_route_t *rp)

case RTN_UNICAST:
case RTN_UNSPEC:
if (rp->nh.gateway.ss_family == AF_UNSPEC)
if (!ni_sockaddr_is_specified(&rp->nh.gateway))
return RT_SCOPE_LINK;
default: ;
}
Expand Down

0 comments on commit f930bcd

Please sign in to comment.