ospf6d : Preparing for ospf6d VRF support.

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>
This commit is contained in:
Kaushik 2020-09-01 01:31:49 -07:00
parent ddffdcf728
commit c5d28568c6
15 changed files with 98 additions and 69 deletions

View file

@ -72,7 +72,7 @@ static int ospf6_abr_nexthops_belong_to_area(struct ospf6_route *route,
struct ospf6_interface *oi; struct ospf6_interface *oi;
oi = ospf6_interface_lookup_by_ifindex( 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) if (oi && oi->area && oi->area == area)
return 1; return 1;
else else

View file

@ -47,8 +47,8 @@
#include "ospf6_flood.h" #include "ospf6_flood.h"
#include "ospf6d.h" #include "ospf6d.h"
static void ospf6_asbr_redistribute_set(int type); static void ospf6_asbr_redistribute_set(int type, vrf_id_t vrf_id);
static void ospf6_asbr_redistribute_unset(int type); static void ospf6_asbr_redistribute_unset(int type, vrf_id_t vrf_id);
unsigned char conf_debug_ospf6_asbr = 0; unsigned char conf_debug_ospf6_asbr = 0;
@ -881,8 +881,8 @@ static int ospf6_asbr_routemap_update_timer(struct thread *thread)
__func__, ospf6->rmap[arg_type].name, __func__, ospf6->rmap[arg_type].name,
ZROUTE_NAME(arg_type)); ZROUTE_NAME(arg_type));
ospf6_zebra_no_redistribute(arg_type); ospf6_zebra_no_redistribute(arg_type, ospf6->vrf_id);
ospf6_zebra_redistribute(arg_type); ospf6_zebra_redistribute(arg_type, ospf6->vrf_id);
} }
XFREE(MTYPE_OSPF6_DIST_ARGS, arg); XFREE(MTYPE_OSPF6_DIST_ARGS, arg);
@ -948,9 +948,11 @@ static void ospf6_asbr_routemap_update(const char *mapname)
"%s: route-map %s deleted, reset redist %s", "%s: route-map %s deleted, reset redist %s",
__func__, mapname, __func__, mapname,
ZROUTE_NAME(type)); ZROUTE_NAME(type));
ospf6_asbr_redistribute_unset(type); ospf6_asbr_redistribute_unset(
type, ospf6->vrf_id);
ospf6_asbr_routemap_set(type, mapname); ospf6_asbr_routemap_set(type, mapname);
ospf6_asbr_redistribute_set(type); ospf6_asbr_redistribute_set(
type, ospf6->vrf_id);
} }
} }
} else } else
@ -977,17 +979,17 @@ int ospf6_asbr_is_asbr(struct ospf6 *o)
return o->external_table->count; 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_route *route;
struct ospf6_external_info *info; 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; for (route = ospf6_route_head(ospf6->external_table); route;
route = ospf6_route_next(route)) { route = ospf6_route_next(route)) {
@ -1031,7 +1033,7 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
struct listnode *lnode, *lnnode; struct listnode *lnode, *lnnode;
struct ospf6_area *oa; struct ospf6_area *oa;
if (!ospf6_zebra_is_redistribute(type)) if (!ospf6_zebra_is_redistribute(type, ospf6->vrf_id))
return; return;
memset(&troute, 0, sizeof(troute)); memset(&troute, 0, sizeof(troute));
@ -1243,13 +1245,15 @@ DEFUN (ospf6_redistribute,
{ {
int type; int type;
OSPF6_CMD_CHECK_RUNNING();
char *proto = argv[argc - 1]->text; char *proto = argv[argc - 1]->text;
type = proto_redistnum(AFI_IP6, proto); type = proto_redistnum(AFI_IP6, proto);
if (type < 0) if (type < 0)
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
ospf6_asbr_redistribute_unset(type); ospf6_asbr_redistribute_unset(type, ospf6->vrf_id);
ospf6_asbr_redistribute_set(type); ospf6_asbr_redistribute_set(type, ospf6->vrf_id);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1265,14 +1269,16 @@ DEFUN (ospf6_redistribute_routemap,
int idx_word = 3; int idx_word = 3;
int type; int type;
OSPF6_CMD_CHECK_RUNNING();
char *proto = argv[idx_protocol]->text; char *proto = argv[idx_protocol]->text;
type = proto_redistnum(AFI_IP6, proto); type = proto_redistnum(AFI_IP6, proto);
if (type < 0) if (type < 0)
return CMD_WARNING_CONFIG_FAILED; 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_routemap_set(type, argv[idx_word]->arg);
ospf6_asbr_redistribute_set(type); ospf6_asbr_redistribute_set(type, ospf6->vrf_id);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1288,12 +1294,14 @@ DEFUN (no_ospf6_redistribute,
int idx_protocol = 2; int idx_protocol = 2;
int type; int type;
OSPF6_CMD_CHECK_RUNNING();
char *proto = argv[idx_protocol]->text; char *proto = argv[idx_protocol]->text;
type = proto_redistnum(AFI_IP6, proto); type = proto_redistnum(AFI_IP6, proto);
if (type < 0) if (type < 0)
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
ospf6_asbr_redistribute_unset(type); ospf6_asbr_redistribute_unset(type, ospf6->vrf_id);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1305,7 +1313,7 @@ int ospf6_redistribute_config_write(struct vty *vty)
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
if (type == ZEBRA_ROUTE_OSPF6) if (type == ZEBRA_ROUTE_OSPF6)
continue; continue;
if (!ospf6_zebra_is_redistribute(type)) if (!ospf6_zebra_is_redistribute(type, ospf6->vrf_id))
continue; continue;
if (ospf6->rmap[type].name) if (ospf6->rmap[type].name)
@ -1340,7 +1348,7 @@ static void ospf6_redistribute_show_config(struct vty *vty)
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
if (type == ZEBRA_ROUTE_OSPF6) if (type == ZEBRA_ROUTE_OSPF6)
continue; continue;
if (!ospf6_zebra_is_redistribute(type)) if (!ospf6_zebra_is_redistribute(type, ospf6->vrf_id))
continue; continue;
if (ospf6->rmap[type].name) if (ospf6->rmap[type].name)
@ -1408,7 +1416,7 @@ ospf6_routemap_rule_match_interface(void *rule, const struct prefix *prefix,
if (type == RMAP_OSPF6) { if (type == RMAP_OSPF6) {
ei = ((struct ospf6_route *)object)->route_option; 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) if (ifp != NULL && ei->ifindex == ifp->ifindex)
return RMAP_MATCH; return RMAP_MATCH;
@ -1880,15 +1888,15 @@ void ospf6_asbr_init(void)
install_element(OSPF6_NODE, &no_ospf6_redistribute_cmd); 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; int type;
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
if (type == ZEBRA_ROUTE_OSPF6) if (type == ZEBRA_ROUTE_OSPF6)
continue; continue;
if (ospf6_zebra_is_redistribute(type)) if (ospf6_zebra_is_redistribute(type, vrf_id))
ospf6_asbr_redistribute_unset(type); ospf6_asbr_redistribute_unset(type, vrf_id);
} }
} }

View file

@ -88,7 +88,7 @@ extern void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex,
extern int ospf6_redistribute_config_write(struct vty *vty); extern int ospf6_redistribute_config_write(struct vty *vty);
extern void ospf6_asbr_init(void); 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_terminate(void);
extern void ospf6_asbr_send_externals_to_area(struct ospf6_area *); extern void ospf6_asbr_send_externals_to_area(struct ospf6_area *);

View file

@ -89,8 +89,8 @@ void ospf6_bfd_reg_dereg_nbr(struct ospf6_neighbor *on, int command)
cbit = CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_CBIT_ON); cbit = CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_CBIT_ON);
bfd_peer_sendmsg(zclient, bfd_info, AF_INET6, &on->linklocal_addr, bfd_peer_sendmsg(zclient, bfd_info, AF_INET6, &on->linklocal_addr,
on->ospf6_if->linklocal_addr, ifp->name, 0, 0, on->ospf6_if->linklocal_addr, ifp->name, 0, 0, cbit,
cbit, command, 0, VRF_DEFAULT); command, 0, ifp->vrf_id);
if (command == ZEBRA_BFD_DEST_DEREGISTER) if (command == ZEBRA_BFD_DEST_DEREGISTER)
bfd_info_free((struct bfd_info **)&on->bfd_info); bfd_info_free((struct bfd_info **)&on->bfd_info);
@ -143,7 +143,7 @@ static void ospf6_bfd_reg_dereg_all_nbr(struct ospf6_interface *oi, int command)
*/ */
static int ospf6_bfd_nbr_replay(ZAPI_CALLBACK_ARGS) 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 listnode *node;
struct interface *ifp; struct interface *ifp;
struct ospf6_interface *oi; struct ospf6_interface *oi;

View file

@ -56,12 +56,13 @@ const char *const ospf6_interface_state_str[] = {
"None", "Down", "Loopback", "Waiting", "PointToPoint", "None", "Down", "Loopback", "Waiting", "PointToPoint",
"DROther", "BDR", "DR", NULL}; "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 ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
ifp = if_lookup_by_index(ifindex, VRF_DEFAULT); ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) if (ifp == NULL)
return (struct ospf6_interface *)NULL; return (struct ospf6_interface *)NULL;
@ -1022,7 +1023,7 @@ DEFUN (show_ipv6_ospf6_interface,
return CMD_SUCCESS; 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, struct interface *intf_ifp,
int display_once) int display_once)
{ {
@ -1030,7 +1031,7 @@ static int ospf6_interface_show_traffic(struct vty *vty, uint32_t vrf_id,
struct vrf *vrf = NULL; struct vrf *vrf = NULL;
struct ospf6_interface *oi = 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) { if (!display_once) {
vty_out(vty, "\n"); vty_out(vty, "\n");
@ -1105,7 +1106,7 @@ DEFUN (show_ipv6_ospf6_interface_traffic,
} }
} }
ospf6_interface_show_traffic(vty, VRF_DEFAULT, ifp, display_once); ospf6_interface_show_traffic(vty, ifp, display_once);
return CMD_SUCCESS; return CMD_SUCCESS;

View file

@ -170,7 +170,8 @@ extern const char *const ospf6_interface_state_str[];
/* Function Prototypes */ /* 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 struct ospf6_interface *ospf6_interface_create(struct interface *);
extern void ospf6_interface_delete(struct ospf6_interface *); extern void ospf6_interface_delete(struct ospf6_interface *);

View file

@ -1569,8 +1569,8 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
if (intra_prefix_lsa->ref_adv_router if (intra_prefix_lsa->ref_adv_router
== oa->ospf6->router_id) { == oa->ospf6->router_id) {
ifp = if_lookup_prefix( ifp = if_lookup_prefix(
&old_route->prefix, &old_route->prefix,
VRF_DEFAULT); oa->ospf6->vrf_id);
if (ifp) if (ifp)
ospf6_route_add_nexthop( ospf6_route_add_nexthop(
old_route, old_route,
@ -1714,7 +1714,8 @@ void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa)
memcpy(&route->path.ls_prefix, &ls_prefix, memcpy(&route->path.ls_prefix, &ls_prefix,
sizeof(struct prefix)); sizeof(struct prefix));
if (direct_connect) { if (direct_connect) {
ifp = if_lookup_prefix(&route->prefix, VRF_DEFAULT); ifp = if_lookup_prefix(&route->prefix,
oa->ospf6->vrf_id);
if (ifp) if (ifp)
ospf6_route_add_nexthop(route, ifp->ifindex, ospf6_route_add_nexthop(route, ifp->ifindex,
NULL); NULL);

View file

@ -79,15 +79,17 @@ struct thread_master *master;
static void __attribute__((noreturn)) ospf6_exit(int status) static void __attribute__((noreturn)) ospf6_exit(int status)
{ {
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct vrf *vrf;
struct interface *ifp; struct interface *ifp;
frr_early_fini(); frr_early_fini();
if (ospf6) { if (ospf6) {
vrf = vrf_lookup_by_id(ospf6->vrf_id);
ospf6_delete(ospf6); ospf6_delete(ospf6);
ospf6 = NULL; ospf6 = NULL;
} } else
vrf = vrf_lookup_by_id(VRF_DEFAULT);
bfd_gbl_exit(); bfd_gbl_exit();

View file

@ -1554,7 +1554,7 @@ int ospf6_receive(struct thread *thread)
return 0; 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 if (oi == NULL || oi->area == NULL
|| CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) { || CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) {
if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV))

View file

@ -307,14 +307,14 @@ void ospf6_route_zebra_copy_nexthops(struct ospf6_route *route,
inet_ntop(AF_INET6, &nh->address, buf, inet_ntop(AF_INET6, &nh->address, buf,
sizeof(buf)); sizeof(buf));
ifname = ifindex2ifname(nh->ifindex, ifname = ifindex2ifname(nh->ifindex,
VRF_DEFAULT); ospf6->vrf_id);
zlog_debug(" nexthop: %s%%%.*s(%d)", buf, zlog_debug(" nexthop: %s%%%.*s(%d)", buf,
IFNAMSIZ, ifname, nh->ifindex); IFNAMSIZ, ifname, nh->ifindex);
} }
if (i >= entries) if (i >= entries)
return; return;
nexthops[i].vrf_id = VRF_DEFAULT; nexthops[i].vrf_id = ospf6->vrf_id;
nexthops[i].ifindex = nh->ifindex; nexthops[i].ifindex = nh->ifindex;
if (!IN6_IS_ADDR_UNSPECIFIED(&nh->address)) { if (!IN6_IS_ADDR_UNSPECIFIED(&nh->address)) {
nexthops[i].gate.ipv6 = nh->address; nexthops[i].gate.ipv6 = nh->address;
@ -1042,6 +1042,11 @@ void ospf6_route_show(struct vty *vty, struct ospf6_route *route)
struct listnode *node; struct listnode *node;
struct ospf6_nexthop *nh; struct ospf6_nexthop *nh;
if (ospf6 == NULL) {
vty_out(vty, "OSPFv3 is not running\n");
return;
}
monotime(&now); monotime(&now);
timersub(&now, &route->changed, &res); timersub(&now, &route->changed, &res);
timerstring(&res, duration, sizeof(duration)); timerstring(&res, duration, sizeof(duration));
@ -1060,7 +1065,7 @@ void ospf6_route_show(struct vty *vty, struct ospf6_route *route)
for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) { for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) {
/* nexthop */ /* nexthop */
inet_ntop(AF_INET6, &nh->address, nexthop, sizeof(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) { if (!i) {
vty_out(vty, "%c%1s %2s %-30s %-25s %6.*s %s\n", vty_out(vty, "%c%1s %2s %-30s %-25s %6.*s %s\n",
@ -1086,6 +1091,11 @@ void ospf6_route_show_detail(struct vty *vty, struct ospf6_route *route)
struct listnode *node; struct listnode *node;
struct ospf6_nexthop *nh; struct ospf6_nexthop *nh;
if (ospf6 == NULL) {
vty_out(vty, "OSPFv3 is not running\n");
return;
}
monotime(&now); monotime(&now);
/* destination */ /* destination */
@ -1160,7 +1170,7 @@ void ospf6_route_show_detail(struct vty *vty, struct ospf6_route *route)
for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) { for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) {
/* nexthop */ /* nexthop */
inet_ntop(AF_INET6, &nh->address, nexthop, sizeof(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, " %s %.*s\n", nexthop, IFNAMSIZ, ifname);
} }
vty_out(vty, "\n"); vty_out(vty, "\n");

View file

@ -837,7 +837,7 @@ static uint8_t *ospfv3WwLsdbEntry(struct variable *v, oid *name, size_t *length,
int exact, size_t *var_len, int exact, size_t *var_len,
WriteMethod **write_method) WriteMethod **write_method)
{ {
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct vrf *vrf;
struct ospf6_lsa *lsa = NULL; struct ospf6_lsa *lsa = NULL;
ifindex_t ifindex; ifindex_t ifindex;
uint32_t area_id, id, instid, adv_router; uint32_t area_id, id, instid, adv_router;
@ -861,6 +861,7 @@ static uint8_t *ospfv3WwLsdbEntry(struct variable *v, oid *name, size_t *length,
if (ospf6 == NULL) if (ospf6 == NULL)
return NULL; return NULL;
vrf = vrf_lookup_by_id(ospf6->vrf_id);
/* Get variable length. */ /* Get variable length. */
offset = name + v->namelen; offset = name + v->namelen;
offsetlen = *length - v->namelen; offsetlen = *length - v->namelen;
@ -926,7 +927,8 @@ static uint8_t *ospfv3WwLsdbEntry(struct variable *v, oid *name, size_t *length,
return NULL; return NULL;
lsa = ospf6_lsdb_lookup(type, id, adv_router, oa->lsdb); lsa = ospf6_lsdb_lookup(type, id, adv_router, oa->lsdb);
} else if (v->magic & OSPFv3WWLINKTABLE) { } 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) if (!oi || oi->instance_id != instid)
return NULL; return NULL;
lsa = ospf6_lsdb_lookup(type, id, adv_router, oi->lsdb); lsa = ospf6_lsdb_lookup(type, id, adv_router, oi->lsdb);
@ -963,7 +965,7 @@ static uint8_t *ospfv3WwLsdbEntry(struct variable *v, oid *name, size_t *length,
if (!iif->ifindex) if (!iif->ifindex)
continue; continue;
oi = ospf6_interface_lookup_by_ifindex( oi = ospf6_interface_lookup_by_ifindex(
iif->ifindex); iif->ifindex, iif->vrf_id);
if (!oi) if (!oi)
continue; continue;
if (iif->ifindex < ifindex) if (iif->ifindex < ifindex)
@ -1038,7 +1040,7 @@ static uint8_t *ospfv3IfEntry(struct variable *v, oid *name, size_t *length,
int exact, size_t *var_len, int exact, size_t *var_len,
WriteMethod **write_method) WriteMethod **write_method)
{ {
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct vrf *vrf;
ifindex_t ifindex = 0; ifindex_t ifindex = 0;
unsigned int instid = 0; unsigned int instid = 0;
struct ospf6_interface *oi = NULL; struct ospf6_interface *oi = NULL;
@ -1058,6 +1060,7 @@ static uint8_t *ospfv3IfEntry(struct variable *v, oid *name, size_t *length,
if (ospf6 == NULL) if (ospf6 == NULL)
return NULL; return NULL;
vrf = vrf_lookup_by_id(ospf6->vrf_id);
/* Get variable length. */ /* Get variable length. */
offset = name + v->namelen; offset = name + v->namelen;
offsetlen = *length - v->namelen; offsetlen = *length - v->namelen;
@ -1080,7 +1083,7 @@ static uint8_t *ospfv3IfEntry(struct variable *v, oid *name, size_t *length,
// offsetlen -= len; // offsetlen -= len;
if (exact) { 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) if (!oi || oi->instance_id != instid)
return NULL; return NULL;
} else { } else {
@ -1095,7 +1098,8 @@ static uint8_t *ospfv3IfEntry(struct variable *v, oid *name, size_t *length,
for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) { for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
if (!iif->ifindex) if (!iif->ifindex)
continue; continue;
oi = ospf6_interface_lookup_by_ifindex(iif->ifindex); oi = ospf6_interface_lookup_by_ifindex(iif->ifindex,
iif->vrf_id);
if (!oi) if (!oi)
continue; continue;
if (iif->ifindex > ifindex if (iif->ifindex > ifindex
@ -1191,7 +1195,7 @@ static uint8_t *ospfv3NbrEntry(struct variable *v, oid *name, size_t *length,
int exact, size_t *var_len, int exact, size_t *var_len,
WriteMethod **write_method) WriteMethod **write_method)
{ {
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct vrf *vrf;
ifindex_t ifindex = 0; ifindex_t ifindex = 0;
unsigned int instid, rtrid; unsigned int instid, rtrid;
struct ospf6_interface *oi = NULL; struct ospf6_interface *oi = NULL;
@ -1212,6 +1216,7 @@ static uint8_t *ospfv3NbrEntry(struct variable *v, oid *name, size_t *length,
if (ospf6 == NULL) if (ospf6 == NULL)
return NULL; return NULL;
vrf = vrf_lookup_by_id(ospf6->vrf_id);
/* Get variable length. */ /* Get variable length. */
offset = name + v->namelen; offset = name + v->namelen;
offsetlen = *length - v->namelen; offsetlen = *length - v->namelen;
@ -1241,7 +1246,7 @@ static uint8_t *ospfv3NbrEntry(struct variable *v, oid *name, size_t *length,
// offsetlen -= len; // offsetlen -= len;
if (exact) { 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) if (!oi || oi->instance_id != instid)
return NULL; return NULL;
on = ospf6_neighbor_lookup(rtrid, oi); on = ospf6_neighbor_lookup(rtrid, oi);
@ -1257,7 +1262,8 @@ static uint8_t *ospfv3NbrEntry(struct variable *v, oid *name, size_t *length,
for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) { for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
if (!iif->ifindex) if (!iif->ifindex)
continue; continue;
oi = ospf6_interface_lookup_by_ifindex(iif->ifindex); oi = ospf6_interface_lookup_by_ifindex(iif->ifindex,
iif->vrf_id);
if (!oi) if (!oi)
continue; continue;
for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, j, on)) { for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, j, on)) {

View file

@ -278,7 +278,7 @@ static void ospf6_nexthop_calc(struct ospf6_vertex *w, struct ospf6_vertex *v,
return; return;
} }
oi = ospf6_interface_lookup_by_ifindex(ifindex); oi = ospf6_interface_lookup_by_ifindex(ifindex, ospf6->vrf_id);
if (oi == NULL) { if (oi == NULL) {
if (IS_OSPF6_DEBUG_SPF(PROCESS)) if (IS_OSPF6_DEBUG_SPF(PROCESS))
zlog_debug("Can't find interface in SPF: ifindex %d", zlog_debug("Can't find interface in SPF: ifindex %d",

View file

@ -232,7 +232,7 @@ static void ospf6_disable(struct ospf6 *o)
ospf6_area_disable(oa); ospf6_area_disable(oa);
/* XXX: This also changes persistent settings */ /* XXX: This also changes persistent settings */
ospf6_asbr_redistribute_reset(); ospf6_asbr_redistribute_reset(o->vrf_id);
ospf6_lsdb_remove_all(o->lsdb); ospf6_lsdb_remove_all(o->lsdb);
ospf6_route_remove_all(o->route_table); ospf6_route_remove_all(o->route_table);

View file

@ -75,25 +75,25 @@ static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
} }
/* redistribute function */ /* 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; 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) if (zclient->sock > 0)
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, 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; 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) if (zclient->sock > 0)
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, 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) static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
@ -279,7 +279,7 @@ static void ospf6_zebra_route_update(int type, struct ospf6_route *request)
dest = &request->prefix; dest = &request->prefix;
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = ospf6->vrf_id;
api.type = ZEBRA_ROUTE_OSPF6; api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = *dest; api.prefix = *dest;
@ -330,7 +330,7 @@ void ospf6_zebra_add_discard(struct ospf6_route *request)
if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) { if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = ospf6->vrf_id;
api.type = ZEBRA_ROUTE_OSPF6; api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = *dest; api.prefix = *dest;
@ -363,7 +363,7 @@ void ospf6_zebra_delete_discard(struct ospf6_route *request)
if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) { if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = ospf6->vrf_id;
api.type = ZEBRA_ROUTE_OSPF6; api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = *dest; api.prefix = *dest;

View file

@ -45,10 +45,10 @@ extern struct zclient *zclient;
extern void ospf6_zebra_route_update_add(struct ospf6_route *request); 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_route_update_remove(struct ospf6_route *request);
extern void ospf6_zebra_redistribute(int); extern void ospf6_zebra_redistribute(int, vrf_id_t vrf_id);
extern void ospf6_zebra_no_redistribute(int); extern void ospf6_zebra_no_redistribute(int, vrf_id_t vrf_id);
#define ospf6_zebra_is_redistribute(type) \ #define ospf6_zebra_is_redistribute(type, vrf_id) \
vrf_bitmap_check(zclient->redist[AFI_IP6][type], VRF_DEFAULT) vrf_bitmap_check(zclient->redist[AFI_IP6][type], vrf_id)
extern void ospf6_zebra_init(struct thread_master *); extern void ospf6_zebra_init(struct thread_master *);
extern void ospf6_zebra_add_discard(struct ospf6_route *request); extern void ospf6_zebra_add_discard(struct ospf6_route *request);
extern void ospf6_zebra_delete_discard(struct ospf6_route *request); extern void ospf6_zebra_delete_discard(struct ospf6_route *request);