lldpad/lldpad-0.9.41-lldpad-rtnl_recv_operstate-uses-incorrect-recv-lengt.patch
2011-04-21 09:10:21 +02:00

44 lines
1.6 KiB
Diff

From c18a94f5600d65f414e9ffe5579171c6700078fc Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 6 Apr 2011 08:47:23 -0700
Subject: [PATCH 36/51] lldpad: rtnl_recv_operstate uses incorrect recv length
lldpad monitors the current operstate to stop repeated resets
from occurring while dcbx or other LLDP TLVs are being negotiated.
This can occur when the driver resets the device due to a LLDP
negotiated object.
In rtnl_recv_operstate() used to query the interface operstate the
recv message length was not being set correctly. This resulted in
netlink messages being truncated. Specifically, nlh is a pointer
to nlmsghdr and points to the head of the allocated memory block
used for the nlmsg. Taking the sizeof() of this only returns the
size of the nlsg header.
This was seen during DCB testing and resulted in repeated link resets
because the hardware was being reprogrammed multiple times during
link negotiation until the DCB negotiation reached a steady state.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <psabata@redhat.com>
---
lldp_rtnl.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lldp_rtnl.c b/lldp_rtnl.c
index 77b013d..b966261 100644
--- a/lldp_rtnl.c
+++ b/lldp_rtnl.c
@@ -222,7 +222,7 @@ static ssize_t rtnl_recv_operstate(int s, int ifindex,
/* recv ifname reply */
memset(nlh, 0, NLMSG_SIZE);
- rc = recv(s, (void *) nlh, sizeof(*nlh), MSG_DONTWAIT);
+ rc = recv(s, (void *) nlh, NLMSG_SIZE, MSG_DONTWAIT);
if (rc < 0)
goto out;
ifi = NLMSG_DATA(nlh);
--
1.7.4.4