From e82a974a6636ebadfad4d31384760acbec41ed27 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 24 Apr 2008 12:06:13 -0700 Subject: mark static routes as inactive when link is down When link becomes unavailable, unselect any routes that use that link as the next hop. This keeps routing protocols from propogating routes these routes and greating black holes. --- zebra/zebra_rib.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'zebra/zebra_rib.c') diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 80a7279f..77406b0c 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -342,6 +342,7 @@ static int nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set, struct route_node *top) { + struct interface *ifp; struct prefix_ipv4 p; struct route_table *table; struct route_node *rn; @@ -398,7 +399,16 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set, newhop = match->nexthop; if (newhop && nexthop->type == NEXTHOP_TYPE_IPV4) nexthop->ifindex = newhop->ifindex; - + else if (newhop && newhop->type == NEXTHOP_TYPE_IFINDEX) + { + ifp = if_lookup_by_index (newhop->ifindex); + return (ifp && if_is_operative (ifp)); + } + else if (newhop && newhop->type == NEXTHOP_TYPE_IFNAME) + { + ifp = if_lookup_by_name(newhop->ifname); + return (ifp && if_is_operative (ifp)); + } return 1; } else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL)) @@ -439,6 +449,7 @@ static int nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set, struct route_node *top) { + struct interface *ifp; struct prefix_ipv6 p; struct route_table *table; struct route_node *rn; @@ -496,7 +507,17 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set, if (newhop && nexthop->type == NEXTHOP_TYPE_IPV6) nexthop->ifindex = newhop->ifindex; - + else if (newhop && newhop->type == NEXTHOP_TYPE_IFINDEX) + { + ifp = if_lookup_by_index (newhop->ifindex); + return (ifp && if_is_operative (ifp)); + } + else if (newhop && newhop->type == NEXTHOP_TYPE_IFNAME) + { + ifp = if_lookup_by_name(newhop->ifname); + return (ifp && if_is_operative (ifp)); + } + return 1; } else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL)) -- cgit v1.2.3 From df7ff29201ccfeb39f0cf5112930aae2f30bb5ec Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Sat, 26 Apr 2008 09:51:39 -0700 Subject: Check nexthop for internal routes Check if nexthop is active when doing RIB update. This should fix issues with static routes staying active after link going down. --- zebra/zebra_rib.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'zebra/zebra_rib.c') diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 77406b0c..5de320d9 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -428,6 +428,17 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set, || newhop->type == NEXTHOP_TYPE_IFNAME || newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX) nexthop->rifindex = newhop->ifindex; + + if (newhop->type == NEXTHOP_TYPE_IFINDEX) + { + ifp = if_lookup_by_index (newhop->ifindex); + return (ifp && if_is_operative (ifp)); + } + else if (newhop && newhop->type == NEXTHOP_TYPE_IFNAME) + { + ifp = if_lookup_by_name(newhop->ifname); + return (ifp && if_is_operative (ifp)); + } } return 1; } @@ -539,6 +550,17 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set, || newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX || newhop->type == NEXTHOP_TYPE_IPV6_IFNAME) nexthop->rifindex = newhop->ifindex; + + if (newhop && newhop->type == NEXTHOP_TYPE_IFINDEX) + { + ifp = if_lookup_by_index (newhop->ifindex); + return (ifp && if_is_operative (ifp)); + } + else if (newhop && newhop->type == NEXTHOP_TYPE_IFNAME) + { + ifp = if_lookup_by_name(newhop->ifname); + return (ifp && if_is_operative (ifp)); + } } return 1; } -- cgit v1.2.3 From ccbba60205d0cf64fe12611e057d4581d40e4e22 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 28 Apr 2008 10:02:25 -0700 Subject: Check nexthop status Need to check if next hop is interface and if so then only mark route active is interface is active. This addresses some of the problems with static routes when interface goes down. --- zebra/zebra_rib.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'zebra/zebra_rib.c') diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 5de320d9..27cd4fa9 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -428,17 +428,17 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set, || newhop->type == NEXTHOP_TYPE_IFNAME || newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX) nexthop->rifindex = newhop->ifindex; + } - if (newhop->type == NEXTHOP_TYPE_IFINDEX) - { - ifp = if_lookup_by_index (newhop->ifindex); - return (ifp && if_is_operative (ifp)); - } - else if (newhop && newhop->type == NEXTHOP_TYPE_IFNAME) - { - ifp = if_lookup_by_name(newhop->ifname); - return (ifp && if_is_operative (ifp)); - } + if (newhop->type == NEXTHOP_TYPE_IFINDEX) + { + ifp = if_lookup_by_index (newhop->ifindex); + return (ifp && if_is_operative (ifp)); + } + else if (newhop && newhop->type == NEXTHOP_TYPE_IFNAME) + { + ifp = if_lookup_by_name(newhop->ifname); + return (ifp && if_is_operative (ifp)); } return 1; } @@ -550,17 +550,17 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set, || newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX || newhop->type == NEXTHOP_TYPE_IPV6_IFNAME) nexthop->rifindex = newhop->ifindex; + } - if (newhop && newhop->type == NEXTHOP_TYPE_IFINDEX) - { - ifp = if_lookup_by_index (newhop->ifindex); - return (ifp && if_is_operative (ifp)); - } - else if (newhop && newhop->type == NEXTHOP_TYPE_IFNAME) - { - ifp = if_lookup_by_name(newhop->ifname); - return (ifp && if_is_operative (ifp)); - } + if (newhop && newhop->type == NEXTHOP_TYPE_IFINDEX) + { + ifp = if_lookup_by_index (newhop->ifindex); + return (ifp && if_is_operative (ifp)); + } + else if (newhop && newhop->type == NEXTHOP_TYPE_IFNAME) + { + ifp = if_lookup_by_name(newhop->ifname); + return (ifp && if_is_operative (ifp)); } return 1; } -- cgit v1.2.3