]>
git.proxmox.com Git - mirror_frr.git/blob - lib/mlag.c
2 * Copyright (C) 2018 Cumulus Networks, Inc.
5 * This file is part of FRR.
7 * FRR is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * FRR is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with FRR; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 char *mlag_role2str(enum mlag_role role
, char *buf
, size_t size
)
30 snprintf(buf
, size
, "NONE");
32 case MLAG_ROLE_PRIMARY
:
33 snprintf(buf
, size
, "PRIMARY");
35 case MLAG_ROLE_SECONDARY
:
36 snprintf(buf
, size
, "SECONDARY");
43 char *mlag_lib_msgid_to_str(enum mlag_msg_type msg_type
, char *buf
, size_t size
)
47 snprintf(buf
, size
, "Register");
50 snprintf(buf
, size
, "De-Register");
53 snprintf(buf
, size
, "Mroute add");
56 snprintf(buf
, size
, "Mroute del");
59 snprintf(buf
, size
, "Mlag Replay");
61 case MLAG_MROUTE_ADD_BULK
:
62 snprintf(buf
, size
, "Mroute Add Batch");
64 case MLAG_MROUTE_DEL_BULK
:
65 snprintf(buf
, size
, "Mroute Del Batch");
67 case MLAG_STATUS_UPDATE
:
68 snprintf(buf
, size
, "Mlag Status");
70 case MLAG_VXLAN_UPDATE
:
71 snprintf(buf
, size
, "Mlag vxlan update");
73 case MLAG_PEER_FRR_STATUS
:
74 snprintf(buf
, size
, "Mlag Peer FRR Status");
77 snprintf(buf
, size
, "Unknown %d", msg_type
);
84 int mlag_lib_decode_mlag_hdr(struct stream
*s
, struct mlag_msg
*msg
,
87 #define LIB_MLAG_HDR_LENGTH 8
88 if (s
== NULL
|| msg
== NULL
)
91 *length
= stream_get_endp(s
);
93 if (*length
< LIB_MLAG_HDR_LENGTH
)
96 *length
-= LIB_MLAG_HDR_LENGTH
;
98 STREAM_GETL(s
, msg
->msg_type
);
99 STREAM_GETW(s
, msg
->data_len
);
100 STREAM_GETW(s
, msg
->msg_cnt
);
107 #define MLAG_MROUTE_ADD_LENGTH \
108 (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4 + 1 + 1 + 4)
110 int mlag_lib_decode_mroute_add(struct stream
*s
, struct mlag_mroute_add
*msg
,
113 if (s
== NULL
|| msg
== NULL
|| *length
< MLAG_MROUTE_ADD_LENGTH
)
116 STREAM_GET(msg
->vrf_name
, s
, VRF_NAMSIZ
);
117 STREAM_GETL(s
, msg
->source_ip
);
118 STREAM_GETL(s
, msg
->group_ip
);
119 STREAM_GETL(s
, msg
->cost_to_rp
);
120 STREAM_GETL(s
, msg
->owner_id
);
121 STREAM_GETC(s
, msg
->am_i_dr
);
122 STREAM_GETC(s
, msg
->am_i_dual_active
);
123 STREAM_GETL(s
, msg
->vrf_id
);
124 STREAM_GET(msg
->intf_name
, s
, INTERFACE_NAMSIZ
);
131 #define MLAG_MROUTE_DEL_LENGTH (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4)
133 int mlag_lib_decode_mroute_del(struct stream
*s
, struct mlag_mroute_del
*msg
,
136 if (s
== NULL
|| msg
== NULL
|| *length
< MLAG_MROUTE_DEL_LENGTH
)
139 STREAM_GET(msg
->vrf_name
, s
, VRF_NAMSIZ
);
140 STREAM_GETL(s
, msg
->source_ip
);
141 STREAM_GETL(s
, msg
->group_ip
);
142 STREAM_GETL(s
, msg
->owner_id
);
143 STREAM_GETL(s
, msg
->vrf_id
);
144 STREAM_GET(msg
->intf_name
, s
, INTERFACE_NAMSIZ
);
151 int mlag_lib_decode_mlag_status(struct stream
*s
, struct mlag_status
*msg
)
153 if (s
== NULL
|| msg
== NULL
)
156 STREAM_GET(msg
->peerlink_rif
, s
, INTERFACE_NAMSIZ
);
157 STREAM_GETL(s
, msg
->my_role
);
158 STREAM_GETL(s
, msg
->peer_state
);
164 int mlag_lib_decode_vxlan_update(struct stream
*s
, struct mlag_vxlan
*msg
)
166 if (s
== NULL
|| msg
== NULL
)
169 STREAM_GETL(s
, msg
->anycast_ip
);
170 STREAM_GETL(s
, msg
->local_ip
);
177 int mlag_lib_decode_frr_status(struct stream
*s
, struct mlag_frr_status
*msg
)
179 if (s
== NULL
|| msg
== NULL
)
182 STREAM_GETL(s
, msg
->frr_state
);