summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2020-03-09 20:34:18 +0100
committerGitHub <noreply@github.com>2020-03-09 20:34:18 +0100
commit7f6c322d50e8d7c56ee0bc88ab23c901a1f7495e (patch)
tree2400e5dbccb0c431965d752a130bfc290dd1ce35 /lib
parentMerge pull request #5942 from patrasar/2438087 (diff)
parentdoc: Add missing mlag documentation (diff)
downloadfrr-7f6c322d50e8d7c56ee0bc88ab23c901a1f7495e.tar.xz
frr-7f6c322d50e8d7c56ee0bc88ab23c901a1f7495e.zip
Merge pull request #5839 from donaldsharp/upstream_merge
Upstream merge of missed MLAG code
Diffstat (limited to 'lib')
-rw-r--r--lib/mlag.c28
-rw-r--r--lib/mlag.h9
2 files changed, 28 insertions, 9 deletions
diff --git a/lib/mlag.c b/lib/mlag.c
index 1daf29072..733dd41ea 100644
--- a/lib/mlag.c
+++ b/lib/mlag.c
@@ -81,22 +81,33 @@ char *mlag_lib_msgid_to_str(enum mlag_msg_type msg_type, char *buf, size_t size)
}
-int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg)
+int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg,
+ size_t *length)
{
- if (s == NULL || msg == NULL)
+#define LIB_MLAG_HDR_LENGTH 8
+ *length = stream_get_endp(s);
+
+ if (s == NULL || msg == NULL || *length < LIB_MLAG_HDR_LENGTH)
return -1;
+ *length -= LIB_MLAG_HDR_LENGTH;
+
STREAM_GETL(s, msg->msg_type);
STREAM_GETW(s, msg->data_len);
STREAM_GETW(s, msg->msg_cnt);
+
return 0;
stream_failure:
return -1;
}
-int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg)
+#define MLAG_MROUTE_ADD_LENGTH \
+ (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4 + 1 + 1 + 4)
+
+int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg,
+ size_t *length)
{
- if (s == NULL || msg == NULL)
+ if (s == NULL || msg == NULL || *length < MLAG_MROUTE_ADD_LENGTH)
return -1;
STREAM_GET(msg->vrf_name, s, VRF_NAMSIZ);
@@ -108,14 +119,18 @@ int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg)
STREAM_GETC(s, msg->am_i_dual_active);
STREAM_GETL(s, msg->vrf_id);
STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ);
+
return 0;
stream_failure:
return -1;
}
-int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg)
+#define MLAG_MROUTE_DEL_LENGTH (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4)
+
+int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg,
+ size_t *length)
{
- if (s == NULL || msg == NULL)
+ if (s == NULL || msg == NULL || *length < MLAG_MROUTE_DEL_LENGTH)
return -1;
STREAM_GET(msg->vrf_name, s, VRF_NAMSIZ);
@@ -124,6 +139,7 @@ int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg)
STREAM_GETL(s, msg->owner_id);
STREAM_GETL(s, msg->vrf_id);
STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ);
+
return 0;
stream_failure:
return -1;
diff --git a/lib/mlag.h b/lib/mlag.h
index c531fb5b6..37bb3aa6d 100644
--- a/lib/mlag.h
+++ b/lib/mlag.h
@@ -125,11 +125,14 @@ struct mlag_msg {
extern char *mlag_role2str(enum mlag_role role, char *buf, size_t size);
extern char *mlag_lib_msgid_to_str(enum mlag_msg_type msg_type, char *buf,
size_t size);
-extern int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg);
+extern int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg,
+ size_t *length);
extern int mlag_lib_decode_mroute_add(struct stream *s,
- struct mlag_mroute_add *msg);
+ struct mlag_mroute_add *msg,
+ size_t *length);
extern int mlag_lib_decode_mroute_del(struct stream *s,
- struct mlag_mroute_del *msg);
+ struct mlag_mroute_del *msg,
+ size_t *length);
extern int mlag_lib_decode_mlag_status(struct stream *s,
struct mlag_status *msg);
extern int mlag_lib_decode_vxlan_update(struct stream *s,