networkd-link.c revision 91b5f997316ddc77d26f9a7a5e24c335484586bd
87d2c1ff6a7375f03476767e6f59454bcc5cd04bLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
87d2c1ff6a7375f03476767e6f59454bcc5cd04bLennart Poettering This file is part of systemd.
87d2c1ff6a7375f03476767e6f59454bcc5cd04bLennart Poettering Copyright 2013 Tom Gundersen <teg@jklm.no>
44a6b1b68029833893f6e9cee35aa27a974038f6Zbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
44a6b1b68029833893f6e9cee35aa27a974038f6Zbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
44a6b1b68029833893f6e9cee35aa27a974038f6Zbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
87d2c1ff6a7375f03476767e6f59454bcc5cd04bLennart Poettering (at your option) any later version.
44a6b1b68029833893f6e9cee35aa27a974038f6Zbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
87d2c1ff6a7375f03476767e6f59454bcc5cd04bLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
87d2c1ff6a7375f03476767e6f59454bcc5cd04bLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44a6b1b68029833893f6e9cee35aa27a974038f6Zbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
87d2c1ff6a7375f03476767e6f59454bcc5cd04bLennart Poettering You should have received a copy of the GNU Lesser General Public License
87d2c1ff6a7375f03476767e6f59454bcc5cd04bLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
#include "bus-util.h"
#include "dhcp-lease-internal.h"
#include "fileio.h"
#include "netlink-util.h"
#include "network-internal.h"
#include "set.h"
#include "socket-util.h"
#include "udev-util.h"
#include "util.h"
#include "virt.h"
#include "networkd-link.h"
#include "networkd-netdev.h"
return _IPV6_PRIVACY_EXTENSIONS_INVALID;
return _IPV6_PRIVACY_EXTENSIONS_INVALID;
if (unknown_flags_added)
const char *ifname;
int r, ifindex;
return -EINVAL;
else if (ifindex <= 0)
return -EINVAL;
if (!link)
return -ENOMEM;
return -ENOMEM;
return -ENOMEM;
return -ENOMEM;
return -ENOMEM;
Iterator i;
if (!link)
if (!link)
return NULL;
return NULL;
return NULL;
if (!link)
return NULL;
return link;
assert(m);
if (!link)
return -ENODEV;
return address;
return address;
return NULL;
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -EEXIST)
assert(m);
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -ESRCH)
assert(m);
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -EEXIST)
return log_oom();
return log_oom();
n_addresses += n;
if (n_addresses <= 0)
return log_oom();
return log_oom();
n_addresses += n;
if (n_addresses <= 0)
bool acquired_uplink = false;
if (!address) {
r = sd_dhcp_server_set_dns(link->dhcp_server, link->network->dhcp_server_dns, link->network->n_dhcp_server_dns);
acquired_uplink = true;
if (!uplink) {
log_link_debug(link, "Not emitting DNS server information on link, couldn't find suitable uplink.");
r = sd_dhcp_server_set_ntp(link->dhcp_server, link->network->dhcp_server_ntp, link->network->n_dhcp_server_ntp);
if (!acquired_uplink)
if (!uplink) {
log_link_debug(link, "Not emitting NTP server information on link, couldn't find suitable uplink.");
if (tz) {
assert(m);
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -EADDRNOTAVAIL)
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
const sd_bus_error *e;
assert(m);
e = sd_bus_message_get_error(m);
NULL,
"org.freedesktop.hostname1",
"/org/freedesktop/hostname1",
"org.freedesktop.hostname1",
link,
const sd_bus_error *e;
assert(m);
e = sd_bus_message_get_error(m);
NULL,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
link,
tz,
assert(m);
r = sd_netlink_message_get_errno(m);
switch (event) {
/* see Documentation/networking/operstates.txt in the kernel sources */
r = sd_netlink_message_get_errno(m);
if (socket_ipv6_is_supported()) {
r = sd_netlink_message_get_errno(m);
Link *l;
Iterator i;
bool required_up = false;
bool link_is_up = false;
link_is_up = true;
if (link_has_carrier(l)) {
required_up = true;
Iterator i;
Link *l;
r = link_handle_bound_to_list(l);
Manager *m;
Iterator i;
bool list_updated = false;
list_updated = true;
if (list_updated)
Manager *m;
Iterator i;
bool list_updated = false;
list_updated = true;
if (list_updated)
Iterator i;
Iterator i;
bool list_updated = false;
list_updated = true;
list_updated = true;
if (list_updated)
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
Iterator i;
NULL);
NULL);
NULL);
NULL),
NULL);
NULL);
const char *p = NULL, *v;
r = write_string_file(p, v, 0);
if (verify_one_line_file(p, v) > 0)
log_link_warning_errno(link, r, "Cannot configure IPv4 forwarding for interface %s: %m", link->ifname);
if (!socket_ipv6_is_supported())
r = write_string_file(p, v, 0);
if (verify_one_line_file(p, v) > 0)
const char *p = NULL;
if (!socket_ipv6_is_supported())
if (s == _IPV6_PRIVACY_EXTENSIONS_INVALID)
if (!socket_ipv6_is_supported())
r = write_string_file(p, v, 0);
if (verify_one_line_file(p, v) > 0)
void *userdata) {
if (r == -ENOENT) {
assert(m);
if (detect_container() <= 0) {
if (!device) {
goto failed;
goto failed;
goto failed;
const char *ifname;
assert(m);
if (r >= 0 && mtu > 0) {
ETH_ALEN)) {
ETH_ALEN);
if (carrier_gained) {
} else if (carrier_lost) {
Iterator i;
goto fail;
fprintf(f,
bool space;
&dhcp6_lease);
space = false;
if (space)
space = true;
if (space)
space = true;
if (space)
space = false;
if (space)
space = true;
if (space)
space = true;
char **hosts;
char **hostname;
&in6_addrs);
if (space)
space = true;
if (space)
space = true;
space = false;
if (space)
space = true;
const char *domainname;
if (space)
space = true;
char **domains;
if (space)
space = true;
Iterator i;
bool space = false;
if (space)
space = true;
Iterator i;
bool space = false;
if (space)
space = true;
goto fail;
fprintf(f,
goto fail;
fprintf(f,
r = fflush_and_check(f);
goto fail;
r = -errno;
goto fail;
fail:
if (temp_path)