link-config.c revision 07630cea1f3a845c09309f197ac7c4f11edd3b62
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering This file is part of systemd.
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering systemd is free software; you can redistribute it and/or modify it
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering under the terms of the GNU Lesser General Public License as published by
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering (at your option) any later version.
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering systemd is distributed in the hope that it will be useful, but
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering Lesser General Public License for more details.
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering You should have received a copy of the GNU Lesser General Public License
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poetteringstatic const char* const link_dirs[] = {
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poetteringstatic void link_config_free(link_config *link) {
if (!ctx)
if (!ctx)
if (!ret)
return -EINVAL;
if (!ctx)
return -ENOMEM;
if (!file) {
return -errno;
if (!link)
return log_oom();
false, false, true, link);
return -ERANGE;
static bool enable_name_policy(void) {
size_t l;
if (!enable_name_policy()) {
const char* attr_value;
if (attr_value)
log_warning("Config file %s applies to device based on potentially unpredictable interface name '%s'",
return -ENOENT;
unsigned type;
unsigned type;
switch (type) {
case NET_NAME_USER:
case NET_NAME_RENAMED:
case NET_NAME_PREDICTABLE:
if (respect_predictable)
case NET_NAME_ENUM:
if (want_random)
const char *old_name;
bool respect_predictable = false;
int r, ifindex;
if (!old_name)
return -EINVAL;
if (ifindex <= 0) {
return -ENODEV;
switch (*policy) {
case NAMEPOLICY_KERNEL:
respect_predictable = true;
case NAMEPOLICY_DATABASE:
case NAMEPOLICY_ONBOARD:
case NAMEPOLICY_SLOT:
case NAMEPOLICY_PATH:
case NAMEPOLICY_MAC:
if (!new_name)
case MACPOLICY_PERSISTENT:
if (r == -ENOENT) {
case MACPOLICY_RANDOM:
if (r == -ENOENT) {
case MACPOLICY_NONE:
const char *name;
if (!name)
return -EINVAL;