/* Distance or tag changed. */
if (update)
- static_delete_ipv4 (safi, p, gate, ifindex, update->tag, update->distance, zvrf);
+ static_delete_route (AFI_IP, safi, type, p, (union g_addr *)gate,
+ ifindex, update->tag, update->distance, zvrf);
/* Make new static route structure. */
si = XCALLOC (MTYPE_STATIC_ROUTE, sizeof (struct static_route));
}
int
-static_delete_ipv4 (safi_t safi, struct prefix *p, struct in_addr *gate, ifindex_t ifindex,
- u_short tag, u_char distance, struct zebra_vrf *zvrf)
+static_delete_route (afi_t afi, safi_t safi, u_char type, struct prefix *p,
+ union g_addr *gate, ifindex_t ifindex,
+ u_short tag, u_char distance, struct zebra_vrf *zvrf)
{
- u_char type = 0;
struct route_node *rn;
struct static_route *si;
struct route_table *stable;
/* Lookup table. */
- stable = zebra_vrf_static_table (AFI_IP, safi, zvrf);
+ stable = zebra_vrf_static_table (afi, safi, zvrf);
if (! stable)
return -1;
if (! rn)
return 0;
- /* Make flags. */
- if (gate)
- type = STATIC_IPV4_GATEWAY;
- else if (ifindex)
- type = STATIC_IFINDEX;
- else
- type = STATIC_IPV4_BLACKHOLE;
-
/* Find same static route is the tree */
for (si = rn->info; si; si = si->next)
if (type == si->type
- && (! gate || IPV4_ADDR_SAME (gate, &si->addr.ipv4))
+ && (! gate || (
+ (afi == AFI_IP && IPV4_ADDR_SAME (gate, &si->addr.ipv4)) ||
+ (afi == AFI_IP6 && IPV6_ADDR_SAME (gate, &si->addr.ipv6))))
&& (! ifindex || ifindex == si->ifindex)
&& (! tag || (tag == si->tag)))
break;
/* Distance or tag changed. */
if (update)
- static_delete_ipv6 (p, type, gate, ifindex, update->tag, update->distance, zvrf);
+ static_delete_route (AFI_IP6, SAFI_UNICAST, type, p,
+ (union g_addr *)gate, ifindex,
+ update->tag, update->distance, zvrf);
/* Make new static route structure. */
si = XCALLOC (MTYPE_STATIC_ROUTE, sizeof (struct static_route));
return 1;
}
-
-/* Delete static route from static route configuration. */
-int
-static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
- ifindex_t ifindex, u_short tag, u_char distance,
- struct zebra_vrf *zvrf)
-{
- struct route_node *rn;
- struct static_route *si;
- struct route_table *stable;
-
- /* Lookup table. */
- stable = zebra_vrf_static_table (AFI_IP6, SAFI_UNICAST, zvrf);
- if (! stable)
- return -1;
-
- /* Lookup static route prefix. */
- rn = route_node_lookup (stable, p);
- if (! rn)
- return 0;
-
- /* Find same static route is the tree */
- for (si = rn->info; si; si = si->next)
- if (distance == si->distance
- && type == si->type
- && (! gate || IPV6_ADDR_SAME (gate, &si->addr.ipv6))
- && (! ifindex || ifindex == si->ifindex)
- && (! tag || (tag == si->tag)))
- break;
-
- /* Can't find static route. */
- if (! si)
- {
- route_unlock_node (rn);
- return 0;
- }
-
- /* Install into rib. */
- static_uninstall_route (AFI_IP6, SAFI_UNICAST, p, si);
-
- /* Unlink static route from linked list. */
- if (si->prev)
- si->prev->next = si->next;
- else
- rn->info = si->next;
- if (si->next)
- si->next->prev = si->prev;
-
- /* Free static route configuration. */
- XFREE (MTYPE_STATIC_ROUTE, si);
-
- return 1;
-}
u_char distance, struct zebra_vrf *zvrf);
extern int
-static_delete_ipv4 (safi_t safi, struct prefix *p, struct in_addr *gate, ifindex_t ifindex,
- u_short tag, u_char distance, struct zebra_vrf *zvrf);
+static_delete_route (afi_t, safi_t safi, u_char type, struct prefix *p,
+ union g_addr *gate, ifindex_t ifindex,
+ u_short tag, u_char distance,
+ struct zebra_vrf *zvrf);
extern int
static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
ifindex_t ifindex, const char *ifname, u_char flags,
u_short tag, u_char distance, struct zebra_vrf *zvrf);
-extern int
-static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
- ifindex_t ifindex, u_short tag, u_char distance,
- struct zebra_vrf *zvrf);
-
#endif
struct zebra_vrf *zvrf = NULL;
unsigned int ifindex = 0;
const char *ifname = NULL;
+ u_char type = STATIC_IPV4_BLACKHOLE;
ret = str2prefix (dest_str, &p);
if (ret <= 0)
if (add_cmd)
static_add_ipv4 (safi, &p, NULL, ifindex, ifname, ZEBRA_FLAG_BLACKHOLE, tag, distance, zvrf);
else
- static_delete_ipv4 (safi, &p, NULL, ifindex, tag, distance, zvrf);
+ static_delete_route (AFI_IP, safi, type, &p, NULL, ifindex, tag, distance, zvrf);
return CMD_SUCCESS;
}
if (gate_str == NULL)
{
+ type = STATIC_IFINDEX;
if (add_cmd)
static_add_ipv4 (safi, &p, NULL, ifindex, ifname, flag, tag, distance, zvrf);
else
- static_delete_ipv4 (safi, &p, NULL, ifindex, tag, distance, zvrf);
+ static_delete_route (AFI_IP, safi, type, &p, NULL, ifindex, tag, distance, zvrf);
return CMD_SUCCESS;
}
else
ifindex = ifp->ifindex;
ifname = gate_str;
+ type = STATIC_IFINDEX;
}
+ else
+ type = STATIC_IPV4_GATEWAY;
if (add_cmd)
static_add_ipv4 (safi, &p, ifindex ? NULL : &gate, ifindex, ifname, flag, tag, distance, zvrf);
else
- static_delete_ipv4 (safi, &p, ifindex ? NULL : &gate, ifindex, tag, distance, zvrf);
+ static_delete_route (AFI_IP, safi, type, &p, ifindex ? NULL : (union g_addr *)&gate, ifindex, tag, distance, zvrf);
return CMD_SUCCESS;
}
if (add_cmd)
static_add_ipv6 (&p, type, gate, ifindex, ifname, flag, tag, distance, zvrf);
else
- static_delete_ipv6 (&p, type, gate, ifindex, tag, distance, zvrf);
+ static_delete_route (AFI_IP6, SAFI_UNICAST, type, &p, (union g_addr *)gate, ifindex, tag, distance, zvrf);
return CMD_SUCCESS;
}