From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Np1Ds-0006td-OA for qemu-devel@nongnu.org; Tue, 09 Mar 2010 10:19:52 -0500 Received: from [199.232.76.173] (port=36949 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Np1Ds-0006tV-9j for qemu-devel@nongnu.org; Tue, 09 Mar 2010 10:19:52 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Np1Dq-0002is-PP for qemu-devel@nongnu.org; Tue, 09 Mar 2010 10:19:52 -0500 Received: from g4t0014.houston.hp.com ([15.201.24.17]:43023) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Np1Dq-0002im-Bj for qemu-devel@nongnu.org; Tue, 09 Mar 2010 10:19:50 -0500 From: Alex Williamson In-Reply-To: <20100309131544.GA15319@redhat.com> References: <20100309131544.GA15319@redhat.com> Content-Type: text/plain; charset="UTF-8" Date: Tue, 09 Mar 2010 08:19:12 -0700 Message-ID: <1268147952.14039.70.camel@8530w.home> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH RFC] net: add a flag to disable mac/vlan filtering List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, Andreas Plesner Jacobsen On Tue, 2010-03-09 at 15:15 +0200, Michael S. Tsirkin wrote: > diff --git a/hw/virtio-net.c b/hw/virtio-net.c > index 5c0093e..01b45ed 100644 > --- a/hw/virtio-net.c > +++ b/hw/virtio-net.c > @@ -47,6 +47,7 @@ typedef struct VirtIONet > uint8_t nomulti; > uint8_t nouni; > uint8_t nobcast; > + uint32_t filtering; > struct { > int in_use; > int first_multi; > @@ -475,12 +476,17 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) > ptr += sizeof(struct virtio_net_hdr); > } > > - if (!memcmp(&ptr[12], vlan, sizeof(vlan))) { > + if ((n->filtering & (0x1 << NICCONF_F_VLAN_FILTERING)) && > + !memcmp(&ptr[12], vlan, sizeof(vlan))) { > int vid = be16_to_cpup((uint16_t *)(ptr + 14)) & 0xfff; > if (!(n->vlans[vid >> 5] & (1U << (vid & 0x1f)))) > return 0; > } > > + if (!(n->filtering & (0x1 << NICCONF_F_MAC_FILTERING))) { > + return 1; > + } > + A filtering flags bitmap is a logical choice here, but I found the overhead to be non-trivial, which is why we have separate variables for the other filtering options. > if (ptr[0] & 1) { // multicast > if (!memcmp(ptr, bcast, sizeof(bcast))) { > return !n->nobcast; > @@ -863,6 +869,8 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) > > n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN); > > + n->filtering = conf->filtering; > + Since we're not touching this in the savevm code, I assume the intention is that we can transparently migrate between filtered bridges and non-filtered bridges, right? Thanks, Alex