summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-10-04 01:27:14 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-10-06 19:50:51 +0200
commiteaff204f099a8c23048f7f247fbc78cf86c75021 (patch)
tree608479e0e68934b10b5fad7d9903ae1907b6d2cf /src
parentnetwork: fix indentation (diff)
downloadsystemd-eaff204f099a8c23048f7f247fbc78cf86c75021.tar.xz
systemd-eaff204f099a8c23048f7f247fbc78cf86c75021.zip
network: do not update Address::flags in address_configure()
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-address.c46
-rw-r--r--src/network/networkd-address.h4
-rw-r--r--src/network/networkd-dhcp4.c2
-rw-r--r--src/network/networkd-network-gperf.gperf10
4 files changed, 19 insertions, 43 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index cf83da47f4..78c8a3f043 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -48,7 +48,6 @@ int address_new(Address **ret) {
.cinfo.ifa_prefered = CACHE_INFO_INFINITY_LIFE_TIME,
.cinfo.ifa_valid = CACHE_INFO_INFINITY_LIFE_TIME,
.duplicate_address_detection = ADDRESS_FAMILY_IPV6,
- .prefix_route = true,
};
*ret = TAKE_PTR(address);
@@ -754,6 +753,7 @@ static int address_acquire(Link *link, Address *original, Address **ret) {
if (r < 0)
return r;
+ na->flags = original->flags;
na->family = original->family;
na->prefixlen = original->prefixlen;
na->scope = original->scope;
@@ -787,6 +787,7 @@ int address_configure(
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
Address *acquired_address, *a;
+ uint32_t flags;
int r;
assert(address);
@@ -829,29 +830,13 @@ int address_configure(
if (r < 0)
return log_link_error_errno(link, r, "Could not set prefixlen: %m");
- address->flags |= IFA_F_PERMANENT;
-
- if (address->home_address)
- address->flags |= IFA_F_HOMEADDRESS;
-
- if (!FLAGS_SET(address->duplicate_address_detection, ADDRESS_FAMILY_IPV6))
- address->flags |= IFA_F_NODAD;
-
- if (address->manage_temporary_address)
- address->flags |= IFA_F_MANAGETEMPADDR;
-
- if (!address->prefix_route)
- address->flags |= IFA_F_NOPREFIXROUTE;
-
- if (address->autojoin)
- address->flags |= IFA_F_MCAUTOJOIN;
-
- r = sd_rtnl_message_addr_set_flags(req, (address->flags & 0xff));
+ flags = address->flags | IFA_F_PERMANENT;
+ r = sd_rtnl_message_addr_set_flags(req, flags & 0xff);
if (r < 0)
return log_link_error_errno(link, r, "Could not set flags: %m");
- if (address->flags & ~0xff) {
- r = sd_netlink_message_append_u32(req, IFA_FLAGS, address->flags);
+ if (flags & ~0xff) {
+ r = sd_netlink_message_append_u32(req, IFA_FLAGS, flags);
if (r < 0)
return log_link_error_errno(link, r, "Could not set extended flags: %m");
}
@@ -1707,18 +1692,10 @@ int config_parse_address_flags(
return 0;
}
- if (streq(lvalue, "HomeAddress"))
- n->home_address = r;
- else if (streq(lvalue, "ManageTemporaryAddress"))
- n->manage_temporary_address = r;
- else if (streq(lvalue, "PrefixRoute"))
- n->prefix_route = !r;
- else if (streq(lvalue, "AddPrefixRoute"))
- n->prefix_route = r;
- else if (streq(lvalue, "AutoJoin"))
- n->autojoin = r;
- else
- assert_not_reached("Invalid address flag type.");
+ if (streq(lvalue, "AddPrefixRoute"))
+ r = !r;
+
+ SET_FLAG(n->flags, ltype, r);
n = NULL;
return 0;
@@ -1852,6 +1829,9 @@ static int address_section_verify(Address *address) {
if (!address->scope_set && in_addr_is_localhost(address->family, &address->in_addr) > 0)
address->scope = RT_SCOPE_HOST;
+ if (!FLAGS_SET(address->duplicate_address_detection, ADDRESS_FAMILY_IPV6))
+ address->flags |= IFA_F_NODAD;
+
return 0;
}
diff --git a/src/network/networkd-address.h b/src/network/networkd-address.h
index ec1f51927e..e935b6ffa9 100644
--- a/src/network/networkd-address.h
+++ b/src/network/networkd-address.h
@@ -38,10 +38,6 @@ typedef struct Address {
bool scope_set:1;
bool ip_masquerade_done:1;
- bool manage_temporary_address:1;
- bool home_address:1;
- bool prefix_route:1;
- bool autojoin:1;
AddressFamily duplicate_address_detection;
/* Called when address become ready */
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index d4a8f98570..ed4d7c34e4 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -815,7 +815,7 @@ static int dhcp4_update_address(Link *link, bool announce) {
addr->cinfo.ifa_valid = lifetime;
addr->prefixlen = prefixlen;
addr->broadcast.s_addr = address.s_addr | ~netmask.s_addr;
- addr->prefix_route = link_prefixroute(link);
+ SET_FLAG(addr->flags, IFA_F_NOPREFIXROUTE, !link_prefixroute(link));
/* allow reusing an existing address and simply update its lifetime
* in case it already exists */
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index a5680adc16..21d2e820e9 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -131,11 +131,11 @@ Address.Peer, config_parse_address,
Address.Broadcast, config_parse_broadcast, 0, 0
Address.Label, config_parse_label, 0, 0
Address.PreferredLifetime, config_parse_lifetime, 0, 0
-Address.HomeAddress, config_parse_address_flags, 0, 0
-Address.ManageTemporaryAddress, config_parse_address_flags, 0, 0
-Address.PrefixRoute, config_parse_address_flags, 0, 0 /* deprecated */
-Address.AddPrefixRoute, config_parse_address_flags, 0, 0
-Address.AutoJoin, config_parse_address_flags, 0, 0
+Address.HomeAddress, config_parse_address_flags, IFA_F_HOMEADDRESS, 0
+Address.ManageTemporaryAddress, config_parse_address_flags, IFA_F_MANAGETEMPADDR, 0
+Address.PrefixRoute, config_parse_address_flags, IFA_F_NOPREFIXROUTE, 0 /* deprecated */
+Address.AddPrefixRoute, config_parse_address_flags, IFA_F_NOPREFIXROUTE, 0
+Address.AutoJoin, config_parse_address_flags, IFA_F_MCAUTOJOIN, 0
Address.DuplicateAddressDetection, config_parse_duplicate_address_detection, 0, 0
Address.Scope, config_parse_address_scope, 0, 0
IPv6AddressLabel.Prefix, config_parse_address_label_prefix, 0, 0