Skip to contentSkip to conversation

Optimize filter-mirror and filter-rewriter

PATCH RESEND Superseded Zhang Chen 3 participants 8 messages May 15, 2017 – May 17, 2017 Networking

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Zhang Chen

author
#0 lore raw

v2 cover Optimize filter-mirror and filter-rewriter

Fix some duplicate codes and remove unused codes.

v2: Address Eric's comment on patch 3.

Zhang Chen (3):
net/filter-mirror.c: Remove duplicate check code. net/filter-mirror.c: Rename filter_mirror_send() and fix codestyle net/filter-rewriter: Remove unused option in filter-rewriter

 net/filter-mirror.c | 35 ++++++++++++++++-------------------
 qemu-options.hx     |  2 +-
 2 files changed, 17 insertions(+), 20 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH RESEND v2 1/3 net/filter-mirror.c: Remove duplicate check code.

The s->outdev have checked in filter_mirror_set_outdev().

---
 net/filter-mirror.c | 6 ------
 1 file changed, 6 deletions(-)
net/filter-mirror.c +0 -6
index 72fa7c2..fd0322f 100644
@@ -194,12 +194,6 @@ static void filter_mirror_setup(NetFilterState *nf, Error **errp)
     MirrorState *s = FILTER_MIRROR(nf);
     Chardev *chr;
 
-    if (!s->outdev) {
-        error_setg(errp, "filter mirror needs 'outdev' "
-                   "property set");
-        return;
-    }
-
     chr = qemu_chr_find(s->outdev);
     if (chr == NULL) {
         error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH RESEND v2 2/3 net/filter-mirror.c: Rename filter_mirror_send() and fix codestyle

In reply to Zhang Chen

Because filter_mirror_receive_iov() and filter_redirector_receive_iov() both use the filter_mirror_send() to send packet, so I change filter_mirror_send() to filter_send() that looks more common. And fix some codestyle.

---
 net/filter-mirror.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)
net/filter-mirror.c +16 -13
index fd0322f..8b1b069 100644
@@ -43,9 +43,9 @@ typedef struct MirrorState {
     SocketReadState rs;
 } MirrorState;
 
