]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: consolidate how we indentify address-families in the NHT code
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 21 Jan 2019 14:30:36 +0000 (12:30 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 21 Jan 2019 15:26:36 +0000 (13:26 -0200)
Favor usage of the afi_t enumeration to identify address-families
over using the classic AF_INET[6] constants for that. The choice to
use either of the two seems to be mostly arbitrary throughout our
code base, which leads to confusion and bugs like the one fixed by
commit 6f95d11a1. To address this problem, favor usage of the afi_t
enumeration whenever possible, since 1) it's an enumeration (helps
the compilers to catch some bugs), 2) has a safi_t sibling and 3)
can be used to index static arrays. AF_INET[6] should then be used
only when interfacing with the kernel or external libraries like
libc. The family2afi() and afi2family() functions can be used to
convert between the two different representations back and forth.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
zebra/zapi_msg.c
zebra/zebra_rib.c
zebra/zebra_rnh.c
zebra/zebra_rnh.h
zebra/zebra_routemap.c
zebra/zebra_routemap.h
zebra/zebra_vty.c

index 15f9da0cba747b09d2e1f36aff9ea43ece465f58..aa8ebd05cb5ec646f028bda439c908d0a8b0d173 100644 (file)
@@ -1108,7 +1108,8 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS)
                zebra_add_rnh_client(rnh, client, type, zvrf_id(zvrf));
                /* Anything not AF_INET/INET6 has been filtered out above */
                if (!exist)
-                       zebra_evaluate_rnh(zvrf, p.family, 1, type, &p);
+                       zebra_evaluate_rnh(zvrf, family2afi(p.family), 1, type,
+                                          &p);
        }
 
 stream_failure:
index 7e4ac1ddd22bf22ee9bd9446e600f7f6140325d8..458757affe3c96d713968343e9d5544ed9ebd6ac 100644 (file)
@@ -2090,11 +2090,11 @@ static void do_nht_processing(void)
                                   zvrf_name(zvrf));
 
                zvrf->flags &= ~ZEBRA_VRF_RIB_SCHEDULED;
-               zebra_evaluate_rnh(zvrf, AF_INET, 0, RNH_NEXTHOP_TYPE, NULL);
-               zebra_evaluate_rnh(zvrf, AF_INET, 0, RNH_IMPORT_CHECK_TYPE,
+               zebra_evaluate_rnh(zvrf, AFI_IP, 0, RNH_NEXTHOP_TYPE, NULL);
+               zebra_evaluate_rnh(zvrf, AFI_IP, 0, RNH_IMPORT_CHECK_TYPE,
                                   NULL);
-               zebra_evaluate_rnh(zvrf, AF_INET6, 0, RNH_NEXTHOP_TYPE, NULL);
-               zebra_evaluate_rnh(zvrf, AF_INET6, 0, RNH_IMPORT_CHECK_TYPE,
+               zebra_evaluate_rnh(zvrf, AFI_IP6, 0, RNH_NEXTHOP_TYPE, NULL);
+               zebra_evaluate_rnh(zvrf, AFI_IP6, 0, RNH_IMPORT_CHECK_TYPE,
                                   NULL);
        }
 
index c3781888b1fba80a5d88a4e211cc911bf811cb2d..ee76df4db15e8ddfd187fe348b40f68133f5d02a 100644 (file)
@@ -78,7 +78,7 @@ void zebra_rnh_init(void)
        hook_register(zserv_client_close, zebra_client_cleanup_rnh);
 }
 
