]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Fix for LLDP related netlink error messages 375/head
authorRadhika Mahankali <radhika@cumulusnetworks.com>
Mon, 9 Dec 2019 06:59:16 +0000 (22:59 -0800)
committerSam Tannous <stannous@cumulusnetworks.com>
Mon, 9 Dec 2019 18:10:11 +0000 (10:10 -0800)
Ticket: CM-27243
Reviewed By: CCR-9608
Testing Done: Unit tseting, PTM Smoke

Issue: Error messages "netlink: 8 bytes leftover after parsing attributes
in process `lldpd'"

Root cause: Root Cause: The length of the netlink message was not being set
properly for non-bridge family type messages. Same length was being used for
both type of messages even though bridge family type message has extra
attribute. This causes 8 extra bytes being left over in the non-bridge
family type netlink messages.

Fix: Calculating and setting the length separately for bridge and non-bridge
family type messages.
(cherry picked from commit aac76966539bf932d5923b165762db370990bf94)

src/daemon/netlink.c

index 6d69011d1d70844be836070d031497af023dfcd5..f017ffe3bbed2eac1c4513be1c37bf7f1c250464 100644 (file)
@@ -145,7 +145,7 @@ netlink_send(int s, int type, int family, int seq)
 {
        struct netlink_req req = {
                .hdr = {
 {
        struct netlink_req req = {
                .hdr = {
-                       .nlmsg_len = sizeof(struct netlink_req),
+                       .nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
                        .nlmsg_type = type,
                        .nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP,
                        .nlmsg_seq = seq,
                        .nlmsg_type = type,
                        .nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP,
                        .nlmsg_seq = seq,
@@ -165,10 +165,13 @@ netlink_send(int s, int type, int family, int seq)
        };
 
        if (family == AF_BRIDGE) {
        };
 
        if (family == AF_BRIDGE) {
+               unsigned int len = RTA_LENGTH(sizeof(__u32));
                /* request bridge vlan attributes */
                req.ext_req.rta_type = IFLA_EXT_MASK;
                /* request bridge vlan attributes */
                req.ext_req.rta_type = IFLA_EXT_MASK;
-               req.ext_req.rta_len = RTA_LENGTH(sizeof(__u32));
+               req.ext_req.rta_len = len;
                req.ext_filter_mask = RTEXT_FILTER_BRVLAN;
                req.ext_filter_mask = RTEXT_FILTER_BRVLAN;
+               req.hdr.nlmsg_len = NLMSG_ALIGN(req.hdr.nlmsg_len) + RTA_ALIGN(len);
+               iov.iov_len = req.hdr.nlmsg_len;
        }
 
        /* Send netlink message. This is synchronous but we are guaranteed
        }
 
        /* Send netlink message. This is synchronous but we are guaranteed