Lines Matching refs:link
98 if (address->link) {
99 set_remove(address->link->addresses, address);
100 set_remove(address->link->addresses_foreign, address);
203 static int address_establish(Address *address, Link *link) {
208 assert(link);
210 masq = link->network &&
211 link->network->ip_masquerade &&
222 log_link_warning_errno(link, r, "Could not enable IP masquerading: %m");
230 static int address_add_internal(Link *link, Set **addresses,
238 assert(link);
260 address->link = link;
270 int address_add_foreign(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret) {
271 return address_add_internal(link, &link->addresses_foreign, family, in_addr, prefixlen, ret);
274 int address_add(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret) {
278 r = address_get(link, family, in_addr, prefixlen, &address);
281 r = address_add_internal(link, &link->addresses, family, in_addr, prefixlen, &address);
286 r = set_ensure_allocated(&link->addresses, &address_hash_ops);
290 r = set_put(link->addresses, address);
294 set_remove(link->addresses_foreign, address);
311 assert(address->link);
320 log_link_warning_errno(address->link, r, "Failed to disable IP masquerading: %m");
341 if (address->link) {
342 link_update_operstate(address->link);
345 link_check_ready(address->link);
349 in_addr_is_null(AF_INET6, (const union in_addr_union*) &address->link->ipv6ll_address) > 0) {
350 r = link_ipv6ll_gained(address->link, &address->in_addr.in6);
361 Link *link;
367 link = address->link;
372 link_update_operstate(link);
374 if (link && !ready)
375 link_check_ready(link);
380 int address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret) {
383 assert(link);
391 existing = set_get(link->addresses, &address);
397 existing = set_get(link->addresses_foreign, &address);
407 int address_remove(Address *address, Link *link,
414 assert(link);
415 assert(link->ifindex > 0);
416 assert(link->manager);
417 assert(link->manager->rtnl);
419 r = sd_rtnl_message_new_addr(link->manager->rtnl, &req, RTM_DELADDR,
420 link->ifindex, address->family);
435 r = sd_netlink_call_async(link->manager->rtnl, req, callback, link, 0, NULL);
439 link_ref(link);
444 static int address_acquire(Link *link, Address *original, Address **ret) {
450 assert(link);
460 r = manager_address_pool_acquire(link->manager, original->family, original->prefixlen, &in_addr);
462 return log_link_error_errno(link, r, "Failed to acquire address from pool: %m");
464 log_link_error(link, "Couldn't find free address for interface, all taken.");
495 LIST_PREPEND(addresses, link->pool_addresses, na);
503 int address_configure(Address *address, Link *link, sd_netlink_message_handler_t callback, bool update) {
509 assert(link);
510 assert(link->ifindex > 0);
511 assert(link->manager);
512 assert(link->manager->rtnl);
514 r = address_acquire(link, address, &address);
519 r = sd_rtnl_message_new_addr_update(link->manager->rtnl, &req,
520 link->ifindex, address->family);
522 r = sd_rtnl_message_new_addr(link->manager->rtnl, &req, RTM_NEWADDR,
523 link->ifindex, address->family);
580 r = address_establish(address, link);
584 r = sd_netlink_call_async(link->manager->rtnl, req, callback, link, 0, NULL);
590 link_ref(link);
592 r = address_add(link, address->family, &address->in_addr, address->prefixlen, NULL);