{"id":811052,"url":"http://patchwork.ozlabs.org/api/patches/811052/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1504794403-45690-5-git-send-email-arkadis@mellanox.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","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-5-git-send-email-arkadis@mellanox.com>","list_archive_url":null,"date":"2017-09-07T14:26:43","name":"[iproute2,4/4] devlink: Add support for protocol IPv4/IPv6/Ethernet special formats","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"d408754cba7cd878c1a021d52154592abb6a7453","submitter":{"id":71504,"url":"http://patchwork.ozlabs.org/api/people/71504/?format=json","name":"Arkadi Sharshevsky","email":"arkadis@mellanox.com"},"delegate":{"id":389,"url":"http://patchwork.ozlabs.org/api/users/389/?format=json","username":"shemminger","first_name":"stephen","last_name":"hemminger","email":"shemminger@vyatta.com"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/1504794403-45690-5-git-send-email-arkadis@mellanox.com/mbox/","series":[{"id":2006,"url":"http://patchwork.ozlabs.org/api/series/2006/?format=json","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/811052/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/811052/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 3xp2l55J5lz9sPm\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri,  8 Sep 2017 00:24:17 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1755419AbdIGOYP (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 7 Sep 2017 10:24:15 -0400","from mail-il-dmz.mellanox.com ([193.47.165.129]:40364 \"EHLO\n\tmellanox.co.il\" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org\n\twith ESMTP id S1755309AbdIGOYH (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 v87EO1oE010674;\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 4/4] devlink: Add support for protocol\n\tIPv4/IPv6/Ethernet special formats","Date":"Thu,  7 Sep 2017 17:26:43 +0300","Message-Id":"<1504794403-45690-5-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":"Add support for protocol IPv4/IPv6/Ethernet special formats.\n\nSigned-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>\nSigned-off-by: Jiri Pirko <jiri@mellanox.com>\n---\n devlink/devlink.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 74 insertions(+), 1 deletion(-)","diff":"diff --git a/devlink/devlink.c b/devlink/devlink.c\nindex b87de38..39cda06 100644\n--- a/devlink/devlink.c\n+++ b/devlink/devlink.c\n@@ -20,6 +20,7 @@\n #include <linux/genetlink.h>\n #include <linux/devlink.h>\n #include <libmnl/libmnl.h>\n+#include <netinet/ether.h>\n \n #include \"SNAPSHOT.h\"\n #include \"list.h\"\n@@ -3401,7 +3402,79 @@ struct dpipe_header_printer {\n \tunsigned int header_id;\n };\n \n-static struct dpipe_header_printer *dpipe_header_printers[] = {};\n+static void dpipe_field_printer_ipv4_addr(struct dpipe_ctx *ctx,\n+\t\t\t\t\t  enum dpipe_value_type type,\n+\t\t\t\t\t  void *value)\n+{\n+\tstruct in_addr ip_addr;\n+\n+\tip_addr.s_addr = htonl(*(uint32_t *)value);\n+\tpr_out_str(ctx->dl, dpipe_value_type_e2s(type), inet_ntoa(ip_addr));\n+}\n+\n+static void\n+dpipe_field_printer_ethernet_addr(struct dpipe_ctx *ctx,\n+\t\t\t\t  enum dpipe_value_type type,\n+\t\t\t\t  void *value)\n+{\n+\tpr_out_str(ctx->dl, dpipe_value_type_e2s(type),\n+\t\t   ether_ntoa((struct ether_addr *)value));\n+}\n+\n+static void dpipe_field_printer_ipv6_addr(struct dpipe_ctx *ctx,\n+\t\t\t\t\t  enum dpipe_value_type type,\n+\t\t\t\t\t  void *value)\n+{\n+\tchar str[INET6_ADDRSTRLEN];\n+\n+\tinet_ntop(AF_INET6, value, str, INET6_ADDRSTRLEN);\n+\tpr_out_str(ctx->dl, dpipe_value_type_e2s(type), str);\n+}\n+\n+static struct dpipe_field_printer dpipe_field_printers_ipv4[] = {\n+\t{\n+\t\t.printer = dpipe_field_printer_ipv4_addr,\n+\t\t.field_id = DEVLINK_DPIPE_FIELD_IPV4_DST_IP,\n+\t}\n+};\n+\n+static struct dpipe_header_printer dpipe_header_printer_ipv4  = {\n+\t.printers = dpipe_field_printers_ipv4,\n+\t.printers_count = ARRAY_SIZE(dpipe_field_printers_ipv4),\n+\t.header_id = DEVLINK_DPIPE_HEADER_IPV4,\n+};\n+\n+static struct dpipe_field_printer dpipe_field_printers_ethernet[] = {\n+\t{\n+\t\t.printer = dpipe_field_printer_ethernet_addr,\n+\t\t.field_id = DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC,\n+\t},\n+};\n+\n+static struct dpipe_header_printer dpipe_header_printer_ethernet = {\n+\t.printers = dpipe_field_printers_ethernet,\n+\t.printers_count = ARRAY_SIZE(dpipe_field_printers_ethernet),\n+\t.header_id = DEVLINK_DPIPE_HEADER_ETHERNET,\n+};\n+\n+static struct dpipe_field_printer dpipe_field_printers_ipv6[] = {\n+\t{\n+\t\t.printer = dpipe_field_printer_ipv6_addr,\n+\t\t.field_id = DEVLINK_DPIPE_FIELD_IPV6_DST_IP,\n+\t}\n+};\n+\n+static struct dpipe_header_printer dpipe_header_printer_ipv6 = {\n+\t.printers = dpipe_field_printers_ipv6,\n+\t.printers_count = ARRAY_SIZE(dpipe_field_printers_ipv6),\n+\t.header_id = DEVLINK_DPIPE_HEADER_IPV6,\n+};\n+\n+static struct dpipe_header_printer *dpipe_header_printers[] = {\n+\t&dpipe_header_printer_ipv4,\n+\t&dpipe_header_printer_ethernet,\n+\t&dpipe_header_printer_ipv6,\n+};\n \n static int dpipe_print_prot_header(struct dpipe_ctx *ctx,\n \t\t\t\t   struct dpipe_op_info *info,\n","prefixes":["iproute2","4/4"]}