diff mbox series

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

Message ID 20181031005015.5433-1-zhangckid@gmail.com (mailing list archive)
State New, archived
Headers show
Series [V2] net/filter-rewriter.c: Fix coverity static analysis issue | expand

Commit Message

Zhang Chen Oct. 31, 2018, 12:50 a.m. UTC
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.

Signed-off-by: Zhang Chen <zhangckid@gmail.com>
---
 net/filter-rewriter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jason Wang Nov. 2, 2018, 2:21 a.m. UTC | #1
On 2018/10/31 上午8:50, Zhang Chen wrote:
> 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.
>
> Signed-off-by: Zhang Chen <zhangckid@gmail.com>
> ---
>   net/filter-rewriter.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
> index bb8f4d93b1..2e26839bc2 100644
> --- a/net/filter-rewriter.c
> +++ b/net/filter-rewriter.c
> @@ -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);


Applied.

Thanks
Peter Maydell Nov. 15, 2018, 10:32 a.m. UTC | #2
On 2 November 2018 at 02:21, Jason Wang <jasowang@redhat.com> wrote:
>
> On 2018/10/31 上午8:50, Zhang Chen wrote:
>>
>> 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.
>>
>> Signed-off-by: Zhang Chen <zhangckid@gmail.com>
>> ---
>>   net/filter-rewriter.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
>> index bb8f4d93b1..2e26839bc2 100644
>> --- a/net/filter-rewriter.c
>> +++ b/net/filter-rewriter.c
>> @@ -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);
>
>
>
> Applied.

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

thanks
-- PMM
Jason Wang Nov. 16, 2018, 2:21 a.m. UTC | #3
On 2018/11/15 下午6:32, Peter Maydell wrote:
> On 2 November 2018 at 02:21, Jason Wang <jasowang@redhat.com> wrote:
>> On 2018/10/31 上午8:50, Zhang Chen wrote:
>>> 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.
>>>
>>> Signed-off-by: Zhang Chen <zhangckid@gmail.com>
>>> ---
>>>    net/filter-rewriter.c | 3 ++-
>>>    1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
>>> index bb8f4d93b1..2e26839bc2 100644
>>> --- a/net/filter-rewriter.c
>>> +++ b/net/filter-rewriter.c
>>> @@ -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);
>>
>>
>> Applied.
> Ping -- this doesn't seem to have made it into master?
>
> thanks
> -- PMM
>

Will send a pull request soon.

Thanks
diff mbox series

Patch

diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
index bb8f4d93b1..2e26839bc2 100644
--- a/net/filter-rewriter.c
+++ b/net/filter-rewriter.c
@@ -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);