summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-10-04 01:47:42 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-10-06 19:54:01 +0200
commitcde1f0e8fcf07eec2a19eae89090326dbb565707 (patch)
tree491af8645ea6692859ded9994d0be284b565fc62 /src
parentnetwork: do not update Address::flags in address_configure() (diff)
downloadsystemd-cde1f0e8fcf07eec2a19eae89090326dbb565707.tar.xz
systemd-cde1f0e8fcf07eec2a19eae89090326dbb565707.zip
network: introduce address_copy()
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-address.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 78c8a3f043..89b17d3147 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -215,6 +215,29 @@ bool address_equal(Address *a1, Address *a2) {
return address_compare_func(a1, a2) == 0;
}
+static int address_copy(Address *dest, const Address *src) {
+ int r;
+
+ assert(dest);
+ assert(src);
+
+ r = free_and_strdup(&dest->label, src->label);
+ if (r < 0)
+ return r;
+
+ dest->family = src->family;
+ dest->prefixlen = src->prefixlen;
+ dest->scope = src->scope;
+ dest->flags = src->flags;
+ dest->broadcast = src->broadcast;
+ dest->cinfo = src->cinfo;
+ dest->in_addr = src->in_addr;
+ dest->in_addr_peer = src->in_addr_peer;
+ dest->duplicate_address_detection = src->duplicate_address_detection;
+
+ return 0;
+}
+
static int address_establish(Address *address, Link *link) {
bool masq;
int r;
@@ -753,17 +776,9 @@ 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;
- na->cinfo = original->cinfo;
-
- if (original->label) {
- na->label = strdup(original->label);
- if (!na->label)
- return -ENOMEM;
- }
+ r = address_copy(na, original);
+ if (r < 0)
+ return r;
na->broadcast = broadcast;
na->in_addr = in_addr;