When COLO use only one vnet_hdr_support parameter between
COLO network filter(filter-mirror, filter-redirector or
filter-rewriter and colo-compare, packet will not be parsed
correctly. Acquire network driver related to COLO, if it is
nirtio-net, check vnet_hdr_support flag of COLO network filter
and colo-compare.
Signed-off-by: Tao Xu <tao3.xu@intel.com>
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
---
net/colo-compare.c | 25 +++++++++++++++++++++++++
net/colo.c | 20 ++++++++++++++++++++
net/colo.h | 4 ++++
net/filter-mirror.c | 17 +++++++++++++++++
net/filter-rewriter.c | 9 +++++++++
5 files changed, 75 insertions(+)
diff --git a/net/colo-compare.c b/net/colo-compare.c
index b100e7b51f..bc1cc951c0 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -838,6 +838,23 @@ static int compare_chr_can_read(void *opaque)
return COMPARE_READ_LEN_MAX;
}
+/* check vnet_hdr_support flag through COLO filter modules */
+static int colo_vnet_driver_check(void *opaque, QemuOpts *opts,
Error **errp)
+{
+ const char *colo_obj_type;
+
+ colo_obj_type = qemu_opt_get(opts, "qom-type");
+
+ if (strcmp(colo_obj_type, "filter-mirror") == 0 ||
+ strcmp(colo_obj_type, "filter-redirector") == 0 ||
+ strcmp(colo_obj_type, "filter-rewriter") == 0) {
+ if (qemu_opt_get(opts, "vnet_hdr_support")) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
/*
* Called from the main thread on the primary for packets
* arriving over the socket from the primary.
@@ -1289,6 +1306,14 @@ static void
colo_compare_complete(UserCreatable *uc, Error **errp)
return;
}
+ if (!s->vnet_hdr &&
+ qemu_opts_foreach(qemu_find_opts("object"),
+ colo_vnet_driver_check, NULL, NULL)) {
+ error_setg(errp, "colo compare needs 'vnet_hdr_support' "
+ "when colo filter modules work on virtio-net");
+ return;
+ }