get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 98806,
    "url": "http://patches.dpdk.org/api/patches/98806/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20210913181510.46058-9-stephen@networkplumber.org/",
    "project": {
        "id": 1,
        "url": "http://patches.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": "<20210913181510.46058-9-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210913181510.46058-9-stephen@networkplumber.org",
    "date": "2021-09-13T18:15:06",
    "name": "[v8,08/12] test: add test for bpf_convert",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8c46a85486fc0e3446cb264e3e7a05a5fd2283a1",
    "submitter": {
        "id": 27,
        "url": "http://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20210913181510.46058-9-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 18882,
            "url": "http://patches.dpdk.org/api/series/18882/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=18882",
            "date": "2021-09-13T18:14:58",
            "name": "Packet capture framework enhancements",
            "version": 8,
            "mbox": "http://patches.dpdk.org/series/18882/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/98806/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/98806/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 EEEF0A0C45;\n\tMon, 13 Sep 2021 20:16:02 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id BA25B4113A;\n\tMon, 13 Sep 2021 20:15:29 +0200 (CEST)",
            "from mail-pj1-f54.google.com (mail-pj1-f54.google.com\n [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id C0EB141104\n for <dev@dpdk.org>; Mon, 13 Sep 2021 20:15:22 +0200 (CEST)",
            "by mail-pj1-f54.google.com with SMTP id\n mi6-20020a17090b4b4600b00199280a31cbso469321pjb.0\n for <dev@dpdk.org>; Mon, 13 Sep 2021 11:15:22 -0700 (PDT)",
            "from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123])\n by smtp.gmail.com with ESMTPSA id b10sm7616888pfl.220.2021.09.13.11.15.20\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 13 Sep 2021 11:15:21 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20150623.gappssmtp.com; s=20150623;\n h=from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding;\n bh=gKV/CMkqsKunN1bgM9X+4Z365mCEbjpfy6/Rr22Gs+Y=;\n b=0fdJ7/uNTSxfT/zLb++tv08JSFJlqZRouBm7Z7Bomy2f7kwc9wsD5VKZ77gadPWg6F\n /sahSisuClyRcrGFdYgpacX7ZL3Ui1vHnddB3pI9XNqazkiqJtvcDq8oxZgp/R6MhJE4\n or8CIExR5LXBAKlzCRPHZbp+vugI4djTmnpmQgng+e0qz371OUQbrH57ouTxZVDcahRI\n 1+Byi+WvZSWTxCJLtuYkvNbCllA2S1q1xGoK4lNYdD4+vgWC2R7PcQRTdERkf7MTTtSr\n a9sXasosZn28WWDrxreo9SvYIJ3Uw+elfS5KfUUA4AXkstqwcNoVUc9RKTZx9GrQOogZ\n A/tw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20210112;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references:mime-version:content-transfer-encoding;\n bh=gKV/CMkqsKunN1bgM9X+4Z365mCEbjpfy6/Rr22Gs+Y=;\n b=1xsn/1iR0ZYwdSM0Fqu/grtdPrdltkTVXzw8zW46xRbMR66c3bom8SL3ltFJYslQ+Z\n P+yNZJc8XI7CLIKgZuvSqWiHMXBI23B42vnCal9+atPsOCawbMn3hHKWNL3GBjbdq98H\n tSkU+PJJEJHdCRkdhrZk4DRGK+NaR+KITSf3trrJf2cxLUP0LSBIv3teBvu6h5fM0TDo\n ILi9zCayxQ45tbi7XfQbg9O0mFGCtfRnAcpdVWkQU2MGaYjW3oDa2TyLK6pE2MGzw/To\n ou0Z0Fz+GGrCdcOTTykGMmFQzPd1z8swSTQDnOo7jJS99SaLGpbf/iyOgZN3h+cq7H5l\n XUMg==",
        "X-Gm-Message-State": "AOAM533dOqfbd0s7PBWy4tEe0AcIyXshqlhtXUqeuqh9Qvh1RXBLUo29\n zOWo5rRiMYS1pYiS8Zh1U5glU5K54eFF7A==",
        "X-Google-Smtp-Source": "\n ABdhPJxWl16Z1RP9i7NuehN+1w93iAVyr4Wh5BJDkraE0kyGGSG/tjk4fjC6oZFRAWvZ5iwRkDtUQg==",
        "X-Received": "by 2002:a17:90a:d307:: with SMTP id\n p7mr842404pju.144.1631556921540;\n Mon, 13 Sep 2021 11:15:21 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>",
        "Date": "Mon, 13 Sep 2021 11:15:06 -0700",
        "Message-Id": "<20210913181510.46058-9-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20210913181510.46058-1-stephen@networkplumber.org>",
        "References": "<20210903004732.109023-1-stephen@networkplumber.org>\n <20210913181510.46058-1-stephen@networkplumber.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v8 08/12] test: add test for bpf_convert",
        "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": "Add some functional tests for the Classic BPF to DPDK BPF converter.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n app/test/test_bpf.c | 173 ++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 173 insertions(+)",
    "diff": "diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c\nindex 527c06b80708..1b5a178241d8 100644\n--- a/app/test/test_bpf.c\n+++ b/app/test/test_bpf.c\n@@ -10,6 +10,7 @@\n #include <rte_memory.h>\n #include <rte_debug.h>\n #include <rte_hexdump.h>\n+#include <rte_malloc.h>\n #include <rte_random.h>\n #include <rte_byteorder.h>\n #include <rte_errno.h>\n@@ -3233,3 +3234,175 @@ test_bpf(void)\n }\n \n REGISTER_TEST_COMMAND(bpf_autotest, test_bpf);\n+\n+#ifdef RTE_PORT_PCAP\n+#include <pcap/pcap.h>\n+\n+static void\n+test_bpf_dump(struct bpf_program *cbf, const struct rte_bpf_prm *prm)\n+{\n+\tprintf(\"cBPF program (%u insns)\\n\", cbf->bf_len);\n+\tbpf_dump(cbf, 1);\n+\n+\tprintf(\"\\neBPF program (%u insns)\\n\", prm->nb_ins);\n+\trte_bpf_dump(stdout, prm->ins, prm->nb_ins);\n+}\n+\n+static int\n+test_bpf_match(pcap_t *pcap, const char *str, bool expected)\n+{\n+\tstruct bpf_program fcode;\n+\tstruct rte_bpf_prm *prm = NULL;\n+\tstruct rte_bpf *bpf = NULL;\n+\tuint8_t tbuf[sizeof(struct dummy_mbuf)];\n+\tint ret = -1;\n+\tuint64_t rc;\n+\n+\tif (pcap_compile(pcap, &fcode, str, 1, PCAP_NETMASK_UNKNOWN)) {\n+\t\tprintf(\"%s@%d: pcap_compile(\\\"%s\\\") failed: %s;\\n\",\n+\t\t       __func__, __LINE__,  str, pcap_geterr(pcap));\n+\t\treturn -1;\n+\t}\n+\n+\tprm = rte_bpf_convert(&fcode);\n+\tif (prm == NULL) {\n+\t\tprintf(\"%s@%d: bpf_convert('%s') failed,, error=%d(%s);\\n\",\n+\t\t       __func__, __LINE__, str, rte_errno, strerror(rte_errno));\n+\t\tgoto error;\n+\t}\n+\n+\tbpf = rte_bpf_load(prm);\n+\tif (bpf == NULL) {\n+\t\tprintf(\"%s@%d: failed to load bpf code, error=%d(%s);\\n\",\n+\t\t\t__func__, __LINE__, rte_errno, strerror(rte_errno));\n+\t\tgoto error;\n+\t}\n+\n+\ttest_ld_mbuf1_prepare(tbuf);\n+\trc = rte_bpf_exec(bpf, tbuf);\n+\tif ((rc == 0) == expected)\n+\t\tret = 0;\n+\telse\n+\t\tprintf(\"%s@%d: failed match: expect %s 0 got %\"PRIu64\"\\n\",\n+\t\t       __func__, __LINE__, expected ? \"==\" : \"<>\",  rc);\n+error:\n+\tif (bpf)\n+\t\trte_bpf_destroy(bpf);\n+\trte_free(prm);\n+\tpcap_freecode(&fcode);\n+\treturn ret;\n+}\n+\n+/* Basic sanity test can we match a IP packet */\n+static int\n+test_bpf_filter_sanity(pcap_t *pcap)\n+{\n+\tint ret;\n+\n+\tret = test_bpf_match(pcap, \"ip\", true);\n+\tret |= test_bpf_match(pcap, \"not ip\", false);\n+\n+\treturn ret;\n+}\n+\n+/*\n+ * Some sample pcap filter strings from\n+ * https://wiki.wireshark.org/CaptureFilters\n+ */\n+static const char * const sample_filters[] = {\n+\t\"host 172.18.5.4\",\n+\t\"net 192.168.0.0/24\",\n+\t\"src net 192.168.0.0/24\",\n+\t\"src net 192.168.0.0 mask 255.255.255.0\",\n+\t\"dst net 192.168.0.0/24\",\n+\t\"dst net 192.168.0.0 mask 255.255.255.0\",\n+\t\"port 53\",\n+\t\"host www.example.com and not (port 80 or port 25)\",\n+\t\"host www.example.com and not port 80 and not port 25\",\n+\t\"port not 53 and not arp\",\n+\t\"(tcp[0:2] > 1500 and tcp[0:2] < 1550) or (tcp[2:2] > 1500 and tcp[2:2] < 1550)\",\n+\t\"ether proto 0x888e\",\n+\t\"ether[0] & 1 = 0 and ip[16] >= 224\",\n+\t\"icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply\",\n+\t\"tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net 127.0.0.1\",\n+\t\"not ether dst 01:80:c2:00:00:0e\",\n+\t\"not broadcast and not multicast\",\n+\t\"dst host ff02::1\",\n+\t\"port 80 and tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420\",\n+\t/* Worms */\n+\t\"dst port 135 and tcp port 135 and ip[2:2]==48\",\n+\t\"icmp[icmptype]==icmp-echo and ip[2:2]==92 and icmp[8:4]==0xAAAAAAAA\",\n+\t\"dst port 135 or dst port 445 or dst port 1433\"\n+\t\" and tcp[tcpflags] & (tcp-syn) != 0\"\n+\t\" and tcp[tcpflags] & (tcp-ack) = 0 and src net 192.168.0.0/24\",\n+\t\"tcp src port 443 and (tcp[((tcp[12] & 0xF0) >> 4 ) * 4] = 0x18)\"\n+\t\" and (tcp[((tcp[12] & 0xF0) >> 4 ) * 4 + 1] = 0x03)\"\n+\t\" and (tcp[((tcp[12] & 0xF0) >> 4 ) * 4 + 2] < 0x04)\"\n+\t\" and ((ip[2:2] - 4 * (ip[0] & 0x0F) - 4 * ((tcp[12] & 0xF0) >> 4) > 69))\",\n+\t/* Other */\n+\t\"len = 128\",\n+};\n+\n+static int\n+test_bpf_filter(pcap_t *pcap, const char *s)\n+{\n+\tstruct bpf_program fcode;\n+\tstruct rte_bpf_prm *prm = NULL;\n+\tstruct rte_bpf *bpf = NULL;\n+\n+\tif (pcap_compile(pcap, &fcode, s, 1, PCAP_NETMASK_UNKNOWN)) {\n+\t\tprintf(\"%s@%d: pcap_compile('%s') failed: %s;\\n\",\n+\t\t       __func__, __LINE__, s, pcap_geterr(pcap));\n+\t\treturn -1;\n+\t}\n+\n+\tprm = rte_bpf_convert(&fcode);\n+\tif (prm == NULL) {\n+\t\tprintf(\"%s@%d: bpf_convert('%s') failed,, error=%d(%s);\\n\",\n+\t\t       __func__, __LINE__, s, rte_errno, strerror(rte_errno));\n+\t\tgoto error;\n+\t}\n+\n+\tbpf = rte_bpf_load(prm);\n+\tif (bpf == NULL) {\n+\t\tprintf(\"%s@%d: failed to load bpf code, error=%d(%s);\\n\",\n+\t\t\t__func__, __LINE__, rte_errno, strerror(rte_errno));\n+\t\tgoto error;\n+\t}\n+\n+error:\n+\tif (bpf)\n+\t\trte_bpf_destroy(bpf);\n+\telse {\n+\t\tprintf(\"%s \\\"%s\\\"\\n\", __func__, s);\n+\t\ttest_bpf_dump(&fcode, prm);\n+\t}\n+\n+\trte_free(prm);\n+\tpcap_freecode(&fcode);\n+\treturn (bpf == NULL) ? -1 : 0;\n+}\n+\n+static int\n+test_bpf_convert(void)\n+{\n+\tunsigned int i;\n+\tpcap_t *pcap;\n+\tint rc;\n+\n+\tpcap = pcap_open_dead(DLT_EN10MB, 262144);\n+\tif (!pcap) {\n+\t\tprintf(\"pcap_open_dead failed\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\trc = test_bpf_filter_sanity(pcap);\n+\tfor (i = 0; i < RTE_DIM(sample_filters); i++)\n+\t\trc |= test_bpf_filter(pcap, sample_filters[i]);\n+\n+\tpcap_close(pcap);\n+\treturn rc;\n+}\n+\n+REGISTER_TEST_COMMAND(bpf_convert_autotest, test_bpf_convert);\n+#endif /* RTE_PORT_PCAP */\n",
    "prefixes": [
        "v8",
        "08/12"
    ]
}