]> git.proxmox.com Git - mirror_frr.git/blobdiff - pimd/pim_vxlan.c
*: s/TRUE/true/, s/FALSE/false/
[mirror_frr.git] / pimd / pim_vxlan.c
index 43269b74a1a15fd708e0dcede1f0c117fcf85c11..cc2e6627d57e279368e2d817d1c826dff7bedfed 100644 (file)
@@ -115,7 +115,7 @@ static void pim_vxlan_init_work(void)
        vxlan_info.max_work_cnt = PIM_VXLAN_WORK_MAX;
        vxlan_info.flags |= PIM_VXLANF_WORK_INITED;
        vxlan_info.work_list = list_new();
-       pim_vxlan_work_timer_setup(TRUE /* start */);
+       pim_vxlan_work_timer_setup(true/* start */);
 }
 
 static void pim_vxlan_add_work(struct pim_vxlan_sg *vxlan_sg)
@@ -808,6 +808,27 @@ void pim_vxlan_mlag_update(bool enable, bool peer_state, uint32_t role,
 }
 
 /****************************** misc callbacks *******************************/
+void pim_vxlan_config_write(struct vty *vty, char *spaces, int *writes)
+{
+       char addr_buf[INET_ADDRSTRLEN];
+
+       if ((vxlan_mlag.flags & PIM_VXLAN_MLAGF_ENABLED) &&
+                       vxlan_mlag.peerlink_rif) {
+
+               inet_ntop(AF_INET, &vxlan_mlag.reg_addr,
+                               addr_buf, sizeof(addr_buf));
+               vty_out(vty,
+                       "%sip pim mlag %s role %s state %s addr %s\n",
+                       spaces,
+                       vxlan_mlag.peerlink_rif->name,
+                       (vxlan_mlag.role == PIM_VXLAN_MLAG_ROLE_PRIMARY) ?
+                               "primary":"secondary",
+                       vxlan_mlag.peer_state ? "up" : "down",
+                       addr_buf);
+               *writes += 1;
+       }
+}
+
 static void pim_vxlan_set_default_iif(struct pim_instance *pim,
                                struct interface *ifp)
 {
@@ -837,7 +858,9 @@ static void pim_vxlan_set_default_iif(struct pim_instance *pim,
        /* add/del upstream entries for the existing vxlan SG when the
         * interface becomes available
         */
-       hash_iterate(pim->vxlan.sg_hash, pim_vxlan_orig_mr_iif_update, ifp);
+       if (pim->vxlan.sg_hash)
+               hash_iterate(pim->vxlan.sg_hash,
+                               pim_vxlan_orig_mr_iif_update, ifp);
 }
 
 static void pim_vxlan_set_peerlink_rif(struct pim_instance *pim,
@@ -868,7 +891,9 @@ static void pim_vxlan_set_peerlink_rif(struct pim_instance *pim,
        /* add/del upstream entries for the existing vxlan SG when the
         * interface becomes available
         */
-       hash_iterate(pim->vxlan.sg_hash, pim_vxlan_orig_mr_iif_update, ifp);
+       if (pim->vxlan.sg_hash)
+               hash_iterate(pim->vxlan.sg_hash,
+                               pim_vxlan_orig_mr_iif_update, ifp);
 }
 
 void pim_vxlan_add_vif(struct interface *ifp)
@@ -935,19 +960,26 @@ void pim_vxlan_add_term_dev(struct pim_instance *pim,
        if (PIM_DEBUG_VXLAN)
                zlog_debug("vxlan term oif changed from %s to %s",
                        pim->vxlan.term_if ? pim->vxlan.term_if->name : "-",
-                       ifp ? ifp->name : "-");
+                       ifp->name);
 
        /* enable pim on the term ifp */
        pim_ifp = (struct pim_interface *)ifp->info;
-       if (pim_ifp)
+       if (pim_ifp) {
                PIM_IF_DO_PIM(pim_ifp->options);
-       else
+       } else {
                pim_ifp = pim_if_new(ifp, false /*igmp*/, true /*pim*/,
                                false /*pimreg*/, true /*vxlan_term*/);
+               /* ensure that pimreg existss before using the newly created
+                * vxlan termination device
+                */
+               pim_if_create_pimreg(pim);
+       }
 
        pim->vxlan.term_if = ifp;
-       hash_iterate(pim_ifp->pim->vxlan.sg_hash,
-               pim_vxlan_term_mr_oif_update, ifp);
+
+       if (pim->vxlan.sg_hash)
+               hash_iterate(pim_ifp->pim->vxlan.sg_hash,
+                               pim_vxlan_term_mr_oif_update, ifp);
 }
 
 void pim_vxlan_del_term_dev(struct pim_instance *pim)
@@ -959,8 +991,10 @@ void pim_vxlan_del_term_dev(struct pim_instance *pim)
                zlog_debug("vxlan term oif changed from %s to -", ifp->name);
 
        pim->vxlan.term_if = NULL;
-       hash_iterate(pim->vxlan.sg_hash,
-               pim_vxlan_term_mr_oif_update, NULL);
+
+       if (pim->vxlan.sg_hash)
+               hash_iterate(pim->vxlan.sg_hash,
+                               pim_vxlan_term_mr_oif_update, NULL);
 
        pim_ifp = (struct pim_interface *)ifp->info;
        if (pim_ifp) {