]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Correct valgrind errors 11715/head
authorOlivier Dugeon <olivier.dugeon@orange.com>
Mon, 1 Aug 2022 15:26:36 +0000 (17:26 +0200)
committerOlivier Dugeon <olivier.dugeon@orange.com>
Mon, 1 Aug 2022 15:32:56 +0000 (17:32 +0200)
In CSPF topo test, valgrind detects uninitialized bytes when exporting TE
Opaque information through ZEBRA. This is due to C pragma compilation directive
__attribute__(aligned(8)) in struct ls_node_id in link_state.h. Valgrind
consideris that struct ls_node_id nid = {} doesn't initialized the padding
bytes introduced by gcc.

This patch simply removes the C pragma compilation directive and also takes
opportunity to remove the transmission of remote node id for vertices and
subnets which is not known. Indeed, remote node id is only pertinent for
edges.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
lib/link_state.c
lib/link_state.h

index 639a1d37d8a152cc69d43db4786434fed8566dfe..0ef87b7a51949b8fdbd175f7b4e4f33cd5f54b42 100644 (file)
@@ -1357,7 +1357,6 @@ struct ls_message *ls_parse_msg(struct stream *s)
        /* Read LS Message header */
        STREAM_GETC(s, msg->event);
        STREAM_GETC(s, msg->type);
-       STREAM_GET(&msg->remote_id, s, sizeof(struct ls_node_id));
 
        /* Read Message Payload */
        switch (msg->type) {
@@ -1365,6 +1364,7 @@ struct ls_message *ls_parse_msg(struct stream *s)
                msg->data.node = ls_parse_node(s);
                break;
        case LS_MSG_TYPE_ATTRIBUTES:
+               STREAM_GET(&msg->remote_id, s, sizeof(struct ls_node_id));
                msg->data.attr = ls_parse_attributes(s);
                break;
        case LS_MSG_TYPE_PREFIX:
@@ -1563,13 +1563,14 @@ static int ls_format_msg(struct stream *s, struct ls_message *msg)
        /* Prepare Link State header */
        stream_putc(s, msg->event);
        stream_putc(s, msg->type);
-       stream_put(s, &msg->remote_id, sizeof(struct ls_node_id));
 
        /* Add Message Payload */
        switch (msg->type) {
        case LS_MSG_TYPE_NODE:
                return ls_format_node(s, msg->data.node);
        case LS_MSG_TYPE_ATTRIBUTES:
+               /* Add remote node first */
+               stream_put(s, &msg->remote_id, sizeof(struct ls_node_id));
                return ls_format_attributes(s, msg->data.attr);
        case LS_MSG_TYPE_PREFIX:
                return ls_format_prefix(s, msg->data.prefix);
@@ -1625,7 +1626,6 @@ int ls_send_msg(struct zclient *zclient, struct ls_message *msg,
 
        return zclient_send_message(zclient);
 }
-
 struct ls_message *ls_vertex2msg(struct ls_message *msg,
                                 struct ls_vertex *vertex)
 {
index f46a2068a1d13eec4b196f5905c8bf2294756c41..ed315452da6d9193365259488b26e383ca65e1ac 100644 (file)
@@ -91,7 +91,7 @@ struct ls_node_id {
                        uint8_t level;                  /* ISIS Level */
                        uint8_t padding;
                } iso;
-       } id __attribute__((aligned(8)));
+       } id;
 };
 
 /**