From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: qemu-devel@nongnu.org
Cc: jasowang@redhat.com,
zhanghailiang <zhang.zhanghailiang@huawei.com>,
zhangchen.fnst@cn.fujitsu.com, hongyang.yang@easystack.cn
Subject: [Qemu-devel] [PATCH RFC v2 5/5] net/filter: Add a default filter to each netdev
Date: Wed, 27 Jan 2016 16:29:40 +0800 [thread overview]
Message-ID: <1453883380-10532-6-git-send-email-zhang.zhanghailiang@huawei.com> (raw)
In-Reply-To: <1453883380-10532-1-git-send-email-zhang.zhanghailiang@huawei.com>
We add each netdev a default buffer filter, and
the default buffer filter is disabled, so it has
no side effect for packets delivering in qemu net layer.
The default buffer filter can be used by COLO or Micro-checkpoint,
The reason we add the default filter is we hope to support
hot add network during COLO state in future.
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
v2:
- Add codes that generate id automatically for default filter
(Jason's suggestion)
- Some other minor fixes.
---
include/net/filter.h | 4 ++++
net/net.c | 23 +++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/include/net/filter.h b/include/net/filter.h
index ee1c024..e443f9c 100644
--- a/include/net/filter.h
+++ b/include/net/filter.h
@@ -22,6 +22,10 @@
#define NETFILTER_CLASS(klass) \
OBJECT_CLASS_CHECK(NetFilterClass, (klass), TYPE_NETFILTER)
+#define DEFAULT_FILTER_TYPE "nop"
+
+#define TYPE_FILTER_BUFFER "filter-buffer"
+
typedef void (FilterSetup) (NetFilterState *nf, Error **errp);
typedef void (FilterCleanup) (NetFilterState *nf);
/*
diff --git a/net/net.c b/net/net.c
index a49af48..12c13f9 100644
--- a/net/net.c
+++ b/net/net.c
@@ -77,6 +77,12 @@ const char *host_net_devices[] = {
int default_net = 1;
+/*
+ * TODO: Export this with an option for users to control
+ * this with comand line ?
+ */
+char default_netfilter_type[16] = TYPE_FILTER_BUFFER;
+
/***********************************************************/
/* network device redirectors */
@@ -1029,6 +1035,23 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)
}
return -1;
}
+
+ if (is_netdev) {
+ const Netdev *netdev = object;
+ char default_name[128];
+
+ snprintf(default_name, sizeof(default_name),
+ "%s%s0", netdev->id, DEFAULT_FILTER_TYPE);
+ /*
+ * Here we add each netdev a default filter,
+ * it will disabled by default, Users can enable it when necessary.
+ */
+ netdev_add_filter(netdev->id,
+ default_netfilter_type,
+ default_name,
+ true,
+ errp);
+ }
return 0;
}
--
1.8.3.1
prev parent reply other threads:[~2016-01-27 8:38 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-27 8:29 [Qemu-devel] [PATCH RFC v2 0/5] Netfilter: Add each netdev a default filter zhanghailiang
2016-01-27 8:29 ` [Qemu-devel] [PATCH RFC v2 1/5] net/filter: Add a 'status' property for filter object zhanghailiang
2016-01-27 8:29 ` [Qemu-devel] [PATCH RFC v2 2/5] vl: Make object_create() public zhanghailiang
2016-02-01 3:05 ` Jason Wang
2016-02-01 6:19 ` Hailiang Zhang
2016-02-01 7:27 ` Jason Wang
2016-02-01 7:34 ` Hailiang Zhang
2016-02-01 10:41 ` Daniel P. Berrange
2016-02-01 10:44 ` Hailiang Zhang
2016-01-27 8:29 ` [Qemu-devel] [PATCH RFC v2 3/5] net/filter: Introduce a helper to add a filter to the netdev zhanghailiang
2016-02-01 3:14 ` Jason Wang
2016-02-01 6:13 ` Hailiang Zhang
2016-02-01 7:46 ` Jason Wang
2016-02-01 7:56 ` Hailiang Zhang
2016-02-01 8:05 ` Yang Hongyang
2016-02-01 8:21 ` Hailiang Zhang
2016-02-01 9:18 ` Jason Wang
2016-02-01 9:39 ` Hailiang Zhang
2016-02-01 9:49 ` Jason Wang
2016-02-01 10:41 ` Hailiang Zhang
2016-02-01 9:04 ` Jason Wang
2016-02-01 9:22 ` Hailiang Zhang
2016-02-01 9:42 ` Jason Wang
2016-02-01 10:40 ` Hailiang Zhang
2016-02-05 6:19 ` Jason Wang
2016-02-05 7:01 ` Hailiang Zhang
2016-02-05 7:40 ` Jason Wang
2016-02-05 8:29 ` Hailiang Zhang
2016-02-01 12:21 ` Hailiang Zhang
2016-02-01 10:43 ` Daniel P. Berrange
2016-02-01 10:57 ` Hailiang Zhang
2016-01-27 8:29 ` [Qemu-devel] [PATCH RFC v2 4/5] filter-buffer: Accept zero interval zhanghailiang
2016-01-27 8:29 ` zhanghailiang [this message]
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=1453883380-10532-6-git-send-email-zhang.zhanghailiang@huawei.com \
--to=zhang.zhanghailiang@huawei.com \
--cc=hongyang.yang@easystack.cn \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhangchen.fnst@cn.fujitsu.com \
/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).