summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zebra/rt_netlink.c9
-rw-r--r--zebra/zebra_rib.c42
2 files changed, 33 insertions, 18 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 4ab6b4bc15..290c8bc282 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -839,6 +839,7 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h)
int len;
struct rtmsg *rtm;
struct rtattr *tb[RTA_MAX + 1];
+ u_char zebra_flags = 0;
char anyaddr[16] = { 0 };
@@ -895,6 +896,8 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h)
if (rtm->rtm_protocol == RTPROT_ZEBRA && h->nlmsg_type == RTM_NEWROUTE)
return 0;
+ if (rtm->rtm_protocol == RTPROT_ZEBRA)
+ SET_FLAG(zebra_flags, ZEBRA_FLAG_SELFROUTE);
if (rtm->rtm_src_len != 0)
{
@@ -1004,7 +1007,8 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h)
}
}
else
- rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table, SAFI_UNICAST);
+ rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p, gate, index,
+ table, SAFI_UNICAST);
}
#ifdef HAVE_IPV6
@@ -1032,7 +1036,8 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h)
if (h->nlmsg_type == RTM_NEWROUTE)
rib_add_ipv6 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table, metric, 0, SAFI_UNICAST);
else
- rib_delete_ipv6 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table, SAFI_UNICAST);
+ rib_delete_ipv6 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p, gate, index,
+ table, SAFI_UNICAST);
}
#endif /* HAVE_IPV6 */
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 5cd81e3de4..dac1166cbc 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -2236,14 +2236,19 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
kernel. */
if (! same)
{
- if (fib && type == ZEBRA_ROUTE_KERNEL)
- {
- /* Unset flags. */
- for (nexthop = fib->nexthop; nexthop; nexthop = nexthop->next)
- UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
-
- UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED);
- }
+ if (fib && type == ZEBRA_ROUTE_KERNEL &&
+ CHECK_FLAG(flags, ZEBRA_FLAG_SELFROUTE))
+ {
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ {
+ zlog_debug ("Zebra route %s/%d was deleted by others from kernel",
+ inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
+ p->prefixlen);
+ }
+ /* This means someone else, other than Zebra, has deleted
+ * a Zebra router from the kernel. We will add it back */
+ rib_install_kernel(rn, fib);
+ }
else
{
if (IS_ZEBRA_DEBUG_KERNEL)
@@ -2900,14 +2905,19 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
kernel. */
if (! same)
{
- if (fib && type == ZEBRA_ROUTE_KERNEL)
- {
- /* Unset flags. */
- for (nexthop = fib->nexthop; nexthop; nexthop = nexthop->next)
- UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
-
- UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED);
- }
+ if (fib && type == ZEBRA_ROUTE_KERNEL &&
+ CHECK_FLAG(flags, ZEBRA_FLAG_SELFROUTE))
+ {
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ {
+ zlog_debug ("Zebra route %s/%d was deleted by others from kernel",
+ inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
+ p->prefixlen);
+ }
+ /* This means someone else, other than Zebra, has deleted a Zebra
+ * route from the kernel. We will add it back */
+ rib_install_kernel(rn, fib);
+ }
else
{
if (IS_ZEBRA_DEBUG_KERNEL)