1. Removed the VRF_DEFAULT dependency from ospf6d.
2. The dependency on show command still exist
will be fixed when the ospf6 master is available.
Co-authored-by: Harios <hari@niralnetworks.com>
Signed-off-by: Kaushik <kaushik@niralnetworks.com>
struct ospf6_interface *oi;
oi = ospf6_interface_lookup_by_ifindex(
- ospf6_route_get_first_nh_index(route));
+ ospf6_route_get_first_nh_index(route), area->ospf6->vrf_id);
if (oi && oi->area && oi->area == area)
return 1;
else
#include "ospf6_flood.h"
#include "ospf6d.h"
-static void ospf6_asbr_redistribute_set(int type);
-static void ospf6_asbr_redistribute_unset(int type);
+static void ospf6_asbr_redistribute_set(int type, vrf_id_t vrf_id);
+static void ospf6_asbr_redistribute_unset(int type, vrf_id_t vrf_id);
unsigned char conf_debug_ospf6_asbr = 0;
__func__, ospf6->rmap[arg_type].name,
ZROUTE_NAME(arg_type));
- ospf6_zebra_no_redistribute(arg_type);
- ospf6_zebra_redistribute(arg_type);
+ ospf6_zebra_no_redistribute(arg_type, ospf6->vrf_id);
+ ospf6_zebra_redistribute(arg_type, ospf6->vrf_id);
}
XFREE(MTYPE_OSPF6_DIST_ARGS, arg);
"%s: route-map %s deleted, reset redist %s",
__func__, mapname,
ZROUTE_NAME(type));
- ospf6_asbr_redistribute_unset(type);
+ ospf6_asbr_redistribute_unset(
+ type, ospf6->vrf_id);
ospf6_asbr_routemap_set(type, mapname);
- ospf6_asbr_redistribute_set(type);
+ ospf6_asbr_redistribute_set(
+ type, ospf6->vrf_id);
}
}
} else
return o->external_table->count;
}
-static void ospf6_asbr_redistribute_set(int type)
+static void ospf6_asbr_redistribute_set(int type, vrf_id_t vrf_id)
{
- ospf6_zebra_redistribute(type);
+ ospf6_zebra_redistribute(type, vrf_id);
}
-static void ospf6_asbr_redistribute_unset(int type)
+static void ospf6_asbr_redistribute_unset(int type, vrf_id_t vrf_id)
{
struct ospf6_route *route;
struct ospf6_external_info *info;
- ospf6_zebra_no_redistribute(type);
+ ospf6_zebra_no_redistribute(type, vrf_id);
for (route = ospf6_route_head(ospf6->external_table); route;
route = ospf6_route_next(route)) {
struct listnode *lnode, *lnnode;
struct ospf6_area *oa;
- if (!ospf6_zebra_is_redistribute(type))
+ if (!ospf6_zebra_is_redistribute(type, ospf6->vrf_id))
return;
memset(&troute, 0, sizeof(troute));
{
int type;
+ OSPF6_CMD_CHECK_RUNNING();
+
char *proto = argv[argc - 1]->text;
type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
return CMD_WARNING_CONFIG_FAILED;
- ospf6_asbr_redistribute_unset(type);
- ospf6_asbr_redistribute_set(type);
+ ospf6_asbr_redistribute_unset(type, ospf6->vrf_id);
+ ospf6_asbr_redistribute_set(type, ospf6->vrf_id);
return CMD_SUCCESS;
}
int idx_word = 3;
int type;
+ OSPF6_CMD_CHECK_RUNNING();
+
char *proto = argv[idx_protocol]->text;
type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
return CMD_WARNING_CONFIG_FAILED;
- ospf6_asbr_redistribute_unset(type);
+ ospf6_asbr_redistribute_unset(type, ospf6->vrf_id);
ospf6_asbr_routemap_set(type, argv[idx_word]->arg);
- ospf6_asbr_redistribute_set(type);
+ ospf6_asbr_redistribute_set(type, ospf6->vrf_id);
return CMD_SUCCESS;
}
int idx_protocol = 2;
int type;
+ OSPF6_CMD_CHECK_RUNNING();
+
char *proto = argv[idx_protocol]->text;
type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
return CMD_WARNING_CONFIG_FAILED;
- ospf6_asbr_redistribute_unset(type);
+ ospf6_asbr_redistribute_unset(type, ospf6->vrf_id);
return CMD_SUCCESS;
}
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
if (type == ZEBRA_ROUTE_OSPF6)
continue;
- if (!ospf6_zebra_is_redistribute(type))
+ if (!ospf6_zebra_is_redistribute(type, ospf6->vrf_id))
continue;
if (ospf6->rmap[type].name)
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
if (type == ZEBRA_ROUTE_OSPF6)
continue;
- if (!ospf6_zebra_is_redistribute(type))
+ if (!ospf6_zebra_is_redistribute(type, ospf6->vrf_id))
continue;
if (ospf6->rmap[type].name)
if (type == RMAP_OSPF6) {
ei = ((struct ospf6_route *)object)->route_option;
- ifp = if_lookup_by_name((char *)rule, VRF_DEFAULT);
+ ifp = if_lookup_by_name_all_vrf((char *)rule);
if (ifp != NULL && ei->ifindex == ifp->ifindex)
return RMAP_MATCH;
install_element(OSPF6_NODE, &no_ospf6_redistribute_cmd);
}
-void ospf6_asbr_redistribute_reset(void)
+void ospf6_asbr_redistribute_reset(vrf_id_t vrf_id)
{
int type;
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
if (type == ZEBRA_ROUTE_OSPF6)
continue;
- if (ospf6_zebra_is_redistribute(type))
- ospf6_asbr_redistribute_unset(type);
+ if (ospf6_zebra_is_redistribute(type, vrf_id))
+ ospf6_asbr_redistribute_unset(type, vrf_id);
}
}
extern int ospf6_redistribute_config_write(struct vty *vty);
extern void ospf6_asbr_init(void);
-extern void ospf6_asbr_redistribute_reset(void);
+extern void ospf6_asbr_redistribute_reset(vrf_id_t vrf_id);
extern void ospf6_asbr_terminate(void);
extern void ospf6_asbr_send_externals_to_area(struct ospf6_area *);
cbit = CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_CBIT_ON);
bfd_peer_sendmsg(zclient, bfd_info, AF_INET6, &on->linklocal_addr,
- on->ospf6_if->linklocal_addr, ifp->name, 0, 0,
- cbit, command, 0, VRF_DEFAULT);
+ on->ospf6_if->linklocal_addr, ifp->name, 0, 0, cbit,
+ command, 0, ifp->vrf_id);
if (command == ZEBRA_BFD_DEST_DEREGISTER)
bfd_info_free((struct bfd_info **)&on->bfd_info);
*/
static int ospf6_bfd_nbr_replay(ZAPI_CALLBACK_ARGS)
{
- struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct listnode *node;
struct interface *ifp;
struct ospf6_interface *oi;
"None", "Down", "Loopback", "Waiting", "PointToPoint",
"DROther", "BDR", "DR", NULL};
-struct ospf6_interface *ospf6_interface_lookup_by_ifindex(ifindex_t ifindex)
+struct ospf6_interface *ospf6_interface_lookup_by_ifindex(ifindex_t ifindex,
+ vrf_id_t vrf_id)
{
struct ospf6_interface *oi;
struct interface *ifp;
- ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
+ ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL)
return (struct ospf6_interface *)NULL;
return CMD_SUCCESS;
}
-static int ospf6_interface_show_traffic(struct vty *vty, uint32_t vrf_id,
+static int ospf6_interface_show_traffic(struct vty *vty,
struct interface *intf_ifp,
int display_once)
{
struct vrf *vrf = NULL;
struct ospf6_interface *oi = NULL;
- vrf = vrf_lookup_by_id(vrf_id);
+ vrf = vrf_lookup_by_id(intf_ifp->vrf_id);
if (!display_once) {
vty_out(vty, "\n");
}
}
- ospf6_interface_show_traffic(vty, VRF_DEFAULT, ifp, display_once);
+ ospf6_interface_show_traffic(vty, ifp, display_once);
return CMD_SUCCESS;
/* Function Prototypes */
-extern struct ospf6_interface *ospf6_interface_lookup_by_ifindex(ifindex_t);
+extern struct ospf6_interface *
+ospf6_interface_lookup_by_ifindex(ifindex_t, vrf_id_t vrf_id);
extern struct ospf6_interface *ospf6_interface_create(struct interface *);
extern void ospf6_interface_delete(struct ospf6_interface *);
if (intra_prefix_lsa->ref_adv_router
== oa->ospf6->router_id) {
ifp = if_lookup_prefix(
- &old_route->prefix,
- VRF_DEFAULT);
+ &old_route->prefix,
+ oa->ospf6->vrf_id);
if (ifp)
ospf6_route_add_nexthop(
old_route,
memcpy(&route->path.ls_prefix, &ls_prefix,
sizeof(struct prefix));
if (direct_connect) {
- ifp = if_lookup_prefix(&route->prefix, VRF_DEFAULT);
+ ifp = if_lookup_prefix(&route->prefix,
+ oa->ospf6->vrf_id);
if (ifp)
ospf6_route_add_nexthop(route, ifp->ifindex,
NULL);
static void __attribute__((noreturn)) ospf6_exit(int status)
{
- struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct vrf *vrf;
struct interface *ifp;
frr_early_fini();
if (ospf6) {
+ vrf = vrf_lookup_by_id(ospf6->vrf_id);
ospf6_delete(ospf6);
ospf6 = NULL;
- }
+ } else
+ vrf = vrf_lookup_by_id(VRF_DEFAULT);
bfd_gbl_exit();
return 0;
}
- oi = ospf6_interface_lookup_by_ifindex(ifindex);
+ oi = ospf6_interface_lookup_by_ifindex(ifindex, ospf6->vrf_id);
if (oi == NULL || oi->area == NULL
|| CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) {
if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV))
inet_ntop(AF_INET6, &nh->address, buf,
sizeof(buf));
ifname = ifindex2ifname(nh->ifindex,
- VRF_DEFAULT);
+ ospf6->vrf_id);
zlog_debug(" nexthop: %s%%%.*s(%d)", buf,
IFNAMSIZ, ifname, nh->ifindex);
}
if (i >= entries)
return;
- nexthops[i].vrf_id = VRF_DEFAULT;
+ nexthops[i].vrf_id = ospf6->vrf_id;
nexthops[i].ifindex = nh->ifindex;
if (!IN6_IS_ADDR_UNSPECIFIED(&nh->address)) {
nexthops[i].gate.ipv6 = nh->address;
struct listnode *node;
struct ospf6_nexthop *nh;
+ if (ospf6 == NULL) {
+ vty_out(vty, "OSPFv3 is not running\n");
+ return;
+ }
+
monotime(&now);
timersub(&now, &route->changed, &res);
timerstring(&res, duration, sizeof(duration));
for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) {
/* nexthop */
inet_ntop(AF_INET6, &nh->address, nexthop, sizeof(nexthop));
- ifname = ifindex2ifname(nh->ifindex, VRF_DEFAULT);
+ ifname = ifindex2ifname(nh->ifindex, ospf6->vrf_id);
if (!i) {
vty_out(vty, "%c%1s %2s %-30s %-25s %6.*s %s\n",
struct listnode *node;
struct ospf6_nexthop *nh;
+ if (ospf6 == NULL) {
+ vty_out(vty, "OSPFv3 is not running\n");
+ return;
+ }
+
monotime(&now);
/* destination */
for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) {
/* nexthop */
inet_ntop(AF_INET6, &nh->address, nexthop, sizeof(nexthop));
- ifname = ifindex2ifname(nh->ifindex, VRF_DEFAULT);
+ ifname = ifindex2ifname(nh->ifindex, ospf6->vrf_id);
vty_out(vty, " %s %.*s\n", nexthop, IFNAMSIZ, ifname);
}
vty_out(vty, "\n");
int exact, size_t *var_len,
WriteMethod **write_method)
{
- struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct vrf *vrf;
struct ospf6_lsa *lsa = NULL;
ifindex_t ifindex;
uint32_t area_id, id, instid, adv_router;
if (ospf6 == NULL)
return NULL;
+ vrf = vrf_lookup_by_id(ospf6->vrf_id);
/* Get variable length. */
offset = name + v->namelen;
offsetlen = *length - v->namelen;
return NULL;
lsa = ospf6_lsdb_lookup(type, id, adv_router, oa->lsdb);
} else if (v->magic & OSPFv3WWLINKTABLE) {
- oi = ospf6_interface_lookup_by_ifindex(ifindex);
+ oi = ospf6_interface_lookup_by_ifindex(ifindex,
+ ospf6->vrf_id);
if (!oi || oi->instance_id != instid)
return NULL;
lsa = ospf6_lsdb_lookup(type, id, adv_router, oi->lsdb);
if (!iif->ifindex)
continue;
oi = ospf6_interface_lookup_by_ifindex(
- iif->ifindex);
+ iif->ifindex, iif->vrf_id);
if (!oi)
continue;
if (iif->ifindex < ifindex)
int exact, size_t *var_len,
WriteMethod **write_method)
{
- struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct vrf *vrf;
ifindex_t ifindex = 0;
unsigned int instid = 0;
struct ospf6_interface *oi = NULL;
if (ospf6 == NULL)
return NULL;
+ vrf = vrf_lookup_by_id(ospf6->vrf_id);
/* Get variable length. */
offset = name + v->namelen;
offsetlen = *length - v->namelen;
// offsetlen -= len;
if (exact) {
- oi = ospf6_interface_lookup_by_ifindex(ifindex);
+ oi = ospf6_interface_lookup_by_ifindex(ifindex, ospf6->vrf_id);
if (!oi || oi->instance_id != instid)
return NULL;
} else {
for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
if (!iif->ifindex)
continue;
- oi = ospf6_interface_lookup_by_ifindex(iif->ifindex);
+ oi = ospf6_interface_lookup_by_ifindex(iif->ifindex,
+ iif->vrf_id);
if (!oi)
continue;
if (iif->ifindex > ifindex
int exact, size_t *var_len,
WriteMethod **write_method)
{
- struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct vrf *vrf;
ifindex_t ifindex = 0;
unsigned int instid, rtrid;
struct ospf6_interface *oi = NULL;
if (ospf6 == NULL)
return NULL;
+ vrf = vrf_lookup_by_id(ospf6->vrf_id);
/* Get variable length. */
offset = name + v->namelen;
offsetlen = *length - v->namelen;
// offsetlen -= len;
if (exact) {
- oi = ospf6_interface_lookup_by_ifindex(ifindex);
+ oi = ospf6_interface_lookup_by_ifindex(ifindex, ospf6->vrf_id);
if (!oi || oi->instance_id != instid)
return NULL;
on = ospf6_neighbor_lookup(rtrid, oi);
for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
if (!iif->ifindex)
continue;
- oi = ospf6_interface_lookup_by_ifindex(iif->ifindex);
+ oi = ospf6_interface_lookup_by_ifindex(iif->ifindex,
+ iif->vrf_id);
if (!oi)
continue;
for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, j, on)) {
return;
}
- oi = ospf6_interface_lookup_by_ifindex(ifindex);
+ oi = ospf6_interface_lookup_by_ifindex(ifindex, ospf6->vrf_id);
if (oi == NULL) {
if (IS_OSPF6_DEBUG_SPF(PROCESS))
zlog_debug("Can't find interface in SPF: ifindex %d",
ospf6_area_disable(oa);
/* XXX: This also changes persistent settings */
- ospf6_asbr_redistribute_reset();
+ ospf6_asbr_redistribute_reset(o->vrf_id);
ospf6_lsdb_remove_all(o->lsdb);
ospf6_route_remove_all(o->route_table);
}
/* redistribute function */
-void ospf6_zebra_redistribute(int type)
+void ospf6_zebra_redistribute(int type, vrf_id_t vrf_id)
{
- if (vrf_bitmap_check(zclient->redist[AFI_IP6][type], VRF_DEFAULT))
+ if (vrf_bitmap_check(zclient->redist[AFI_IP6][type], vrf_id))
return;
- vrf_bitmap_set(zclient->redist[AFI_IP6][type], VRF_DEFAULT);
+ vrf_bitmap_set(zclient->redist[AFI_IP6][type], vrf_id);
if (zclient->sock > 0)
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient,
- AFI_IP6, type, 0, VRF_DEFAULT);
+ AFI_IP6, type, 0, vrf_id);
}
-void ospf6_zebra_no_redistribute(int type)
+void ospf6_zebra_no_redistribute(int type, vrf_id_t vrf_id)
{
- if (!vrf_bitmap_check(zclient->redist[AFI_IP6][type], VRF_DEFAULT))
+ if (!vrf_bitmap_check(zclient->redist[AFI_IP6][type], vrf_id))
return;
- vrf_bitmap_unset(zclient->redist[AFI_IP6][type], VRF_DEFAULT);
+ vrf_bitmap_unset(zclient->redist[AFI_IP6][type], vrf_id);
if (zclient->sock > 0)
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient,
- AFI_IP6, type, 0, VRF_DEFAULT);
+ AFI_IP6, type, 0, vrf_id);
}
static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
dest = &request->prefix;
memset(&api, 0, sizeof(api));
- api.vrf_id = VRF_DEFAULT;
+ api.vrf_id = ospf6->vrf_id;
api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST;
api.prefix = *dest;
if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
memset(&api, 0, sizeof(api));
- api.vrf_id = VRF_DEFAULT;
+ api.vrf_id = ospf6->vrf_id;
api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST;
api.prefix = *dest;
if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
memset(&api, 0, sizeof(api));
- api.vrf_id = VRF_DEFAULT;
+ api.vrf_id = ospf6->vrf_id;
api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST;
api.prefix = *dest;
extern void ospf6_zebra_route_update_add(struct ospf6_route *request);
extern void ospf6_zebra_route_update_remove(struct ospf6_route *request);
-extern void ospf6_zebra_redistribute(int);
-extern void ospf6_zebra_no_redistribute(int);
-#define ospf6_zebra_is_redistribute(type) \
- vrf_bitmap_check(zclient->redist[AFI_IP6][type], VRF_DEFAULT)
+extern void ospf6_zebra_redistribute(int, vrf_id_t vrf_id);
+extern void ospf6_zebra_no_redistribute(int, vrf_id_t vrf_id);
+#define ospf6_zebra_is_redistribute(type, vrf_id) \
+ vrf_bitmap_check(zclient->redist[AFI_IP6][type], vrf_id)
extern void ospf6_zebra_init(struct thread_master *);
extern void ospf6_zebra_add_discard(struct ospf6_route *request);
extern void ospf6_zebra_delete_discard(struct ospf6_route *request);