[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110906223555.6552.50485.stgit@savbu-pc100.cisco.com>
Date: Tue, 06 Sep 2011 15:35:55 -0700
From: Roopa Prabhu <roprabhu@...co.com>
To: netdev@...r.kernel.org
Cc: dragos.tatulea@...il.com, arnd@...db.de, mst@...hat.com,
dwang2@...co.com, benve@...co.com, kaber@...sh.net, sri@...ibm.com
Subject: [net-next-2.6 PATCH 3/3 RFC] macvtap: Add support for TUNSETTXFILTER
From: Roopa Prabhu <roprabhu@...co.com>
This patch adds support for TUNSETTXFILTER. Calls macvlan set filter function
with address list and flags received via TUNSETTXFILTER.
Signed-off-by: Roopa Prabhu <roprabhu@...co.com>
Signed-off-by: Christian Benvenuti <benve@...co.com>
Signed-off-by: David Wang <dwang2@...co.com>
---
drivers/net/macvtap.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index ab96c31..9943683 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -825,6 +825,10 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
int __user *sp = argp;
int s;
int ret;
+ u8 *addrs;
+ struct tun_filter tf;
+ unsigned int flags = 0;
+ int alen;
switch (cmd) {
case TUNSETIFF:
@@ -896,6 +900,51 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
return -EINVAL;
return 0;
+ case TUNSETTXFILTER:
+ rcu_read_lock_bh();
+ vlan = rcu_dereference_bh(q->vlan);
+ if (vlan)
+ dev_hold(vlan->dev);
+ rcu_read_unlock_bh();
+
+ if (!vlan)
+ return -ENOLINK;
+
+ if (copy_from_user(&tf, argp, sizeof(tf))) {
+ dev_put(vlan->dev);
+ return -EFAULT;
+ }
+
+ /* XXX: If broadcast address present, set IFF_BROADCAST */
+ /* XXX: If multicast address present, set IFF_MULTICAST */
+ flags |= (tf.flags & TUN_FLT_ALLMULTI ? IFF_ALLMULTI : 0) |
+ (!tf.count ? IFF_PROMISC : 0);
+ ret = 0;
+ if (tf.count > 0) {
+ alen = ETH_ALEN * tf.count;
+ addrs = kmalloc(alen, GFP_KERNEL);
+ if (!addrs) {
+ dev_put(vlan->dev);
+ return -ENOMEM;
+ }
+
+ if (copy_from_user(addrs, argp + sizeof(tf), alen)) {
+ kfree(addrs);
+ dev_put(vlan->dev);
+ return -EFAULT;
+ }
+ }
+
+ if (tf.count > 0 || flags)
+ ret = macvlan_set_filter(vlan->dev, flags,
+ tf.count, addrs);
+ dev_put(vlan->dev);
+
+ if (tf.count > 0)
+ kfree(addrs);
+
+ return ret;
+
default:
return -EINVAL;
}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists