link-config.c revision 92d927f850d4b668b44f3e5f41e266d934d03726
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic const char* const link_dirs[] = {
8300ba218e3cf5049496937be8bce10f22d09bbcTom GundersenDEFINE_TRIVIAL_CLEANUP_FUNC(link_config_ctx*, link_config_ctx_free);
8300ba218e3cf5049496937be8bce10f22d09bbcTom Gundersen#define _cleanup_link_config_ctx_free_ _cleanup_(link_config_ctx_freep)
if (!ret)
return -EINVAL;
if (!ctx)
return -ENOMEM;
if (!ctx)
if (!ctx)
if (!file) {
return -errno;
if (!link)
return log_oom();
static bool enable_name_policy(void) {
char *w, *state;
size_t l;
char **files, **f;
if (!enable_name_policy()) {
NULL)) {
return -ENOENT;
unsigned type;
if (want_random)
int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_device *device, const char **name) {
const char *old_name;
int r, ifindex;
if (!old_name)
return -EINVAL;
strerror(-r));
if (ifindex <= 0) {
return -ENODEV;
switch (*policy) {
case NAMEPOLICY_DATABASE:
case NAMEPOLICY_ONBOARD:
case NAMEPOLICY_SLOT:
case NAMEPOLICY_PATH:
case NAMEPOLICY_MAC:
if (new_name)
case MACPOLICY_PERSISTENT:
case MACPOLICY_RANDOM:
const char *name;
char *driver;
if (!name)
return -EINVAL;
DEFINE_CONFIG_PARSE_ENUM(config_parse_mac_policy, mac_policy, MACPolicy, "Failed to parse MAC address policy");
DEFINE_CONFIG_PARSE_ENUMV(config_parse_name_policy, name_policy, NamePolicy, _NAMEPOLICY_INVALID, "Failed to parse interface name policy");