]> git.proxmox.com Git - mirror_frr.git/blobdiff - pbrd/pbr_nht.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / pbrd / pbr_nht.h
index cbcf71d2f5e543169c1ffb43cdd1efc907802f17..9b67492fbc2708e642e172b72da022efdc5c63eb 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * PBR-nht Header
  * Copyright (C) 2018 Cumulus Networks, Inc.
  *               Donald Sharp
- *
- * FRR is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * FRR is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #ifndef __PBR_NHT_H__
 #define __PBR_NHT_H__
@@ -28,6 +15,8 @@
 
 #define PBR_NHC_NAMELEN PBR_MAP_NAMELEN + 10
 
+extern struct hash *pbr_nhg_hash;
+
 struct pbr_nexthop_group_cache {
        char name[PBR_NHC_NAMELEN];
 
@@ -46,9 +35,14 @@ struct pbr_nexthop_group_cache {
 struct pbr_nexthop_cache {
        struct pbr_nexthop_group_cache *parent;
 
-       struct nexthop *nexthop;
+       char vrf_name[VRF_NAMSIZ + 1];
+       char intf_name[INTERFACE_NAMSIZ + 1];
+
+       struct nexthop nexthop;
 
+       bool looked_at;
        bool valid;
+       bool nhr_matched;
 };
 
 extern void pbr_nht_write_table_range(struct vty *vty);
@@ -57,13 +51,26 @@ extern void pbr_nht_write_table_range(struct vty *vty);
 extern void pbr_nht_set_tableid_range(uint32_t low, uint32_t high);
 
 /*
- * Get the next tableid to use for installation.
- *
- * peek
- *    If set to true, retrieves the next ID without marking it used. The next
- *    call will return the same ID.
+ * Find and reserve the next available table for installation;
+ * Sequential calls to this function will reserve sequential table numbers
+ * until the configured range is exhausted; calls made after exhaustion always
+ * return 0
+ */
+extern uint32_t
+pbr_nht_reserve_next_table_id(struct pbr_nexthop_group_cache *nhgc);
+/*
+ * Get the next tableid to use for installation to kernel
+ */
+extern uint32_t pbr_nht_find_next_unallocated_table_id(void);
+/*
+ * Calculate where the next table representing a nhg will go in kernel
+ */
+extern void pbr_nht_update_next_unallocated_table_id(void);
+/*
+ * Indicate if there are free spots to install a table to kernel within the
+ * configured PBR table range
  */
-extern uint32_t pbr_nht_get_next_tableid(bool peek);
+extern bool pbr_nht_has_unallocated_table(void);
 /*
  * Get the next rule number to use for installation
  */
@@ -76,6 +83,7 @@ extern void pbr_nht_set_rule_range(uint32_t low, uint32_t high);
 extern uint32_t pbr_nht_get_next_rule(uint32_t seqno);
 
 extern void pbr_nhgroup_add_cb(const char *name);
+extern void pbr_nhgroup_modify_cb(const struct nexthop_group_cmd *nhgc);
 extern void pbr_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhg,
                                       const struct nexthop *nhop);
 extern void pbr_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd *nhg,
@@ -89,6 +97,11 @@ extern struct pbr_nexthop_group_cache *pbr_nht_add_group(const char *name);
 extern void pbr_nht_change_group(const char *name);
 extern void pbr_nht_delete_group(const char *name);
 
+extern void pbr_nht_set_seq_nhg_data(struct pbr_map_sequence *pbrms,
+                                    const struct nexthop_group_cmd *nhgc);
+extern void pbr_nht_set_seq_nhg(struct pbr_map_sequence *pbrms,
+                               const char *name);
+
 extern void pbr_nht_add_individual_nexthop(struct pbr_map_sequence *pbrms,
                                           const struct nexthop *nhop);
 extern void pbr_nht_delete_individual_nexthop(struct pbr_map_sequence *pbrms);
@@ -126,4 +139,7 @@ extern void pbr_nht_nexthop_update(struct zapi_route *nhr);
 extern void pbr_nht_nexthop_interface_update(struct interface *ifp);
 
 extern void pbr_nht_init(void);
+
+extern void pbr_nht_vrf_update(struct pbr_vrf *pbr_vrf);
+extern void pbr_nht_interface_update(struct interface *ifp);
 #endif