struct prefix nh;
struct rnh *rnh;
bool exists;
+ struct zebra_vrf *zvrf;
+
+ zvrf = vrf_info_lookup(vrf_id);
+ if (!zvrf)
+ return;
addr2hostprefix(pw->af, &pw->nexthop, &nh);
rnh = zebra_add_rnh(&nh, vrf_id, RNH_NEXTHOP_TYPE, &exists);
if (rnh && !listnode_lookup(rnh->zebra_pseudowire_list, pw)) {
listnode_add(rnh->zebra_pseudowire_list, pw);
pw->rnh = rnh;
- zebra_evaluate_rnh(vrf_id, pw->af, 1, RNH_NEXTHOP_TYPE, &nh);
+ zebra_evaluate_rnh(zvrf, pw->af, 1, RNH_NEXTHOP_TYPE, &nh);
}
}
/* Apply the NHT route-map for a client to the route (and nexthops)
* resolving a NH.
*/
-static int zebra_rnh_apply_nht_rmap(int family, struct route_node *prn,
+static int zebra_rnh_apply_nht_rmap(int family, struct zebra_vrf *zvrf,
+ struct route_node *prn,
struct route_entry *re, int proto)
{
int at_least_one = 0;
if (prn && re) {
for (nexthop = re->ng.nexthop; nexthop;
nexthop = nexthop->next) {
- struct zebra_vrf *zvrf =
- zebra_vrf_lookup_by_id(nexthop->vrf_id);
ret = zebra_nht_route_map_check(
rmap_family, proto, &prn->p, zvrf, re, nexthop);
if (ret != RMAP_DENYMATCH) {
* for BGP route for import.
*/
static struct route_entry *
-zebra_rnh_resolve_import_entry(vrf_id_t vrfid, int family,
+zebra_rnh_resolve_import_entry(struct zebra_vrf *zvrf, int family,
struct route_node *nrn, struct rnh *rnh,
struct route_node **prn)
{
*prn = NULL;
- route_table = zebra_vrf_table(family2afi(family), SAFI_UNICAST, vrfid);
+ route_table = zvrf->table[family2afi(family)][SAFI_UNICAST];
if (!route_table) // unexpected
return NULL;
/*
* Notify clients registered for this nexthop about a change.
*/
-static void zebra_rnh_notify_protocol_clients(vrf_id_t vrfid, int family,
- struct route_node *nrn,
- struct rnh *rnh,
- struct route_node *prn,
- struct route_entry *re)
+static void zebra_rnh_notify_protocol_clients(
+ struct zebra_vrf *zvrf, int family, struct route_node *nrn,
+ struct rnh *rnh, struct route_node *prn, struct route_entry *re)
{
struct listnode *node;
struct zserv *client;
prefix2str(&nrn->p, bufn, INET6_ADDRSTRLEN);
if (prn && re) {
prefix2str(&prn->p, bufp, INET6_ADDRSTRLEN);
- zlog_debug("%u:%s: NH resolved over route %s", vrfid,
- bufn, bufp);
+ zlog_debug("%u:%s: NH resolved over route %s",
+ zvrf->vrf->vrf_id, bufn, bufp);
} else
- zlog_debug("%u:%s: NH has become unresolved", vrfid,
- bufn);
+ zlog_debug("%u:%s: NH has become unresolved",
+ zvrf->vrf->vrf_id, bufn);
}
for (ALL_LIST_ELEMENTS_RO(rnh->client_list, node, client)) {
* nexthop to see if it is filtered or not.
*/
num_resolving_nh = zebra_rnh_apply_nht_rmap(
- family, prn, re, client->proto);
+ family, zvrf, prn, re, client->proto);
if (num_resolving_nh)
rnh->filtered[client->proto] = 0;
else
if (IS_ZEBRA_DEBUG_NHT)
zlog_debug(
"%u:%s: Notifying client %s about NH %s",
- vrfid, bufn,
+ zvrf->vrf->vrf_id, bufn,
zebra_route_string(client->proto),
num_resolving_nh
? ""
if (IS_ZEBRA_DEBUG_NHT)
zlog_debug(
"%u:%s: Notifying client %s about NH (unreachable)",
- vrfid, bufn,
+ zvrf->vrf->vrf_id, bufn,
zebra_route_string(client->proto));
}
- send_client(rnh, client, RNH_NEXTHOP_TYPE, vrfid);
+ send_client(rnh, client, RNH_NEXTHOP_TYPE, zvrf->vrf->vrf_id);
}
}
* nexthop.
*/
static struct route_entry *
-zebra_rnh_resolve_nexthop_entry(vrf_id_t vrfid, int family,
+zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, int family,
struct route_node *nrn, struct rnh *rnh,
struct route_node **prn)
{
*prn = NULL;
- route_table = zebra_vrf_table(family2afi(family), SAFI_UNICAST, vrfid);
+ route_table = zvrf->table[family2afi(family)][SAFI_UNICAST];
if (!route_table)
return NULL;
* take appropriate action; this involves notifying any clients and/or
* scheduling dependent static routes for processing.
*/
-static void zebra_rnh_eval_nexthop_entry(vrf_id_t vrfid, int family, int force,
- struct route_node *nrn,
+static void zebra_rnh_eval_nexthop_entry(struct zebra_vrf *zvrf, int family,
+ int force, struct route_node *nrn,
struct rnh *rnh,
struct route_node *prn,
struct route_entry *re)
* rnh->state.
*/
/* Notify registered protocol clients. */
- zebra_rnh_notify_protocol_clients(vrfid, family, nrn, rnh, prn,
+ zebra_rnh_notify_protocol_clients(zvrf, family, nrn, rnh, prn,
rnh->state);
- zebra_rnh_process_pbr_tables(family, nrn, rnh, prn,
- rnh->state);
+ zebra_rnh_process_pbr_tables(family, nrn, rnh, prn, rnh->state);
/* Process pseudowires attached to this nexthop */
- zebra_rnh_process_pseudowires(vrfid, rnh);
+ zebra_rnh_process_pseudowires(zvrf->vrf->vrf_id, rnh);
}
}
/* Evaluate one tracked entry */
-static void zebra_rnh_evaluate_entry(vrf_id_t vrfid, int family, int force,
- rnh_type_t type, struct route_node *nrn)
+static void zebra_rnh_evaluate_entry(struct zebra_vrf *zvrf, int family,
+ int force, rnh_type_t type,
+ struct route_node *nrn)
{
struct rnh *rnh;
struct route_entry *re;
if (IS_ZEBRA_DEBUG_NHT) {
prefix2str(&nrn->p, bufn, INET6_ADDRSTRLEN);
- zlog_debug("%u:%s: Evaluate RNH, type %d %s", vrfid, bufn, type,
- force ? "(force)" : "");
+ zlog_debug("%u:%s: Evaluate RNH, type %d %s", zvrf->vrf->vrf_id,
+ bufn, type, force ? "(force)" : "");
}
rnh = nrn->info;
/* Identify route entry (RE) resolving this tracked entry. */
if (type == RNH_IMPORT_CHECK_TYPE)
- re = zebra_rnh_resolve_import_entry(vrfid, family, nrn, rnh,
+ re = zebra_rnh_resolve_import_entry(zvrf, family, nrn, rnh,
&prn);
else
- re = zebra_rnh_resolve_nexthop_entry(vrfid, family, nrn, rnh,
+ re = zebra_rnh_resolve_nexthop_entry(zvrf, family, nrn, rnh,
&prn);
/* If the entry cannot be resolved and that is also the existing state,
/* Process based on type of entry. */
if (type == RNH_IMPORT_CHECK_TYPE)
- zebra_rnh_eval_import_check_entry(vrfid, family, force, nrn,
- rnh, re);
+ zebra_rnh_eval_import_check_entry(zvrf->vrf->vrf_id, family,
+ force, nrn, rnh, re);
else
- zebra_rnh_eval_nexthop_entry(vrfid, family, force, nrn, rnh,
- prn, re);
+ zebra_rnh_eval_nexthop_entry(zvrf, family, force, nrn, rnh, prn,
+ re);
}
/*
* we can have a situation where one re entry
* covers multiple nexthops we are interested in.
*/
-static void zebra_rnh_clear_nhc_flag(vrf_id_t vrfid, int family,
+static void zebra_rnh_clear_nhc_flag(struct zebra_vrf *zvrf, int family,
rnh_type_t type, struct route_node *nrn)
{
struct rnh *rnh;
/* Identify route entry (RIB) resolving this tracked entry. */
if (type == RNH_IMPORT_CHECK_TYPE)
- re = zebra_rnh_resolve_import_entry(vrfid, family, nrn, rnh,
+ re = zebra_rnh_resolve_import_entry(zvrf, family, nrn, rnh,
&prn);
else
- re = zebra_rnh_resolve_nexthop_entry(vrfid, family, nrn, rnh,
+ re = zebra_rnh_resolve_nexthop_entry(zvrf, family, nrn, rnh,
&prn);
if (re) {
/* Evaluate all tracked entries (nexthops or routes for import into BGP)
* of a particular VRF and address-family or a specific prefix.
*/
-void zebra_evaluate_rnh(vrf_id_t vrfid, int family, int force, rnh_type_t type,
- struct prefix *p)
+void zebra_evaluate_rnh(struct zebra_vrf *zvrf, int family, int force,
+ rnh_type_t type, struct prefix *p)
{
struct route_table *rnh_table;
struct route_node *nrn;
- rnh_table = get_rnh_table(vrfid, family, type);
+ rnh_table = get_rnh_table(zvrf->vrf->vrf_id, family, type);
if (!rnh_table) // unexpected
return;
/* Evaluating a specific entry, make sure it exists. */
nrn = route_node_lookup(rnh_table, p);
if (nrn && nrn->info)
- zebra_rnh_evaluate_entry(vrfid, family, force, type,
+ zebra_rnh_evaluate_entry(zvrf, family, force, type,
nrn);
if (nrn)
nrn = route_top(rnh_table);
while (nrn) {
if (nrn->info)
- zebra_rnh_evaluate_entry(vrfid, family, force,
+ zebra_rnh_evaluate_entry(zvrf, family, force,
type, nrn);
nrn = route_next(nrn); /* this will also unlock nrn */
}
nrn = route_top(rnh_table);
while (nrn) {
if (nrn->info)
- zebra_rnh_clear_nhc_flag(vrfid, family, type,
+ zebra_rnh_clear_nhc_flag(zvrf, family, type,
nrn);
nrn = route_next(nrn); /* this will also unlock nrn */
}