filter-rewriter: Add TCP state machine and fix memory leak in connection_track_table
PATCH 1/19 filter-rewriter: Add TCP state machine and fix memory leak in connection_track_table
We add almost full TCP state machine in filter-rewriter, except TCPS_LISTEN and some simplify in VM active close FIN states.
The reason for this simplify job is because guest kernel will track the TCP status and wait 2MSL time too, if client resend the FIN packet, guest will resend the last ACK, so we needn't wait 2MSL time in filter-rewriter.
After a net connection is closed, we didn't clear its releated resources in connection_track_table, which will lead to memory leak.
Let't track the state of net connection, if it is closed, its related resources will be cleared up.
--- net/colo.c | 2 +- net/colo.h | 9 ++-- net/filter-rewriter.c | 109 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 104 insertions(+), 16 deletions(-)
net/colo.c +1 -1
@@ -137,7 +137,7 @@ Connection *connection_new(ConnectionKey *key) conn->ip_proto = key->ip_proto; conn->processing = false; conn->offset =0 ; - conn->syn_flag =0 ; + conn->tcp_state =TCPS_CLOSED ; conn->pack =0 ; conn->sack =0 ;g_queue_init (&conn->primary_list);
net/colo.h +4 -5
@@ -18,6 +18,7 @@#include "slirp/slirp.h" #include "qemu/jhash.h" #include "qemu/timer.h" +#include "slirp/tcp.h" #define HASHTABLE_MAX_SIZE 16384
@@ -81,11 +82,9 @@ typedef struct Connection {uint32_t sack;/* offset = secondary_seq - primary_seq */ tcp_seq offset; -/* -* we use this flag update offset func -* run once in independent tcp connection -*/ -int syn_flag; + +int tcp_state;/* TCP FSM state */ +tcp_seq fin_ack_seq;/* the seq of 'fin=1,ack=1' */ } Connection;uint32_t connection_key_hash (const void *opaque);
net/filter-rewriter.c +99 -10
179 lines not on this page · raw message
Signature · 1 line
2.17.GIT
Quoted 7 lines · Zhang Chen
We add almost full TCP state machine in filter-rewriter, except
TCPS_LISTENand some simplify in VM active close FIN states.
The reason for this simplify job is because guest kernel will track the TCP status and wait 2MSL time too, if client resend the FIN packet, guest will resend the last ACK, so we needn't wait 2MSL time in filter-rewriter.After a net connection is closed, we didn't clear its releated resources
s/releated/related/
Quoted 3 lines
in
connection_track_table, which will lead to memory leak.Let't track the state of net connection, if it is closed, its related
s/Let't/Let's/
Quoted 5 lines
resources will be cleared up.
Signed-off-by zhanghailiang <[email protected]>Signed-off-by Zhang Chen <[email protected]>Signed-off-by Zhang Chen <[email protected]>
Should both of these last two S-o-b be present?
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 6 lines · Eric Blake
Quoted 5 lines · Zhang Chen
We add almost full TCP state machine in filter-rewriter, except
TCPS_LISTENand some simplify in VM active close FIN states. The reason for this simplify job is because guest kernel will track the TCP status and wait 2MSL time too, if client resend the FIN packet, guest will resend the last ACK, so we needn't wait 2MSL time in
Quoted 6 lines
filter-rewriter.
Quoted 2 lines
After a net connection is closed, we didn't clear its releated resources
s/releated/related/
OK.
Quoted 8 lines
Quoted 4 lines
in
connection_track_table, which will lead to memory leak.Let't track the state of net connection, if it is closed, its related
s/Let't/Let's/
OK.
Quoted 9 lines
Quoted 5 lines
resources will be cleared up.
Signed-off-by zhanghailiang <[email protected]>Signed-off-by Zhang Chen <[email protected]>Signed-off-by Zhang Chen <[email protected]>Should both of these last two S-o-b be present?
Maybe it will be more convenient to contact me, I use both of the email. :)
Thanks
Zhang Chen
Quoted 5 lines
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
Quoted 9 lines · Zhang Chen
Quoted 7 lines
Quoted 3 lines
Signed-off-by zhanghailiang <[email protected]>Signed-off-by Zhang Chen <[email protected]>Signed-off-by Zhang Chen <[email protected]>Should both of these last two S-o-b be present?
Maybe it will be more convenient to contact me, I use both of the email. :)
I can't tell you it's wrong, only that it is unusual. Statistics-wise, it's nicer if .mailmap consolidates multiple working email addresses into one individual, both for the sake of 'git shortlog' author attribution, and for making it easier to grep the git logs for your contributions regardless of which of the two emails that particular commit was sent under. If it were me, I'd rely on .mailmap rather than trying to double-sign my contributions.
Also, since one email appears to be personal while the other Intel, your company may have specific rules on which email address to use (was the patch written on your time or on Intel time?) (here, I have to admit that Red Hat's policy allows me to choose either my personal or my work email for open source contributions, regardless of whether I did it on my time or company time, but very few companies have equivalent policies that relaxed).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org