snabbco / snabb

Snabb: Simple and fast packet networking
Apache License 2.0
2.97k stars 301 forks source link

Snabb NFV appears to incorrectly cache virtio features #932

Closed wingo closed 8 years ago

wingo commented 8 years ago

If I run Snabb NFV then connect a QEMU, I get something like this:

Get features 0x18428001
 VIRTIO_F_ANY_LAYOUT VIRTIO_NET_F_MQ VIRTIO_NET_F_CTRL_VQ VIRTIO_NET_F_MRG_RXBUF VIRTIO_RING_F_INDIRECT_DESC VIRTIO_NET_F_CSUM
vhost_user: Skipped old feature cache in /tmp/vhost_features___home__wingo__guest__sockets__v4.sock
vhost_user: Caching features (0x18028001) in /tmp/vhost_features___home__wingo__guest__sockets__v4.sock
Set features 0x18028001
 VIRTIO_F_ANY_LAYOUT VIRTIO_NET_F_CTRL_VQ VIRTIO_NET_F_MRG_RXBUF VIRTIO_RING_F_INDIRECT_DESC VIRTIO_NET_F_CSUM
rxavail = 0 rxused = 0
rxavail = 0 rxused = 0
vhost_user: Connected and initialized: /home/wingo/guest/sockets/v4.sock

OK fine. Now when I start the app, I arrange to ask for only CSUM, ANY_LAYOUT, and MAC. However:

vhost_user: Read cached features (0x18028001) from /tmp/vhost_features___home__wingo__guest__sockets__v4.sock
Set features 0x18028001
 VIRTIO_F_ANY_LAYOUT VIRTIO_NET_F_CTRL_VQ VIRTIO_NET_F_MRG_RXBUF VIRTIO_RING_F_INDIRECT_DESC VIRTIO_NET_F_CSUM
rxavail = 0 rxused = 0
vhost_user: Connected and initialized: /home/wingo/guest/sockets/v4.sock

Somehow it doesn't invalidate its old cached features.

wingo commented 8 years ago

Indeed: https://github.com/snabbco/snabb/blob/master/src/apps/vhost/vhost_user.lua#L173-L207

If the file is up to date with itself (????) we don't set the new features at all!

wingo commented 8 years ago

https://github.com/snabbco/snabb/pull/440/commits/1f27b5b42f8958f30f55c3be0332c4c7e14f304e was the commit that added this strange cache