-static inline struct route_table *get_rnh_table(vrf_id_t vrfid, int family,
+static inline struct route_table *get_rnh_table(vrf_id_t vrfid, afi_t afi,
                                                rnh_type_t type)
 {
        struct zebra_vrf *zvrf;
@@ -88,10 +88,10 @@ static inline struct route_table *get_rnh_table(vrf_id_t vrfid, int family,
        if (zvrf)
                switch (type) {
                case RNH_NEXTHOP_TYPE:
-                       t = zvrf->rnh_table[family2afi(family)];
+                       t = zvrf->rnh_table[afi];
                        break;
                case RNH_IMPORT_CHECK_TYPE:
-                       t = zvrf->import_check_table[family2afi(family)];
+                       t = zvrf->import_check_table[afi];
                        break;
                }
 
@@ -116,7 +116,7 @@ struct rnh *zebra_add_rnh(struct prefix *p, vrf_id_t vrfid, rnh_type_t type,
                prefix2str(p, buf, sizeof(buf));
                zlog_debug("%u: Add RNH %s type %d", vrfid, buf, type);
        }
-       table = get_rnh_table(vrfid, PREFIX_FAMILY(p), type);
+       table = get_rnh_table(vrfid, family2afi(PREFIX_FAMILY(p)), type);
        if (!table) {
                prefix2str(p, buf, sizeof(buf));
                flog_warn(EC_ZEBRA_RNH_NO_TABLE,
@@ -153,7 +153,7 @@ struct rnh *zebra_lookup_rnh(struct prefix *p, vrf_id_t vrfid, rnh_type_t type)
        struct route_table *table;
        struct route_node *rn;
 
-       table = get_rnh_table(vrfid, PREFIX_FAMILY(p), type);
+       table = get_rnh_table(vrfid, family2afi(PREFIX_FAMILY(p)), type);
        if (!table)
                return NULL;
 
@@ -278,7 +278,8 @@ void zebra_register_rnh_pseudowire(vrf_id_t vrf_id, struct zebra_pw *pw)
        if (rnh && !listnode_lookup(rnh->zebra_pseudowire_list, pw)) {
                listnode_add(rnh->zebra_pseudowire_list, pw);
                pw->rnh = rnh;
-               zebra_evaluate_rnh(zvrf, pw->af, 1, RNH_NEXTHOP_TYPE, &nh);
+               zebra_evaluate_rnh(zvrf, family2afi(pw->af), 1,
+                                  RNH_NEXTHOP_TYPE, &nh);
        }
 }
 
@@ -299,22 +300,19 @@ void zebra_deregister_rnh_pseudowire(vrf_id_t vrf_id, struct zebra_pw *pw)
 /* 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 zebra_vrf *zvrf,
+static int zebra_rnh_apply_nht_rmap(afi_t afi, struct zebra_vrf *zvrf,
                                    struct route_node *prn,
                                    struct route_entry *re, int proto)
 {
        int at_least_one = 0;
-       int rmap_family; /* Route map has diff AF family enum */
        struct nexthop *nexthop;
        int ret;
 
-       rmap_family = (family == AF_INET) ? AFI_IP : AFI_IP6;
-
        if (prn && re) {
                for (nexthop = re->ng.nexthop; nexthop;
                     nexthop = nexthop->next) {
                        ret = zebra_nht_route_map_check(
-                               rmap_family, proto, &prn->p, zvrf, re, nexthop);
+                               afi, proto, &prn->p, zvrf, re, nexthop);
                        if (ret != RMAP_DENYMATCH) {
                                SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
                                at_least_one++; /* at least one valid NH */
@@ -331,7 +329,7 @@ static int zebra_rnh_apply_nht_rmap(int family, struct zebra_vrf *zvrf,
  * for BGP route for import.
  */
 static struct route_entry *
-zebra_rnh_resolve_import_entry(struct zebra_vrf *zvrf, int family,
+zebra_rnh_resolve_import_entry(struct zebra_vrf *zvrf, afi_t afi,
                               struct route_node *nrn, struct rnh *rnh,
                               struct route_node **prn)
 {
@@ -341,7 +339,7 @@ zebra_rnh_resolve_import_entry(struct zebra_vrf *zvrf, int family,
 
        *prn = NULL;
 
-       route_table = zvrf->table[family2afi(family)][SAFI_UNICAST];
+       route_table = zvrf->table[afi][SAFI_UNICAST];
        if (!route_table) // unexpected
                return NULL;
 
@@ -373,7 +371,7 @@ zebra_rnh_resolve_import_entry(struct zebra_vrf *zvrf, int family,
  * See if a tracked route entry for import (by BGP) has undergone any
  * change, and if so, notify the client.
  */
-static void zebra_rnh_eval_import_check_entry(vrf_id_t vrfid, int family,
+static void zebra_rnh_eval_import_check_entry(vrf_id_t vrfid, afi_t afi,
                                              int force, struct route_node *nrn,
                                              struct rnh *rnh,
                                              struct route_entry *re)
@@ -413,9 +411,11 @@ static void zebra_rnh_eval_import_check_entry(vrf_id_t vrfid, int family,
 /*
  * Notify clients registered for this nexthop about a change.
  */
-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)
+static void zebra_rnh_notify_protocol_clients(struct zebra_vrf *zvrf, afi_t afi,
+                                             struct route_node *nrn,
+                                             struct rnh *rnh,
+                                             struct route_node *prn,
+                                             struct route_entry *re)
 {
        struct listnode *node;
        struct zserv *client;
@@ -441,7 +441,7 @@ static void zebra_rnh_notify_protocol_clients(
                         * nexthop to see if it is filtered or not.
                         */
                        num_resolving_nh = zebra_rnh_apply_nht_rmap(
-                               family, zvrf, prn, re, client->proto);
+                               afi, zvrf, prn, re, client->proto);
                        if (num_resolving_nh)
                                rnh->filtered[client->proto] = 0;
                        else
@@ -468,8 +468,7 @@ static void zebra_rnh_notify_protocol_clients(
        }
 }
 
-static void zebra_rnh_process_pbr_tables(int family,
-                                        struct route_node *nrn,
+static void zebra_rnh_process_pbr_tables(afi_t afi, struct route_node *nrn,
                                         struct rnh *rnh,
                                         struct route_node *prn,
                                         struct route_entry *re)
@@ -479,10 +478,6 @@ static void zebra_rnh_process_pbr_tables(int family,
        struct route_node *o_rn;
        struct listnode *node;
        struct zserv *client;
-       afi_t afi = AFI_IP;
-
-       if (family == AF_INET6)
-               afi = AFI_IP6;
 
        /*
         * We are only concerned about nexthops that change for
@@ -537,7 +532,7 @@ static bool rnh_nexthop_valid(const struct nexthop *nh)
  * nexthop.
  */
 static struct route_entry *
-zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, int family,
+zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,
                                struct route_node *nrn, struct rnh *rnh,
                                struct route_node **prn)
 {
@@ -548,7 +543,7 @@ zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, int family,
 
        *prn = NULL;
 
-       route_table = zvrf->table[family2afi(family)][SAFI_UNICAST];
+       route_table = zvrf->table[afi][SAFI_UNICAST];
        if (!route_table)
                return NULL;
 
@@ -635,7 +630,7 @@ static void zebra_rnh_process_pseudowires(vrf_id_t vrfid, struct rnh *rnh)
  * take appropriate action; this involves notifying any clients and/or
  * scheduling dependent static routes for processing.
  */
-static void zebra_rnh_eval_nexthop_entry(struct zebra_vrf *zvrf, int family,
+static void zebra_rnh_eval_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,
                                         int force, struct route_node *nrn,
                                         struct rnh *rnh,
                                         struct route_node *prn,
@@ -665,10 +660,10 @@ static void zebra_rnh_eval_nexthop_entry(struct zebra_vrf *zvrf, int family,
                 * rnh->state.
                 */
                /* Notify registered protocol clients. */
-               zebra_rnh_notify_protocol_clients(zvrf, family, nrn, rnh, prn,
+               zebra_rnh_notify_protocol_clients(zvrf, afi, nrn, rnh, prn,
                                                  rnh->state);
 
-               zebra_rnh_process_pbr_tables(family, nrn, rnh, prn, rnh->state);
+               zebra_rnh_process_pbr_tables(afi, nrn, rnh, prn, rnh->state);
 
                /* Process pseudowires attached to this nexthop */
                zebra_rnh_process_pseudowires(zvrf->vrf->vrf_id, rnh);
@@ -676,7 +671,7 @@ static void zebra_rnh_eval_nexthop_entry(struct zebra_vrf *zvrf, int family,
 }
 
 /* Evaluate one tracked entry */
-static void zebra_rnh_evaluate_entry(struct zebra_vrf *zvrf, int family,
+static void zebra_rnh_evaluate_entry(struct zebra_vrf *zvrf, afi_t afi,
                                     int force, rnh_type_t type,
                                     struct route_node *nrn)
 {
@@ -695,11 +690,9 @@ static void zebra_rnh_evaluate_entry(struct zebra_vrf *zvrf, int family,
 
        /* Identify route entry (RE) resolving this tracked entry. */
        if (type == RNH_IMPORT_CHECK_TYPE)
-               re = zebra_rnh_resolve_import_entry(zvrf, family, nrn, rnh,
-                                                   &prn);
+               re = zebra_rnh_resolve_import_entry(zvrf, afi, nrn, rnh, &prn);
        else
-               re = zebra_rnh_resolve_nexthop_entry(zvrf, family, nrn, rnh,
-                                                    &prn);
+               re = zebra_rnh_resolve_nexthop_entry(zvrf, afi, nrn, rnh, &prn);
 
        /* If the entry cannot be resolved and that is also the existing state,
         * there is nothing further to do.
@@ -709,10 +702,10 @@ static void zebra_rnh_evaluate_entry(struct zebra_vrf *zvrf, int family,
 
        /* Process based on type of entry. */
        if (type == RNH_IMPORT_CHECK_TYPE)
-               zebra_rnh_eval_import_check_entry(zvrf->vrf->vrf_id, family,
-                                                 force, nrn, rnh, re);
+               zebra_rnh_eval_import_check_entry(zvrf->vrf->vrf_id, afi, force,
+                                                 nrn, rnh, re);
        else
-               zebra_rnh_eval_nexthop_entry(zvrf, family, force, nrn, rnh, prn,
+               zebra_rnh_eval_nexthop_entry(zvrf, afi, force, nrn, rnh, prn,
                                             re);
 }
 
@@ -725,7 +718,7 @@ static void zebra_rnh_evaluate_entry(struct zebra_vrf *zvrf, int family,
  * we can have a situation where one re entry
  * covers multiple nexthops we are interested in.
  */
-static void zebra_rnh_clear_nhc_flag(struct zebra_vrf *zvrf, int family,
+static void zebra_rnh_clear_nhc_flag(struct zebra_vrf *zvrf, afi_t afi,
                                     rnh_type_t type, struct route_node *nrn)
 {
        struct rnh *rnh;
@@ -736,10 +729,10 @@ static void zebra_rnh_clear_nhc_flag(struct zebra_vrf *zvrf, int family,
 
        /* Identify route entry (RIB) resolving this tracked entry. */
        if (type == RNH_IMPORT_CHECK_TYPE)
-               re = zebra_rnh_resolve_import_entry(zvrf, family, nrn, rnh,
+               re = zebra_rnh_resolve_import_entry(zvrf, afi, nrn, rnh,
                                                    &prn);
        else
-               re = zebra_rnh_resolve_nexthop_entry(zvrf, family, nrn, rnh,
+               re = zebra_rnh_resolve_nexthop_entry(zvrf, afi, nrn, rnh,
                                                     &prn);
 
        if (re) {
@@ -751,13 +744,13 @@ static void zebra_rnh_clear_nhc_flag(struct zebra_vrf *zvrf, int family,
 /* 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(struct zebra_vrf *zvrf, int family, int force,
+void zebra_evaluate_rnh(struct zebra_vrf *zvrf, afi_t afi, int force,
                        rnh_type_t type, struct prefix *p)
 {
        struct route_table *rnh_table;
        struct route_node *nrn;
 
-       rnh_table = get_rnh_table(zvrf->vrf->vrf_id, family, type);
+       rnh_table = get_rnh_table(zvrf->vrf->vrf_id, afi, type);
        if (!rnh_table) // unexpected
                return;
 
@@ -765,8 +758,7 @@ void zebra_evaluate_rnh(struct zebra_vrf *zvrf, int family, int force,
                /* Evaluating a specific entry, make sure it exists. */
                nrn = route_node_lookup(rnh_table, p);
                if (nrn && nrn->info)
-                       zebra_rnh_evaluate_entry(zvrf, family, force, type,
-                                                nrn);
+                       zebra_rnh_evaluate_entry(zvrf, afi, force, type, nrn);
 
                if (nrn)
                        route_unlock_node(nrn);
@@ -775,27 +767,26 @@ void zebra_evaluate_rnh(struct zebra_vrf *zvrf, int family, int force,
                nrn = route_top(rnh_table);
                while (nrn) {
                        if (nrn->info)
-                               zebra_rnh_evaluate_entry(zvrf, family, force,
-                                                        type, nrn);
+                               zebra_rnh_evaluate_entry(zvrf, afi, 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(zvrf, family, type,
-                                                        nrn);
+                               zebra_rnh_clear_nhc_flag(zvrf, afi, type, nrn);
                        nrn = route_next(nrn); /* this will also unlock nrn */
                }
        }
 }
 
-void zebra_print_rnh_table(vrf_id_t vrfid, int af, struct vty *vty,
+void zebra_print_rnh_table(vrf_id_t vrfid, afi_t afi, struct vty *vty,
                           rnh_type_t type)
 {
        struct route_table *table;
        struct route_node *rn;
 
-       table = get_rnh_table(vrfid, af, type);
+       table = get_rnh_table(vrfid, afi, type);
        if (!table) {
                zlog_debug("print_rnhs: rnh table not found\n");
                return;
@@ -1032,7 +1023,7 @@ static void print_rnh(struct route_node *rn, struct vty *vty)
        vty_out(vty, "\n");
 }
 
-static int zebra_cleanup_rnh_client(vrf_id_t vrf_id, int family,
+static int zebra_cleanup_rnh_client(vrf_id_t vrf_id, afi_t afi,
                                    struct zserv *client, rnh_type_t type)
 {
        struct route_table *ntable;
@@ -1040,11 +1031,11 @@ static int zebra_cleanup_rnh_client(vrf_id_t vrf_id, int family,
        struct rnh *rnh;
 
        if (IS_ZEBRA_DEBUG_NHT)
-               zlog_debug("%u: Client %s RNH cleanup for family %d type %d",
-                          vrf_id, zebra_route_string(client->proto), family,
-                          type);
+               zlog_debug("%u: Client %s RNH cleanup for family %s type %d",
+                          vrf_id, zebra_route_string(client->proto),
+                          afi2str(afi), type);
 
-       ntable = get_rnh_table(vrf_id, family, type);
+       ntable = get_rnh_table(vrf_id, afi, type);
        if (!ntable) {
                zlog_debug("cleanup_rnh_client: rnh table not found\n");
                return -1;
@@ -1069,14 +1060,14 @@ static int zebra_client_cleanup_rnh(struct zserv *client)
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
                zvrf = vrf->info;
                if (zvrf) {
-                       zebra_cleanup_rnh_client(zvrf_id(zvrf), AF_INET, client,
+                       zebra_cleanup_rnh_client(zvrf_id(zvrf), AFI_IP, client,
                                                 RNH_NEXTHOP_TYPE);
-                       zebra_cleanup_rnh_client(zvrf_id(zvrf), AF_INET6,
-                                                client, RNH_NEXTHOP_TYPE);
-                       zebra_cleanup_rnh_client(zvrf_id(zvrf), AF_INET, client,
+                       zebra_cleanup_rnh_client(zvrf_id(zvrf), AFI_IP6, client,
+                                                RNH_NEXTHOP_TYPE);
+                       zebra_cleanup_rnh_client(zvrf_id(zvrf), AFI_IP, client,
+                                                RNH_IMPORT_CHECK_TYPE);
+                       zebra_cleanup_rnh_client(zvrf_id(zvrf), AFI_IP6, client,
                                                 RNH_IMPORT_CHECK_TYPE);
-                       zebra_cleanup_rnh_client(zvrf_id(zvrf), AF_INET6,
-                                                client, RNH_IMPORT_CHECK_TYPE);
                        if (client->proto == ZEBRA_ROUTE_LDP) {
                                hash_iterate(zvrf->lsp_table,
                                             mpls_ldp_lsp_uninstall_all,
index ed1fe9b756af54d1b30125d8b1f0a1d166dd4a6c..00ee60dc1a8c7efff632598ef28209abd4523744 100644 (file)
@@ -78,9 +78,9 @@ extern void zebra_register_rnh_pseudowire(vrf_id_t, struct zebra_pw *);
 extern void zebra_deregister_rnh_pseudowire(vrf_id_t, struct zebra_pw *);
 extern void zebra_remove_rnh_client(struct rnh *rnh, struct zserv *client,
                                    rnh_type_t type);
-extern void zebra_evaluate_rnh(struct zebra_vrf *zvrf, int family, int force,
+extern void zebra_evaluate_rnh(struct zebra_vrf *zvrf, afi_t afi, int force,
                               rnh_type_t type, struct prefix *p);
-extern void zebra_print_rnh_table(vrf_id_t vrfid, int family, struct vty *vty,
+extern void zebra_print_rnh_table(vrf_id_t vrfid, afi_t afi, struct vty *vty,
                                  rnh_type_t);
 extern char *rnh_str(struct rnh *rnh, char *buf, int size);
 #endif /*_ZEBRA_RNH_H */
index c9918a7887e3b66abc1cb9520cd6fbcfa3c34eb5..5461a7883d8f52fc9d6fc00bcbaa64d18b62f3e8 100644 (file)
@@ -389,7 +389,7 @@ static int ip_nht_rm_add(struct zebra_vrf *zvrf, const char *rmap, int rtype,
                route_map_lookup_by_name(NHT_RM_NAME(zvrf, afi, rtype));
 
        if (NHT_RM_MAP(zvrf, afi, rtype))
-               zebra_evaluate_rnh(zvrf, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL);
+               zebra_evaluate_rnh(zvrf, AFI_IP, 1, RNH_NEXTHOP_TYPE, NULL);
 
        return CMD_SUCCESS;
 }
@@ -409,7 +409,7 @@ static int ip_nht_rm_del(struct zebra_vrf *zvrf, const char *rmap, int rtype,
                                        zvrf->vrf->vrf_id, rtype);
                        NHT_RM_MAP(zvrf, afi, rtype) = NULL;
 
-                       zebra_evaluate_rnh(zvrf, AF_INET, 1, RNH_NEXTHOP_TYPE,
+                       zebra_evaluate_rnh(zvrf, AFI_IP, 1, RNH_NEXTHOP_TYPE,
                                           NULL);
                }
                XFREE(MTYPE_ROUTE_MAP_NAME, NHT_RM_NAME(zvrf, afi, rtype));
@@ -1556,7 +1556,7 @@ static void zebra_nht_rm_update(const char *rmap)
                                                afi_ip = 1;
 
                                                zebra_evaluate_rnh(
-                                                       zvrf, AF_INET, 1,
+                                                       zvrf, AFI_IP, 1,
                                                        RNH_NEXTHOP_TYPE, NULL);
                                        }
                                }
@@ -1582,7 +1582,7 @@ static void zebra_nht_rm_update(const char *rmap)
                                                afi_ipv6 = 1;
 
                                                zebra_evaluate_rnh(
-                                                       zvrf, AF_INET, 1,
+                                                       zvrf, AFI_IP, 1,
                                                        RNH_NEXTHOP_TYPE, NULL);
                                        }
                                }
@@ -1713,7 +1713,7 @@ zebra_import_table_route_map_check(int family, int re_type, uint8_t instance,
        return (ret);
 }
 
-route_map_result_t zebra_nht_route_map_check(int family, int client_proto,
+route_map_result_t zebra_nht_route_map_check(afi_t afi, int client_proto,
                                             const struct prefix *p,
                                             struct zebra_vrf *zvrf,
                                             struct route_entry *re,
@@ -1731,9 +1731,9 @@ route_map_result_t zebra_nht_route_map_check(int family, int client_proto,
        nh_obj.tag = re->tag;
 
        if (client_proto >= 0 && client_proto < ZEBRA_ROUTE_MAX)
-               rmap = NHT_RM_MAP(zvrf, family, client_proto);
-       if (!rmap && NHT_RM_MAP(zvrf, family, ZEBRA_ROUTE_MAX))
-               rmap = NHT_RM_MAP(zvrf, family, ZEBRA_ROUTE_MAX);
+               rmap = NHT_RM_MAP(zvrf, afi, client_proto);
+       if (!rmap && NHT_RM_MAP(zvrf, afi, ZEBRA_ROUTE_MAX))
+               rmap = NHT_RM_MAP(zvrf, afi, ZEBRA_ROUTE_MAX);
        if (rmap)
                ret = route_map_apply(rmap, p, RMAP_ZEBRA, &nh_obj);
 
index a8579e7c6eedc93f217e1b12354db0666d063a19..abd2ad78f750fc49ba9106ec5612d004c8968428 100644 (file)
@@ -44,7 +44,7 @@ zebra_route_map_check(int family, int rib_type, uint8_t instance,
                      const struct prefix *p, struct nexthop *nexthop,
                      struct zebra_vrf *zvrf, route_tag_t tag);
 extern route_map_result_t
-zebra_nht_route_map_check(int family, int client_proto, const struct prefix *p,
+zebra_nht_route_map_check(afi_t afi, int client_proto, const struct prefix *p,
                          struct zebra_vrf *zvrf, struct route_entry *,
                          struct nexthop *nexthop);
 
index b62ff81bf60c7b80723d0810471db7cb0e55ab87..83c12e2bdcfb183b01274565cfc9812c7c01fd30 100644 (file)
@@ -944,7 +944,7 @@ DEFUN (show_ip_nht,
        if (argc == 5)
                VRF_GET_ID(vrf_id, argv[idx_vrf]->arg, false);
 
-       zebra_print_rnh_table(vrf_id, AF_INET, vty, RNH_NEXTHOP_TYPE);
+       zebra_print_rnh_table(vrf_id, AFI_IP, vty, RNH_NEXTHOP_TYPE);
        return CMD_SUCCESS;
 }
 
@@ -958,7 +958,7 @@ DEFPY (show_ip_import_check,
        VRF_CMD_HELP_STR
        VRF_ALL_CMD_HELP_STR)
 {
-       int family = ipv4 ? AF_INET : AF_INET6;
+       afi_t afi = ipv4 ? AFI_IP : AFI_IP6;
        vrf_id_t vrf_id = VRF_DEFAULT;
 
        if (vrf_all) {
@@ -969,8 +969,7 @@ DEFPY (show_ip_import_check,
                        if ((zvrf = vrf->info) != NULL) {
                                vty_out(vty, "\nVRF %s:\n",
                                        zvrf_name(zvrf));
-                               zebra_print_rnh_table(zvrf_id(zvrf),
-                                                     family, vty,
+                               zebra_print_rnh_table(zvrf_id(zvrf), afi, vty,
                                                      RNH_IMPORT_CHECK_TYPE);
                        }
                return CMD_SUCCESS;
@@ -978,7 +977,7 @@ DEFPY (show_ip_import_check,
        if (vrf_name)
                VRF_GET_ID(vrf_id, vrf_name, false);
 
-       zebra_print_rnh_table(vrf_id, family, vty, RNH_IMPORT_CHECK_TYPE);
+       zebra_print_rnh_table(vrf_id, afi, vty, RNH_IMPORT_CHECK_TYPE);
        return CMD_SUCCESS;
 }
 
@@ -996,7 +995,7 @@ DEFUN (show_ip_nht_vrf_all,
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
                if ((zvrf = vrf->info) != NULL) {
                        vty_out(vty, "\nVRF %s:\n", zvrf_name(zvrf));
-                       zebra_print_rnh_table(zvrf_id(zvrf), AF_INET, vty,
+                       zebra_print_rnh_table(zvrf_id(zvrf), AFI_IP, vty,
                                              RNH_NEXTHOP_TYPE);
                }
 
@@ -1017,7 +1016,7 @@ DEFUN (show_ipv6_nht,
        if (argc == 5)
                VRF_GET_ID(vrf_id, argv[idx_vrf]->arg, false);
 
-       zebra_print_rnh_table(vrf_id, AF_INET6, vty, RNH_NEXTHOP_TYPE);
+       zebra_print_rnh_table(vrf_id, AFI_IP6, vty, RNH_NEXTHOP_TYPE);
        return CMD_SUCCESS;
 }
 
@@ -1036,7 +1035,7 @@ DEFUN (show_ipv6_nht_vrf_all,
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
                if ((zvrf = vrf->info) != NULL) {
                        vty_out(vty, "\nVRF %s:\n", zvrf_name(zvrf));
-                       zebra_print_rnh_table(zvrf_id(zvrf), AF_INET6, vty,
+                       zebra_print_rnh_table(zvrf_id(zvrf), AFI_IP6, vty,
                                              RNH_NEXTHOP_TYPE);
                }
 
@@ -1060,7 +1059,7 @@ DEFUN (ip_nht_default_route,
 
        zebra_rnh_ip_default_route = 1;
 
-       zebra_evaluate_rnh(zvrf, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL);
+       zebra_evaluate_rnh(zvrf, AFI_IP, 1, RNH_NEXTHOP_TYPE, NULL);
        return CMD_SUCCESS;
 }
 
@@ -1081,7 +1080,7 @@ DEFUN (no_ip_nht_default_route,
                return CMD_SUCCESS;
 
        zebra_rnh_ip_default_route = 0;
-       zebra_evaluate_rnh(zvrf, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL);
+       zebra_evaluate_rnh(zvrf, AFI_IP, 1, RNH_NEXTHOP_TYPE, NULL);
        return CMD_SUCCESS;
 }
 
@@ -1101,7 +1100,7 @@ DEFUN (ipv6_nht_default_route,
                return CMD_SUCCESS;
 
        zebra_rnh_ipv6_default_route = 1;
-       zebra_evaluate_rnh(zvrf, AF_INET6, 1, RNH_NEXTHOP_TYPE, NULL);
+       zebra_evaluate_rnh(zvrf, AFI_IP6, 1, RNH_NEXTHOP_TYPE, NULL);
        return CMD_SUCCESS;
 }
 
@@ -1123,7 +1122,7 @@ DEFUN (no_ipv6_nht_default_route,
                return CMD_SUCCESS;
 
        zebra_rnh_ipv6_default_route = 0;
-       zebra_evaluate_rnh(zvrf, AF_INET6, 1, RNH_NEXTHOP_TYPE, NULL);
+       zebra_evaluate_rnh(zvrf, AFI_IP6, 1, RNH_NEXTHOP_TYPE, NULL);
        return CMD_SUCCESS;
 }