link-config.c revision 32bc8adcd836baff68e4d0f53b9a382f358cccf8
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 PoetteringDEFINE_TRIVIAL_CLEANUP_FUNC(link_config_ctx*, link_config_ctx_free);
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering#define _cleanup_link_config_ctx_free_ _cleanup_(link_config_ctx_freep)
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poetteringint link_config_ctx_new(link_config_ctx **ret) {
d0767ffd08bbb5c069e266710eb0462315e47e6dLennart Poettering _cleanup_link_config_ctx_free_ link_config_ctx *ctx = NULL;
return -ENOMEM;
if (!ctx)
if (!ctx)
if (!file) {
return -errno;
if (!link)
return log_oom();
false, false, true, link);
static bool enable_name_policy(void) {
size_t l;
if (!enable_name_policy()) {
const char* attr_value;
if (attr_value)
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)
const char *name;
char *driver;
if (!name)
return -EINVAL;