Show a patch.

Update a patch.

Update a patch.

GET /api/patches/1555197/
Content-Type: application/json
Vary: Accept

    "id": 1555197,
    "url": "",
    "web_url": "",
    "project": {
        "id": 47,
        "url": "",
        "name": "Open vSwitch",
        "link_name": "openvswitch",
        "list_id": "",
        "list_email": "",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    "msgid": "<>",
    "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": "",
        "name": "wenxu",
        "email": ""
    "delegate": null,
    "mbox": "",
    "series": [
            "id": 272027,
            "url": "",
            "web_url": "",
            "date": "2021-11-15T08:36:18",
            "name": "[ovs-dev,v2] conntrack: support default timeout policy get/set cmd for netdev datapath",
            "version": 2,
            "mbox": ""
    "comments": "",
    "check": "fail",
    "checks": "",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<>",
        "X-Original-To": [
        "Delivered-To": [
        "Authentication-Results": ";\n spf=pass (sender SPF authorized)\n (client-ip=2605:bc80:3010::137;;\n; receiver=<UNKNOWN>)",
        "Received": [
            "from ( [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 (Postfix) with ESMTPS id 4Ht2bl4hqxz9s5P\n\tfor <>; Mon, 15 Nov 2021 19:36:34 +1100 (AEDT)",
            "from localhost (localhost [])\n\tby (Postfix) with ESMTP id 94B1140445;\n\tMon, 15 Nov 2021 08:36:30 +0000 (UTC)",
            "from ([])\n\tby localhost ( []) (amavisd-new, port 10024)\n\twith ESMTP id ZNBGbDCu58zr; Mon, 15 Nov 2021 08:36:28 +0000 (UTC)",
            "from (\n [IPv6:2605:bc80:3010:104::8cd3:938])\n\tby (Postfix) with ESMTPS id 4937740438;\n\tMon, 15 Nov 2021 08:36:27 +0000 (UTC)",
            "from (localhost [])\n\tby (Postfix) with ESMTP id 113BBC001E;\n\tMon, 15 Nov 2021 08:36:27 +0000 (UTC)",
            "from ( [IPv6:2605:bc80:3010::136])\n by (Postfix) with ESMTP id 4B517C0012\n for <>; Mon, 15 Nov 2021 08:36:25 +0000 (UTC)",
            "from localhost (localhost [])\n by (Postfix) with ESMTP id 33428606E7\n for <>; Mon, 15 Nov 2021 08:36:25 +0000 (UTC)",
            "from ([])\n by localhost ( []) (amavisd-new, port 10024)\n with ESMTP id wJ-XkR-uKMna for <>;\n Mon, 15 Nov 2021 08:36:23 +0000 (UTC)",
            "from (\n [])\n by (Postfix) with ESMTPS id 6CB3D606D5\n for <>; Mon, 15 Nov 2021 08:36:23 +0000 (UTC)",
            "from localhost.localdomain (unknown [])\n by (Hmail) with ESMTPA id 2E34B70012A;\n Mon, 15 Nov 2021 16:36:19 +0800 (CST)"
        "X-Virus-Scanned": [
            "amavisd-new at",
            "amavisd-new at"
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.8.0",
        "From": "",
        "To": ",\n\",
        "Date": "Mon, 15 Nov 2021 16:36:18 +0800",
        "Message-Id": "<>",
        "X-Mailer": "git-send-email",
        "X-HM-Tid": "0a7d22bd6c838c15kuqt2e34b70012a",
        "Cc": "",
        "Subject": "[ovs-dev] [PATCH v2] conntrack: support default timeout policy\n\tget/set cmd for netdev datapath",
        "X-BeenThere": "",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "<>",
        "List-Unsubscribe": "<>,\n <>",
        "List-Archive": "<>",
        "List-Post": "<>",
        "List-Help": "<>",
        "List-Subscribe": "<>,\n <>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "",
        "Sender": "\"dev\" <>"
    "content": "From: wenxu <>\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 <>\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/ |  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+ = 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/ b/tests/\nindex a69896d..867cab9 100644\n--- a/tests/\n+++ b/tests/\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": [