get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 48914,
    "url": "http://patches.dpdk.org/api/patches/48914/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1544805623-18150-3-git-send-email-konstantin.ananyev@intel.com/",
    "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": "<1544805623-18150-3-git-send-email-konstantin.ananyev@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1544805623-18150-3-git-send-email-konstantin.ananyev@intel.com",
    "date": "2018-12-14T16:40:16",
    "name": "[v4,2/9] examples/ipsec-secgw: allow to specify neighbor mac address",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ffecea37773e0bac3cf48b154d34117621763528",
    "submitter": {
        "id": 33,
        "url": "http://patches.dpdk.org/api/people/33/?format=api",
        "name": "Ananyev, Konstantin",
        "email": "konstantin.ananyev@intel.com"
    },
    "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/1544805623-18150-3-git-send-email-konstantin.ananyev@intel.com/mbox/",
    "series": [
        {
            "id": 2794,
            "url": "http://patches.dpdk.org/api/series/2794/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=2794",
            "date": "2018-12-14T16:40:16",
            "name": null,
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/2794/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/48914/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/48914/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id B2F011B603;\n\tFri, 14 Dec 2018 17:40:36 +0100 (CET)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id A249F1B56D\n\tfor <dev@dpdk.org>; Fri, 14 Dec 2018 17:40:31 +0100 (CET)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t14 Dec 2018 08:40:31 -0800",
            "from sivswdev08.ir.intel.com (HELO localhost.localdomain)\n\t([10.237.217.47])\n\tby orsmga008.jf.intel.com with ESMTP; 14 Dec 2018 08:40:29 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.56,353,1539673200\"; d=\"scan'208\";a=\"101573802\"",
        "From": "Konstantin Ananyev <konstantin.ananyev@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "akhil.goyal@nxp.com, radu.nicolau@intel.com,\n\tKonstantin Ananyev <konstantin.ananyev@intel.com>",
        "Date": "Fri, 14 Dec 2018 16:40:16 +0000",
        "Message-Id": "<1544805623-18150-3-git-send-email-konstantin.ananyev@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": "<1544111691-7481-1-git-send-email-konstantin.ananyev@intel.com>",
        "References": "<1544111691-7481-1-git-send-email-konstantin.ananyev@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v4 2/9] examples/ipsec-secgw: allow to specify\n\tneighbor mac address",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "In some cases it is useful to allow user to specify destination\nether address for outgoing packets.\nThis patch adds such ability by introducing new 'neigh' config\nfile option.\n\nSigned-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>\nAcked-by: Radu Nicolau <radu.nicolau@intel.com>\n---\n examples/ipsec-secgw/ipsec-secgw.c | 21 +++++++--\n examples/ipsec-secgw/ipsec.h       |  3 ++\n examples/ipsec-secgw/parser.c      | 75 ++++++++++++++++++++++++++++++\n examples/ipsec-secgw/parser.h      |  8 ++--\n 4 files changed, 99 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c\nindex cfc2b05e5..2ed757922 100644\n--- a/examples/ipsec-secgw/ipsec-secgw.c\n+++ b/examples/ipsec-secgw/ipsec-secgw.c\n@@ -104,9 +104,9 @@ static uint16_t nb_txd = IPSEC_SECGW_TX_DESC_DEFAULT;\n #define ETHADDR(a, b, c, d, e, f) (__BYTES_TO_UINT64(a, b, c, d, e, f, 0, 0))\n \n #define ETHADDR_TO_UINT64(addr) __BYTES_TO_UINT64( \\\n-\t\taddr.addr_bytes[0], addr.addr_bytes[1], \\\n-\t\taddr.addr_bytes[2], addr.addr_bytes[3], \\\n-\t\taddr.addr_bytes[4], addr.addr_bytes[5], \\\n+\t\t(addr)->addr_bytes[0], (addr)->addr_bytes[1], \\\n+\t\t(addr)->addr_bytes[2], (addr)->addr_bytes[3], \\\n+\t\t(addr)->addr_bytes[4], (addr)->addr_bytes[5], \\\n \t\t0, 0)\n \n /* port/source ethernet addr and destination ethernet addr */\n@@ -1188,6 +1188,19 @@ print_ethaddr(const char *name, const struct ether_addr *eth_addr)\n \tprintf(\"%s%s\", name, buf);\n }\n \n+/*\n+ * Update destination ethaddr for the port.\n+ */\n+int\n+add_dst_ethaddr(uint16_t port, const struct ether_addr *addr)\n+{\n+\tif (port > RTE_DIM(ethaddr_tbl))\n+\t\treturn -EINVAL;\n+\n+\tethaddr_tbl[port].dst = ETHADDR_TO_UINT64(addr);\n+\treturn 0;\n+}\n+\n /* Check the link status of all ports in up to 9s, and print them finally */\n static void\n check_all_ports_link_status(uint32_t port_mask)\n@@ -1564,7 +1577,7 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads)\n \tprintf(\"Configuring device port %u:\\n\", portid);\n \n \trte_eth_macaddr_get(portid, &ethaddr);\n-\tethaddr_tbl[portid].src = ETHADDR_TO_UINT64(ethaddr);\n+\tethaddr_tbl[portid].src = ETHADDR_TO_UINT64(&ethaddr);\n \tprint_ethaddr(\"Address: \", &ethaddr);\n \tprintf(\"\\n\");\n \ndiff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h\nindex 9b1586f52..580f7876b 100644\n--- a/examples/ipsec-secgw/ipsec.h\n+++ b/examples/ipsec-secgw/ipsec.h\n@@ -245,4 +245,7 @@ int\n sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads,\n \t\tuint64_t *tx_offloads);\n \n+int\n+add_dst_ethaddr(uint16_t port, const struct ether_addr *addr);\n+\n #endif /* __IPSEC_H__ */\ndiff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.c\nindex 91282ca94..6769a8e6d 100644\n--- a/examples/ipsec-secgw/parser.c\n+++ b/examples/ipsec-secgw/parser.c\n@@ -306,6 +306,30 @@ parse_range(const char *token, uint16_t *low, uint16_t *high)\n \treturn 0;\n }\n \n+#define PARSE_UINT8x16(s, v, l)\t                          \\\n+do {                                                      \\\n+\tchar *end;                                        \\\n+\tunsigned long t;                                  \\\n+\terrno = 0;                                        \\\n+\tt = strtoul((s), &end, 16);                       \\\n+\tif (errno != 0 || end[0] != (l) || t > UINT8_MAX) \\\n+\t\treturn -EINVAL;                           \\\n+\t(s) = end + 1;                                    \\\n+\t(v) = t;                                          \\\n+} while (0)\n+\n+static int\n+parse_mac(const char *str, struct ether_addr *addr)\n+{\n+\tPARSE_UINT8x16(str, addr->addr_bytes[0], ':');\n+\tPARSE_UINT8x16(str, addr->addr_bytes[1], ':');\n+\tPARSE_UINT8x16(str, addr->addr_bytes[2], ':');\n+\tPARSE_UINT8x16(str, addr->addr_bytes[3], ':');\n+\tPARSE_UINT8x16(str, addr->addr_bytes[4], ':');\n+\tPARSE_UINT8x16(str, addr->addr_bytes[5], 0);\n+\treturn 0;\n+}\n+\n /** sp add parse */\n struct cfg_sp_add_cfg_item {\n \tcmdline_fixed_string_t sp_keyword;\n@@ -444,11 +468,61 @@ cmdline_parse_inst_t cfg_rt_add_rule = {\n \t},\n };\n \n+/* neigh add parse */\n+struct cfg_neigh_add_item {\n+\tcmdline_fixed_string_t neigh;\n+\tcmdline_fixed_string_t pstr;\n+\tuint16_t port;\n+\tcmdline_fixed_string_t mac;\n+};\n+\n+static void\n+cfg_parse_neigh(void *parsed_result, __rte_unused struct cmdline *cl,\n+\tvoid *data)\n+{\n+\tint32_t rc;\n+\tstruct cfg_neigh_add_item *res;\n+\tstruct parse_status *st;\n+\tstruct ether_addr mac;\n+\n+\tst = data;\n+\tres = parsed_result;\n+\trc = parse_mac(res->mac, &mac);\n+\tAPP_CHECK(rc == 0, st, \"invalid ether addr:%s\", res->mac);\n+\trc = add_dst_ethaddr(res->port, &mac);\n+\tAPP_CHECK(rc == 0, st, \"invalid port numer:%hu\", res->port);\n+\tif (st->status < 0)\n+\t\treturn;\n+}\n+\n+cmdline_parse_token_string_t cfg_add_neigh_start =\n+\tTOKEN_STRING_INITIALIZER(struct cfg_neigh_add_item, neigh, \"neigh\");\n+cmdline_parse_token_string_t cfg_add_neigh_pstr =\n+\tTOKEN_STRING_INITIALIZER(struct cfg_neigh_add_item, pstr, \"port\");\n+cmdline_parse_token_num_t cfg_add_neigh_port =\n+\tTOKEN_NUM_INITIALIZER(struct cfg_neigh_add_item, port, UINT16);\n+cmdline_parse_token_string_t cfg_add_neigh_mac =\n+\tTOKEN_STRING_INITIALIZER(struct cfg_neigh_add_item, mac, NULL);\n+\n+cmdline_parse_inst_t cfg_neigh_add_rule = {\n+\t.f = cfg_parse_neigh,\n+\t.data = NULL,\n+\t.help_str = \"\",\n+\t.tokens = {\n+\t\t(void *)&cfg_add_neigh_start,\n+\t\t(void *)&cfg_add_neigh_pstr,\n+\t\t(void *)&cfg_add_neigh_port,\n+\t\t(void *)&cfg_add_neigh_mac,\n+\t\tNULL,\n+\t},\n+};\n+\n /** set of cfg items */\n cmdline_parse_ctx_t ipsec_ctx[] = {\n \t(cmdline_parse_inst_t *)&cfg_sp_add_rule,\n \t(cmdline_parse_inst_t *)&cfg_sa_add_rule,\n \t(cmdline_parse_inst_t *)&cfg_rt_add_rule,\n+\t(cmdline_parse_inst_t *)&cfg_neigh_add_rule,\n \tNULL,\n };\n \n@@ -474,6 +548,7 @@ parse_cfg_file(const char *cfg_filename)\n \tcfg_sp_add_rule.data = &status;\n \tcfg_sa_add_rule.data = &status;\n \tcfg_rt_add_rule.data = &status;\n+\tcfg_neigh_add_rule.data = &status;\n \n \tdo {\n \t\tchar oneline[1024];\ndiff --git a/examples/ipsec-secgw/parser.h b/examples/ipsec-secgw/parser.h\nindex be02537c5..6b8a10076 100644\n--- a/examples/ipsec-secgw/parser.h\n+++ b/examples/ipsec-secgw/parser.h\n@@ -14,14 +14,14 @@ struct parse_status {\n \tchar parse_msg[256];\n };\n \n-#define\tAPP_CHECK(exp, status, fmt, ...)\t\t\t\t\\\n+#define\tAPP_CHECK(exp, st, fmt, ...)\t\t\t\t\t\\\n do {\t\t\t\t\t\t\t\t\t\\\n \tif (!(exp)) {\t\t\t\t\t\t\t\\\n-\t\tsprintf(status->parse_msg, fmt \"\\n\",\t\t\t\\\n+\t\tsprintf((st)->parse_msg, fmt \"\\n\",\t\t\t\\\n \t\t\t## __VA_ARGS__);\t\t\t\t\\\n-\t\tstatus->status = -1;\t\t\t\t\t\\\n+\t\t(st)->status = -1;\t\t\t\t\t\\\n \t} else\t\t\t\t\t\t\t\t\\\n-\t\tstatus->status = 0;\t\t\t\t\t\\\n+\t\t(st)->status = 0;\t\t\t\t\t\\\n } while (0)\n \n #define APP_CHECK_PRESENCE(val, str, status)\t\t\t\t\\\n",
    "prefixes": [
        "v4",
        "2/9"
    ]
}