Represent default route with destination address length zero
So far the destination address for default routes was NULL which complicated the handling of routes in general. By assigning a address of length zero they can be compared to each other. This allows the cache manager to properly handle default routes.
This commit is contained in:
parent
680c54fd46
commit
4649886288
2 changed files with 13 additions and 9 deletions
|
@ -91,15 +91,18 @@ static int route_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
dst = nla_get_addr(tb[RTA_DST], rtm->rtm_family);
|
||||
if (dst == NULL)
|
||||
goto errout_errno;
|
||||
} else if (rtm->rtm_dst_len)
|
||||
} else {
|
||||
dst = nl_addr_alloc(0);
|
||||
|
||||
if (dst) {
|
||||
nl_addr_set_prefixlen(dst, rtm->rtm_dst_len);
|
||||
rtnl_route_set_dst(route, dst);
|
||||
nl_addr_put(dst);
|
||||
nl_addr_set_family(dst, rtm->rtm_family);
|
||||
}
|
||||
|
||||
nl_addr_set_prefixlen(dst, rtm->rtm_dst_len);
|
||||
err = rtnl_route_set_dst(route, dst);
|
||||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
nl_addr_put(dst);
|
||||
|
||||
if (tb[RTA_SRC]) {
|
||||
src = nla_get_addr(tb[RTA_SRC], rtm->rtm_family);
|
||||
if (src == NULL)
|
||||
|
|
|
@ -136,10 +136,11 @@ static int route_dump_brief(struct nl_object *a, struct nl_dump_params *p)
|
|||
|
||||
link_cache = nl_cache_mngt_require("route/link");
|
||||
|
||||
if (r->ce_mask & ROUTE_ATTR_DST)
|
||||
dp_dump(p, "%s ", nl_addr2str(r->rt_dst, buf, sizeof(buf)));
|
||||
else
|
||||
if (!(r->ce_mask & ROUTE_ATTR_DST) ||
|
||||
nl_addr_get_len(r->rt_dst) == 0)
|
||||
dp_dump(p, "default ");
|
||||
else
|
||||
dp_dump(p, "%s ", nl_addr2str(r->rt_dst, buf, sizeof(buf)));
|
||||
|
||||
if (r->ce_mask & ROUTE_ATTR_OIF) {
|
||||
if (link_cache)
|
||||
|
|
Loading…
Add table
Reference in a new issue