Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/811050/?format=api
{ "id": 811050, "url": "http://patchwork.ozlabs.org/api/patches/811050/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1504794403-45690-3-git-send-email-arkadis@mellanox.com/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504794403-45690-3-git-send-email-arkadis@mellanox.com>", "list_archive_url": null, "date": "2017-09-07T14:26:41", "name": "[iproute2,2/4] devlink: Add support for special format protocol headers", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "49572bca628feab03c906b64e53a0fac345cd8e4", "submitter": { "id": 71504, "url": "http://patchwork.ozlabs.org/api/people/71504/?format=api", "name": "Arkadi Sharshevsky", "email": "arkadis@mellanox.com" }, "delegate": { "id": 389, "url": "http://patchwork.ozlabs.org/api/users/389/?format=api", "username": "shemminger", "first_name": "stephen", "last_name": "hemminger", "email": "shemminger@vyatta.com" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/1504794403-45690-3-git-send-email-arkadis@mellanox.com/mbox/", "series": [ { "id": 2006, "url": "http://patchwork.ozlabs.org/api/series/2006/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=2006", "date": "2017-09-07T14:26:41", "name": "Add support for dpipe's global header formatting", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/2006/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/811050/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/811050/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xp2ky70pQz9sPm\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 8 Sep 2017 00:24:10 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1755400AbdIGOYI (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 7 Sep 2017 10:24:08 -0400", "from mail-il-dmz.mellanox.com ([193.47.165.129]:40330 \"EHLO\n\tmellanox.co.il\" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org\n\twith ESMTP id S1754273AbdIGOYH (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Thu, 7 Sep 2017 10:24:07 -0400", "from Internal Mail-Server by MTLPINE1 (envelope-from\n\tarkadis@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 7 Sep 2017 17:24:02 +0300", "from dev-r-vrt-156.mtr.labs.mlnx (dev-r-vrt-156.mtr.labs.mlnx\n\t[10.212.156.1])\n\tby labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v87EO1oC010674;\n\tThu, 7 Sep 2017 17:24:02 +0300" ], "From": "Arkadi Sharshevsky <arkadis@mellanox.com>", "To": "netdev@vger.kernel.org", "Cc": "davem@davemloft.net, stephen@networkplumber.org, jiri@resnulli.us,\n\tmlxsw@mellanox.com, andrew@lunn.ch,\n\tArkadi Sharshevsky <arkadis@mellanox.com>, Jiri Pirko <jiri@mellanox.com>", "Subject": "[PATCH iproute2 2/4] devlink: Add support for special format\n\tprotocol headers", "Date": "Thu, 7 Sep 2017 17:26:41 +0300", "Message-Id": "<1504794403-45690-3-git-send-email-arkadis@mellanox.com>", "X-Mailer": "git-send-email 2.4.11", "In-Reply-To": "<1504794403-45690-1-git-send-email-arkadis@mellanox.com>", "References": "<1504794403-45690-1-git-send-email-arkadis@mellanox.com>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "In case of global header (protocol header), the header:field ids are used\nto perform lookup for special format printer. In case no printer existence\nfallback to plain value printing.\n\nSigned-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>\nSigned-off-by: Jiri Pirko <jiri@mellanox.com>\n---\n devlink/devlink.c | 119 ++++++++++++++++++++++++++++++++++++++++++------------\n 1 file changed, 94 insertions(+), 25 deletions(-)", "diff": "diff --git a/devlink/devlink.c b/devlink/devlink.c\nindex 36a2b36..b87de38 100644\n--- a/devlink/devlink.c\n+++ b/devlink/devlink.c\n@@ -3372,9 +3372,89 @@ static int cmd_dpipe_table_set(struct dl *dl)\n \treturn _mnlg_socket_sndrcv(dl->nlg, nlh, NULL, NULL);\n }\n \n-static int dpipe_entry_value_show(struct dpipe_ctx *ctx,\n-\t\t\t\t struct nlattr **nla_match_value)\n+enum dpipe_value_type {\n+\tDPIPE_VALUE_TYPE_VALUE,\n+\tDPIPE_VALUE_TYPE_MASK,\n+};\n+\n+static const char *\n+dpipe_value_type_e2s(enum dpipe_value_type type)\n+{\n+\tswitch (type) {\n+\tcase DPIPE_VALUE_TYPE_VALUE:\n+\t\treturn \"value\";\n+\tcase DPIPE_VALUE_TYPE_MASK:\n+\t\treturn \"value_mask\";\n+\tdefault:\n+\t\treturn \"<unknown>\";\n+\t}\n+}\n+\n+struct dpipe_field_printer {\n+\tunsigned int field_id;\n+\tvoid (*printer)(struct dpipe_ctx *, enum dpipe_value_type, void *);\n+};\n+\n+struct dpipe_header_printer {\n+\tstruct dpipe_field_printer *printers;\n+\tunsigned int printers_count;\n+\tunsigned int header_id;\n+};\n+\n+static struct dpipe_header_printer *dpipe_header_printers[] = {};\n+\n+static int dpipe_print_prot_header(struct dpipe_ctx *ctx,\n+\t\t\t\t struct dpipe_op_info *info,\n+\t\t\t\t enum dpipe_value_type type,\n+\t\t\t\t void *value)\n {\n+\tunsigned int header_printers_count = ARRAY_SIZE(dpipe_header_printers);\n+\tstruct dpipe_header_printer *header_printer;\n+\tstruct dpipe_field_printer *field_printer;\n+\tunsigned int field_printers_count;\n+\tint j;\n+\tint i;\n+\n+\tfor (i = 0; i < header_printers_count; i++) {\n+\t\theader_printer = dpipe_header_printers[i];\n+\t\tif (header_printer->header_id != info->header_id)\n+\t\t\tcontinue;\n+\t\tfield_printers_count = header_printer->printers_count;\n+\t\tfor (j = 0; j < field_printers_count; j++) {\n+\t\t\tfield_printer = &header_printer->printers[j];\n+\t\t\tif (field_printer->field_id != info->field_id)\n+\t\t\t\tcontinue;\n+\t\t\tfield_printer->printer(ctx, type, value);\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\treturn -EINVAL;\n+}\n+\n+static void __pr_out_entry_value(struct dpipe_ctx *ctx,\n+\t\t\t\t void *value,\n+\t\t\t\t unsigned int value_len,\n+\t\t\t\t struct dpipe_op_info *info,\n+\t\t\t\t enum dpipe_value_type type)\n+{\n+\tif (info->header_global &&\n+\t !dpipe_print_prot_header(ctx, info, type, value))\n+\t\treturn;\n+\n+\tif (value_len == sizeof(uint32_t)) {\n+\t\tuint32_t *value_32 = value;\n+\n+\t\tpr_out_uint(ctx->dl, dpipe_value_type_e2s(type), *value_32);\n+\t}\n+}\n+\n+static void pr_out_dpipe_entry_value(struct dpipe_ctx *ctx,\n+\t\t\t\t struct nlattr **nla_match_value,\n+\t\t\t\t struct dpipe_op_info *info)\n+{\n+\tvoid *value, *value_mask;\n+\tuint32_t value_mapping;\n \tuint16_t value_len;\n \tbool mask, mapping;\n \n@@ -3382,27 +3462,20 @@ static int dpipe_entry_value_show(struct dpipe_ctx *ctx,\n \tmapping = !!nla_match_value[DEVLINK_ATTR_DPIPE_VALUE_MAPPING];\n \n \tvalue_len = mnl_attr_get_payload_len(nla_match_value[DEVLINK_ATTR_DPIPE_VALUE]);\n-\tif (value_len == sizeof(uint32_t)) {\n-\t\tuint32_t value, value_mask, value_mapping;\n-\n-\t\tif (mapping) {\n-\t\t\tvalue_mapping = mnl_attr_get_u32(nla_match_value[DEVLINK_ATTR_DPIPE_VALUE_MAPPING]);\n-\t\t\tpr_out_uint(ctx->dl, \"mapping_value\", value_mapping);\n-\t\t}\n-\n-\t\tif (mask) {\n-\t\t\tvalue_mask = mnl_attr_get_u32(nla_match_value[DEVLINK_ATTR_DPIPE_VALUE_MASK]);\n-\t\t\tpr_out_uint(ctx->dl, \"mask_value\", value_mask);\n-\t\t}\n+\tvalue = mnl_attr_get_payload(nla_match_value[DEVLINK_ATTR_DPIPE_VALUE]);\n \n-\t\tvalue = mnl_attr_get_u32(nla_match_value[DEVLINK_ATTR_DPIPE_VALUE]);\n-\t\tpr_out_uint(ctx->dl, \"value\", value);\n+\tif (mapping) {\n+\t\tvalue_mapping = mnl_attr_get_u32(nla_match_value[DEVLINK_ATTR_DPIPE_VALUE_MAPPING]);\n+\t\tpr_out_uint(ctx->dl, \"mapping_value\", value_mapping);\n+\t}\n \n-\t} else {\n-\t\treturn -EINVAL;\n+\tif (mask) {\n+\t\tvalue_mask = mnl_attr_get_payload(nla_match_value[DEVLINK_ATTR_DPIPE_VALUE]);\n+\t\t__pr_out_entry_value(ctx, value_mask, value_len, info,\n+\t\t\t\t DPIPE_VALUE_TYPE_MASK);\n \t}\n \n-\treturn 0;\n+\t__pr_out_entry_value(ctx, value, value_len, info, DPIPE_VALUE_TYPE_VALUE);\n }\n \n static int dpipe_entry_match_value_show(struct dpipe_ctx *ctx,\n@@ -3426,13 +3499,11 @@ static int dpipe_entry_match_value_show(struct dpipe_ctx *ctx,\n \t\t\t nla_match_value[DEVLINK_ATTR_DPIPE_MATCH]))\n \t\tgoto err_match_parse;\n \tpr_out_dpipe_match(&match, ctx);\n-\tif (dpipe_entry_value_show(ctx, nla_match_value))\n-\t\tgoto err_value_show;\n+\tpr_out_dpipe_entry_value(ctx, nla_match_value, &match.info);\n \tpr_out_entry_end(ctx->dl);\n \n \treturn 0;\n \n-err_value_show:\n err_match_parse:\n \tpr_out_entry_end(ctx->dl);\n \treturn -EINVAL;\n@@ -3459,13 +3530,11 @@ static int dpipe_entry_action_value_show(struct dpipe_ctx *ctx,\n \t\t\t nla_action_value[DEVLINK_ATTR_DPIPE_ACTION]))\n \t\tgoto err_action_parse;\n \tpr_out_dpipe_action(&action, ctx);\n-\tif (dpipe_entry_value_show(ctx, nla_action_value))\n-\t\tgoto err_value_show;\n+\tpr_out_dpipe_entry_value(ctx, nla_action_value, &action.info);\n \tpr_out_entry_end(ctx->dl);\n \n \treturn 0;\n \n-err_value_show:\n err_action_parse:\n \tpr_out_entry_end(ctx->dl);\n \treturn -EINVAL;\n", "prefixes": [ "iproute2", "2/4" ] }