get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1555197/
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1555197,
    "url": "http://patchwork.ozlabs.org/api/patches/1555197/",
    "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/1636965378-618-1-git-send-email-wenxu@ucloud.cn/",
    "project": {
        "id": 47,
        "url": "http://patchwork.ozlabs.org/api/projects/47/",
        "name": "Open vSwitch",
        "link_name": "openvswitch",
        "list_id": "ovs-dev.openvswitch.org",
        "list_email": "ovs-dev@openvswitch.org",
        "web_url": "http://openvswitch.org/",
        "scm_url": "git@github.com:openvswitch/ovs.git",
        "webscm_url": "https://github.com/openvswitch/ovs",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1636965378-618-1-git-send-email-wenxu@ucloud.cn>",
    "list_archive_url": null,
    "date": "2021-11-15T08:36:18",
    "name": "[ovs-dev,v2] conntrack: support default timeout policy get/set cmd for netdev datapath",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "e7cb9d8569798e60886e72d8b35c7cdca1b7d6f9",
    "submitter": {
        "id": 67928,
        "url": "http://patchwork.ozlabs.org/api/people/67928/",
        "name": "wenxu",
        "email": "wenxu@ucloud.cn"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/1636965378-618-1-git-send-email-wenxu@ucloud.cn/mbox/",
    "series": [
        {
            "id": 272027,
            "url": "http://patchwork.ozlabs.org/api/series/272027/",
            "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=272027",
            "date": "2021-11-15T08:36:18",
            "name": "[ovs-dev,v2] conntrack: support default timeout policy get/set cmd for netdev datapath",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/272027/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1555197/comments/",
    "check": "fail",
    "checks": "http://patchwork.ozlabs.org/api/patches/1555197/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "ovs-dev@lists.linuxfoundation.org"
        ],
        "Authentication-Results": "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>)",
        "Received": [
            "from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby bilbo.ozlabs.org (Postfix) with ESMTPS id 4Ht2bl4hqxz9s5P\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 15 Nov 2021 19:36:34 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id 94B1140445;\n\tMon, 15 Nov 2021 08:36:30 +0000 (UTC)",
            "from smtp4.osuosl.org ([127.0.0.1])\n\tby localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id ZNBGbDCu58zr; Mon, 15 Nov 2021 08:36:28 +0000 (UTC)",
            "from lists.linuxfoundation.org (lf-lists.osuosl.org\n [IPv6:2605:bc80:3010:104::8cd3:938])\n\tby smtp4.osuosl.org (Postfix) with ESMTPS id 4937740438;\n\tMon, 15 Nov 2021 08:36:27 +0000 (UTC)",
            "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 113BBC001E;\n\tMon, 15 Nov 2021 08:36:27 +0000 (UTC)",
            "from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 4B517C0012\n for <dev@openvswitch.org>; Mon, 15 Nov 2021 08:36:25 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by smtp3.osuosl.org (Postfix) with ESMTP id 33428606E7\n for <dev@openvswitch.org>; Mon, 15 Nov 2021 08:36:25 +0000 (UTC)",
            "from smtp3.osuosl.org ([127.0.0.1])\n by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id wJ-XkR-uKMna for <dev@openvswitch.org>;\n Mon, 15 Nov 2021 08:36:23 +0000 (UTC)",
            "from mail-m2456.qiye.163.com (mail-m2456.qiye.163.com\n [220.194.24.56])\n by smtp3.osuosl.org (Postfix) with ESMTPS id 6CB3D606D5\n for <dev@openvswitch.org>; Mon, 15 Nov 2021 08:36:23 +0000 (UTC)",
            "from localhost.localdomain (unknown [117.50.0.204])\n by mail-m2456.qiye.163.com (Hmail) with ESMTPA id 2E34B70012A;\n Mon, 15 Nov 2021 16:36:19 +0800 (CST)"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.8.0",
        "From": "wenxu@ucloud.cn",
        "To": "i.maximets@ovn.org,\n\tpvalerio@redhat.com",
        "Date": "Mon, 15 Nov 2021 16:36:18 +0800",
        "Message-Id": "<1636965378-618-1-git-send-email-wenxu@ucloud.cn>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "X-HM-Spam-Status": "e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1\n kWDxoPAgseWUFZKDYvK1lXWShZQUlCN1dZLVlBSVdZDwkaFQgSH1lBWUJNTkxWSUJLHk8YGUhITU\n wfVRkRExYaEhckFA4PWVdZFhoPEhUdFFlBWVVLWQY+",
        "X-HM-Sender-Digest": "e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NQg6Vjo*CjI4IUhISx9NKFYS\n HiowFDhVSlVKTUhNQk1OSExCT0tLVTMWGhIXVQweFQMOOw4YFxQOH1UYFUVZV1kSC1lBWUpKTFVO\n S1VLVUlLT1lXWQgBWUFKSk5JTDcG",
        "X-HM-Tid": "0a7d22bd6c838c15kuqt2e34b70012a",
        "Cc": "dev@openvswitch.org",
        "Subject": "[ovs-dev] [PATCH v2] conntrack: support default timeout policy\n\tget/set cmd for netdev datapath",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "<ovs-dev.openvswitch.org>",
        "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>",
        "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>",
        "List-Post": "<mailto:ovs-dev@openvswitch.org>",
        "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>",
        "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "ovs-dev-bounces@openvswitch.org",
        "Sender": "\"dev\" <ovs-dev-bounces@openvswitch.org>"
    },
    "content": "From: wenxu <wenxu@ucloud.cn>\n\nNow, the default timeout policy for netdev datapath is hard codeing. In\nsome case show or modify is needed.\nAdd command for get/set default timeout policy. Using like this:\n\novs-appctl dpctl/ct-get-default-timeout-policy [dp]\novs-appctl dpctl/ct-set-default-timeout-policy [dp] policies\n\nSigned-off-by: wenxu <wenxu@ucloud.cn>\n---\n NEWS                    |  4 +++\n lib/conntrack-tp.c      |  9 ++++++\n lib/conntrack-tp.h      |  2 ++\n lib/ct-dpif.c           | 63 +++++++++++++++++++++++++++++++++++++\n lib/ct-dpif.h           |  8 +++++\n lib/dpctl.c             | 84 +++++++++++++++++++++++++++++++++++++++++++++++++\n tests/system-traffic.at |  6 ++++\n 7 files changed, 176 insertions(+)",
    "diff": "diff --git a/NEWS b/NEWS\nindex 434ee57..c6a2eda 100644\n--- a/NEWS\n+++ b/NEWS\n@@ -16,6 +16,10 @@ Post-v2.16.0\n    - ovs-dpctl and 'ovs-appctl dpctl/':\n      * New commands 'cache-get-size' and 'cache-set-size' that allows to\n        get or configure linux kernel datapath cache sizes.\n+   - ovs-appctl dpctl/:\n+     * New commands 'ct-set-default-timeout-policy' and\n+       'ct-set-default-timeout-policy' that allows to get or configure\n+       netdev datapath ct default timeout policy.\n \n \n v2.16.0 - 16 Aug 2021\ndiff --git a/lib/conntrack-tp.c b/lib/conntrack-tp.c\nindex a586d3a..726b854 100644\n--- a/lib/conntrack-tp.c\n+++ b/lib/conntrack-tp.c\n@@ -230,6 +230,15 @@ tm_to_ct_dpif_tp(enum ct_timeout tm)\n     return CT_DPIF_TP_ATTR_MAX;\n }\n \n+void\n+timeout_policy_dump(const struct ct_dpif_timeout_policy *tp, struct ds *ds)\n+{\n+    for (unsigned i = 0; i < N_CT_TM; i++) {\n+        ds_put_format(ds, \"\\n\\t%s = %\"PRIu32, ct_timeout_str[i],\n+                      tp->attrs[tm_to_ct_dpif_tp(i)]);\n+    }\n+}\n+\n static void\n conn_update_expiration__(struct conntrack *ct, struct conn *conn,\n                          enum ct_timeout tm, long long now,\ndiff --git a/lib/conntrack-tp.h b/lib/conntrack-tp.h\nindex 4d411d1..bd22242 100644\n--- a/lib/conntrack-tp.h\n+++ b/lib/conntrack-tp.h\n@@ -22,6 +22,8 @@ enum ct_timeout;\n void timeout_policy_init(struct conntrack *ct);\n int timeout_policy_update(struct conntrack *ct, struct timeout_policy *tp);\n int timeout_policy_delete(struct conntrack *ct, uint32_t tp_id);\n+void timeout_policy_dump(const struct ct_dpif_timeout_policy *tp,\n+                         struct ds *ds);\n struct timeout_policy *timeout_policy_get(struct conntrack *ct, int32_t tp_id);\n void conn_init_expiration(struct conntrack *ct, struct conn *conn,\n                           enum ct_timeout tm, long long now);\ndiff --git a/lib/ct-dpif.c b/lib/ct-dpif.c\nindex cfc2315..6e36da2 100644\n--- a/lib/ct-dpif.c\n+++ b/lib/ct-dpif.c\n@@ -20,6 +20,8 @@\n #include <errno.h>\n \n #include \"ct-dpif.h\"\n+#include \"conntrack-private.h\"\n+#include \"conntrack-tp.h\"\n #include \"openvswitch/ofp-parse.h\"\n #include \"openvswitch/vlog.h\"\n \n@@ -180,6 +182,24 @@ ct_dpif_get_tcp_seq_chk(struct dpif *dpif, bool *enabled)\n }\n \n int\n+ct_dpif_set_default_timeout_policy(struct dpif *dpif,\n+                                   const struct ct_dpif_timeout_policy *tp)\n+{\n+    return (dpif->dpif_class->ct_set_timeout_policy\n+            ? dpif->dpif_class->ct_set_timeout_policy(dpif, tp)\n+            : EOPNOTSUPP);\n+}\n+\n+int\n+ct_dpif_get_default_timeout_policy(struct dpif *dpif,\n+                                   struct ct_dpif_timeout_policy *tp)\n+{\n+    return (dpif->dpif_class->ct_get_timeout_policy\n+            ? dpif->dpif_class->ct_get_timeout_policy(dpif, DEFAULT_TP_ID, tp)\n+            : EOPNOTSUPP);\n+}\n+\n+int\n ct_dpif_set_limits(struct dpif *dpif, const uint32_t *default_limit,\n                    const struct ovs_list *zone_limits)\n {\n@@ -710,6 +730,42 @@ ct_dpif_free_zone_limits(struct ovs_list *zone_limits)\n     }\n }\n \n+\n+/* Parses a specification of a timeout policy from 's' into '*tp'\n+ * .  Returns true on success.  Otherwise, returns false and\n+ * and puts the error message in 'ds'. */\n+bool\n+ct_dpif_parse_timeout_policy_tuple(const char *s, struct ds *ds,\n+                                   struct ct_dpif_timeout_policy *tp)\n+{\n+    char *pos, *key, *value, *copy, *err;\n+\n+    pos = copy = xstrdup(s);\n+    while (ofputil_parse_key_value(&pos, &key, &value)) {\n+        uint32_t tmp;\n+\n+        if (!*value) {\n+            ds_put_format(ds, \"field %s missing value\", key);\n+            goto error;\n+        }\n+\n+        err = str_to_u32(value, &tmp);\n+        if (err) {\n+          free(err);\n+          goto error_with_msg;\n+        }\n+\n+        ct_dpif_set_timeout_policy_attr_by_name(tp, key, tmp);\n+    }\n+    free(copy);\n+    return true;\n+\n+error_with_msg:\n+    ds_put_format(ds, \"failed to parse field %s\", key);\n+error:\n+    free(copy);\n+    return false;\n+}\n /* Parses a specification of a conntrack zone limit from 's' into '*pzone'\n  * and '*plimit'.  Returns true on success.  Otherwise, returns false and\n  * and puts the error message in 'ds'. */\n@@ -792,6 +848,13 @@ static const char *const ct_dpif_tp_attr_string[] = {\n #undef CT_DPIF_TP_ICMP_ATTR\n };\n \n+void\n+ct_dpif_format_timeout_policy(const struct ct_dpif_timeout_policy *tp,\n+                              struct ds *ds)\n+{\n+    timeout_policy_dump(tp, ds);\n+}\n+\n static bool\n ct_dpif_set_timeout_policy_attr(struct ct_dpif_timeout_policy *tp,\n                                 uint32_t attr, uint32_t value)\ndiff --git a/lib/ct-dpif.h b/lib/ct-dpif.h\nindex b59cba9..9f09ee0 100644\n--- a/lib/ct-dpif.h\n+++ b/lib/ct-dpif.h\n@@ -292,6 +292,12 @@ int ct_dpif_set_limits(struct dpif *dpif, const uint32_t *default_limit,\n int ct_dpif_get_limits(struct dpif *dpif, uint32_t *default_limit,\n                        const struct ovs_list *, struct ovs_list *);\n int ct_dpif_del_limits(struct dpif *dpif, const struct ovs_list *);\n+int ct_dpif_set_default_timeout_policy(struct dpif *dpif,\n+                                       const struct ct_dpif_timeout_policy *);\n+int ct_dpif_get_default_timeout_policy(struct dpif *dpif,\n+                                       struct ct_dpif_timeout_policy *tp);\n+bool ct_dpif_parse_timeout_policy_tuple(const char *s, struct ds *ds,\n+                                        struct ct_dpif_timeout_policy *);\n int ct_dpif_ipf_set_enabled(struct dpif *, bool v6, bool enable);\n int ct_dpif_ipf_set_min_frag(struct dpif *, bool v6, uint32_t min_frag);\n int ct_dpif_ipf_set_max_nfrags(struct dpif *, uint32_t max_frags);\n@@ -315,6 +321,8 @@ bool ct_dpif_parse_zone_limit_tuple(const char *s, uint16_t *pzone,\n                                     uint32_t *plimit, struct ds *);\n void ct_dpif_format_zone_limits(uint32_t default_limit,\n                                 const struct ovs_list *, struct ds *);\n+void ct_dpif_format_timeout_policy(const struct ct_dpif_timeout_policy *tp,\n+                                   struct ds *ds);\n bool ct_dpif_set_timeout_policy_attr_by_name(struct ct_dpif_timeout_policy *tp,\n                                              const char *key, uint32_t value);\n bool ct_dpif_timeout_policy_support_ipproto(uint8_t ipproto);\ndiff --git a/lib/dpctl.c b/lib/dpctl.c\nindex 1ba1a96..e7442c9 100644\n--- a/lib/dpctl.c\n+++ b/lib/dpctl.c\n@@ -2074,6 +2074,86 @@ dpctl_ct_get_tcp_seq_chk(int argc, const char *argv[],\n }\n \n static int\n+dpctl_ct_set_default_timeout_policy(int argc, const char *argv[],\n+                    struct dpctl_params *dpctl_p)\n+{\n+    struct dpif *dpif;\n+    struct ds ds = DS_EMPTY_INITIALIZER;\n+    int i =  dp_arg_exists(argc, argv) ? 2 : 1;\n+    struct ct_dpif_timeout_policy tp;\n+    int error = opt_dpif_open(argc, argv, dpctl_p, 3, &dpif);\n+    if (error) {\n+        return error;\n+    }\n+\n+    if (!strstr(dpif->full_name, \"netdev@\")) {\n+        error = EOPNOTSUPP;\n+        dpctl_print(dpctl_p, \"not support set default timeout policy\");\n+        goto error;\n+    }\n+\n+    memset(&tp, 0, sizeof tp);\n+    tp.id = DEFAULT_TP_ID;\n+\n+    /* Parse timeout policy tuples */\n+    if (!ct_dpif_parse_timeout_policy_tuple(argv[i], &ds, &tp)) {\n+        error = EINVAL;\n+        goto error;\n+    }\n+\n+    error = ct_dpif_set_default_timeout_policy(dpif, &tp);\n+    if (!error) {\n+        dpif_close(dpif);\n+        return 0;\n+    } else {\n+        ds_put_cstr(&ds, \"failed to set timeout policy\");\n+    }\n+\n+error:\n+    dpctl_error(dpctl_p, error, \"%s\", ds_cstr(&ds));\n+    ds_destroy(&ds);\n+    dpif_close(dpif);\n+    return error;\n+}\n+\n+static int\n+dpctl_ct_get_default_timeout_policy(int argc, const char *argv[],\n+                    struct dpctl_params *dpctl_p)\n+{\n+    struct dpif *dpif;\n+    struct ds ds = DS_EMPTY_INITIALIZER;\n+    struct ct_dpif_timeout_policy tp;\n+\n+    int error = opt_dpif_open(argc, argv, dpctl_p, INT_MAX, &dpif);\n+    if (error) {\n+        return error;\n+    }\n+\n+    if (!strstr(dpif->full_name, \"netdev@\")) {\n+        error = EOPNOTSUPP;\n+        dpctl_print(dpctl_p, \"not support get default timeout policy, \");\n+        goto out;\n+    }\n+\n+    error = ct_dpif_get_default_timeout_policy(dpif, &tp);\n+\n+    if (!error) {\n+        ds_put_format(&ds, \"default timeout policy (s): \");\n+        ct_dpif_format_timeout_policy(&tp, &ds);\n+        dpctl_print(dpctl_p, \"%s\\n\", ds_cstr(&ds));\n+        goto out;\n+    } else {\n+        ds_put_format(&ds, \"failed to get conntrack timeout policy %s\",\n+                      ovs_strerror(error));\n+    }\n+\n+out:\n+    ds_destroy(&ds);\n+    dpif_close(dpif);\n+    return error;\n+}\n+\n+static int\n dpctl_ct_set_limits(int argc, const char *argv[],\n                     struct dpctl_params *dpctl_p)\n {\n@@ -2842,6 +2922,10 @@ static const struct dpctl_command all_commands[] = {\n     { \"ct-disable-tcp-seq-chk\", \"[dp]\", 0, 1, dpctl_ct_disable_tcp_seq_chk,\n        DP_RW },\n     { \"ct-get-tcp-seq-chk\", \"[dp]\", 0, 1, dpctl_ct_get_tcp_seq_chk, DP_RO },\n+    { \"ct-set-default-timeout-policy\", \"[dp]\", 1, 2,\n+       dpctl_ct_set_default_timeout_policy, DP_RW },\n+    { \"ct-get-default-timeout-policy\", \"[dp]\", 0, 1,\n+       dpctl_ct_get_default_timeout_policy, DP_RO },\n     { \"ct-set-limits\", \"[dp] [default=L] [zone=N,limit=L]...\", 1, INT_MAX,\n         dpctl_ct_set_limits, DP_RO },\n     { \"ct-del-limits\", \"[dp] zone=N1[,N2]...\", 1, 2, dpctl_ct_del_limits,\ndiff --git a/tests/system-traffic.at b/tests/system-traffic.at\nindex a69896d..867cab9 100644\n--- a/tests/system-traffic.at\n+++ b/tests/system-traffic.at\n@@ -1786,6 +1786,12 @@ AT_CHECK([ovs-appctl dpctl/ct-get-maxconns], [], [dnl\n 10\n ])\n \n+AT_CHECK([ovs-appctl dpctl/ct-set-default-timeout-policy tcp_syn_sent=60])\n+\n+AT_CHECK([ovs-appctl dpctl/ct-get-default-timeout-policy  | grep \"TCP_FIRST_PACKET\" ], [], [dnl\n+\tTCP_FIRST_PACKET = 60\n+])\n+\n OVS_TRAFFIC_VSWITCHD_STOP\n AT_CLEANUP\n \n",
    "prefixes": [
        "ovs-dev",
        "v2"
    ]
}