Skip to contentSkip to conversation

net/filter-rewriter.c: Fix coverity static analysis issue

PATCH Applied Zhang Chen 3 participants 4 messages Oct 31, 2018 – Nov 16, 2018 Networking

lore
Share & tools
lore

Zhang Chen

author
#0 lore raw

PATCH v2 1/1 net/filter-rewriter.c: Fix coverity static analysis issue

The original code just follow the TCP state diagram, but in this case, we can skip the TCPS_TIME_WAIT state to simplify the implementation.

---
 net/filter-rewriter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/filter-rewriter.c +2 -1
index bb8f4d93b1..2e26839bc2 100644
@@ -155,12 +155,13 @@ static int handle_primary_tcp_pkt(RewriterState *rf,
          * Active close step 2.
          */
         if (conn->tcp_state == TCPS_FIN_WAIT_1) {
-            conn->tcp_state = TCPS_TIME_WAIT;
             /*
              * For simplify implementation, we needn't wait 2MSL time
              * in filter rewriter. Because guest kernel will track the
              * TCP status and wait 2MSL time, if client resend the FIN
              * packet, guest will apply the last ACK too.
+             * So, we skip the TCPS_TIME_WAIT state here and go straight
+             * to TCPS_CLOSED state.
              */
             conn->tcp_state = TCPS_CLOSED;
             g_hash_table_remove(rf->connection_track_table, key);
Signature · 1 line
2.17.1
Applied
#1 lore raw
Quoted 18 lines · Zhang Chen

The original code just follow the TCP state diagram, but in this case, we can skip the TCPS_TIME_WAIT state to simplify the implementation.

---
  net/filter-rewriter.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
net/filter-rewriter.c +0 -1
index bb8f4d93b1..2e26839bc2 100644
@@ -155,12 +155,13 @@ static int handle_primary_tcp_pkt(RewriterState *rf,
           * Active close step 2.
           */
          if (conn->tcp_state == TCPS_FIN_WAIT_1) {
-            conn->tcp_state = TCPS_TIME_WAIT;

net/filter-rewriter.c static int handle_primary_tcp_pkt(RewriterState *rf, · line 167

Quoted 10 lines
net/filter-rewriter.c +2 -0
              /*
               * For simplify implementation, we needn't wait 2MSL time
               * in filter rewriter. Because guest kernel will track the
               * TCP status and wait 2MSL time, if client resend the FIN
               * packet, guest will apply the last ACK too.
+             * So, we skip the TCPS_TIME_WAIT state here and go straight
+             * to TCPS_CLOSED state.
               */
              conn->tcp_state = TCPS_CLOSED;
              g_hash_table_remove(rf->connection_track_table, key);

Applied.

Thanks

#2 lore raw
Quoted 27 lines · Jason Wang
Quoted 25 lines · Zhang Chen

The original code just follow the TCP state diagram, but in this case, we can skip the TCPS_TIME_WAIT state to simplify the implementation.

---
  net/filter-rewriter.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
net/filter-rewriter.c +1 -1
index bb8f4d93b1..2e26839bc2 100644
@@ -155,12 +155,13 @@ static int handle_primary_tcp_pkt(RewriterState *rf,
           * Active close step 2.
           */
          if (conn->tcp_state == TCPS_FIN_WAIT_1) {
-            conn->tcp_state = TCPS_TIME_WAIT;
              /*
               * For simplify implementation, we needn't wait 2MSL time
               * in filter rewriter. Because guest kernel will track the
               * TCP status and wait 2MSL time, if client resend the FIN
               * packet, guest will apply the last ACK too.
+             * So, we skip the TCPS_TIME_WAIT state here and go straight
Quoted 8 lines

net/filter-rewriter.c static int handle_primary_tcp_pkt(RewriterState *rf, · line 167

Quoted 4 lines
net/filter-rewriter.c +1 -0
+             * to TCPS_CLOSED state.
               */
              conn->tcp_state = TCPS_CLOSED;
              g_hash_table_remove(rf->connection_track_table, key);

Applied.

Ping -- this doesn't seem to have made it into master?

thanks
-- PMM

#3 lore raw
Quoted 33 lines · Peter Maydell
Quoted 24 lines · Jason Wang
Quoted 23 lines · Zhang Chen

The original code just follow the TCP state diagram, but in this case, we can skip the TCPS_TIME_WAIT state to simplify the implementation.

---
   net/filter-rewriter.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
net/filter-rewriter.c +0 -1
index bb8f4d93b1..2e26839bc2 100644
@@ -155,12 +155,13 @@ static int handle_primary_tcp_pkt(RewriterState *rf,
            * Active close step 2.
            */
           if (conn->tcp_state == TCPS_FIN_WAIT_1) {
-            conn->tcp_state = TCPS_TIME_WAIT;
               /*
                * For simplify implementation, we needn't wait 2MSL time
                * in filter rewriter. Because guest kernel will track the
                * TCP status and wait 2MSL time, if client resend the FIN
                * packet, guest will apply the last ACK too.
Quoted 8 lines

net/filter-rewriter.c static int handle_primary_tcp_pkt(RewriterState *rf, · line 167

Quoted 5 lines
net/filter-rewriter.c +2 -0
+             * So, we skip the TCPS_TIME_WAIT state here and go straight
+             * to TCPS_CLOSED state.
                */
               conn->tcp_state = TCPS_CLOSED;
               g_hash_table_remove(rf->connection_track_table, key);

Applied.

Quoted 5 lines

Ping -- this doesn't seem to have made it into master?

thanks
-- PMM

Will send a pull request soon.

Thanks