Skip to content

Commit 05a3192

Browse files
committed
network: deprecate DuplicateAddressDetection=
And this introduces IPv6DuplicateAddressDetection=. DuplicateAddressDetection= _disable_ IPv6 DAD if set to yes. It is very confusing...
1 parent 444ed67 commit 05a3192

File tree

5 files changed

+20
-49
lines changed

5 files changed

+20
-49
lines changed

man/systemd.network.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -984,18 +984,19 @@
984984
</listitem>
985985
</varlistentry>
986986
<varlistentry>
987-
<term><varname>DuplicateAddressDetection=</varname></term>
987+
<term><varname>IPv6DuplicateAddressDetection=</varname></term>
988988
<listitem>
989-
<para>Takes a boolean. Do not perform Duplicate Address Detection
990-
<ulink url="https://tools.ietf.org/html/rfc4862">RFC 4862</ulink> when adding this address.
991-
Supported only on IPv6. Defaults to false.</para>
989+
<para>Takes a boolean. When true performs IPv6 Duplicate Address Detection. See
990+
<ulink url="https://tools.ietf.org/html/rfc4862">RFC 4862</ulink>.
991+
Supported only on IPv6. Defaults to true.</para>
992992
</listitem>
993993
</varlistentry>
994994
<varlistentry>
995995
<term><varname>IPv4DuplicateAddressDetection=</varname></term>
996996
<listitem>
997997
<para>Takes a boolean. When true performs IPv4 Duplicate Address Detection. See
998-
<ulink url="https://tools.ietf.org/html/rfc5227">RFC 5224</ulink>. Defaults to false.</para>
998+
<ulink url="https://tools.ietf.org/html/rfc5227">RFC 5224</ulink>.
999+
Supported only on IPv4. Defaults to false.</para>
9991000
</listitem>
10001001
</varlistentry>
10011002
<varlistentry>

src/network/networkd-address.c

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ int address_new(Address **ret) {
3232
.scope = RT_SCOPE_UNIVERSE,
3333
.cinfo.ifa_prefered = CACHE_INFO_INFINITY_LIFE_TIME,
3434
.cinfo.ifa_valid = CACHE_INFO_INFINITY_LIFE_TIME,
35+
.ipv6_duplicate_address_detection = true,
3536
};
3637

3738
*ret = TAKE_PTR(address);
@@ -593,7 +594,7 @@ int address_configure(
593594
if (address->home_address)
594595
address->flags |= IFA_F_HOMEADDRESS;
595596

596-
if (address->duplicate_address_detection)
597+
if (!address->ipv6_duplicate_address_detection)
597598
address->flags |= IFA_F_NODAD;
598599

599600
if (address->manage_temporary_address)
@@ -994,14 +995,18 @@ int config_parse_address_flags(const char *unit,
994995
r = parse_boolean(rvalue);
995996
if (r < 0) {
996997
log_syntax(unit, LOG_ERR, filename, line, r,
997-
"Failed to parse address flag, ignoring: %s", rvalue);
998+
"Failed to parse %s=, ignoring: %s", lvalue, rvalue);
998999
return 0;
9991000
}
10001001

10011002
if (streq(lvalue, "HomeAddress"))
10021003
n->home_address = r;
10031004
else if (streq(lvalue, "DuplicateAddressDetection"))
1004-
n->duplicate_address_detection = r;
1005+
n->ipv6_duplicate_address_detection = !!r;
1006+
else if (streq(lvalue, "IPv6DuplicateAddressDetection"))
1007+
n->ipv6_duplicate_address_detection = r;
1008+
else if (streq(lvalue, "IPv4DuplicateAddressDetection"))
1009+
n->ipv4_duplicate_address_detection = r;
10051010
else if (streq(lvalue, "ManageTemporaryAddress"))
10061011
n->manage_temporary_address = r;
10071012
else if (streq(lvalue, "PrefixRoute"))
@@ -1058,43 +1063,6 @@ int config_parse_address_scope(const char *unit,
10581063
return 0;
10591064
}
10601065

1061-
int config_parse_address_ipv4_dad(const char *unit,
1062-
const char *filename,
1063-
unsigned line,
1064-
const char *section,
1065-
unsigned section_line,
1066-
const char *lvalue,
1067-
int ltype,
1068-
const char *rvalue,
1069-
void *data,
1070-
void *userdata) {
1071-
Network *network = userdata;
1072-
_cleanup_(address_free_or_set_invalidp) Address *n = NULL;
1073-
int r;
1074-
1075-
assert(filename);
1076-
assert(section);
1077-
assert(lvalue);
1078-
assert(rvalue);
1079-
assert(data);
1080-
1081-
r = address_new_static(network, filename, section_line, &n);
1082-
if (r < 0)
1083-
return r;
1084-
1085-
r = parse_boolean(rvalue);
1086-
if (r < 0) {
1087-
log_syntax(unit, LOG_ERR, filename, line, r,
1088-
"Failed to parse IPv4 duplicate address detection, ignoring: %s", rvalue);
1089-
return 0;
1090-
}
1091-
1092-
n->ipv4_duplicate_address_detection = r;
1093-
1094-
n = NULL;
1095-
return 0;
1096-
}
1097-
10981066
bool address_is_ready(const Address *a) {
10991067
assert(a);
11001068

src/network/networkd-address.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct Address {
4040
union in_addr_union in_addr_peer;
4141

4242
bool ip_masquerade_done:1;
43-
bool duplicate_address_detection:1;
43+
bool ipv6_duplicate_address_detection:1;
4444
bool ipv4_duplicate_address_detection:1;
4545
bool manage_temporary_address:1;
4646
bool home_address:1;

src/network/networkd-network-gperf.gperf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,12 @@ Address.Broadcast, config_parse_broadcast,
105105
Address.Label, config_parse_label, 0, 0
106106
Address.PreferredLifetime, config_parse_lifetime, 0, 0
107107
Address.HomeAddress, config_parse_address_flags, 0, 0
108-
Address.DuplicateAddressDetection, config_parse_address_flags, 0, 0
108+
Address.DuplicateAddressDetection, config_parse_address_flags, 0, 0 /* deprecated */
109+
Address.IPv6DuplicateAddressDetection, config_parse_address_flags, 0, 0
110+
Address.IPv4DuplicateAddressDetection, config_parse_address_flags, 0, 0
109111
Address.ManageTemporaryAddress, config_parse_address_flags, 0, 0
110112
Address.PrefixRoute, config_parse_address_flags, 0, 0
111113
Address.AutoJoin, config_parse_address_flags, 0, 0
112-
Address.IPv4DuplicateAddressDetection, config_parse_address_ipv4_dad, 0, 0
113114
Address.Scope, config_parse_address_scope, 0, 0
114115
IPv6AddressLabel.Prefix, config_parse_address_label_prefix, 0, 0
115116
IPv6AddressLabel.Label, config_parse_address_label, 0, 0

test/fuzz/fuzz-network-parser/directives.network

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ RestartSec=
196196
TripleSampling=
197197
[Address]
198198
DuplicateAddressDetection=
199+
IPv6DuplicateAddressDetection=
200+
IPv4DuplicateAddressDetection=
199201
AutoJoin=
200202
PreferredLifetime=
201203
Address=
@@ -206,7 +208,6 @@ ManageTemporaryAddress=
206208
Broadcast=
207209
Peer=
208210
Label=
209-
IPv4DuplicateAddressDetection=
210211
[RoutingPolicyRule]
211212
Table=
212213
IncomingInterface=

0 commit comments

Comments
 (0)