qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Alex Williamson <alex.williamson@hp.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] Re: [PATCH][RFC] qemu:virtio-net: Use TUNSETTXFILTER for MAC filtering
Date: Fri, 06 Feb 2009 07:59:52 -0600	[thread overview]
Message-ID: <498C4258.3060502@codemonkey.ws> (raw)
In-Reply-To: <20090206044853.3116.46699.stgit@kvm.aw>

Alex Williamson wrote:
> Now that virtio-net knows what packets the guest wants to see, we
> can start moving the filtering down the stack.  This patch adds
> an interface to set the software filter in the tap device.  It's
> fairly limited, but we can back it up with our own filtering if it
> overflows.
>
> Here are a couple issues I'm still pondering:
>  - Is the fd_rx_filter() interface sufficiently generic
>  - Should vlan_set_hw_rx_filter() live in net.c or elsewhere
>  - Is it ok to call fd_rx_filter() against all the vlan clients.  I
>    exit on the first one, which covers the simple config.
>
> Insterested in feedback.  Thanks,
>
> Alex
>
> Signed-off-by: Alex Williamson <alex.williamson@hp.com>
> ---
>
>  hw/virtio-net.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  net.c           |   28 +++++++++++++++++++++++++++
>  net.h           |    3 +++
>  3 files changed, 88 insertions(+), 0 deletions(-)
>
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 62153e9..2556f42 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -15,6 +15,7 @@
>  #include "net.h"
>  #include "qemu-timer.h"
>  #include "virtio-net.h"
> +#include <net/if.h>
>  
>  #define VIRTIO_NET_VM_VERSION    6
>  
> @@ -35,6 +36,7 @@ typedef struct VirtIONet
>      int mergeable_rx_bufs;
>      int promisc;
>      int allmulti;
> +    int hw_mac_filter;
>      struct {
>          int in_use;
>          uint8_t *macs;
> @@ -88,6 +90,51 @@ static void virtio_net_set_link_status(VLANClientState *vc)
>          virtio_notify_config(&n->vdev);
>  }
>  
> +static int vlan_set_hw_rx_filter(VLANState *vlan, int flags,
> +                                 int count, uint8_t *buf)
> +{
> +    VLANClientState *vc;
> +
> +    for (vc = vlan->first_client; vc != NULL; vc = vc->next) {
> +        int ret;
> +
> +        if (!vc->fd_rx_filter)
> +            continue;
> +
> +        ret = vc->fd_rx_filter(vc->opaque, flags, count, buf);
> +        return (ret == count);
> +    } 
> +    return 0;
> +}
>   

This should go in net.c.

> +static void virtio_net_set_hw_rx_filter(VirtIONet *n)
> +{
> +    static const uint8_t bcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
> +    uint8_t *buf;
> +    int flags = 0;
> +
> +    if (n->promisc)
> +        flags |= IFF_PROMISC;
> +    if (n->allmulti)
> +        flags |= IFF_ALLMULTI;
> +
> +    buf = qemu_mallocz((n->mac_table.in_use + 2) * ETH_ALEN);
> +    if (!buf) {
>   
Don't need to handle these failures anymore.
> +static int tap_rx_filter(void *opaque, unsigned int flags, int count,
> +                         uint8_t *list)
>   

Instead of having each network device do it's own filtering if the VLAN 
doesn't support it, I think we should move the software filtering to the 
VLAN layer so that we aren't duplicating code in each network device.

Also, instead of using IFF_xxx, I think we should introduce our own 
flags.  net/if.h doesn't exist on Windows most likely.

Regards,

Anthony Liguori

  parent reply	other threads:[~2009-02-06 14:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-06  4:51 [Qemu-devel] [PATCH][RFC] qemu:virtio-net: Use TUNSETTXFILTER for MAC filtering Alex Williamson
2009-02-06  7:47 ` [Qemu-devel] " Mark McLoughlin
2009-02-06 18:09   ` Alex Williamson
2009-02-06 13:59 ` Anthony Liguori [this message]
2009-02-06 18:06   ` Alex Williamson
2009-02-06 15:12 ` [Qemu-devel] " Paul Brook
2009-02-06 17:59   ` Alex Williamson
2009-02-06 22:16     ` Paul Brook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=498C4258.3060502@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=alex.williamson@hp.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).