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

Thomas-Mich Richter tmricht at linux.vnet.ibm.com
Thu Nov 14 09:20:37 UTC 2013

On 11/13/2013 10:10 PM, Philbert Lin wrote:
> In the vdptest man pages the following profile is given as an example:
> 	name=thomas2,mgrid=1,typeid=123452,typeidver=1,hints=none\
> 		uuid=a1412857-60f7-4ce1-e95a-2164943f53dd,\
> 		map=2-52:54:00:8e:50:53-9999,map=0/10-52:54:00:8e:50:54-8888
> When this profile is used as a basic test, it causes lldpad to segfault
> and vdptest to fail. The command used is:

Your are correct. When I submitted the changes to the vdptest program to
support VPD22 protocol, I started with my test program vdptest.c. I assumed
I was the only one using it and have submitted the changes.
To fully support the message format for VDP22 and especially the return
of changed VLAN Ids and QoS values, I need the change the netlink messages
used to communicate from libvirtd/vdptest to lldpad. To test this I needed
a modified vdptest.c test program to support the input to lldpad.
The changes have to be done in a backward compatible way, because libvirtd is still
using draft 0.2 of the IEEE 802.1 Qbg standard.

I have discussed the new netlink message format with John and have implemented
it in the past few week (on a low priority). I have done extensive testing and
have also discovered some issue which I fixed and submitted to the mailing list
earlier this week.

I am now polishing the qbg/vdpnl.c and include/qbg_vdpnl.h files to fully support
the features introduces and exploited by vdptest.c. I should be done in a few days
and will post the patches. 

> 	sudo ./vdptest -i eth5 -Aname=thomas2,mgrid=1,typeid=123452,\
> 	typeidver=1,hints=none,uuid=a1412857-60f7-4ce1-e95a-2164943f53dd,\
> 	map=2-52:54:00:8e:50:53-9999,map=0/10-52:54:00:8e:50:54-8888\
> 	-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.

Your patch is ok. It will handle one VLAN 0 case and makes the example not
crashing lldpad . So we should commit it even when I will post a  reworked version

> 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);
Thanks a lot for looking into this.

Thomas Richter, Dept 3250, IBM LTC Boeblingen, Data Center Networking
Vorsitzende des Aufsichtsrats: Martina Koederitz 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294

More information about the lldp-devel mailing list