summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroopa <roopa@cumulusnetworks.com>2013-01-17 06:48:59 -0800
committerThomas Graf <tgraf@suug.ch>2013-01-23 11:02:51 +0100
commit1481f97d3663ed35dc86020911aa9cf8ea104859 (patch)
tree354ff167251e2a11aa8aad8032481fca411457c3
parent2b96c3381d1048d36e58d312b186f439d74c895d (diff)
downloadlibnl-1481f97d3663ed35dc86020911aa9cf8ea104859.tar.gz
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>
-rw-r--r--lib/route/route_obj.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c
index e092d80..0c472b7 100644
--- a/lib/route/route_obj.c
+++ b/lib/route/route_obj.c
@@ -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 */