>Number:         178955
>Category:       kern
>Synopsis:       virtio network (if_vtnet) interacts badly with qemu 1.5.0
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 24 17:50:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Julian Stecklina
>Release:        10-CURRENT
>Organization:
TU Dresden
>Environment:
FreeBSD  10.0-CURRENT FreeBSD 10.0-CURRENT #5 r+6436670: Fri May 24 19:34:14 
CEST 2013     
[email protected]:/usr/obj/usr/home/julian/src/freebsd/sys/GENERIC  
amd64
>Description:
I just compiled qemu 1.5.0 on Linux and noticed that virtio network seems to 
have problems updating the MAC filter table:

vtnet0: error setting host MAC filter table

As far as I understand, if_vtnet.c does the following in vtnet_rx_filter_mac. 
It appends two full struct vtnet_mac_tables (one for unicast and one for 
multicast) to the request. Each consists of the number of actual entries in the 
table and space for 128 (mostly unused) entries in total.

The qemu code parses this differently. It first reads the number of elements in 
the first table and then skips over so many MAC addresses and then expects the 
header to the second table (which in our case points to zero'd memory). Then it 
skips those 0 MAC entries as well and expects that it has consumed the whole 
request and returns an error, because there is still data left. The relevant 
code is in qemu/hw/net/virtio-net.c in virtio_net_handle_rx_mode.

This problem was introduced with the following commit in qemu:
http://git.qemu.org/?p=qemu.git;a=commit;h=921ac5d0f3a0df869db5ce4edf752f51d8b1596a


>How-To-Repeat:
Boot FreeBSD CURRENT in qemu 1.5.0 with virtio networking:
 qemu-system-x86_64 -net nic,model=virtio -net user -hda disk.img

In the FreeBSD system, issue
 ifconfig vtnet0 up

Kernel will fail to update MAC filter multiple times:
vtnet0: error setting host MAC filter table
>Fix:


Patch attached with submission follows:

commit 4775464859691e16b9ad75e0a55b610f7a8c4030
Author: Julian Stecklina <[email protected]>
Date:   Thu May 23 14:59:03 2013 +0200

    Workaround qemu changes in handling MAC filter updates

diff --git a/sys/dev/virtio/network/if_vtnet.c 
b/sys/dev/virtio/network/if_vtnet.c
index ffc349a..6f00dfb 100644
--- a/sys/dev/virtio/network/if_vtnet.c
+++ b/sys/dev/virtio/network/if_vtnet.c
@@ -2470,9 +2470,9 @@ vtnet_rx_filter_mac(struct vtnet_softc *sc)
        sglist_init(&sg, 4, segs);
        error |= sglist_append(&sg, &hdr, sizeof(struct virtio_net_ctrl_hdr));
        error |= sglist_append(&sg, &filter->vmf_unicast,
-           sizeof(struct vtnet_mac_table));
+           sizeof(uint32_t) + ETHER_ADDR_LEN*filter->vmf_unicast.nentries);
        error |= sglist_append(&sg, &filter->vmf_multicast,
-           sizeof(struct vtnet_mac_table));
+           sizeof(uint32_t) + ETHER_ADDR_LEN*filter->vmf_multicast.nentries);
        error |= sglist_append(&sg, &ack, sizeof(uint8_t));
        KASSERT(error == 0 && sg.sg_nseg == 4,
            ("error adding MAC filtering message to sglist"));


>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to