From: Radhika Mahankali Date: Mon, 9 Dec 2019 06:59:16 +0000 (-0800) Subject: Fix for LLDP related netlink error messages X-Git-Tag: 1.0.5~25^2 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Flldpd.git;a=commitdiff_plain;h=e512429c88d2dfa7d37fa39b2c6735d0c8f1042f Fix for LLDP related netlink error messages 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) --- diff --git a/src/daemon/netlink.c b/src/daemon/netlink.c index 6d69011d..f017ffe3 100644 --- a/src/daemon/netlink.c +++ b/src/daemon/netlink.c @@ -145,7 +145,7 @@ netlink_send(int s, int type, int family, int seq) { 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, @@ -165,10 +165,13 @@ netlink_send(int s, int type, int family, int seq) }; if (family == AF_BRIDGE) { + unsigned int len = RTA_LENGTH(sizeof(__u32)); /* 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.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