-static int filter_mirror_send(CharBackend *chr_out,
-                              const struct iovec *iov,
-                              int iovcnt)
+static int filter_send(CharBackend *chr_out,
+                       const struct iovec *iov,
+                       int iovcnt)
 {
     int ret = 0;
     ssize_t size = 0;
@@ -141,9 +141,9 @@ static ssize_t filter_mirror_receive_iov(NetFilterState *nf,
     MirrorState *s = FILTER_MIRROR(nf);
     int ret;
 
-    ret = filter_mirror_send(&s->chr_out, iov, iovcnt);
+    ret = filter_send(&s->chr_out, iov, iovcnt);
     if (ret) {
-        error_report("filter_mirror_send failed(%s)", strerror(-ret));
+        error_report("filter mirror send failed(%s)", strerror(-ret));
     }
 
     /*
@@ -164,9 +164,9 @@ static ssize_t filter_redirector_receive_iov(NetFilterState *nf,
     int ret;
 
     if (qemu_chr_fe_get_driver(&s->chr_out)) {
-        ret = filter_mirror_send(&s->chr_out, iov, iovcnt);
+        ret = filter_send(&s->chr_out, iov, iovcnt);
         if (ret) {
-            error_report("filter_mirror_send failed(%s)", strerror(-ret));
+            error_report("filter redirector send failed(%s)", strerror(-ret));
         }
         return iov_size(iov, iovcnt);
     } else {
@@ -286,8 +286,9 @@ static char *filter_redirector_get_indev(Object *obj, Error **errp)
     return g_strdup(s->indev);
 }
 
-static void
-filter_redirector_set_indev(Object *obj, const char *value, Error **errp)
+static void filter_redirector_set_indev(Object *obj,
+                                        const char *value,
+                                        Error **errp)
 {
     MirrorState *s = FILTER_REDIRECTOR(obj);
 
@@ -302,8 +303,9 @@ static char *filter_mirror_get_outdev(Object *obj, Error **errp)
     return g_strdup(s->outdev);
 }
 
-static void
-filter_mirror_set_outdev(Object *obj, const char *value, Error **errp)
+static void filter_mirror_set_outdev(Object *obj,
+                                     const char *value,
+                                     Error **errp)
 {
     MirrorState *s = FILTER_MIRROR(obj);
 
@@ -323,8 +325,9 @@ static char *filter_redirector_get_outdev(Object *obj, Error **errp)
     return g_strdup(s->outdev);
 }
 
-static void
-filter_redirector_set_outdev(Object *obj, const char *value, Error **errp)
+static void filter_redirector_set_outdev(Object *obj,
+                                         const char *value,
+                                         Error **errp)
 {
     MirrorState *s = FILTER_REDIRECTOR(obj);
 
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH RESEND v2 3/3 net/filter-rewriter: Remove unused option in filter-rewriter

In reply to Zhang Chen
---
 qemu-options.hx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-options.hx +1 -1
index f806af9..cbec279 100644
@@ -4038,7 +4038,7 @@ Create a filter-redirector we need to differ outdev id from indev id, id can not
 be the same. we can just use indev or outdev, but at least one of indev or outdev
 need to be specified.
 
-@item -object filter-rewriter,id=@var{id},netdev=@var{netdevid},rewriter-mode=@var{mode}[,queue=@var{all|rx|tx}]
+@item -object filter-rewriter,id=@var{id},netdev=@var{netdevid}[,queue=@var{all|rx|tx}]
 
 Filter-rewriter is a part of COLO project.It will rewrite tcp packet to
 secondary from primary to keep secondary tcp connection,and rewrite
Signature · 1 line
2.7.4
#4 lore raw
In reply to Zhang Chen
Quoted 4 lines · Zhang Chen

Fix some duplicate codes and remove unused codes.

v2: Address Eric's comment on patch 3.

Quoted 9 lines

Zhang Chen (3):
net/filter-mirror.c: Remove duplicate check code. net/filter-mirror.c: Rename filter_mirror_send() and fix codestyle net/filter-rewriter: Remove unused option in filter-rewriter

  net/filter-mirror.c | 35 ++++++++++++++++-------------------
  qemu-options.hx     |  2 +-
  2 files changed, 17 insertions(+), 20 deletions(-)

Hi:

What's the difference compared with V2? I think I should apply this series?

Thanks

author
#5 lore raw
Quoted 12 lines · Jason Wang
Quoted 9 lines · Zhang Chen

Fix some duplicate codes and remove unused codes.

v2: Address Eric's comment on patch 3.

Zhang Chen (3):
net/filter-mirror.c: Remove duplicate check code. net/filter-mirror.c: Rename filter_mirror_send() and fix codestyle net/filter-rewriter: Remove unused option in filter-rewriter

Quoted 8 lines
Quoted 4 lines
  net/filter-mirror.c | 35 ++++++++++++++++-------------------
  qemu-options.hx     |  2 +-
  2 files changed, 17 insertions(+), 20 deletions(-)

Hi:

What's the difference compared with V2? I think I should apply this series?

In V2 I forgot remove "," in patch 3/3, Yes, please apply this series.

Quoted 5 lines

Thanks

Signature · 2 lines
Thanks
Zhang Chen
#6 lore raw
Quoted 5 lines · Zhang Chen
Quoted 3 lines

What's the difference compared with V2? I think I should apply this series?

In V2 I forgot remove "," in patch 3/3, Yes, please apply this series.

If you changed the patches, even just to add a ',', then it's best to post the resend as "v3", not "RESEND V2". Also, documenting what changed between versions, rather than just blindly titling a message RESEND (or even explaining WHY you are resending without change, such as to correct an incorrect cc to save people the problem of bounce replies when replying to the thread), is good netiquette.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
author
#7 lore raw
Quoted 11 lines · Eric Blake
Quoted 3 lines · Zhang Chen
Quoted 2 lines

What's the difference compared with V2? I think I should apply this series?

In V2 I forgot remove "," in patch 3/3, Yes, please apply this series.

If you changed the patches, even just to add a ',', then it's best to post the resend as "v3", not "RESEND V2". Also, documenting what changed between versions, rather than just blindly titling a message RESEND (or even explaining WHY you are resending without change, such as to correct an incorrect cc to save people the problem of bounce replies when replying to the thread), is good netiquette.

OK, I got your point, will send the V3 later.

Thanks
Zhang Chen

Quoted 1 line
Signature · 2 lines
Thanks
Zhang Chen