dect
/
libnl
Archived
13
0
Fork 0

route cache: This patch adds route priority to route object oo_id_attrs

The kernel allows multiple entries in the main table which differ in the
priority value. In libnl currently, since priority is not part of the base
netlink route message, it is not used as part of the key. This patch
includes priority in the key/oo_id_attrs and defaults the value to zero
for messages where priority is not included.

One point to note is that the actual selection of route from multiple
options is done implicitly in the kernel by storing the routes in sort
priority order, but there is no explicit communication to a client of libnl
of that.

Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
roopa 2013-01-17 06:48:59 -08:00 committed by Thomas Graf
parent 2b96c3381d
commit 1481f97d36
1 changed files with 7 additions and 2 deletions

View File

@ -71,6 +71,7 @@ static void route_constructor(struct nl_object *c)
r->rt_table = RT_TABLE_MAIN;
r->rt_protocol = RTPROT_STATIC;
r->rt_type = RTN_UNICAST;
r->rt_prio = 0;
nl_init_list_head(&r->rt_nexthops);
}
@ -303,6 +304,7 @@ static void route_keygen(struct nl_object *obj, uint32_t *hashkey,
uint8_t rt_family;
uint8_t rt_tos;
uint32_t rt_table;
uint32_t rt_prio;
char rt_addr[0];
} __attribute__((packed)) *rkey;
char buf[INET6_ADDRSTRLEN+5];
@ -322,6 +324,7 @@ static void route_keygen(struct nl_object *obj, uint32_t *hashkey,
rkey->rt_family = route->rt_family;
rkey->rt_tos = route->rt_tos;
rkey->rt_table = route->rt_table;
rkey->rt_prio = route->rt_prio;
if (addr)
memcpy(rkey->rt_addr, nl_addr_get_binary_addr(addr),
nl_addr_get_len(addr));
@ -1026,11 +1029,12 @@ int rtnl_route_parse(struct nlmsghdr *nlh, struct rtnl_route **result)
route->rt_scope = rtm->rtm_scope;
route->rt_protocol = rtm->rtm_protocol;
route->rt_flags = rtm->rtm_flags;
route->rt_prio = 0;
route->ce_mask |= ROUTE_ATTR_FAMILY | ROUTE_ATTR_TOS |
ROUTE_ATTR_TABLE | ROUTE_ATTR_TYPE |
ROUTE_ATTR_SCOPE | ROUTE_ATTR_PROTOCOL |
ROUTE_ATTR_FLAGS;
ROUTE_ATTR_FLAGS | ROUTE_ATTR_PRIO;
if (tb[RTA_DST]) {
if (!(dst = nl_addr_alloc_attr(tb[RTA_DST], family)))
@ -1299,7 +1303,8 @@ struct nl_object_ops route_obj_ops = {
.oo_update = route_update,
.oo_attrs2str = route_attrs2str,
.oo_id_attrs = (ROUTE_ATTR_FAMILY | ROUTE_ATTR_TOS |
ROUTE_ATTR_TABLE | ROUTE_ATTR_DST),
ROUTE_ATTR_TABLE | ROUTE_ATTR_DST |
ROUTE_ATTR_PRIO),
};
/** @endcond */