* zebra_rib.c: Reduce the height of some staircases. Fix

rib_delete_ipv6() to match routes in the RIB by their gateway as
	  well as by destination.
This commit is contained in:
hasso 2005-09-21 14:58:20 +00:00
parent 75b2dd025a
commit ebf1ead032
2 changed files with 65 additions and 83 deletions

View File

@ -1,3 +1,9 @@
2005-09-21 David Young <dyoung@ojctech.com>
* zebra_rib.c: Reduce the height of some staircases. Fix
rib_delete_ipv6() to match routes in the RIB by their gateway as
well as by destination.
2005-09-21 Paul Jakma <paul.jakma@sun.com> 2005-09-21 Paul Jakma <paul.jakma@sun.com>
* zebra_rib.c: (static_uninstall_ipv{4,6}) Fix regression wrt * zebra_rib.c: (static_uninstall_ipv{4,6}) Fix regression wrt

View File

@ -1157,24 +1157,21 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
withdraw. */ withdraw. */
for (rib = rn->info; rib; rib = rib->next) for (rib = rn->info; rib; rib = rib->next)
{ {
if (rib->type == ZEBRA_ROUTE_CONNECT) if (rib->type != type)
{ continue;
nexthop = rib->nexthop; if (rib->type != ZEBRA_ROUTE_CONNECT)
/* Duplicate connected route comes in. */
if (rib->type == type
&& nexthop && nexthop->type == NEXTHOP_TYPE_IFINDEX
&& nexthop->ifindex == ifindex)
{
rib->refcnt++;
return 0 ;
}
}
else if (rib->type == type)
{ {
same = rib; same = rib;
break; break;
} }
/* Duplicate connected route comes in. */
else if ((nexthop = rib->nexthop) &&
nexthop->type == NEXTHOP_TYPE_IFINDEX &&
nexthop->ifindex == ifindex)
{
rib->refcnt++;
return 0 ;
}
} }
/* Allocate new rib structure. */ /* Allocate new rib structure. */
@ -1274,6 +1271,7 @@ rib_add_ipv4_multipath (struct prefix_ipv4 *p, struct rib *rib)
return 0; return 0;
} }
/* XXX factor with rib_delete_ipv6 */
int int
rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p, rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, unsigned int ifindex, u_int32_t vrf_id) struct in_addr *gate, unsigned int ifindex, u_int32_t vrf_id)
@ -1329,13 +1327,10 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
fib = rib; fib = rib;
if (rib->type == ZEBRA_ROUTE_CONNECT) if (rib->type != type)
{ continue;
nexthop = rib->nexthop; if (rib->type == ZEBRA_ROUTE_CONNECT && (nexthop = rib->nexthop) &&
nexthop->type == NEXTHOP_TYPE_IFINDEX && nexthop->ifindex == ifindex)
if (rib->type == type
&& nexthop && nexthop->type == NEXTHOP_TYPE_IFINDEX
&& nexthop->ifindex == ifindex)
{ {
if (rib->refcnt) if (rib->refcnt)
{ {
@ -1347,30 +1342,16 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
same = rib; same = rib;
break; break;
} }
}
else if (gate)
{
nexthop = rib->nexthop;
/* Make sure that the route found has the same gateway. */ /* Make sure that the route found has the same gateway. */
if (rib->type == type else if (gate == NULL ||
&& nexthop && ((nexthop = rib->nexthop) &&
(IPV4_ADDR_SAME (&nexthop->gate.ipv4, gate) || (IPV4_ADDR_SAME (&nexthop->gate.ipv4, gate) ||
IPV4_ADDR_SAME (&nexthop->rgate.ipv4, gate)) ) IPV4_ADDR_SAME (&nexthop->rgate.ipv4, gate))))
{ {
same = rib; same = rib;
break; break;
} }
} }
else
{
if (rib->type == type)
{
same = rib;
break;
}
}
}
/* If same type of route can't be found and this message is from /* If same type of route can't be found and this message is from
kernel. */ kernel. */
@ -1785,23 +1766,20 @@ rib_add_ipv6 (int type, int flags, struct prefix_ipv6 *p,
withdraw. */ withdraw. */
for (rib = rn->info; rib; rib = rib->next) for (rib = rn->info; rib; rib = rib->next)
{ {
if (rib->type == ZEBRA_ROUTE_CONNECT) if (rib->type != type)
{ continue;
nexthop = rib->nexthop; if (rib->type != ZEBRA_ROUTE_CONNECT)
if (rib->type == type
&& nexthop && nexthop->type == NEXTHOP_TYPE_IFINDEX
&& nexthop->ifindex == ifindex)
{
rib->refcnt++;
return 0;
}
}
else if (rib->type == type)
{ {
same = rib; same = rib;
break; break;
} }
else if ((nexthop = rib->nexthop) &&
nexthop->type == NEXTHOP_TYPE_IFINDEX &&
nexthop->ifindex == ifindex)
{
rib->refcnt++;
return 0;
}
} }
/* Allocate new rib structure. */ /* Allocate new rib structure. */
@ -1845,6 +1823,7 @@ rib_add_ipv6 (int type, int flags, struct prefix_ipv6 *p,
return 0; return 0;
} }
/* XXX factor with rib_delete_ipv6 */
int int
rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p, rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
struct in6_addr *gate, unsigned int ifindex, u_int32_t vrf_id) struct in6_addr *gate, unsigned int ifindex, u_int32_t vrf_id)
@ -1893,13 +1872,10 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
fib = rib; fib = rib;
if (rib->type == ZEBRA_ROUTE_CONNECT) if (rib->type != type)
{ continue;
nexthop = rib->nexthop; if (rib->type == ZEBRA_ROUTE_CONNECT && (nexthop = rib->nexthop) &&
nexthop->type == NEXTHOP_TYPE_IFINDEX && nexthop->ifindex == ifindex)
if (rib->type == type
&& nexthop && nexthop->type == NEXTHOP_TYPE_IFINDEX
&& nexthop->ifindex == ifindex)
{ {
if (rib->refcnt) if (rib->refcnt)
{ {
@ -1911,16 +1887,16 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
same = rib; same = rib;
break; break;
} }
} /* Make sure that the route found has the same gateway. */
else else if (gate == NULL ||
{ ((nexthop = rib->nexthop) &&
if (rib->type == type) (IPV6_ADDR_SAME (&nexthop->gate.ipv6, gate) ||
IPV6_ADDR_SAME (&nexthop->rgate.ipv6, gate))))
{ {
same = rib; same = rib;
break; break;
} }
} }
}
/* If same type of route can't be found and this message is from /* If same type of route can't be found and this message is from
kernel. */ kernel. */