From 6a78645bae656652d2e4183b935eae50284ad581 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 20 Oct 2016 08:30:24 -0700 Subject: [PATCH] net: fix spdk_get_ifc_ipv4 request creation req needs to allocate space for the rtattr. Signed-off-by: Jim Harris Change-Id: Ic7a7c52ae6e2bb5e19b4dafcabf69c6df86bd671 --- lib/net/interface.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/net/interface.c b/lib/net/interface.c index 0f81c12c1..8a1708c26 100644 --- a/lib/net/interface.c +++ b/lib/net/interface.c @@ -51,7 +51,7 @@ #include #include #include - +#include static TAILQ_HEAD(, spdk_interface) g_interface_head; @@ -68,8 +68,8 @@ static uint32_t spdk_get_ifc_ipv4(void) struct { struct nlmsghdr n; struct ifaddrmsg r; + struct rtattr rta; } req; - struct rtattr *rta; char buf[16384]; struct nlmsghdr *nlmp; struct ifaddrmsg *rtmp; @@ -96,8 +96,8 @@ static uint32_t spdk_get_ifc_ipv4(void) /* * Fill up all the attributes for the rtnetlink header. */ - rta = (struct rtattr *)(((char *)&req) + NLMSG_ALIGN(req.n.nlmsg_len)); - rta->rta_len = RTA_LENGTH(16); + assert(&req.rta == (struct rtattr *)(((char *)&req) + NLMSG_ALIGN(req.n.nlmsg_len))); + req.rta.rta_len = RTA_LENGTH(16); /* Send and recv the message from kernel */ ret = send(netlink_fd, &req, req.n.nlmsg_len, 0);