route_obj: don't add empty destination to nlmsg

don't try to give the kernel an empty RTA_DST attribute. this would
previously happening on trying to delete the default route as returned
from the kernel. the kernel doesn't add a RTA_DST atttribute, so libnl
does nl_addr_alloc(0) and inserts a zero-length RTA_DST attribute into
the deletion request, which the kernel then refuses with ERANGE.

Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
David Lamparter 2010-10-13 15:17:33 +02:00 committed by Thomas Graf
parent cb05bbb0e2
commit 2b3fabab9e

View file

@ -1108,7 +1108,8 @@ int rtnl_route_build_msg(struct nl_msg *msg, struct rtnl_route *route)
* required to allow more than 256 tables. */
NLA_PUT_U32(msg, RTA_TABLE, route->rt_table);
NLA_PUT_ADDR(msg, RTA_DST, route->rt_dst);
if (nl_addr_get_len(route->rt_dst))
NLA_PUT_ADDR(msg, RTA_DST, route->rt_dst);
NLA_PUT_U32(msg, RTA_PRIORITY, route->rt_prio);
if (route->ce_mask & ROUTE_ATTR_SRC)