[ovs-dev] [RFC 1/2] OVN: add tcp_reset{} action support

Ben Pfaff blp at ovn.org
Sun Apr 1 17:32:06 UTC 2018


On Tue, Mar 13, 2018 at 05:07:12PM +0100, Lorenzo Bianconi wrote:
> tcp_reset action transforms the current TCP segment according to the
> following pseudocode:
> 
> if (tcp.ack) {
>         tcp.seq = tcp.ack;
> } else {
>         tcp.ack = tcp.seq + length(tcp.payload);
>         tcp.seq = 0;
> }
> tcp.flags = RST;
> 
> Then, the action drops all TCP options and payload data, and updates
> the TCP checksum. IP ttl is set to 255.
> Prerequisite: tcp
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>

Thanks a lot for working on this, it will be very nice to have this
correct.

This only supports IPv4.  Please go the extra mile to support IPv6 as
well.

This provokes a couple of errors from "sparse":

    ../ovn/utilities/ovn-trace.c:1579:21: error: incorrect type in assignment (different base types)
    ../ovn/utilities/ovn-trace.c:1579:21:    expected restricted ovs_be16 [assigned] [usertype] tp_dst
    ../ovn/utilities/ovn-trace.c:1579:21:    got restricted ovs_be32 const [usertype] nw_dst
    ../ovn/utilities/ovn-trace.c:1580:24: error: incorrect type in assignment (different base types)
    ../ovn/utilities/ovn-trace.c:1580:24:    expected restricted ovs_be16 [assigned] [usertype] tcp_flags
    ../ovn/utilities/ovn-trace.c:1580:24:    got int

I think it's right and needs:

diff --git a/ovn/utilities/ovn-trace.c b/ovn/utilities/ovn-trace.c
index 94e79f70494f..4db6f24f2d46 100644
--- a/ovn/utilities/ovn-trace.c
+++ b/ovn/utilities/ovn-trace.c
@@ -1576,8 +1576,8 @@ execute_tcp_reset(const struct ovnact_nest *on,
     tcp_flow.nw_proto = IPPROTO_TCP;
     tcp_flow.nw_ttl = 255;
     tcp_flow.tp_src = uflow->tp_src;
-    tcp_flow.tp_dst = uflow->nw_dst;
-    tcp_flow.tcp_flags = TCP_RST;
+    tcp_flow.tp_dst = uflow->tp_dst;
+    tcp_flow.tcp_flags = htons(TCP_RST);
 
     struct ovntrace_node *node = ovntrace_node_append(
         super, OVNTRACE_NODE_TRANSFORMATION, "tcp_reset");

Thanks,

Ben.


More information about the dev mailing list