From: Andrea Claudi <aclaudi@redhat.com>
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 [thread overview]
Message-ID: <8ceb5d97c00eb4bec860df69e3066be7df1239cc.1561394228.git.aclaudi@redhat.com> (raw)
In-Reply-To: <cover.1561394228.git.aclaudi@redhat.com>
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: <BROADCAST,NOARP> 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 <aclaudi@redhat.com>
---
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) {
--
2.20.1
next prev parent reply other threads:[~2019-06-24 17:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 17:05 [PATCH iproute2 0/3] do not set IPv6-only options on IPv4 addresses Andrea Claudi
2019-06-24 17:05 ` Andrea Claudi [this message]
2019-06-24 17:05 ` [PATCH iproute2 2/3] ip address: do not set home option for " Andrea Claudi
2019-06-24 17:05 ` [PATCH iproute2 3/3] ip address: do not set mngtmpaddr " Andrea Claudi
2019-06-24 17:20 ` [PATCH iproute2 0/3] do not set IPv6-only options on " Stephen Hemminger
2019-06-24 21:38 ` Andrea Claudi
2019-06-24 21:51 ` David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8ceb5d97c00eb4bec860df69e3066be7df1239cc.1561394228.git.aclaudi@redhat.com \
--to=aclaudi@redhat.com \
--cc=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).