From: Hannes Reinecke <h...@suse.de>

When receiving netlink events we should improve the logging to
figure out what exactly went wrong here.

Signed-off-by: Hannes Reinecke <h...@suse.de>
Signed-off-by: Robert Love <robert.w.l...@intel.com>
---
 lib/rtnetlink.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c
index 32b8217..a733fc6 100644
--- a/lib/rtnetlink.c
+++ b/lib/rtnetlink.c
@@ -481,13 +481,22 @@ int rtnl_get_sanmac(const char *ifname, unsigned char 
*addr)
                goto err_close;
        }
 
+       if (nh->nlmsg_type != RTM_GETDCB) {
+               RTNL_LOG_DBG("Ignoring netlink msg %x\n", nh->nlmsg_type);
+               rc = -EIO;
+               goto err_close;
+       }
        dcb = (struct dcbmsg *)NLMSG_DATA(nh);
+       if (dcb->cmd != DCB_CMD_GPERM_HWADDR) {
+               RTNL_LOG_DBG("Unexpected response for DCB command %x\n",
+                            dcb->cmd);
+               rc = -EIO;
+               goto err_close;
+       }
        rta = (struct rtattr *)(((char *)dcb) +
              NLMSG_ALIGN(sizeof(struct dcbmsg)));
-       if ((nh->nlmsg_type != RTM_GETDCB) ||
-           (dcb->cmd != DCB_CMD_GPERM_HWADDR) ||
-           (rta->rta_type != DCB_ATTR_PERM_HWADDR)) {
-               RTNL_LOG_DBG("Unexpected netlink response for GPERM_HWADDR\n");
+       if (rta->rta_type != DCB_ATTR_PERM_HWADDR) {
+               RTNL_LOG_DBG("Unexpected DCB RTA attr %x\n", rta->rta_type);
                rc = -EIO;
                goto err_close;
        }

_______________________________________________
devel mailing list
devel@open-fcoe.org
https://lists.open-fcoe.org/mailman/listinfo/devel

Reply via email to