Skip to content

Commit

Permalink
pimd : Add support for MLAG Register & Un-register
Browse files Browse the repository at this point in the history
when ever a FRR Client wants to send any data to another node
using MLAG Channel, uses below mechanisam.

1. sends  a MLAG Registration to zebra with interested messages that
   it is intended to receive from peer.
2. In response to this request, Zebra opens communication channel with
   MLAG. and also in Rx. diretion zebra forwards only those messages which
   client shown interest during registration
3. when client is no-longer interested in communicating with MLAG, client
   posts De-register to Zebra
4. if this is the last client which is interested for MLAG Communication,
   zebra closes the channel.

why PIM Needs MLAG Communication
================================
1. In general on LAN Networks elecetd DR will send the Join towards
   Multicast RP in case of a LHR and Register in case of FHR.
2. But in case DR Goes down, traffic will be re-converged only after
   the New DR is elected, but this can take time based on Hold Timer to
   detect the DR down.
3. this can be optimised by using MLAG Mecganisam.
4. and also Traffic can be forwarded more efficiently by knowing the cost
   towards RP using MLAG

Signed-off-by: Satheesh Kumar K <sathk@cumulusnetworks.com>
  • Loading branch information
satheeshkarra committed Sep 17, 2019
1 parent 6c11fdb commit 4bf3dda
Show file tree
Hide file tree
Showing 13 changed files with 340 additions and 3 deletions.
21 changes: 21 additions & 0 deletions lib/mlag.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,33 @@
extern "C" {
#endif

#define MLAG_BUF_LIMIT 2048

enum mlag_role {
MLAG_ROLE_NONE,
MLAG_ROLE_PRIMARY,
MLAG_ROLE_SECONDARY
};

/*
* This message definition should match mlag.proto
* Beacuse mesasge registartion is based on this
*/
enum mlag_msg_type {
MLAG_MSG_NONE = 0,
MLAG_REGISTER = 1,
MLAG_DEREGISTER = 2,
MLAG_STATUS_UPDATE = 3,
MLAG_MROUTE_ADD = 4,
MLAG_MROUTE_DEL = 5,
MLAG_DUMP = 6,
MLAG_MROUTE_ADD_BULK = 7,
MLAG_MROUTE_DEL_BULK = 8,
MLAG_PIM_CFG_DUMP = 10,
MLAG_VXLAN_UPDATE = 11,
MLAG_PEER_FRR_STATUS = 12,
};

extern char *mlag_role2str(enum mlag_role role, char *buf, size_t size);

#ifdef __cplusplus
Expand Down
33 changes: 33 additions & 0 deletions lib/zclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,39 @@ static void zclient_capability_decode(ZAPI_CALLBACK_ARGS)
return;
}

void zclient_send_mlag_register(struct zclient *client, uint32_t bit_map)
{
struct stream *s;

s = client->obuf;
stream_reset(s);

zclient_create_header(s, ZEBRA_MLAG_CLIENT_REGISTER, VRF_DEFAULT);
stream_putl(s, bit_map);

stream_putw_at(s, 0, stream_get_endp(s));
zclient_send_message(client);
}

void zclient_send_mlag_deregister(struct zclient *client)
{
zebra_message_send(client, ZEBRA_MLAG_CLIENT_UNREGISTER, VRF_DEFAULT);
}

void zclient_send_mlag_data(struct zclient *client, struct stream *client_s)
{
struct stream *s;

s = client->obuf;
stream_reset(s);

zclient_create_header(s, ZEBRA_MLAG_FORWARD_MSG, VRF_DEFAULT);
stream_put(s, client_s->data, client_s->endp);

stream_putw_at(s, 0, stream_get_endp(s));
zclient_send_message(client);
}

