From patchwork Wed Dec 20 07:57:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhey Popovych X-Patchwork-Id: 851295 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DqkxT0YP"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z1nDf5Knrz9s7m for ; Wed, 20 Dec 2017 18:57:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754326AbdLTH5U (ORCPT ); Wed, 20 Dec 2017 02:57:20 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:42578 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753252AbdLTH5Q (ORCPT ); Wed, 20 Dec 2017 02:57:16 -0500 Received: by mail-lf0-f68.google.com with SMTP id e30so6066785lfb.9 for ; Tue, 19 Dec 2017 23:57:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=+zEPlBFcXhEfLxNZna8m5mS8zt4UIvuYLN/x1OR+jAQ=; b=DqkxT0YPoCxmsQkRbXAWnq2QR/l2LUEzwBnovsKaX0dVqeDi1iInjIzcJcpCQF6g53 pbycmdZNRFi3+u2RtaEmlIWB9JBUKGg6/9ioSzbXTjEbnG0nEkaxqx/EUT778VO312v4 MMMWuCiVkitXVi6706We+dJfp+T4HUjks8ysJbimuKJdbuTyGv66435u7rY83I/BmpQ7 W18tqOVH7roaS4oY1LJE99zH557uUX/oQx07vK6t5vZUivvNqRY7BaSalPuQAhdyvLzA 4359PwNUy/jdMSU0Gk/gsByD0zCk3kq6Wn7h0gaxS3NYYAFhUzcaynNtU9BgTiXzSQUX 7tgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=+zEPlBFcXhEfLxNZna8m5mS8zt4UIvuYLN/x1OR+jAQ=; b=UQYPMNZg/P8cOAYUXbRJiNHosZa56FxE/WNCBkCEdZffcwlL+drZkTDce61Nt+sgoF TfRcP7HMUwkNcHvDaCFxXVJwVjNDTpYDeraJWUdJTKdM6dQSMiAUDxMC+PRjm70tlQyD D7PH8L+XTg0yhjhfHyxEvbBRE1dm9lkiHi0BI+RvLOLrMEX7i+MDdBWj8lp8EbwgPIwG AmBnfRN1M16FwGGfrOuelem1HtOiUNcq8Taz+Ha9pmpSwuglAtakyLOGNPUjtN5ucjvy WIuxiIiYi/yFY9NltDwppoXY6Ck9TZbCrG/qNsbl9JzQgB0OOe3PHB99O+iwG1wgcIcL enzQ== X-Gm-Message-State: AKGB3mJmsGD9lbmahtxW1Bgoc8tWRIJKwcb+RYukNOBNEWY7GVlbPzaZ n1TOJFlyb9lSUKBsqlGODe7eqg== X-Google-Smtp-Source: ACJfBotFm/kKYoYg2b7EED4C7R1cddAzfVXdNYaek4e681DHRWVxSnuDA1WHyS89MzPPvaLd/B1ZXg== X-Received: by 10.25.149.200 with SMTP id x191mr3901420lfd.129.1513756634790; Tue, 19 Dec 2017 23:57:14 -0800 (PST) Received: from tuxracer.localdomain ([2a01:6d80::195:20:96:53]) by smtp.gmail.com with ESMTPSA id a7sm1210048lfh.10.2017.12.19.23.57.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Dec 2017 23:57:14 -0800 (PST) From: Serhey Popovych To: netdev@vger.kernel.org Subject: [PATCH iproute2 1/2] utils: ll_addr: Handle ARPHRD_IP6GRE in ll_addr_n2a() Date: Wed, 20 Dec 2017 09:57:09 +0200 Message-Id: <1513756630-14639-2-git-send-email-serhe.popovych@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1513756630-14639-1-git-send-email-serhe.popovych@gmail.com> References: <1513756630-14639-1-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ll_addr_n2a() correctly prints tunnel endpoints for gre, ipip, sit and ip6tnl, but not for ip6gre. Fix this by adding ARPHRD_IP6GRE to IPv6 tunnel endpoing address conversion. Before: ------- $ ip link show ... 18: ip6tnl0: mtu 1452 qdisc noop state DOWN mode DEFAULT group default link/tunnel6 :: brd :: 19: ip6gre0: mtu 1456 qdisc noop state DOWN mode DEFAULT group default link/gre6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd \ 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 After: ------ $ ip link show ... 18: ip6tnl0: mtu 1452 qdisc noop state DOWN mode DEFAULT group default link/tunnel6 :: brd :: 19: ip6gre0: mtu 1456 qdisc noop state DOWN mode DEFAULT group default link/gre6 :: brd :: Signed-off-by: Serhey Popovych --- lib/ll_addr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ll_addr.c b/lib/ll_addr.c index c03523d..84de64e 100644 --- a/lib/ll_addr.c +++ b/lib/ll_addr.c @@ -36,7 +36,8 @@ const char *ll_addr_n2a(const unsigned char *addr, int alen, int type, char *buf (type == ARPHRD_TUNNEL || type == ARPHRD_SIT || type == ARPHRD_IPGRE)) { return inet_ntop(AF_INET, addr, buf, blen); } - if (alen == 16 && type == ARPHRD_TUNNEL6) { + if (alen == 16 && + (type == ARPHRD_TUNNEL6 || type == ARPHRD_IP6GRE)) { return inet_ntop(AF_INET6, addr, buf, blen); } snprintf(buf, blen, "%02x", addr[0]); From patchwork Wed Dec 20 07:57:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhey Popovych X-Patchwork-Id: 851296 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FcEcVsq0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z1nDm6kqZz9s7m for ; Wed, 20 Dec 2017 18:57:28 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752328AbdLTH51 (ORCPT ); Wed, 20 Dec 2017 02:57:27 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:45711 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754439AbdLTH5R (ORCPT ); Wed, 20 Dec 2017 02:57:17 -0500 Received: by mail-lf0-f65.google.com with SMTP id f13so22935240lff.12 for ; Tue, 19 Dec 2017 23:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=b/jT35ZoII/CRFBmuVkSqsKJ2/WODXD23UOyeQeEOWs=; b=FcEcVsq0KNHyGbl3K/YKRYJN0RljP6dXGoYIRpMgrIlbBzNz7U/eqdGP0CKc3gism1 n51UZMOfF9nMPGctpyspXi3u9RQPFd1i1yyrVu4MIsy1lHmNYt2RniJO9XSHa0iyhHKd cUy70b/qkUUgR1EdUN0q5IMuLroMtIAw9hyGCNQ8Q72pYjOeUX+IWe6kCrLa/sPIEDfo gxjUITY8RPwmD3rBM1NKrUqL0uD0hmHNMsvHQ5COdUyGceXKZEIwX4Ouh4am8+Z02z6E G0mG7b7+gBf3K0IGMDIlXuA1+KdiRMPDmK1l98xqufSa5SS/BzA7kwZ5DkwWcF6tMSm7 wYRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=b/jT35ZoII/CRFBmuVkSqsKJ2/WODXD23UOyeQeEOWs=; b=Da0PEZtK2s1BOh6Q6X0yTFHK70XD69ikANAxWaP1ohWHZTsLtZjg561POGFNcIL/Dp 8u9B8Gevkd2M5Qoqt+m1M1jSJABcL9H6cMlGvsylEg0pk+VA91HAio6GcMPisHo9R86j GGlGnePQ/y0fRkwglLuT4WrxuTi9CbQR2bz3aO+bcAQVe5zFOLrvwQjbbFLsOInyIXN6 NvYmcEbjCnKC0xxDzmP/s9bQhI+j+l7gplm/4Mv8S1aUrQzzomk+8MxoVPAoAWFxaY2A n9F7CXc/+IyLiKDYFUbj+hrTZfTZ61xYdaxBHZuvH6jFcC5vWI7Hhnph7vd7PjRRaQkC zObA== X-Gm-Message-State: AKGB3mJ9jNvtJgfP2HPBpdnKhD5Ef0OkFD60kNvuvQR/CRCh0HylfGa/ dP7mTuvjAwqQbTI0dvz0wNdC2w== X-Google-Smtp-Source: ACJfBouHbrwxy1lcDr7VxsVydOEsCogT56IIwYCqbd5gdImrouchCqMS++AHpfNbBwSyvTIMEABZaw== X-Received: by 10.25.178.10 with SMTP id b10mr3971917lff.13.1513756636036; Tue, 19 Dec 2017 23:57:16 -0800 (PST) Received: from tuxracer.localdomain ([2a01:6d80::195:20:96:53]) by smtp.gmail.com with ESMTPSA id a7sm1210048lfh.10.2017.12.19.23.57.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Dec 2017 23:57:15 -0800 (PST) From: Serhey Popovych To: netdev@vger.kernel.org Subject: [PATCH iproute2 2/2] ip/tunnel: No need to free answer after rtnl_talk() on error Date: Wed, 20 Dec 2017 09:57:10 +0200 Message-Id: <1513756630-14639-3-git-send-email-serhe.popovych@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1513756630-14639-1-git-send-email-serhe.popovych@gmail.com> References: <1513756630-14639-1-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since rtnl_talk() never returns with answer buffer allocated on error we do not need to release it manually. After this initializing answer with NULL before rtnl_talk() is useless. Signed-off-by: Serhey Popovych --- ip/link_gre.c | 3 +-- ip/link_gre6.c | 3 +-- ip/link_ip6tnl.c | 3 +-- ip/link_iptnl.c | 3 +-- ip/link_vti.c | 3 +-- ip/link_vti6.c | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ip/link_gre.c b/ip/link_gre.c index 2397920..f55c40c 100644 --- a/ip/link_gre.c +++ b/ip/link_gre.c @@ -75,7 +75,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, .i.ifi_family = preferred_family, .i.ifi_index = ifi->ifi_index, }; - struct nlmsghdr *answer = NULL; + struct nlmsghdr *answer; struct rtattr *tb[IFLA_MAX + 1]; struct rtattr *linkinfo[IFLA_INFO_MAX+1]; struct rtattr *greinfo[IFLA_GRE_MAX + 1]; @@ -104,7 +104,6 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, get_failed: fprintf(stderr, "Failed to get existing tunnel info.\n"); - free(answer); return -1; } diff --git a/ip/link_gre6.c b/ip/link_gre6.c index 7190ada..a3e8e08 100644 --- a/ip/link_gre6.c +++ b/ip/link_gre6.c @@ -86,7 +86,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, .i.ifi_family = preferred_family, .i.ifi_index = ifi->ifi_index, }; - struct nlmsghdr *answer = NULL; + struct nlmsghdr *answer; struct rtattr *tb[IFLA_MAX + 1]; struct rtattr *linkinfo[IFLA_INFO_MAX+1]; struct rtattr *greinfo[IFLA_GRE_MAX + 1]; @@ -114,7 +114,6 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, get_failed: fprintf(stderr, "Failed to get existing tunnel info.\n"); - free(answer); return -1; } diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c index f11ddd5..0a471c2 100644 --- a/ip/link_ip6tnl.c +++ b/ip/link_ip6tnl.c @@ -83,7 +83,7 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv, .i.ifi_family = preferred_family, .i.ifi_index = ifi->ifi_index, }; - struct nlmsghdr *answer = NULL; + struct nlmsghdr *answer; struct rtattr *tb[IFLA_MAX + 1]; struct rtattr *linkinfo[IFLA_INFO_MAX+1]; struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1]; @@ -108,7 +108,6 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv, get_failed: fprintf(stderr, "Failed to get existing tunnel info.\n"); - free(answer); return -1; } diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c index 5e4dffa..8a8f5dd 100644 --- a/ip/link_iptnl.c +++ b/ip/link_iptnl.c @@ -83,7 +83,7 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv, .i.ifi_family = preferred_family, .i.ifi_index = ifi->ifi_index, }; - struct nlmsghdr *answer = NULL; + struct nlmsghdr *answer; struct rtattr *tb[IFLA_MAX + 1]; struct rtattr *linkinfo[IFLA_INFO_MAX+1]; struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1]; @@ -112,7 +112,6 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv, get_failed: fprintf(stderr, "Failed to get existing tunnel info.\n"); - free(answer); return -1; } diff --git a/ip/link_vti.c b/ip/link_vti.c index 6c5469f..2b0fab2 100644 --- a/ip/link_vti.c +++ b/ip/link_vti.c @@ -60,7 +60,7 @@ static int vti_parse_opt(struct link_util *lu, int argc, char **argv, .i.ifi_family = preferred_family, .i.ifi_index = ifi->ifi_index, }; - struct nlmsghdr *answer = NULL; + struct nlmsghdr *answer; struct rtattr *tb[IFLA_MAX + 1]; struct rtattr *linkinfo[IFLA_INFO_MAX+1]; struct rtattr *vtiinfo[IFLA_VTI_MAX + 1]; @@ -77,7 +77,6 @@ static int vti_parse_opt(struct link_util *lu, int argc, char **argv, get_failed: fprintf(stderr, "Failed to get existing tunnel info.\n"); - free(answer); return -1; } diff --git a/ip/link_vti6.c b/ip/link_vti6.c index 4136b0e..74c246d 100644 --- a/ip/link_vti6.c +++ b/ip/link_vti6.c @@ -55,7 +55,7 @@ static int vti6_parse_opt(struct link_util *lu, int argc, char **argv, .i.ifi_family = preferred_family, .i.ifi_index = ifi->ifi_index, }; - struct nlmsghdr *answer = NULL; + struct nlmsghdr *answer; struct rtattr *tb[IFLA_MAX + 1]; struct rtattr *linkinfo[IFLA_INFO_MAX+1]; struct rtattr *vtiinfo[IFLA_VTI_MAX + 1]; @@ -72,7 +72,6 @@ static int vti6_parse_opt(struct link_util *lu, int argc, char **argv, get_failed: fprintf(stderr, "Failed to get existing tunnel info.\n"); - free(answer); return -1; }