]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_evpn.h
zebra: Refactoring changes for zebra_evpn_map_vlan zebra_evpn_from_svi and zl3vni_fro...
[mirror_frr.git] / zebra / zebra_evpn.h
index 3b6a5b21e82e712cc9e45f9881dea0f9c582a934..b07c6515b2cf9f68dede6cf279d798bfba5b6b87 100644 (file)
 
 #include "zebra/zebra_l2.h"
 #include "zebra/interface.h"
+#include "zebra/zebra_vxlan.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-typedef struct zebra_evpn_t_ zebra_evpn_t;
-typedef struct zebra_vtep_t_ zebra_vtep_t;
-
 RB_HEAD(zebra_es_evi_rb_head, zebra_evpn_es_evi);
 RB_PROTOTYPE(zebra_es_evi_rb_head, zebra_evpn_es_evi, rb_node,
             zebra_es_evi_rb_cmp);
@@ -58,7 +56,7 @@ struct zebra_evpn_show {
  *
  * Right now, this just has each remote VTEP's IP address.
  */
-struct zebra_vtep_t_ {
+struct zebra_vtep {
        /* Remote IP. */
        /* NOTE: Can only be IPv4 right now. */
        struct in_addr vtep_ip;
@@ -68,8 +66,8 @@ struct zebra_vtep_t_ {
        int flood_control;
 
        /* Links. */
-       struct zebra_vtep_t_ *next;
-       struct zebra_vtep_t_ *prev;
+       struct zebra_vtep *next;
+       struct zebra_vtep *prev;
 };
 
 /*
@@ -78,7 +76,7 @@ struct zebra_vtep_t_ {
  * Contains information pertaining to a VNI:
  * - the list of remote VTEPs (with this VNI)
  */
-struct zebra_evpn_t_ {
+struct zebra_evpn {
        /* VNI - key */
        vni_t vni;
 
@@ -86,6 +84,10 @@ struct zebra_evpn_t_ {
        uint32_t flags;
 #define ZEVPN_READY_FOR_BGP (1 << 0) /* ready to be sent to BGP */
 
+       /* Corresponding Bridge information */
+       vlanid_t vid;
+       struct interface *bridge_if;
+
        /* Flag for advertising gw macip */
        uint8_t advertise_gw_macip;
 
@@ -98,8 +100,11 @@ struct zebra_evpn_t_ {
        /* Corresponding VxLAN interface. */
        struct interface *vxlan_if;
 
+       /* Corresponding SVI interface. */
+       struct interface *svi_if;
+
        /* List of remote VTEPs */
-       zebra_vtep_t *vteps;
+       struct zebra_vtep *vteps;
 
        /* Local IP */
        struct in_addr local_vtep_ip;
@@ -123,13 +128,22 @@ struct zebra_evpn_t_ {
        struct list *local_es_evi_list;
 };
 
+/* for parsing evpn and vni contexts */
+struct zebra_from_svi_param {
+       struct interface *br_if;
+       struct interface *svi_if;
+       struct zebra_if *zif;
+       uint8_t bridge_vlan_aware;
+       vlanid_t vid;
+};
+
 struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if);
 
-static inline struct interface *zevpn_map_to_svi(zebra_evpn_t *zevpn)
+static inline struct interface *zevpn_map_to_svi(struct zebra_evpn *zevpn)
 {
        struct interface *ifp;
        struct zebra_if *zif = NULL;
-       struct zebra_l2info_vxlan zl2_info;
+       struct zebra_vxlan_vni *vni;
 
        ifp = zevpn->vxlan_if;
        if (!ifp)
@@ -137,26 +151,31 @@ static inline struct interface *zevpn_map_to_svi(zebra_evpn_t *zevpn)
        zif = ifp->info;
        if (!zif)
                return NULL;
+       vni = zebra_vxlan_if_vni_find(zif, zevpn->vni);
+       if (!vni)
+               return NULL;
 
        /* If down or not mapped to a bridge, we're done. */
        if (!if_is_operative(ifp) || !zif->brslave_info.br_if)
                return NULL;
-       zl2_info = zif->l2info.vxl;
-       return zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);
+
+       return zvni_map_to_svi(vni->access_vlan, zif->brslave_info.br_if);
 }
 
-int advertise_gw_macip_enabled(zebra_evpn_t *zevpn);
-int advertise_svi_macip_enabled(zebra_evpn_t *zevpn);
-void zebra_evpn_print(zebra_evpn_t *zevpn, void **ctxt);
+int advertise_gw_macip_enabled(struct zebra_evpn *zevpn);
+int advertise_svi_macip_enabled(struct zebra_evpn *zevpn);
+void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt);
 void zebra_evpn_print_hash(struct hash_bucket *bucket, void *ctxt[]);
 void zebra_evpn_print_hash_detail(struct hash_bucket *bucket, void *data);
-int zebra_evpn_add_macip_for_intf(struct interface *ifp, zebra_evpn_t *zevpn);
-int zebra_evpn_del_macip_for_intf(struct interface *ifp, zebra_evpn_t *zevpn);
-int zebra_evpn_advertise_subnet(zebra_evpn_t *zevpn, struct interface *ifp,
+int zebra_evpn_add_macip_for_intf(struct interface *ifp,
+                                 struct zebra_evpn *zevpn);
+int zebra_evpn_del_macip_for_intf(struct interface *ifp,
+                                 struct zebra_evpn *zevpn);
+int zebra_evpn_advertise_subnet(struct zebra_evpn *zevpn, struct interface *ifp,
                                int advertise);
-int zebra_evpn_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
+int zebra_evpn_gw_macip_add(struct interface *ifp, struct zebra_evpn *zevpn,
                            struct ethaddr *macaddr, struct ipaddr *ip);
-int zebra_evpn_gw_macip_del(struct interface *ifp, zebra_evpn_t *zevpn,
+int zebra_evpn_gw_macip_del(struct interface *ifp, struct zebra_evpn *zevpn,
                            struct ipaddr *ip);
 void zebra_evpn_gw_macip_del_for_evpn_hash(struct hash_bucket *bucket,
                                           void *ctxt);
@@ -164,40 +183,42 @@ void zebra_evpn_gw_macip_add_for_evpn_hash(struct hash_bucket *bucket,
                                           void *ctxt);
 void zebra_evpn_svi_macip_del_for_evpn_hash(struct hash_bucket *bucket,
                                            void *ctxt);
-zebra_evpn_t *zebra_evpn_map_vlan(struct interface *ifp,
-                                 struct interface *br_if, vlanid_t vid);
-zebra_evpn_t *zebra_evpn_from_svi(struct interface *ifp,
-                                 struct interface *br_if);
+struct zebra_evpn *zebra_evpn_map_vlan(struct interface *ifp,
+                                      struct interface *br_if, vlanid_t vid);
+struct zebra_evpn *zebra_evpn_from_svi(struct interface *ifp,
+                                      struct interface *br_if);
 struct interface *zebra_evpn_map_to_macvlan(struct interface *br_if,
                                            struct interface *svi_if);
 void zebra_evpn_install_mac_hash(struct hash_bucket *bucket, void *ctxt);
-void zebra_evpn_read_mac_neigh(zebra_evpn_t *zevpn, struct interface *ifp);
+void zebra_evpn_read_mac_neigh(struct zebra_evpn *zevpn, struct interface *ifp);
 unsigned int zebra_evpn_hash_keymake(const void *p);
 bool zebra_evpn_hash_cmp(const void *p1, const void *p2);
 int zebra_evpn_list_cmp(void *p1, void *p2);
 void *zebra_evpn_alloc(void *p);
-zebra_evpn_t *zebra_evpn_lookup(vni_t vni);
-zebra_evpn_t *zebra_evpn_add(vni_t vni);
-int zebra_evpn_del(zebra_evpn_t *zevpn);
-int zebra_evpn_send_add_to_client(zebra_evpn_t *zevpn);
-int zebra_evpn_send_del_to_client(zebra_evpn_t *zevpn);
-zebra_vtep_t *zebra_evpn_vtep_find(zebra_evpn_t *zevpn,
-                                  struct in_addr *vtep_ip);
-zebra_vtep_t *zebra_evpn_vtep_add(zebra_evpn_t *zevpn, struct in_addr *vtep_ip,
-                                 int flood_control);
-int zebra_evpn_vtep_del(zebra_evpn_t *zevpn, zebra_vtep_t *zvtep);
-int zebra_evpn_vtep_del_all(zebra_evpn_t *zevpn, int uninstall);
-int zebra_evpn_vtep_install(zebra_evpn_t *zevpn, zebra_vtep_t *zvtep);
-int zebra_evpn_vtep_uninstall(zebra_evpn_t *zevpn, struct in_addr *vtep_ip);
+struct zebra_evpn *zebra_evpn_lookup(vni_t vni);
+struct zebra_evpn *zebra_evpn_add(vni_t vni);
+int zebra_evpn_del(struct zebra_evpn *zevpn);
+int zebra_evpn_send_add_to_client(struct zebra_evpn *zevpn);
+int zebra_evpn_send_del_to_client(struct zebra_evpn *zevpn);
+struct zebra_vtep *zebra_evpn_vtep_find(struct zebra_evpn *zevpn,
+                                       struct in_addr *vtep_ip);
+struct zebra_vtep *zebra_evpn_vtep_add(struct zebra_evpn *zevpn,
+                                      struct in_addr *vtep_ip,
+                                      int flood_control);
+int zebra_evpn_vtep_del(struct zebra_evpn *zevpn, struct zebra_vtep *zvtep);
+int zebra_evpn_vtep_del_all(struct zebra_evpn *zevpn, int uninstall);
+int zebra_evpn_vtep_install(struct zebra_evpn *zevpn, struct zebra_vtep *zvtep);
+int zebra_evpn_vtep_uninstall(struct zebra_evpn *zevpn,
+                             struct in_addr *vtep_ip);
 void zebra_evpn_handle_flooding_remote_vteps(struct hash_bucket *bucket,
                                             void *zvrf);
 void zebra_evpn_cleanup_all(struct hash_bucket *bucket, void *arg);
-void process_remote_macip_add(vni_t vni, struct ethaddr *macaddr,
-                             uint16_t ipa_len, struct ipaddr *ipaddr,
+void zebra_evpn_rem_macip_add(vni_t vni, const struct ethaddr *macaddr,
+                             uint16_t ipa_len, const struct ipaddr *ipaddr,
                              uint8_t flags, uint32_t seq,
-                             struct in_addr vtep_ip, esi_t *esi);
-void process_remote_macip_del(vni_t vni, struct ethaddr *macaddr,
-                             uint16_t ipa_len, struct ipaddr *ipaddr,
+                             struct in_addr vtep_ip, const esi_t *esi);
+void zebra_evpn_rem_macip_del(vni_t vni, const struct ethaddr *macaddr,
+                             uint16_t ipa_len, const struct ipaddr *ipaddr,
                              struct in_addr vtep_ip);
 void zebra_evpn_cfg_cleanup(struct hash_bucket *bucket, void *ctxt);