get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 99044,
    "url": "http://patches.dpdk.org/api/patches/99044/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20210916222630.71543-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": "<20210916222630.71543-9-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210916222630.71543-9-stephen@networkplumber.org",
    "date": "2021-09-16T22:26:26",
    "name": "[v10,08/12] test: add test for bpf_convert",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "7c90b3ddd5acc50f51a8d64491ba9c1b99c69847",
    "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/20210916222630.71543-9-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 18988,
            "url": "http://patches.dpdk.org/api/series/18988/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=18988",
            "date": "2021-09-16T22:26:18",
            "name": "Packet capture framework enhancements",
            "version": 10,
            "mbox": "http://patches.dpdk.org/series/18988/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/99044/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/99044/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 4B7A8A0C47;\n\tFri, 17 Sep 2021 00:27:28 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2A8654113B;\n\tFri, 17 Sep 2021 00:26:58 +0200 (CEST)",
            "from mail-pg1-f173.google.com (mail-pg1-f173.google.com\n [209.85.215.173])\n by mails.dpdk.org (Postfix) with ESMTP id BBB12410F0\n for <dev@dpdk.org>; Fri, 17 Sep 2021 00:26:51 +0200 (CEST)",
            "by mail-pg1-f173.google.com with SMTP id e7so7632151pgk.2\n for <dev@dpdk.org>; Thu, 16 Sep 2021 15:26:51 -0700 (PDT)",
            "from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123])\n by smtp.gmail.com with ESMTPSA id 3sm3937169pfp.112.2021.09.16.15.26.48\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 16 Sep 2021 15:26:48 -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=pcgId2+2sqML7Vrj5tT2iNlvprP4pU6cOK6bBqJGcow=;\n b=1+ruLzfvSYeqdMCnwxcdqndAJkb0iQBzBQHSQP2ESWN1u0UrVjpYQclFo5YHvK28ZC\n rriS6LhcksMAp/HqZirMmEIXdvBvsLZkLRwrgtcqc4qxRpztsmz3WngbXRqA5VAtEozt\n AHOJ1NvqQR2ilOfUUnbrFm+kBbvQTYFaABdHRPUNMKP7yBx7fl94CJIlzrfh+fAEmk5d\n yQWr4ZH1O0MOnMk14hDL+HzxiOWYp5QRpaVWAR+MVAGQD8TvUmeMFMA82SGNALCQU7Pj\n 1VmhlguPBaY89l4xCHPou2soXHRj4mE0Vit37UFFOdhmbOiK8NwLJv4acGxAWKT/Xp1B\n ncEg==",
        "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=pcgId2+2sqML7Vrj5tT2iNlvprP4pU6cOK6bBqJGcow=;\n b=ndOcvyyxj8ZXqGFv3fH8/hzALNFU1qtZD//ijGlMIy1Qm3tN5NOmG2frf+NGL8Z8O6\n PIrj5XYxdHaeVGwglJklZjGp31BaqNe8L4L55oKpiNNTWwx9oacvBjmja2PLtIMssSrw\n iRGKuRiRZgzXCOpYGGaVqv9HyC1RPdwYyPHaG6GQLOE/CyrtGNa7WXfXmi3jQoW35VMX\n 2ESXbY8d6Gx+tiw6AaQrvATgeJp40v2OOyPyY6ExuqQp2D8ys94UTH3Q22pGTb/TrVjR\n 0wH/K+F2KuDW3yuBMi/YHcGF8OXFUi3xqrHDOVmRiSmitPTpgMRzKQ22vJpkhRQ2XAiM\n k9og==",
        "X-Gm-Message-State": "AOAM530Iinx+FtXxxIhz/MSUlFdl6Ya2L8ovhrsqESSe88D27SMh+pfC\n qFZMi2FK7JKuejj1xE5mMknOg+VX01Q3uw==",
        "X-Google-Smtp-Source": "\n ABdhPJxluVaL4JjyZaVJwwtCWsgfXvjxJ7gOgIViRhrcwFhvDi+SPlI3zXWoeiIUwJdl0k4d3T3Bcw==",
        "X-Received": "by 2002:aa7:9841:0:b0:439:c4cb:fe9a with SMTP id\n n1-20020aa79841000000b00439c4cbfe9amr7434826pfq.13.1631831210056;\n Thu, 16 Sep 2021 15:26:50 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>",
        "Date": "Thu, 16 Sep 2021 15:26:26 -0700",
        "Message-Id": "<20210916222630.71543-9-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20210916222630.71543-1-stephen@networkplumber.org>",
        "References": "<20210903004732.109023-1-stephen@networkplumber.org>\n <20210916222630.71543-1-stephen@networkplumber.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v10 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 527c06b80708..543a5fd615b2 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.d_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },\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": [
        "v10",
        "08/12"
    ]
}