Skip to content

Commit ca97e7c

Browse files
committed
network: do not serialize/deserialize ipv4ll address
The link state file is always removed on stop. So, we cannot deserialize the address from the file. Moreover, currently the IPv4 link-local address is always dropped by link_drop_foreign_addresses() on restart. Let's drop the serialize/deserialize logic for IPv4 LL address.
1 parent 778c879 commit ca97e7c

File tree

3 files changed

+11
-82
lines changed

3 files changed

+11
-82
lines changed

src/network/networkd-ipv4ll.c

Lines changed: 9 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,6 @@ static void ipv4ll_handler(sd_ipv4ll *ll, int event, void *userdata) {
142142
}
143143
}
144144

145-
static int ipv4ll_init(Link *link) {
146-
int r;
147-
148-
assert(link);
149-
150-
if (link->ipv4ll)
151-
return 0;
152-
153-
r = sd_ipv4ll_new(&link->ipv4ll);
154-
if (r < 0)
155-
return r;
156-
157-
r = sd_ipv4ll_attach_event(link->ipv4ll, link->manager->event, 0);
158-
if (r < 0)
159-
return r;
160-
161-
return 0;
162-
}
163-
164145
int ipv4ll_configure(Link *link) {
165146
uint64_t seed;
166147
int r;
@@ -170,9 +151,15 @@ int ipv4ll_configure(Link *link) {
170151
if (!link_ipv4ll_enabled(link, ADDRESS_FAMILY_IPV4 | ADDRESS_FAMILY_FALLBACK_IPV4))
171152
return 0;
172153

173-
r = ipv4ll_init(link);
174-
if (r < 0)
175-
return r;
154+
if (!link->ipv4ll) {
155+
r = sd_ipv4ll_new(&link->ipv4ll);
156+
if (r < 0)
157+
return r;
158+
159+
r = sd_ipv4ll_attach_event(link->ipv4ll, link->manager->event, 0);
160+
if (r < 0)
161+
return r;
162+
}
176163

177164
if (link->sd_device &&
178165
net_get_unique_predictable_data(link->sd_device, true, &seed) >= 0) {
@@ -224,52 +211,6 @@ int ipv4ll_update_mac(Link *link) {
224211
return 0;
225212
}
226213

227-
int link_serialize_ipv4ll(Link *link, FILE *f) {
228-
struct in_addr address;
229-
int r;
230-
231-
assert(link);
232-
233-
if (!link->ipv4ll)
234-
return 0;
235-
236-
r = sd_ipv4ll_get_address(link->ipv4ll, &address);
237-
if (r == -ENOENT)
238-
return 0;
239-
if (r < 0)
240-
return r;
241-
242-
fputs("IPV4LL_ADDRESS=", f);
243-
serialize_in_addrs(f, &address, 1, false, NULL);
244-
fputc('\n', f);
245-
246-
return 0;
247-
}
248-
249-
int link_deserialize_ipv4ll(Link *link, const char *ipv4ll_address) {
250-
union in_addr_union address;
251-
int r;
252-
253-
assert(link);
254-
255-
if (isempty(ipv4ll_address))
256-
return 0;
257-
258-
r = in_addr_from_string(AF_INET, ipv4ll_address, &address);
259-
if (r < 0)
260-
return log_link_debug_errno(link, r, "Failed to parse IPv4LL address: %s", ipv4ll_address);
261-
262-
r = ipv4ll_init(link);
263-
if (r < 0)
264-
return log_link_debug_errno(link, r, "Failed to initialize IPv4LL client: %m");
265-
266-
r = sd_ipv4ll_set_address(link->ipv4ll, &address.in);
267-
if (r < 0)
268-
return log_link_debug_errno(link, r, "Failed to set initial IPv4LL address %s: %m", ipv4ll_address);
269-
270-
return 0;
271-
}
272-
273214
int config_parse_ipv4ll(
274215
const char* unit,
275216
const char *filename,

src/network/networkd-ipv4ll.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ typedef struct Link Link;
99

1010
int ipv4ll_configure(Link *link);
1111
int ipv4ll_update_mac(Link *link);
12-
int link_serialize_ipv4ll(Link *link, FILE *f);
13-
int link_deserialize_ipv4ll(Link *link, const char *ipv4ll_address);
1412

1513
CONFIG_PARSER_PROTOTYPE(config_parse_ipv4ll);

src/network/networkd-link.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,17 +2414,15 @@ int link_initialized(Link *link, sd_device *device) {
24142414
static int link_load(Link *link) {
24152415
_cleanup_free_ char *network_file = NULL,
24162416
*addresses = NULL,
2417-
*routes = NULL,
2418-
*ipv4ll_address = NULL;
2417+
*routes = NULL;
24192418
int r;
24202419

24212420
assert(link);
24222421

24232422
r = parse_env_file(NULL, link->state_file,
24242423
"NETWORK_FILE", &network_file,
24252424
"ADDRESSES", &addresses,
2426-
"ROUTES", &routes,
2427-
"IPV4LL_ADDRESS", &ipv4ll_address);
2425+
"ROUTES", &routes);
24282426
if (r < 0 && r != -ENOENT)
24292427
return log_link_error_errno(link, r, "Failed to read %s: %m", link->state_file);
24302428

@@ -2461,10 +2459,6 @@ static int link_load(Link *link) {
24612459
if (r < 0)
24622460
log_link_warning_errno(link, r, "Failed to load routes from %s, ignoring: %m", link->state_file);
24632461

2464-
r = link_deserialize_ipv4ll(link, ipv4ll_address);
2465-
if (r < 0)
2466-
log_link_warning_errno(link, r, "Failed to load IPv4LL address from %s, ignoring: %m", link->state_file);
2467-
24682462
return 0;
24692463
}
24702464

@@ -3170,10 +3164,6 @@ int link_save(Link *link) {
31703164
} else
31713165
(void) unlink(link->lease_file);
31723166

3173-
r = link_serialize_ipv4ll(link, f);
3174-
if (r < 0)
3175-
goto fail;
3176-
31773167
r = link_serialize_dhcp6_client(link, f);
31783168
if (r < 0)
31793169
goto fail;

0 commit comments

Comments
 (0)