/* Zebra client message read function. */
static int zclient_read(struct thread *thread)
{
Expand Down
9 changes: 9 additions & 0 deletions lib/zclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ typedef enum {
ZEBRA_VXLAN_SG_ADD,
ZEBRA_VXLAN_SG_DEL,
ZEBRA_VXLAN_SG_REPLAY,
ZEBRA_MLAG_CLIENT_REGISTER,
ZEBRA_MLAG_CLIENT_UNREGISTER,
ZEBRA_MLAG_FORWARD_MSG,
} zebra_message_types_t;

struct redist_proto {
Expand Down Expand Up @@ -670,5 +673,11 @@ static inline void zapi_route_set_blackhole(struct zapi_route *api,
SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP);
};

extern void zclient_send_mlag_register(struct zclient *client,
uint32_t bit_map);
extern void zclient_send_mlag_deregister(struct zclient *client);

extern void zclient_send_mlag_data(struct zclient *client,
struct stream *client_s);

#endif /* _ZEBRA_ZCLIENT_H */
21 changes: 19 additions & 2 deletions pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include "pim_nht.h"
#include "pim_bfd.h"
#include "pim_vxlan.h"
#include "pim_mlag.h"
#include "bfd.h"
#include "pim_bsm.h"

Expand Down Expand Up @@ -7462,9 +7463,9 @@ DEFPY_HIDDEN (interface_ip_pim_activeactive,

pim_ifp = ifp->info;
if (no)
pim_ifp->activeactive = false;
pim_if_unconfigure_mlag_dualactive(pim_ifp);
else
pim_ifp->activeactive = true;
pim_if_configure_mlag_dualactive(pim_ifp);

return CMD_SUCCESS;
}
Expand Down Expand Up @@ -8382,6 +8383,20 @@ DEFUN (no_debug_pim_zebra,
return CMD_SUCCESS;
}

DEFUN(debug_pim_mlag, debug_pim_mlag_cmd, "debug pim mlag",
DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_MLAG_STR)
{
PIM_DO_DEBUG_MLAG;
return CMD_SUCCESS;
}

DEFUN(no_debug_pim_mlag, no_debug_pim_mlag_cmd, "no debug pim mlag",
NO_STR DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_MLAG_STR)
{
PIM_DONT_DEBUG_MLAG;
return CMD_SUCCESS;
}

DEFUN (debug_pim_vxlan,
debug_pim_vxlan_cmd,
"debug pim vxlan",
Expand Down Expand Up @@ -10408,6 +10423,8 @@ void pim_cmd_init(void)
install_element(ENABLE_NODE, &no_debug_ssmpingd_cmd);
install_element(ENABLE_NODE, &debug_pim_zebra_cmd);
install_element(ENABLE_NODE, &no_debug_pim_zebra_cmd);
install_element(ENABLE_NODE, &debug_pim_mlag_cmd);
install_element(ENABLE_NODE, &no_debug_pim_mlag_cmd);
install_element(ENABLE_NODE, &debug_pim_vxlan_cmd);
install_element(ENABLE_NODE, &no_debug_pim_vxlan_cmd);
install_element(ENABLE_NODE, &debug_msdp_cmd);
Expand Down
1 change: 1 addition & 0 deletions pimd/pim_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#define DEBUG_PIM_PACKETDUMP_RECV_STR "Dump received packets\n"
#define DEBUG_PIM_TRACE_STR "PIM internal daemon activity\n"
#define DEBUG_PIM_ZEBRA_STR "ZEBRA protocol activity\n"
#define DEBUG_PIM_MLAG_STR "PIM Mlag activity\n"
#define DEBUG_PIM_VXLAN_STR "PIM VxLAN events\n"
#define DEBUG_SSMPINGD_STR "ssmpingd activity\n"
#define CLEAR_IP_IGMP_STR "IGMP clear commands\n"
Expand Down
5 changes: 5 additions & 0 deletions pimd/pim_instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "pim_ssmpingd.h"
#include "pim_vty.h"
#include "pim_bsm.h"
#include "pim_mlag.h"

static void pim_instance_terminate(struct pim_instance *pim)
{
Expand All @@ -47,6 +48,8 @@ static void pim_instance_terminate(struct pim_instance *pim)
if (pim->static_routes)
list_delete(&pim->static_routes);

pim_instance_mlag_terminate(pim);

pim_upstream_terminate(pim);

pim_rp_free(pim);
Expand Down Expand Up @@ -115,6 +118,8 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)

pim_upstream_init(pim);

pim_instance_mlag_init(pim);

pim->last_route_change_time = -1;
return pim;
}
Expand Down
14 changes: 14 additions & 0 deletions pimd/pim_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ struct pim_router {
vrf_id_t vrf_id;

enum mlag_role role;
uint32_t pim_mlag_intf_cnt;
/* if true we have registered with MLAG */
bool mlag_process_register;
/* if true local MLAG process reported that it is connected
* with the peer MLAG process
*/
bool connected_to_mlag;
/* Holds the client data(unencoded) that need to be pushed to MCLAGD*/
struct stream_fifo *mlag_fifo;
struct stream *mlag_stream;
struct thread *zpthread_mlag_write;
};

/* Per VRF PIM DB */
Expand Down Expand Up @@ -122,6 +133,9 @@ struct pim_instance {

bool ecmp_enable;
bool ecmp_rebalance_enable;
/* No. of Dual active I/fs in pim_instance */
uint32_t inst_mlag_intf_cnt;

/* Bsm related */
struct bsm_scope global_scope;
uint64_t bsm_rcvd;
Expand Down
2 changes: 2 additions & 0 deletions pimd/pim_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "pim_msdp.h"
#include "pim_iface.h"
#include "pim_bfd.h"
#include "pim_mlag.h"
#include "pim_errors.h"

extern struct host host;
Expand Down Expand Up @@ -129,6 +130,7 @@ int main(int argc, char **argv, char **envp)
*/
pim_zebra_init();
pim_bfd_init();
pim_mlag_init();

frr_config_fork();

Expand Down
Loading

0 comments on commit 4bf3dda

Please sign in to comment.