[lldp-devel] [PATCH 1/2] vdpnl: initialize vdpnl_mac to prevent segfault

Philbert Lin philbert.lin at intel.com
Wed Nov 13 21:10:46 UTC 2013

In the vdptest man pages the following profile is given as an example:


When this profile is used as a basic test, it causes lldpad to segfault
and vdptest to fail. The command used is:

	sudo ./vdptest -i eth5 -Aname=thomas2,mgrid=1,typeid=123452,\
	-a thomas2,w=10,r=2

If vlan == 0 then vdp22_alloc_vsi() sets the VDP22_RETURN_VID flag and
in vdp22_status the following code is performed (and maclist == NULL):

	if (p->flags & VDP22_RETURN_VID) {
		vsi->maclist->vlan = p->fdata[0].vlan;

The attached changes assume that there is only one MAC/VLAN pair but it
seems consistent with the existing code.

Signed-off-by: Philbert Lin <philbert.lin at intel.com>
 qbg/vdpnl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/qbg/vdpnl.c b/qbg/vdpnl.c
index 8e8f518..61b6a2b 100644
--- a/qbg/vdpnl.c
+++ b/qbg/vdpnl.c
@@ -360,10 +360,14 @@ static void vdpnl_reply2(struct vdpnl_vsi *p, struct nlmsghdr *nlh)
 static int vdpnl_getlink(struct nlmsghdr *nlh, size_t len)
 	struct vdpnl_vsi p;
+	struct vdpnl_mac mac;
 	int i = 0, rc;
 	struct nlattr *vf_ports, *vf_port;
 	memset(&p, 0, sizeof p);
+	memset(&mac, 0, sizeof mac);
+	p.macsz = 1;
+	p.maclist = &mac;
 	rc = vdpnl_get(nlh, &p);
 	if (rc)
 		return vdpnl_error(rc, nlh, len);

More information about the lldp-devel mailing list