]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Rename vrf_lookup_by_tableid to zebra_vrf_lookup..
authorDonald Sharp <sharpd@nvidia.com>
Thu, 27 Apr 2023 03:25:27 +0000 (23:25 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 5 Jul 2023 15:49:36 +0000 (11:49 -0400)
Rename the vrf_lookup_by_id function to zebra_vrf_lookup_by_id
and move to zebra_vrf.c where it nominally belongs, as that
we need zebra specific data to find this vrf_id and as such
it does not belong in vrf.c

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/if_netlink.c
zebra/rt_netlink.c
zebra/rt_netlink.h
zebra/zebra_vrf.c
zebra/zebra_vrf.h

index cd200d821d7ae369bbf5f3b76798ef3ef732ba12..cea47b4c30afa30480184919b01497d2c14cc69b 100644 (file)
@@ -325,7 +325,8 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,
                if (!vrf_lookup_by_id((vrf_id_t)ifi->ifi_index)) {
                        vrf_id_t exist_id;
 
-                       exist_id = vrf_lookup_by_table(nl_table_id, ns_id);
+                       exist_id =
+                               zebra_vrf_lookup_by_table(nl_table_id, ns_id);
                        if (exist_id != VRF_DEFAULT) {
                                vrf = vrf_lookup_by_id(exist_id);
 
index de01ced411ef9a05844010fe36b89156c9e97d24..0f542ab807563d5214571d2261bedd7a18cec7a7 100644 (file)
@@ -380,33 +380,6 @@ static inline int proto2zebra(int proto, int family, bool is_nexthop)
        return proto;
 }
 
-/*
-Pending: create an efficient table_id (in a tree/hash) based lookup)
- */
-vrf_id_t vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id)
-{
-       struct vrf *vrf;
-       struct zebra_vrf *zvrf;
-
-       RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
-               zvrf = vrf->info;
-               if (zvrf == NULL)
-                       continue;
-               /* case vrf with netns : match the netnsid */
-               if (vrf_is_backend_netns()) {
-                       if (ns_id == zvrf_id(zvrf))
-                               return zvrf_id(zvrf);
-               } else {
-                       /* VRF is VRF_BACKEND_VRF_LITE */
-                       if (zvrf->table_id != table_id)
-                               continue;
-                       return zvrf_id(zvrf);
-               }
-       }
-
-       return VRF_DEFAULT;
-}
-
 /**
  * @parse_encap_mpls() - Parses encapsulated mpls attributes
  * @tb:         Pointer to rtattr to look for nested items in.
@@ -790,7 +763,7 @@ int netlink_route_change_read_unicast_internal(struct nlmsghdr *h,
                table = rtm->rtm_table;
 
        /* Map to VRF */
-       vrf_id = vrf_lookup_by_table(table, ns_id);
+       vrf_id = zebra_vrf_lookup_by_table(table, ns_id);
        if (vrf_id == VRF_DEFAULT) {
                if (!is_zebra_valid_kernel_table(table)
                    && !is_zebra_main_routing_table(table))
@@ -1079,7 +1052,7 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h,
        else
                table = rtm->rtm_table;
 
-       vrf = vrf_lookup_by_table(table, ns_id);
+       vrf = zebra_vrf_lookup_by_table(table, ns_id);
 
        if (tb[RTA_IIF])
                iif = *(int *)RTA_DATA(tb[RTA_IIF]);
index 3ca59ce676f381e94f30248bbf4d8ad0322b8eda..d9d0ee76249aefcae86e391082a3feb870f68ba7 100644 (file)
@@ -90,7 +90,6 @@ extern int netlink_macfdb_read_specific_mac(struct zebra_ns *zns,
                                            uint16_t vid);
 extern int netlink_neigh_read_specific_ip(const struct ipaddr *ip,
                                          struct interface *vlan_if);
-extern vrf_id_t vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id);
 
 struct nl_batch;
 extern enum netlink_msg_status
index 3365cdcdbaa8b9e25cb106b6eb263f9faccd4040..74b9d106cdc38b052fb079fc7dbee70a8686ca53 100644 (file)
@@ -376,6 +376,33 @@ struct zebra_vrf *zebra_vrf_alloc(struct vrf *vrf)
        return zvrf;
 }
 
+/*
+Pending: create an efficient table_id (in a tree/hash) based lookup)
+ */
+vrf_id_t zebra_vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id)
+{
+       struct vrf *vrf;
+       struct zebra_vrf *zvrf;
+
+       RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
+               zvrf = vrf->info;
+               if (zvrf == NULL)
+                       continue;
+               /* case vrf with netns : match the netnsid */
+               if (vrf_is_backend_netns()) {
+                       if (ns_id == zvrf_id(zvrf))
+                               return zvrf_id(zvrf);
+               } else {
+                       /* VRF is VRF_BACKEND_VRF_LITE */
+                       if (zvrf->table_id != table_id)
+                               continue;
+                       return zvrf_id(zvrf);
+               }
+       }
+
+       return VRF_DEFAULT;
+}
+
 /* Lookup VRF by identifier.  */
 struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id)
 {
index b23b7282610bdf5de89129807d010833a191006f..aef83cd8f172c108274418d0d7688e1e25ff1877 100644 (file)
@@ -237,6 +237,7 @@ extern struct route_table *zebra_vrf_get_table_with_table_id(afi_t afi,
 extern void zebra_vrf_update_all(struct zserv *client);
 extern struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id);
 extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *);
+extern vrf_id_t zebra_vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id);
 extern struct zebra_vrf *zebra_vrf_alloc(struct vrf *vrf);
 extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t);