We need to release all the packets from VM in COLO or Micro-checkpoint,
here we add a new helper function to realse the packets that buffered
by default buffer-filter

Signed-off-by: zhanghailiang <zhang.zhanghaili...@huawei.com>
Cc: Jason Wang <jasow...@redhat.com>
Cc: Yang Hongyang <hongyang.y...@easystack.cn>
---
v12:
- Rename this helper function
v11:
- New patch

Signed-off-by: zhanghailiang <zhang.zhanghaili...@huawei.com>
---
 include/net/filter.h |  1 +
 net/filter-buffer.c  | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/include/net/filter.h b/include/net/filter.h
index 08aa604..52cb38b 100644
--- a/include/net/filter.h
+++ b/include/net/filter.h
@@ -84,5 +84,6 @@ static inline bool qemu_need_skip_netfilter(NetFilterState 
*nf)
 void netdev_add_default_filter_buffer(const char *netdev_id,
                                       NetFilterDirection direction,
                                       Error **errp);
+void qemu_release_default_filters_packets(void);
 void qemu_set_default_filters_status(bool enable);
 #endif /* QEMU_NET_FILTER_H */
diff --git a/net/filter-buffer.c b/net/filter-buffer.c
index 90a50cc..d53b251 100644
--- a/net/filter-buffer.c
+++ b/net/filter-buffer.c
@@ -169,6 +169,24 @@ out:
     error_propagate(errp, local_err);
 }
 
+static void release_default_filter_packets(NetFilterState *nf,
+                                           void *opaque,
+                                           Error **errp)
+{
+    if (!strcmp(object_get_typename(OBJECT(nf)), TYPE_FILTER_BUFFER)) {
+
+        if (nf->is_default) {
+            filter_buffer_flush(nf);
+        }
+    }
+}
+
+/* public APIs */
+void qemu_release_default_filters_packets(void)
+{
+    qemu_foreach_netfilter(release_default_filter_packets, NULL, NULL);
+}
+
 static void set_default_filter_status(NetFilterState *nf,
                                       void *opaque,
                                       Error **errp)
-- 
1.8.3.1



Reply via email to