summaryrefslogtreecommitdiff
path: root/zebra/rt_netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/rt_netlink.c')
-rw-r--r--zebra/rt_netlink.c62
1 files changed, 48 insertions, 14 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index ffab76bbe6..b95ef8462b 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -850,12 +850,6 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h,
if (rtm->rtm_type != RTN_UNICAST)
return 0;
- table = rtm->rtm_table;
- if (!is_zebra_valid_kernel_table(table) && !is_zebra_main_routing_table(table))
- return 0;
-
- vrf_id = vrf_lookup_by_table(table);
-
len = h->nlmsg_len - NLMSG_LENGTH (sizeof (struct rtmsg));
if (len < 0)
return -1;
@@ -873,6 +867,21 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h,
if (rtm->rtm_src_len != 0)
return 0;
+ /* Table corresponding to route. */
+ if (tb[RTA_TABLE])
+ table = *(int *) RTA_DATA (tb[RTA_TABLE]);
+ else
+ table = rtm->rtm_table;
+
+ /* Map to VRF */
+ vrf_id = vrf_lookup_by_table(table);
+ if (vrf_id == VRF_DEFAULT)
+ {
+ if (!is_zebra_valid_kernel_table(table) &&
+ !is_zebra_main_routing_table(table))
+ return 0;
+ }
+
/* Route which inserted by Zebra. */
if (rtm->rtm_protocol == RTPROT_ZEBRA)
flags |= ZEBRA_FLAG_SELFROUTE;
@@ -1045,12 +1054,6 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
return 0;
}
- table = rtm->rtm_table;
- if (!is_zebra_valid_kernel_table(table) && !is_zebra_main_routing_table(table))
- return 0;
-
- vrf_id = vrf_lookup_by_table(table);
-
len = h->nlmsg_len - NLMSG_LENGTH (sizeof (struct rtmsg));
if (len < 0)
return -1;
@@ -1076,6 +1079,21 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
return 0;
}
+ /* Table corresponding to route. */
+ if (tb[RTA_TABLE])
+ table = *(int *) RTA_DATA (tb[RTA_TABLE]);
+ else
+ table = rtm->rtm_table;
+
+ /* Map to VRF */
+ vrf_id = vrf_lookup_by_table(table);
+ if (vrf_id == VRF_DEFAULT)
+ {
+ if (!is_zebra_valid_kernel_table(table) &&
+ !is_zebra_main_routing_table(table))
+ return 0;
+ }
+
index = 0;
metric = 0;
dest = NULL;
@@ -1654,7 +1672,6 @@ netlink_route (int cmd, int family, void *dest, int length, void *gate,
req.n.nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST;
req.n.nlmsg_type = cmd;
req.r.rtm_family = family;
- req.r.rtm_table = table;
req.r.rtm_dst_len = length;
req.r.rtm_protocol = RTPROT_ZEBRA;
req.r.rtm_scope = RT_SCOPE_UNIVERSE;
@@ -1687,6 +1704,15 @@ netlink_route (int cmd, int family, void *dest, int length, void *gate,
if (dest)
addattr_l (&req.n, sizeof req, RTA_DST, dest, bytelen);
+ /* Table corresponding to this route. */
+ if (table < 256)
+ req.r.rtm_table = table;
+ else
+ {
+ req.r.rtm_table = RT_TABLE_UNSPEC;
+ addattr32(&req.n, sizeof req, RTA_TABLE, table);
+ }
+
if (!discard)
{
if (gate)
@@ -2071,7 +2097,6 @@ netlink_route_multipath (int cmd, struct prefix *p, struct rib *rib,
req.n.nlmsg_flags |= NLM_F_REPLACE;
req.n.nlmsg_type = cmd;
req.r.rtm_family = family;
- req.r.rtm_table = rib->table;
req.r.rtm_dst_len = p->prefixlen;
req.r.rtm_protocol = RTPROT_ZEBRA;
req.r.rtm_scope = RT_SCOPE_UNIVERSE;
@@ -2105,6 +2130,15 @@ netlink_route_multipath (int cmd, struct prefix *p, struct rib *rib,
*/
addattr32 (&req.n, sizeof req, RTA_PRIORITY, NL_DEFAULT_ROUTE_METRIC);
+ /* Table corresponding to this route. */
+ if (rib->table < 256)
+ req.r.rtm_table = rib->table;
+ else
+ {
+ req.r.rtm_table = RT_TABLE_UNSPEC;
+ addattr32(&req.n, sizeof req, RTA_TABLE, rib->table);
+ }
+
if (discard)
{
if (cmd == RTM_NEWROUTE)