From patchwork Mon Jun 24 17:05:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Claudi X-Patchwork-Id: 1121450 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45XbJv0PM4z9s3l for ; Tue, 25 Jun 2019 03:05:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732253AbfFXRFd (ORCPT ); Mon, 24 Jun 2019 13:05:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48050 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbfFXRFb (ORCPT ); Mon, 24 Jun 2019 13:05:31 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6EBCE4623E; Mon, 24 Jun 2019 17:05:31 +0000 (UTC) Received: from renaissance-vector.mxp.redhat.com (unknown [10.32.181.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id A10F7600C1; Mon, 24 Jun 2019 17:05:30 +0000 (UTC) From: Andrea Claudi To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, dsahern@kernel.org Subject: [PATCH iproute2 1/3] ip address: do not set nodad option for IPv4 addresses Date: Mon, 24 Jun 2019 19:05:53 +0200 Message-Id: <8ceb5d97c00eb4bec860df69e3066be7df1239cc.1561394228.git.aclaudi@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 24 Jun 2019 17:05:31 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Duplicate Address Detection (RFC 4862) is available only for IPv6 addresses. As a consequence, 'nodad' option, turning it off, should be available only for IPv6, and is defined like that in the man page. However it is possible to set nodad on IPv4 addresses, too: $ ip link add dummy0 type dummy $ ip -4 addr add 192.168.1.1 dev dummy0 nodad $ ip a 1: dummy0: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 1a:6d:c6:96:ca:f8 brd ff:ff:ff:ff:ff:ff inet 192.168.1.1/32 scope global nodad dummy0 valid_lft forever preferred_lft forever Fix this adding a check on the protocol family before setting IFA_F_NODAD flag. Fixes: bac735c53a36d ("enabled to manipulate the flags of IFA_F_HOMEADDRESS or IFA_F_NODAD from ip.") Signed-off-by: Andrea Claudi --- ip/ipaddress.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 47e5be7462fe7..38356cc929e7b 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -2250,7 +2250,10 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv) } else if (strcmp(*argv, "home") == 0) { ifa_flags |= IFA_F_HOMEADDRESS; } else if (strcmp(*argv, "nodad") == 0) { - ifa_flags |= IFA_F_NODAD; + if (req.ifa.ifa_family == AF_INET6) + ifa_flags |= IFA_F_NODAD; + else + invarg("nodad option can be set only for IPv6 addresses\n", *argv); } else if (strcmp(*argv, "mngtmpaddr") == 0) { ifa_flags |= IFA_F_MANAGETEMPADDR; } else if (strcmp(*argv, "noprefixroute") == 0) { From patchwork Mon Jun 24 17:05:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Claudi X-Patchwork-Id: 1121452 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45XbJx6pr1z9s3l for ; Tue, 25 Jun 2019 03:05:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732208AbfFXRFd (ORCPT ); Mon, 24 Jun 2019 13:05:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60686 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732171AbfFXRFc (ORCPT ); Mon, 24 Jun 2019 13:05:32 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81BFC30BC57A; Mon, 24 Jun 2019 17:05:32 +0000 (UTC) Received: from renaissance-vector.mxp.redhat.com (unknown [10.32.181.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2D1F600C0; Mon, 24 Jun 2019 17:05:31 +0000 (UTC) From: Andrea Claudi To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, dsahern@kernel.org Subject: [PATCH iproute2 2/3] ip address: do not set home option for IPv4 addresses Date: Mon, 24 Jun 2019 19:05:54 +0200 Message-Id: <54410e6543be9fb164aa255b906b26db0c196a17.1561394228.git.aclaudi@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 24 Jun 2019 17:05:32 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 'home' option designates a IPv6 address as "home address" as defined in RFC 6275. This option should be available only for IPv6 addresses, as correctly stated in the manpage. However it is possible to set home on IPv4 addresses, too: $ ip link add dummy0 type dummy $ ip -4 addr add 192.168.1.1 dev dummy0 home $ ip a 1: dummy0: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 1a:6d:c6:96:ca:f8 brd ff:ff:ff:ff:ff:ff inet 192.168.1.1/32 scope global home dummy0 valid_lft forever preferred_lft forever Fix this adding a check on the protocol family before setting IFA_F_HOMEADDRESS flag. Fixes: bac735c53a36d ("enabled to manipulate the flags of IFA_F_HOMEADDRESS or IFA_F_NODAD from ip.") Signed-off-by: Andrea Claudi --- ip/ipaddress.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 38356cc929e7b..0f59e0a40468c 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -2248,7 +2248,10 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv) if (set_lifetime(&preferred_lft, *argv)) invarg("preferred_lft value", *argv); } else if (strcmp(*argv, "home") == 0) { - ifa_flags |= IFA_F_HOMEADDRESS; + if (req.ifa.ifa_family == AF_INET6) + ifa_flags |= IFA_F_HOMEADDRESS; + else + invarg("home option can be set only for IPv6 addresses\n", *argv); } else if (strcmp(*argv, "nodad") == 0) { if (req.ifa.ifa_family == AF_INET6) ifa_flags |= IFA_F_NODAD; From patchwork Mon Jun 24 17:05:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Claudi X-Patchwork-Id: 1121451 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45XbJv6ZJJz9s5c for ; Tue, 25 Jun 2019 03:05:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732273AbfFXRFe (ORCPT ); Mon, 24 Jun 2019 13:05:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43614 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732171AbfFXRFd (ORCPT ); Mon, 24 Jun 2019 13:05:33 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 957502F8BEC; Mon, 24 Jun 2019 17:05:33 +0000 (UTC) Received: from renaissance-vector.mxp.redhat.com (unknown [10.32.181.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id C573A600C0; Mon, 24 Jun 2019 17:05:32 +0000 (UTC) From: Andrea Claudi To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, dsahern@kernel.org Subject: [PATCH iproute2 3/3] ip address: do not set mngtmpaddr option for IPv4 addresses Date: Mon, 24 Jun 2019 19:05:55 +0200 Message-Id: <190b07fb798eb1da4051af7671df7c61ceaaba02.1561394228.git.aclaudi@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 24 Jun 2019 17:05:33 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 'mngtmpaddr' option make the kernel manage temporary addresses created from the specified one as template on behalf of Privacy Extensions (RFC3041). This option should be available only for IPv6 addresses, as correctly stated in the manpage. However it is possible to set mngtmpaddr on IPv4 addresses, too: $ ip link add dummy0 type dummy $ ip -4 addr add 192.168.1.1 dev dummy0 mngtmpaddr $ ip a 1: dummy0: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 1a:6d:c6:96:ca:f8 brd ff:ff:ff:ff:ff:ff inet 192.168.1.1/32 scope global mngtmpaddr dummy0 valid_lft forever preferred_lft forever Fix this adding a check on the protocol family before setting IFA_F_MANAGETEMPADDR flag. Fixes: 5b7e21c417bea ("add support for IFA_F_MANAGETEMPADDR") Signed-off-by: Andrea Claudi --- ip/ipaddress.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 0f59e0a40468c..06a9f904201c0 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -2258,7 +2258,10 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv) else invarg("nodad option can be set only for IPv6 addresses\n", *argv); } else if (strcmp(*argv, "mngtmpaddr") == 0) { - ifa_flags |= IFA_F_MANAGETEMPADDR; + if (req.ifa.ifa_family == AF_INET6) + ifa_flags |= IFA_F_MANAGETEMPADDR; + else + invarg("mngtmpaddr option can be set only for IPv6 addresses\n", *argv); } else if (strcmp(*argv, "noprefixroute") == 0) { ifa_flags |= IFA_F_NOPREFIXROUTE; } else if (strcmp(*argv, "autojoin") == 0) {