diff --git a/pimd/pim_vxlan.c b/pimd/pim_vxlan.c index fc34f3f600..4d8fe779ae 100644 --- a/pimd/pim_vxlan.c +++ b/pimd/pim_vxlan.c @@ -660,6 +660,14 @@ static struct pim_vxlan_sg *pim_vxlan_sg_new(struct pim_instance *pim, vxlan_sg = hash_get(pim->vxlan.sg_hash, vxlan_sg, hash_alloc_intern); + /* we register with the MLAG daemon in the first VxLAN SG and never + * de-register during that life of the pimd + */ + if (pim->vxlan.sg_hash->count == 1) { + vxlan_mlag.flags |= PIM_VXLAN_MLAGF_DO_REG; + pim_mlag_register(); + } + return vxlan_sg; } @@ -717,6 +725,11 @@ void pim_vxlan_sg_del(struct pim_instance *pim, struct prefix_sg *sg) } /******************************* MLAG handling *******************************/ +bool pim_vxlan_do_mlag_reg(void) +{ + return (vxlan_mlag.flags & PIM_VXLAN_MLAGF_DO_REG); +} + /* The peerlink sub-interface is added as an OIF to the origination-mroute. * This is done to send a copy of the multicast-vxlan encapsulated traffic * to the MLAG peer which may mroute it over the underlay if there are any diff --git a/pimd/pim_vxlan.h b/pimd/pim_vxlan.h index c6507a474c..22ed1f761a 100644 --- a/pimd/pim_vxlan.h +++ b/pimd/pim_vxlan.h @@ -66,7 +66,8 @@ struct pim_vxlan_sg { enum pim_vxlan_mlag_flags { PIM_VXLAN_MLAGF_NONE = 0, - PIM_VXLAN_MLAGF_ENABLED = (1 << 0) + PIM_VXLAN_MLAGF_ENABLED = (1 << 0), + PIM_VXLAN_MLAGF_DO_REG = (1 << 1) }; enum pim_vxlan_mlag_role { @@ -142,5 +143,6 @@ extern void pim_vxlan_mlag_update(bool enable, bool peer_state, uint32_t role, struct interface *peerlink_rif, struct in_addr *reg_addr); extern void pim_vxlan_config_write(struct vty *vty, char *spaces, int *writes); +extern bool pim_vxlan_do_mlag_reg(void); #endif /* PIM_VXLAN_H */