]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_evpn_mac.h
*: Rename `struct thread` to `struct event`
[mirror_frr.git] / zebra / zebra_evpn_mac.h
index e90082e50bcfd23fb12f54f91505bbe2bda686b5..ba612f76969071f9df3d625febe82c4784088148 100644 (file)
@@ -1,25 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Zebra EVPN MAC Data structures and definitions
  * These are "internal" to this function.
  * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
  * Copyright (C) 2020 Volta Networks.
- *
- * This file is part of FRR.
- *
- * 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 FRR; see the file COPYING.  If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
  */
 
 #ifndef _ZEBRA_EVPN_MAC_H
@@ -29,7 +13,6 @@
 extern "C" {
 #endif
 
-typedef struct zebra_mac_t_ zebra_mac_t;
 
 struct host_rb_entry {
        RB_ENTRY(host_rb_entry) hl_entry;
@@ -52,7 +35,7 @@ RB_PROTOTYPE(host_rb_tree_entry, host_rb_entry, hl_entry,
  * information. The correct VNI will be obtained as zebra maintains
  * the mapping (of VLAN to VNI).
  */
-struct zebra_mac_t_ {
+struct zebra_mac {
        /* MAC address. */
        struct ethaddr macaddr;
 
@@ -88,7 +71,7 @@ struct zebra_mac_t_ {
        (ZEBRA_MAC_ES_PEER_PROXY | ZEBRA_MAC_ES_PEER_ACTIVE)
 
        /* back pointer to zevpn */
-       zebra_evpn_t *zevpn;
+       struct zebra_evpn *zevpn;
 
        /* Local or remote info.
         * Note: fwd_info is only relevant if mac->es is NULL.
@@ -125,20 +108,20 @@ struct zebra_mac_t_ {
        /* List of neigh associated with this mac */
        struct list *neigh_list;
 
-       /* list of hosts pointing to this remote RMAC */
-       struct host_rb_tree_entry host_rb;
+       /* List of nexthop associated with this RMAC */
+       struct list *nh_list;
 
        /* Duplicate mac detection */
        uint32_t dad_count;
 
-       struct thread *dad_mac_auto_recovery_timer;
+       struct event *dad_mac_auto_recovery_timer;
 
        struct timeval detect_start_time;
 
        time_t dad_dup_detect_time;
 
        /* used for ageing out the PEER_ACTIVE flag */
-       struct thread *hold_timer;
+       struct event *hold_timer;
 
        /* number of neigh entries (using this mac) that have
         * ZEBRA_MAC_ES_PEER_ACTIVE or ZEBRA_NEIGH_ES_PEER_PROXY
@@ -152,7 +135,7 @@ struct zebra_mac_t_ {
  * Context for MAC hash walk - used by callbacks.
  */
 struct mac_walk_ctx {
-       zebra_evpn_t *zevpn;    /* EVPN hash */
+       struct zebra_evpn *zevpn; /* EVPN hash */
        struct zebra_vrf *zvrf; /* VRF - for client notification. */
        int uninstall;          /* uninstall from kernel? */
        int upd_client;         /* uninstall from client? */
@@ -177,24 +160,13 @@ struct rmac_walk_ctx {
        struct json_object *json;
 };
 
-/* temporary datastruct to pass info between the mac-update and
- * neigh-update while handling mac-ip routes
- */
-struct sync_mac_ip_ctx {
-       bool ignore_macip;
-       bool mac_created;
-       bool mac_inactive;
-       bool mac_dp_update_deferred;
-       zebra_mac_t *mac;
-};
-
 /**************************** SYNC MAC handling *****************************/
 /* if the mac has been added of a mac-route from the peer
  * or if it is being referenced by a neigh added by the
  * peer we cannot let it age out i.e. we set the static bit
  * in the dataplane
  */
-static inline bool zebra_evpn_mac_is_static(zebra_mac_t *mac)
+static inline bool zebra_evpn_mac_is_static(struct zebra_mac *mac)
 {
        return ((mac->flags & ZEBRA_MAC_ALL_PEER_FLAGS) || mac->sync_neigh_cnt);
 }
@@ -207,86 +179,92 @@ static inline bool zebra_evpn_mac_is_ready_for_bgp(uint32_t flags)
                   || (flags & ZEBRA_MAC_ES_PEER_ACTIVE));
 }
 
-void zebra_evpn_mac_stop_hold_timer(zebra_mac_t *mac);
+void zebra_evpn_mac_stop_hold_timer(struct zebra_mac *mac);
 
-static inline void zebra_evpn_mac_clear_sync_info(zebra_mac_t *mac)
+static inline void zebra_evpn_mac_clear_sync_info(struct zebra_mac *mac)
 {
        UNSET_FLAG(mac->flags, ZEBRA_MAC_ALL_PEER_FLAGS);
        zebra_evpn_mac_stop_hold_timer(mac);
 }
 
-static inline bool zebra_evpn_mac_in_use(zebra_mac_t *mac)
+static inline bool zebra_evpn_mac_in_use(struct zebra_mac *mac)
 {
        return !list_isempty(mac->neigh_list)
               || CHECK_FLAG(mac->flags, ZEBRA_MAC_SVI);
 }
 
 struct hash *zebra_mac_db_create(const char *desc);
-uint32_t num_valid_macs(zebra_evpn_t *zevi);
-uint32_t num_dup_detected_macs(zebra_evpn_t *zevi);
-int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevi, zebra_mac_t *mac,
+uint32_t num_valid_macs(struct zebra_evpn *zevi);
+uint32_t num_dup_detected_macs(struct zebra_evpn *zevi);
+int zebra_evpn_rem_mac_uninstall(struct zebra_evpn *zevi, struct zebra_mac *mac,
                                 bool force);
-int zebra_evpn_rem_mac_install(zebra_evpn_t *zevi, zebra_mac_t *mac,
+int zebra_evpn_rem_mac_install(struct zebra_evpn *zevi, struct zebra_mac *mac,
                               bool was_static);
-void zebra_evpn_deref_ip2mac(zebra_evpn_t *zevi, zebra_mac_t *mac);
-zebra_mac_t *zebra_evpn_mac_lookup(zebra_evpn_t *zevi,
-                                  const struct ethaddr *mac);
-zebra_mac_t *zebra_evpn_mac_add(zebra_evpn_t *zevi,
-                               const struct ethaddr *macaddr);
-int zebra_evpn_mac_del(zebra_evpn_t *zevi, zebra_mac_t *mac);
+void zebra_evpn_deref_ip2mac(struct zebra_evpn *zevi, struct zebra_mac *mac);
+struct zebra_mac *zebra_evpn_mac_lookup(struct zebra_evpn *zevi,
+                                       const struct ethaddr *mac);
+struct zebra_mac *zebra_evpn_mac_add(struct zebra_evpn *zevi,
+                                    const struct ethaddr *macaddr);
+struct zebra_mac *zebra_evpn_mac_add_auto(struct zebra_evpn *zevi,
+                                         const struct ethaddr *macaddr);
+int zebra_evpn_mac_del(struct zebra_evpn *zevi, struct zebra_mac *mac);
 int zebra_evpn_macip_send_msg_to_client(uint32_t id,
                                        const struct ethaddr *macaddr,
                                        const struct ipaddr *ip, uint8_t flags,
                                        uint32_t seq, int state,
                                        struct zebra_evpn_es *es, uint16_t cmd);
-void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json);
+void zebra_evpn_print_mac(struct zebra_mac *mac, void *ctxt, json_object *json);
 void zebra_evpn_print_mac_hash(struct hash_bucket *bucket, void *ctxt);
 void zebra_evpn_print_mac_hash_detail(struct hash_bucket *bucket, void *ctxt);
-int zebra_evpn_sync_mac_dp_install(zebra_mac_t *mac, bool set_inactive,
+int zebra_evpn_sync_mac_dp_install(struct zebra_mac *mac, bool set_inactive,
                                   bool force_clear_static, const char *caller);
-void zebra_evpn_mac_send_add_del_to_client(zebra_mac_t *mac, bool old_bgp_ready,
+void zebra_evpn_mac_send_add_del_to_client(struct zebra_mac *mac,
+                                          bool old_bgp_ready,
                                           bool new_bgp_ready);
 
-void zebra_evpn_mac_del_all(zebra_evpn_t *zevi, int uninstall, int upd_client,
-                           uint32_t flags);
+void zebra_evpn_mac_del_all(struct zebra_evpn *zevi, int uninstall,
+                           int upd_client, uint32_t flags);
 int zebra_evpn_mac_send_add_to_client(vni_t vni, const struct ethaddr *macaddr,
                                      uint32_t mac_flags, uint32_t seq,
                                      struct zebra_evpn_es *es);
 int zebra_evpn_mac_send_del_to_client(vni_t vni, const struct ethaddr *macaddr,
                                      uint32_t flags, bool force);
-void zebra_evpn_send_mac_list_to_client(zebra_evpn_t *zevi);
-zebra_mac_t *zebra_evpn_proc_sync_mac_update(
-       zebra_evpn_t *zevi, const struct ethaddr *macaddr, uint16_t ipa_len,
-       const struct ipaddr *ipaddr, uint8_t flags, uint32_t seq,
-       const esi_t *esi, struct sync_mac_ip_ctx *ctx);
-void zebra_evpn_sync_mac_del(zebra_mac_t *mac);
-void zebra_evpn_rem_mac_del(zebra_evpn_t *zevi, zebra_mac_t *mac);
+void zebra_evpn_send_mac_list_to_client(struct zebra_evpn *zevi);
+struct zebra_mac *zebra_evpn_proc_sync_mac_update(struct zebra_evpn *zevi,
+                                                 const struct ethaddr *macaddr,
+                                                 uint16_t ipa_len,
+                                                 const struct ipaddr *ipaddr,
+                                                 uint8_t flags, uint32_t seq,
+                                                 const esi_t *esi);
+void zebra_evpn_sync_mac_del(struct zebra_mac *mac);
+void zebra_evpn_rem_mac_del(struct zebra_evpn *zevi, struct zebra_mac *mac);
 void zebra_evpn_print_dad_mac_hash(struct hash_bucket *bucket, void *ctxt);
 void zebra_evpn_print_dad_mac_hash_detail(struct hash_bucket *bucket,
                                          void *ctxt);
-int zebra_evpn_mac_remote_macip_add(zebra_evpn_t *zevpn, struct zebra_vrf *zvrf,
+int zebra_evpn_mac_remote_macip_add(struct zebra_evpn *zevpn,
+                                   struct zebra_vrf *zvrf,
                                    const struct ethaddr *macaddr,
-                                   uint16_t ipa_len,
-                                   const struct ipaddr *ipaddr,
-                                   zebra_mac_t **macp, struct in_addr vtep_ip,
-                                   uint8_t flags, uint32_t seq,
-                                   const esi_t *esi);
+                                   struct in_addr vtep_ip, uint8_t flags,
+                                   uint32_t seq, const esi_t *esi);
 
-int zebra_evpn_add_update_local_mac(struct zebra_vrf *zvrf, zebra_evpn_t *zevpn,
+int zebra_evpn_add_update_local_mac(struct zebra_vrf *zvrf,
+                                   struct zebra_evpn *zevpn,
                                    struct interface *ifp,
                                    const struct ethaddr *macaddr, vlanid_t vid,
                                    bool sticky, bool local_inactive,
-                                   bool dp_static, zebra_mac_t *mac);
-int zebra_evpn_del_local_mac(zebra_evpn_t *zevpn, zebra_mac_t *mac,
+                                   bool dp_static, struct zebra_mac *mac);
+int zebra_evpn_del_local_mac(struct zebra_evpn *zevpn, struct zebra_mac *mac,
                             bool clear_static);
-int zebra_evpn_mac_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
-                               const struct ipaddr *ip, zebra_mac_t **macp,
-                               const struct ethaddr *macaddr, vlanid_t vlan_id,
-                               bool def_gw);
-void zebra_evpn_mac_svi_add(struct interface *ifp, zebra_evpn_t *zevpn);
-void zebra_evpn_mac_svi_del(struct interface *ifp, zebra_evpn_t *zevpn);
+void zebra_evpn_mac_gw_macip_add(struct interface *ifp,
+                                struct zebra_evpn *zevpn,
+                                const struct ipaddr *ip,
+                                struct zebra_mac **macp,
+                                const struct ethaddr *macaddr,
+                                vlanid_t vlan_id, bool def_gw);
+void zebra_evpn_mac_svi_add(struct interface *ifp, struct zebra_evpn *zevpn);
+void zebra_evpn_mac_svi_del(struct interface *ifp, struct zebra_evpn *zevpn);
 void zebra_evpn_mac_ifp_del(struct interface *ifp);
-void zebra_evpn_mac_clear_fwd_info(zebra_mac_t *zmac);
+void zebra_evpn_mac_clear_fwd_info(struct zebra_mac *zmac);
 
 #ifdef __cplusplus
 }