networkd-link.c revision f5be560181d092c5f52a2b819aedcd48220f36ab
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Tom Gundersen <teg@jklm.no>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "networkd.h"
#include "libudev-private.h"
#include "util.h"
const char *mac;
struct ether_addr *mac_addr;
const char *ifname;
int r;
if (!link)
return -ENOMEM;
return -EINVAL;
if (mac) {
if (mac_addr)
}
if (r < 0)
return r;
return 0;
}
if (!link)
return;
}
int r;
const char *devtype;
assert(m);
if (link)
return 0;
if (r < 0) {
return r;
}
r = bridge_set_link(m, link);
if (r < 0)
return r == -ENOENT ? 0 : r;
}
if (r < 0)
return r == -ENOENT ? 0 : r;
if (r < 0)
return r;
return 0;
}
return 0;
}
}
int r;
link->route_messages --;
return 1;
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
log_warning("Could not set route on interface '%s': %s",
/* we might have received an old reply after moving back to SETTING_ADDRESSES,
* ignore it */
}
return 1;
}
int r;
return link_enter_configured(link);
if (r < 0) {
return r;
}
link->route_messages ++;
}
if (link->dhcp_route) {
if (r < 0) {
return r;
}
link->route_messages ++;
}
return 0;
}
int r;
assert(m);
link->addr_messages --;
return 1;
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
log_warning("Could not set address on interface '%s': %s",
if (link->addr_messages == 0) {
}
return 1;
}
int r;
return link_enter_set_routes(link);
if (r < 0) {
return r;
}
link->addr_messages ++;
}
if (link->dhcp_address) {
if (r < 0) {
return r;
}
link->addr_messages ++;
}
return 0;
}
int r;
r = sd_rtnl_message_get_errno(m);
if (r < 0) {
log_warning("Could not bring up interface '%s': %s",
}
return 1;
}
int r;
if (r < 0) {
log_error("Could not allocate RTM_SETLINK message");
return r;
}
if (r < 0) {
log_error("Could not set link flags");
return r;
}
if (r < 0) {
return r;
}
return 0;
}
int r;
if (r < 0) {
return r;
}
r = link_enter_set_addresses(link);
if (r < 0)
return r;
}
return 0;
}
int r;
return 1;
r = sd_rtnl_message_get_errno(m);
if (r < 0) {
log_warning("Could not join interface '%s' to bridge '%s': %s",
return 1;
} else
log_info("Join interface '%s' to bridge: %s",
return 1;
}
int r;
return link_bridge_joined(link);
if (r < 0) {
return r;
}
return 0;
}
int r;
r = sd_rtnl_message_get_errno(m);
if (r < 0) {
log_warning("Could not get state of interface '%s': %s",
}
return 1;
}
int r;
if (r < 0) {
log_error("Could not allocate RTM_GETLINK message");
return r;
}
if (r < 0) {
return r;
}
return 0;
}
int r;
if (r < 0) {
return r;
}
r = link_enter_join_bridge(link);
if (r < 0)
return r;
return 0;
}
int r;
assert(m);
return 1;
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
log_warning("Could not drop address from interface '%s': %s",
return 1;
}
int prefixlen;
int r;
return;
if (event < 0) {
return;
}
if (event == DHCP_EVENT_NO_LEASE)
log_info("IP address in use.");
event == DHCP_EVENT_STOP) {
}
if (r < 0) {
log_warning("DHCP error: no address");
return;
}
if (r < 0) {
log_warning("DHCP error: no netmask");
return;
}
if (prefixlen < 0) {
log_warning("DHCP error: no prefixlen");
return;
}
if (r < 0) {
log_warning("DHCP error: no router");
return;
}
log_info("Received config over DHCPv4");
r = address_new_dynamic(&addr);
if (r < 0) {
log_error("Could not allocate address");
return;
}
r = route_new_dynamic(&rt);
if (r < 0) {
log_error("Could not allocate route");
return;
}
}
return;
}
int r;
return -ENOMEM;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
}
if (r < 0)
return r;
return 0;
}
unsigned flags;
int r;
assert(m);
r = sd_rtnl_message_link_get_flags(m, &flags);
if (r < 0) {
return r;
}
if (r < 0) {
return r;
}
}
r = link_acquire_conf(link);
if (r < 0) {
return r;
}
}
}
return 0;
}