extern int
static_add_ipv4 (struct prefix *p, struct in_addr *gate, unsigned int ifindex,
- u_char flags, u_short tag, u_char distance, struct zebra_vrf *zvrf);
+ const char *ifname, u_char flags, u_short tag,
+ u_char distance, struct zebra_vrf *zvrf);
extern int
static_delete_ipv4 (struct prefix *p, struct in_addr *gate, unsigned int ifindex,
extern int
static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
- unsigned int ifindex, u_char flags, u_short tag,
- u_char distance, struct zebra_vrf *zvrf);
+ unsigned int ifindex, const char *ifname, u_char flags,
+ u_short tag, u_char distance, struct zebra_vrf *zvrf);
extern int
rib_add_ipv6_multipath (struct prefix *, struct rib *, safi_t,
/* Add static route into static route configuration. */
int
static_add_ipv4 (struct prefix *p, struct in_addr *gate, unsigned int ifindex,
- u_char flags, u_short tag, u_char distance, struct zebra_vrf *zvrf)
+ const char *ifname, u_char flags, u_short tag,
+ u_char distance, struct zebra_vrf *zvrf)
{
u_char type = 0;
struct route_node *rn;
si->vrf_id = zvrf->vrf_id;
si->ifindex = ifindex;
if (si->ifindex)
- strcpy(si->ifname, ifindex2ifname_vrf (si->ifindex, si->vrf_id));
+ strcpy(si->ifname, ifname);
if (gate)
si->addr.ipv4 = *gate;
/* Add static route into static route configuration. */
int
static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
- unsigned int ifindex, u_char flags, u_short tag,
- u_char distance, struct zebra_vrf *zvrf)
+ unsigned int ifindex, const char *ifname, u_char flags,
+ u_short tag, u_char distance, struct zebra_vrf *zvrf)
{
struct route_node *rn;
struct static_route *si;
si->tag = tag;
si->vrf_id = zvrf->vrf_id;
si->ifindex = ifindex;
+ if (si->ifindex)
+ strcpy (si->ifname, ifname);
switch (type)
{
extern int allow_delete;
-static struct zebra_vrf *
-zebra_vty_vrf_lookup (const char *vrf_id_str)
-{
- struct vrf *vrf = NULL;
-
- if (vrf_id_str)
- {
- vrf = vrf_list_lookup_by_name (vrf_id_str); //Pending: create VRF if the given vrf doesnt exist?
- }
- else
- {
- vrf = vrf_list_lookup_by_name (VRF_DEFAULT_NAME);
- }
-
- if (vrf)
- return (struct zebra_vrf *)vrf->info;
-
- return NULL;
-}
-
/* General fucntion for static route. */
static int
zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
u_short tag = 0;
struct zebra_vrf *zvrf = NULL;
unsigned int ifindex = 0;
+ const char *ifname = NULL;
ret = str2prefix (dest_str, &p);
if (ret <= 0)
tag = atoi(tag_str);
/* VRF id */
- zvrf = zebra_vty_vrf_lookup (vrf_id_str);
+ zvrf = zebra_vrf_list_lookup_by_name (vrf_id_str);
if (!zvrf)
{
return CMD_WARNING;
}
if (add_cmd)
- static_add_ipv4 (&p, NULL, ifindex, ZEBRA_FLAG_BLACKHOLE, tag, distance, zvrf);
+ static_add_ipv4 (&p, NULL, ifindex, ifname, ZEBRA_FLAG_BLACKHOLE, tag, distance, zvrf);
else
static_delete_ipv4 (&p, NULL, ifindex, tag, distance, zvrf);
return CMD_SUCCESS;
if (gate_str == NULL)
{
if (add_cmd)
- static_add_ipv4 (&p, NULL, ifindex, flag, tag, distance, zvrf);
+ static_add_ipv4 (&p, NULL, ifindex, ifname, flag, tag, distance, zvrf);
else
static_delete_ipv4 (&p, NULL, ifindex, tag, distance, zvrf);
{
struct interface *ifp = if_lookup_by_name_vrf (gate_str, zvrf->vrf_id);
if (!ifp)
- {
+ {
vty_out (vty, "%% Unknown interface: %s%s", gate_str, VTY_NEWLINE);
- return CMD_WARNING;
- }
- ifindex = ifp->ifindex;
+ ifindex = IFINDEX_DELETED;
+ }
+ else
+ ifindex = ifp->ifindex;
+ ifname = gate_str;
}
if (add_cmd)
- static_add_ipv4 (&p, ifindex ? NULL : &gate, ifindex, flag, tag, distance, zvrf);
+ static_add_ipv4 (&p, ifindex ? NULL : &gate, ifindex, ifname, flag, tag, distance, zvrf);
else
static_delete_ipv4 (&p, ifindex ? NULL : &gate, ifindex, tag, distance, zvrf);
ret = inet_pton (AF_INET6, gate_str, &gate_addr);
/* VRF id */
- zvrf = zebra_vty_vrf_lookup (vrf_id_str);
+ zvrf = zebra_vrf_list_lookup_by_name (vrf_id_str);
if (!zvrf)
{
if (!ifp)
{
vty_out (vty, "%% Malformed Interface name %s%s", gate_str, VTY_NEWLINE);
- return CMD_WARNING;
+ ifindex = IFINDEX_DELETED;
}
- ifindex = ifp->ifindex;
+ else
+ ifindex = ifp->ifindex;
+ ifname = gate_str;
}
}
if (add_cmd)
- static_add_ipv6 (&p, type, gate, ifindex, flag, tag, distance, zvrf);
+ static_add_ipv6 (&p, type, gate, ifindex, ifname, flag, tag, distance, zvrf);
else
static_delete_ipv6 (&p, type, gate, ifindex, tag, distance, zvrf);