get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 96882,
    "url": "http://patchwork.dpdk.org/api/patches/96882/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/33b007a3b0fa81fdd54c006cd5b481ff06648702.1628796991.git.sovaradh@linux.microsoft.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<33b007a3b0fa81fdd54c006cd5b481ff06648702.1628796991.git.sovaradh@linux.microsoft.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/33b007a3b0fa81fdd54c006cd5b481ff06648702.1628796991.git.sovaradh@linux.microsoft.com",
    "date": "2021-08-12T20:17:48",
    "name": "[2/2] Allow the flow_classify example to add an ACL table for tcp.",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "98b9b857f0900f198d184abbc5a7ab1817fb9aec",
    "submitter": {
        "id": 2330,
        "url": "http://patchwork.dpdk.org/api/people/2330/?format=api",
        "name": "Sowmini Varadhan",
        "email": "sovaradh@linux.microsoft.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/33b007a3b0fa81fdd54c006cd5b481ff06648702.1628796991.git.sovaradh@linux.microsoft.com/mbox/",
    "series": [
        {
            "id": 18276,
            "url": "http://patchwork.dpdk.org/api/series/18276/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=18276",
            "date": "2021-08-12T20:17:46",
            "name": "TCP flow classification using 4-tuple and flags",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/18276/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/96882/comments/",
    "check": "fail",
    "checks": "http://patchwork.dpdk.org/api/patches/96882/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 6CADCA0C4D;\n\tFri, 13 Aug 2021 09:39:02 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 6894841234;\n\tFri, 13 Aug 2021 09:38:58 +0200 (CEST)",
            "from linux.microsoft.com (linux.microsoft.com [13.77.154.182])\n by mails.dpdk.org (Postfix) with ESMTP id 5CEB140042\n for <dev@dpdk.org>; Thu, 12 Aug 2021 22:17:57 +0200 (CEST)",
            "by linux.microsoft.com (Postfix, from userid 1065)\n id 9AEEE20BE693; Thu, 12 Aug 2021 13:17:56 -0700 (PDT)"
        ],
        "DKIM-Filter": "OpenDKIM Filter v2.11.0 linux.microsoft.com 9AEEE20BE693",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;\n s=default; t=1628799476;\n bh=U4/LUjtBpnuY4gZHcjua5wYqLIoe3Qn0OXZiH2mYvGI=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To:\n References:From;\n b=bm3/skjJRk5R25+mwq5nnWavIPFJkP04LGK+mMnpI2/1LRW/+OKcSIeNn5UVID/H0\n IReebZXzPeS9jcraLJE09m8LAIvX7lbw97UAnWmVfaZ0rK1rkzsIctK71yXh/LBtqf\n jFWD253QIRWYM5mKxt4yiHbWkE5Qrg6psQy+ndvQ=",
        "From": "Sowmini Varadhan <sovaradh@linux.microsoft.com>",
        "To": "sowmini05@gmail.com, bernard.iremonger@intel.com, dev@dpdk.org,\n sowmin05@gmail.com, sovaradh@linux.microsoft.com",
        "Cc": "thomas@monjalon.net",
        "Date": "Thu, 12 Aug 2021 13:17:48 -0700",
        "Message-Id": "\n <33b007a3b0fa81fdd54c006cd5b481ff06648702.1628796991.git.sovaradh@linux.microsoft.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": [
            "<cover.1628796991.git.sovaradh@linux.microsoft.com>",
            "<cover.1628796991.git.sovaradh@linux.microsoft.com>"
        ],
        "References": [
            "<cover.1628796991.git.sovaradh@linux.microsoft.com>",
            "<cover.1628796991.git.sovaradh@linux.microsoft.com>"
        ],
        "X-Mailman-Approved-At": "Fri, 13 Aug 2021 09:38:55 +0200",
        "Subject": "[dpdk-dev] [PATCH 2/2] Allow the flow_classify example to add an\n ACL table for tcp.",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The struct rte_flow_classifier can have upto RTE_FLOW_CLASSIFY_TABLE_MAX\n(32) classifier tables, but the existing flow_classify examples only adds\na single table for the L4 5-tuple.\n\nWhen dealing with tcp flows, we frequently want to add add ACLs and filters\nto filter based on the state of the TCP connection, e.g., by looking at\nthe tcp flags field.\n\nSo we enhance flow_classify to add an additional acl table for\ntcp 5-typles. If the input-file-parser detects a filter for a tcp flow with\na non-wildcard argument for tcp_flags, the IP4_TCP_5TUPLE table is used\nby flow_classify.\n\nSigned-off-by: Sowmini Varadhan <sovaradh@linux.microsoft.com>\n---\n examples/flow_classify/flow_classify.c      | 41 +++++++---\n lib/flow_classify/rte_flow_classify.c       | 87 +++++++++++++++++++++\n lib/flow_classify/rte_flow_classify.h       | 19 +++++\n lib/flow_classify/rte_flow_classify_parse.c |  8 +-\n 4 files changed, 142 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/examples/flow_classify/flow_classify.c b/examples/flow_classify/flow_classify.c\nindex 772b15adf2..b42d0df5c3 100644\n--- a/examples/flow_classify/flow_classify.c\n+++ b/examples/flow_classify/flow_classify.c\n@@ -723,11 +723,6 @@ add_classify_rule(struct rte_eth_ntuple_filter *ntuple_filter,\n \t\treturn ret;\n \t}\n \n-\t/* XXX but this only adds table_type of\n-\t * RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE\n-\t * i.e., it only ever does allocate_acl_ipv4_5tuple_rule()\n-\t * so the tcp_flags is ignored!\n-\t */\n \trule = rte_flow_classify_table_entry_add(\n \t\t\tcls_app->cls, &attr, pattern_ipv4_5tuple,\n \t\t\tactions, &key_found, &error);\n@@ -856,7 +851,8 @@ main(int argc, char *argv[])\n \tint ret;\n \tint socket_id;\n \tstruct rte_table_acl_params table_acl_params;\n-\tstruct rte_flow_classify_table_params cls_table_params;\n+\tstruct rte_table_acl_params table_acl_tcp_params;\n+\tstruct rte_flow_classify_table_params cls_table_params[2];\n \tstruct flow_classifier *cls_app;\n \tstruct rte_flow_classifier_params cls_params;\n \tuint32_t size;\n@@ -923,21 +919,42 @@ main(int argc, char *argv[])\n \tmemcpy(table_acl_params.field_format, ipv4_defs, sizeof(ipv4_defs));\n \n \t/* initialise table create params */\n-\tcls_table_params.ops = &rte_table_acl_ops;\n-\tcls_table_params.arg_create = &table_acl_params;\n-\tcls_table_params.type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE;\n+\tcls_table_params[0].ops = &rte_table_acl_ops;\n+\tcls_table_params[0].arg_create = &table_acl_params;\n+\tcls_table_params[0].type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE;\n+\n+\t/* initialise ACL table params */\n+\ttable_acl_tcp_params.name = \"table_acl_ipv4_tcp_5tuple\";\n+\ttable_acl_tcp_params.n_rules = FLOW_CLASSIFY_MAX_RULE_NUM;\n+\ttable_acl_tcp_params.n_rule_fields = RTE_DIM(ipv4_defs);\n+\tmemcpy(table_acl_tcp_params.field_format, ipv4_defs, sizeof(ipv4_defs));\n+\n+\t/* initialise table create params */\n+\tcls_table_params[1].ops = &rte_table_acl_ops;\n+\tcls_table_params[1].arg_create = &table_acl_tcp_params;\n+\tcls_table_params[1].type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_TCP_5TUPLE;\n \n-\tret = rte_flow_classify_table_create(cls_app->cls, &cls_table_params);\n+\tret = rte_flow_classify_table_create(cls_app->cls,\n+\t\t\t\t\t     &cls_table_params[0]);\n \tif (ret) {\n \t\trte_flow_classifier_free(cls_app->cls);\n \t\trte_free(cls_app);\n \t\trte_exit(EXIT_FAILURE, \"Failed to create classifier table\\n\");\n \t}\n+\tret = rte_flow_classify_table_create(cls_app->cls,\n+\t\t\t\t\t     &cls_table_params[1]);\n+\tif (ret) {\n+\t\trte_flow_classifier_free(cls_app->cls);\n+\t\trte_free(cls_app);\n+\t\trte_exit(EXIT_FAILURE,\n+\t\t\t \"Failed to create classifier table\\n\");\n+\t}\n+\n \t/* >8 End of initialization of table create params. */\n \n \t/* read file of IPv4 5 tuple rules and initialize parameters\n-\t * for rte_flow_classify_validate and rte_flow_classify_table_entry_add\n-\t * API's.\n+\t * for rte_flow_classify_validate and\n+\t * rte_flow_classify_table_entry_add  API's.\n \t */\n \n \t/* Read file of IPv4 tuple rules. 8< */\ndiff --git a/lib/flow_classify/rte_flow_classify.c b/lib/flow_classify/rte_flow_classify.c\nindex d3ba2ed227..e960c3b140 100644\n--- a/lib/flow_classify/rte_flow_classify.c\n+++ b/lib/flow_classify/rte_flow_classify.c\n@@ -60,6 +60,7 @@ enum {\n \tDST_FIELD_IPV4,\n \tSRCP_FIELD_IPV4,\n \tDSTP_FIELD_IPV4,\n+\tTCP_FLAGS_FIELD,\n \tNUM_FIELDS_IPV4\n };\n \n@@ -72,6 +73,7 @@ struct classify_rules {\n \tenum rte_flow_classify_rule_type type;\n \tunion {\n \t\tstruct rte_flow_classify_ipv4_5tuple ipv4_5tuple;\n+\t\tstruct rte_flow_classify_ipv4_tcp_5tuple ipv4_tcp_5tuple;\n \t} u;\n };\n \n@@ -477,6 +479,84 @@ allocate_acl_ipv4_5tuple_rule(struct rte_flow_classifier *cls)\n \treturn rule;\n }\n \n+static struct rte_flow_classify_rule *\n+allocate_acl_ipv4_tcp_5tuple_rule(struct rte_flow_classifier *cls)\n+{\n+\tstruct rte_flow_classify_rule *rule;\n+\tint log_level;\n+\n+\trule = malloc(sizeof(struct rte_flow_classify_rule));\n+\tif (!rule)\n+\t\treturn rule;\n+\n+\tmemset(rule, 0, sizeof(struct rte_flow_classify_rule));\n+\trule->id = unique_id++;\n+\trule->rules.type = RTE_FLOW_CLASSIFY_RULE_TYPE_IPV4_TCP_5TUPLE;\n+\n+\t/* key add values */\n+\trule->u.key.key_add.priority = cls->ntuple_filter.priority;\n+\trule->u.key.key_add.field_value[PROTO_FIELD_IPV4].mask_range.u8 =\n+\t\t\tcls->ntuple_filter.proto_mask;\n+\trule->u.key.key_add.field_value[PROTO_FIELD_IPV4].value.u8 =\n+\t\t\tcls->ntuple_filter.proto;\n+\trule->rules.u.ipv4_tcp_5tuple.proto = cls->ntuple_filter.proto;\n+\trule->rules.u.ipv4_tcp_5tuple.proto_mask =\n+\t\t\tcls->ntuple_filter.proto_mask;\n+\n+\trule->u.key.key_add.field_value[SRC_FIELD_IPV4].mask_range.u32 =\n+\t\t\tcls->ntuple_filter.src_ip_mask;\n+\trule->u.key.key_add.field_value[SRC_FIELD_IPV4].value.u32 =\n+\t\t\tcls->ntuple_filter.src_ip;\n+\trule->rules.u.ipv4_tcp_5tuple.src_ip_mask =\n+\t\t\tcls->ntuple_filter.src_ip_mask;\n+\trule->rules.u.ipv4_tcp_5tuple.src_ip = cls->ntuple_filter.src_ip;\n+\n+\trule->u.key.key_add.field_value[DST_FIELD_IPV4].mask_range.u32 =\n+\t\t\tcls->ntuple_filter.dst_ip_mask;\n+\trule->u.key.key_add.field_value[DST_FIELD_IPV4].value.u32 =\n+\t\t\tcls->ntuple_filter.dst_ip;\n+\trule->rules.u.ipv4_tcp_5tuple.dst_ip_mask =\n+\t\t\tcls->ntuple_filter.dst_ip_mask;\n+\trule->rules.u.ipv4_tcp_5tuple.dst_ip = cls->ntuple_filter.dst_ip;\n+\n+\trule->u.key.key_add.field_value[SRCP_FIELD_IPV4].mask_range.u16 =\n+\t\t\tcls->ntuple_filter.src_port_mask;\n+\trule->u.key.key_add.field_value[SRCP_FIELD_IPV4].value.u16 =\n+\t\t\tcls->ntuple_filter.src_port;\n+\trule->rules.u.ipv4_tcp_5tuple.src_port_mask =\n+\t\t\tcls->ntuple_filter.src_port_mask;\n+\trule->rules.u.ipv4_tcp_5tuple.src_port = cls->ntuple_filter.src_port;\n+\n+\trule->u.key.key_add.field_value[DSTP_FIELD_IPV4].mask_range.u16 =\n+\t\t\tcls->ntuple_filter.dst_port_mask;\n+\trule->u.key.key_add.field_value[DSTP_FIELD_IPV4].value.u16 =\n+\t\t\tcls->ntuple_filter.dst_port;\n+\trule->rules.u.ipv4_tcp_5tuple.dst_port_mask =\n+\t\t\tcls->ntuple_filter.dst_port_mask;\n+\trule->rules.u.ipv4_tcp_5tuple.dst_port = cls->ntuple_filter.dst_port;\n+\n+\trule->u.key.key_add.field_value[TCP_FLAGS_FIELD].mask_range.u32 =\n+\t\t\trte_be_to_cpu_32(0xff);\n+\trule->u.key.key_add.field_value[TCP_FLAGS_FIELD].value.u32 =\n+\t\t\trte_be_to_cpu_32(cls->ntuple_filter.tcp_flags);\n+\trule->rules.u.ipv4_tcp_5tuple.tcp_flags = cls->ntuple_filter.tcp_flags;\n+\n+\tlog_level = rte_log_get_level(librte_flow_classify_logtype);\n+\n+\tif (log_level == RTE_LOG_DEBUG)\n+\t\tprint_acl_ipv4_key_add(&rule->u.key.key_add);\n+\n+\t/* key delete values */\n+\tmemcpy(&rule->u.key.key_del.field_value[PROTO_FIELD_IPV4],\n+\t       &rule->u.key.key_add.field_value[PROTO_FIELD_IPV4],\n+\t       NUM_FIELDS_IPV4 * sizeof(struct rte_acl_field));\n+\n+\tif (log_level == RTE_LOG_DEBUG)\n+\t\tprint_acl_ipv4_key_delete(&rule->u.key.key_del);\n+\n+\treturn rule;\n+}\n+\n struct rte_flow_classify_rule *\n rte_flow_classify_table_entry_add(struct rte_flow_classifier *cls,\n \t\tconst struct rte_flow_attr *attr,\n@@ -514,6 +594,13 @@ rte_flow_classify_table_entry_add(struct rte_flow_classifier *cls,\n \t\trule->tbl_type = table_type;\n \t\tcls->table_mask |= table_type;\n \t\tbreak;\n+\tcase RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_TCP_5TUPLE:\n+\t\trule = allocate_acl_ipv4_tcp_5tuple_rule(cls);\n+\t\tif (!rule)\n+\t\t\treturn NULL;\n+\t\trule->tbl_type = table_type;\n+\t\tcls->table_mask |= table_type;\n+\t\tbreak;\n \tdefault:\n \t\treturn NULL;\n \t}\ndiff --git a/lib/flow_classify/rte_flow_classify.h b/lib/flow_classify/rte_flow_classify.h\nindex 82ea92b6a6..65585d9f92 100644\n--- a/lib/flow_classify/rte_flow_classify.h\n+++ b/lib/flow_classify/rte_flow_classify.h\n@@ -80,6 +80,8 @@ enum rte_flow_classify_rule_type {\n \tRTE_FLOW_CLASSIFY_RULE_TYPE_NONE,\n \t/** IPv4 5tuple type */\n \tRTE_FLOW_CLASSIFY_RULE_TYPE_IPV4_5TUPLE,\n+\t/** IPv4 TCP 5tuple type */\n+\tRTE_FLOW_CLASSIFY_RULE_TYPE_IPV4_TCP_5TUPLE,\n };\n \n /** Flow classify table type */\n@@ -92,6 +94,8 @@ enum rte_flow_classify_table_type {\n \tRTE_FLOW_CLASSIFY_TABLE_ACL_VLAN_IP4_5TUPLE = 1 << 2,\n \t/** ACL QinQ IP4 5TUPLE */\n \tRTE_FLOW_CLASSIFY_TABLE_ACL_QINQ_IP4_5TUPLE = 1 << 3,\n+\t/** ACL IP4 5TUPLE with tcp_flags */\n+\tRTE_FLOW_CLASSIFY_TABLE_ACL_IP4_TCP_5TUPLE = 1 << 4,\n \n };\n \n@@ -131,6 +135,21 @@ struct rte_flow_classify_ipv4_5tuple {\n \tuint8_t proto_mask;      /**< Mask of L4 protocol. */\n };\n \n+/** IPv4 5-tuple data with tcp flags*/\n+struct rte_flow_classify_ipv4_tcp_5tuple {\n+\tuint32_t dst_ip;         /**< Destination IP address in big endian. */\n+\tuint32_t dst_ip_mask;    /**< Mask of destination IP address. */\n+\tuint32_t src_ip;         /**< Source IP address in big endian. */\n+\tuint32_t src_ip_mask;    /**< Mask of destination IP address. */\n+\tuint16_t dst_port;       /**< Destination port in big endian. */\n+\tuint16_t dst_port_mask;  /**< Mask of destination port. */\n+\tuint16_t src_port;       /**< Source Port in big endian. */\n+\tuint16_t src_port_mask;  /**< Mask of source port. */\n+\tuint8_t proto;           /**< L4 protocol. */\n+\tuint8_t proto_mask;      /**< Mask of L4 protocol. */\n+\tuint8_t tcp_flags;       /**< Tcp only */\n+};\n+\n /**\n  * Flow stats\n  *\ndiff --git a/lib/flow_classify/rte_flow_classify_parse.c b/lib/flow_classify/rte_flow_classify_parse.c\nindex 465330291f..fe4ee05b6f 100644\n--- a/lib/flow_classify/rte_flow_classify_parse.c\n+++ b/lib/flow_classify/rte_flow_classify_parse.c\n@@ -216,6 +216,7 @@ classify_parse_ntuple_filter(const struct rte_flow_attr *attr,\n \tconst struct rte_flow_action_count *count;\n \tconst struct rte_flow_action_mark *mark_spec;\n \tuint32_t index;\n+\tbool have_tcp = false;\n \n \t/* parse pattern */\n \tindex = 0;\n@@ -375,6 +376,8 @@ classify_parse_ntuple_filter(const struct rte_flow_attr *attr,\n \t\tfilter->dst_port  = tcp_spec->hdr.dst_port;\n \t\tfilter->src_port  = tcp_spec->hdr.src_port;\n \t\tfilter->tcp_flags = tcp_spec->hdr.tcp_flags;\n+\t\tif (filter->tcp_flags != 0)\n+\t\t\thave_tcp = true;\n \t} else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) {\n \t\tudp_mask = item->mask;\n \n@@ -434,7 +437,10 @@ classify_parse_ntuple_filter(const struct rte_flow_attr *attr,\n \t\treturn -EINVAL;\n \t}\n \n-\ttable_type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE;\n+\tif (have_tcp)\n+\t\ttable_type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_TCP_5TUPLE;\n+\telse\n+\t\ttable_type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE;\n \n \t/* parse attr */\n \t/* must be input direction */\n",
    "prefixes": [
        "2/2"
    ]
}