get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 101820,
    "url": "http://patches.dpdk.org/api/patches/101820/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20211015182903.52615-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": "<20211015182903.52615-9-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211015182903.52615-9-stephen@networkplumber.org",
    "date": "2021-10-15T18:28:59",
    "name": "[v13,08/12] test: add test for bpf_convert",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "92e7404bc4831fdb6d4254b191371b0840c373c3",
    "submitter": {
        "id": 27,
        "url": "http://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20211015182903.52615-9-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 19701,
            "url": "http://patches.dpdk.org/api/series/19701/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=19701",
            "date": "2021-10-15T18:28:51",
            "name": "Packet capture framework update",
            "version": 13,
            "mbox": "http://patches.dpdk.org/series/19701/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/101820/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/101820/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 F3528A0C43;\n\tFri, 15 Oct 2021 20:30:06 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2CDC14116B;\n\tFri, 15 Oct 2021 20:29:23 +0200 (CEST)",
            "from mail-pj1-f46.google.com (mail-pj1-f46.google.com\n [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id 1540B41135\n for <dev@dpdk.org>; Fri, 15 Oct 2021 20:29:20 +0200 (CEST)",
            "by mail-pj1-f46.google.com with SMTP id\n oa12-20020a17090b1bcc00b0019f715462a8so7891786pjb.3\n for <dev@dpdk.org>; Fri, 15 Oct 2021 11:29:20 -0700 (PDT)",
            "from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123])\n by smtp.gmail.com with ESMTPSA id p189sm5526545pfp.167.2021.10.15.11.29.17\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 15 Oct 2021 11:29:18 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20210112.gappssmtp.com; s=20210112;\n h=from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding;\n bh=ekqXHUcuXuALf2KzmjQDEsUuIFhDMn6g9hgVL8Pu6rU=;\n b=4Ph2Pgp3Vn0tA4CvdmWYvd+u8eqqNSQwevUPm8IP2mMn3u+i/Tl+MyYS3lS1VpIXar\n Q7XEgP5UobH84cr6PrBOT9AYYZOt0h8SS+Cxo5ghCDi6zBshaMAwC9WZDsx4qEDKbt7B\n zuWSmi9YHCUDqeGF6I5xKpT5yWeInmEz9+v5ouyiwXYqRhRF+vxs+L2OUxejZrgSFfVs\n yIw4mbziMu1nRpNARmybWQxCZ+xVigilpCay2qdx3NKVmdIFwb2EHaAtqWAfK1YO2fwD\n t4N7E9Mz9us6q9pW7QSRgjIpDpU6mi/bG5fnLsRJxNAv073UKLUpxs5IicQwhZ/8PbBf\n zY1w==",
        "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=ekqXHUcuXuALf2KzmjQDEsUuIFhDMn6g9hgVL8Pu6rU=;\n b=LS78O6O/Nu/YUJIVNRWQxEzn3eoGoIgTS9vOHwtZS2YzKzWeAL0OrBxGKBGeBlcscC\n rJ1gCTcnF9wga3dQPjPU1Cn8ReezlK3tJqv52NEJxAnr2UkMs73htkR/bDglmY6KuaiW\n lxwAIxEfFkJw5wjVjL4IjJ3c9ih0NufVKoLy3EeoAbXNLWlHSAIcZCqxVDSmaXTXEh/e\n T7Lzy+zF0E8YheevEZfuF1GH8/SmAwwHFAIZNGFM3Sy8/+20IbKGmCbpEX1DSpmHuyDC\n L/XJxb/cS1udLvi4J1Qp4QVhKfFuQRTx5odILIghwyB4KD1Jvw7KxNaBpZBQ+J6zhPKT\n hD2A==",
        "X-Gm-Message-State": "AOAM532n41kkcjwBAYFN4JDNtvBTFK8raXUnfc4MLFYTAUt3CRZ8QP3p\n uVDXFaJQmpKYsEvBJhGqW+YWk8XJJZx47w==",
        "X-Google-Smtp-Source": "\n ABdhPJwlF9gL2Rro2l1TDWP5d/vf1A56BgTEwLRo0XqMwOhK0TIQSY5IYaxBDqZgHk6EzsQDU2BXvQ==",
        "X-Received": "by 2002:a17:902:d4ca:b0:13f:36bb:9b20 with SMTP id\n o10-20020a170902d4ca00b0013f36bb9b20mr12249818plg.1.1634322558854;\n Fri, 15 Oct 2021 11:29:18 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>,\n Konstantin Ananyev <konstantin.ananyev@intel.com>",
        "Date": "Fri, 15 Oct 2021 11:28:59 -0700",
        "Message-Id": "<20211015182903.52615-9-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20211015182903.52615-1-stephen@networkplumber.org>",
        "References": "<20210903004732.109023-1-stephen@networkplumber.org>\n <20211015182903.52615-1-stephen@networkplumber.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v13 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 | 200 ++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 200 insertions(+)",
    "diff": "diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c\nindex 8118a1849ba0..d3d385ce1eff 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,202 @@ 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,\n+\t       struct rte_mbuf *mb)\n+{\n+\tstruct bpf_program fcode;\n+\tstruct rte_bpf_prm *prm = NULL;\n+\tstruct rte_bpf *bpf = NULL;\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+\trc = rte_bpf_exec(bpf, mb);\n+\t/* The return code from bpf capture filter is non-zero if matched */\n+\tret = (rc == 0);\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+\tconst uint32_t plen = 100;\n+\tstruct rte_mbuf mb, *m;\n+\tuint8_t tbuf[RTE_MBUF_DEFAULT_BUF_SIZE];\n+\tstruct {\n+\t\tstruct rte_ether_hdr eth_hdr;\n+\t\tstruct rte_ipv4_hdr ip_hdr;\n+\t} *hdr;\n+\n+\tdummy_mbuf_prep(&mb, tbuf, sizeof(tbuf), plen);\n+\tm = &mb;\n+\n+\thdr = rte_pktmbuf_mtod(m, typeof(hdr));\n+\thdr->eth_hdr = (struct rte_ether_hdr) {\n+\t\t.dst_addr.addr_bytes = \"\\xff\\xff\\xff\\xff\\xff\\xff\",\n+\t\t.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4),\n+\t};\n+\thdr->ip_hdr = (struct rte_ipv4_hdr) {\n+\t\t.version_ihl = RTE_IPV4_VHL_DEF,\n+\t\t.total_length = rte_cpu_to_be_16(plen),\n+\t\t.time_to_live = IPDEFTTL,\n+\t\t.next_proto_id = IPPROTO_RAW,\n+\t\t.src_addr = rte_cpu_to_be_32(RTE_IPV4_LOOPBACK),\n+\t\t.dst_addr = rte_cpu_to_be_32(RTE_IPV4_BROADCAST),\n+\t};\n+\n+\tif (test_bpf_match(pcap, \"ip\", m) != 0) {\n+\t\tprintf(\"%s@%d: filter \\\"ip\\\" doesn't match test data\\n\",\n+\t\t       __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\tif (test_bpf_match(pcap, \"not ip\", m) == 0) {\n+\t\tprintf(\"%s@%d: filter \\\"not ip\\\" does match test data\\n\",\n+\t\t       __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\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 dpdk.org and not (port 80 or port 25)\",\n+\t\"host dpdk.org 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": [
        "v13",
        "08/12"
    ]
}