link-config.c revision daeb71a36a98834664e4d95773a3629b746f4db8
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 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 "link-config.h"
#include "ethtool-util.h"
#include "libudev-private.h"
#include "sd-rtnl.h"
#include "util.h"
#include "log.h"
#include "strv.h"
#include "path-util.h"
#include "conf-parser.h"
#include "conf-files.h"
#include "fileio.h"
struct link_config_ctx {
int ethtool_fd;
char **link_dirs;
};
int r;
if (!ret)
return -EINVAL;
if (!ctx)
return -ENOMEM;
if (r < 0) {
return r;
}
if (r < 0) {
return r;
}
NULL);
log_error("failed to build link config directory array");
return -ENOMEM;
}
log_error("failed to canonicalize link config directories\n");
return -ENOMEM;
}
if(!ctx->link_dirs_ts_usec) {
return -ENOMEM;
}
return 0;
}
if (!ctx)
return;
}
}
if (!ctx)
return;
if (ctx->ethtool_fd >= 0)
return;
}
int r;
if (!file) {
return 0;
else
return errno;
}
if (!link) {
r = log_oom();
goto failure;
}
(void*) link_config_gperf_lookup, false, false, link);
if (r < 0) {
goto failure;
} else
return 0;
return r;
}
int r;
char **files, **f;
/* update timestamps */
if (r < 0) {
return r;
}
STRV_FOREACH_BACKWARDS(f, files) {
if (r < 0)
return r;
}
return 0;
}
}
const char *property;
return 0;
}
}
if (match->match_path) {
return 0;
}
}
if (match->match_driver) {
return 0;
}
}
if (match->match_type) {
return 0;
}
}
return 1;
}
log_info("Config file %s does not apply to device %s", link->filename, udev_device_get_sysname(device));
} else {
return 0;
}
}
return -ENOENT;
}
static int rtnl_set_properties(sd_rtnl *rtnl, int ifindex, const char *name, const char *mac, unsigned int mtu) {
struct ether_addr new_mac;
bool need_update;
int r;
if (r < 0)
return r;
if (name) {
if (r < 0)
return r;
need_update = true;
}
if (mac) {
&new_mac.ether_addr_octet[0],
if (r != 6)
return -EINVAL;
if (r < 0)
return r;
need_update = true;
}
if (mtu > 0) {
if (r < 0)
return r;
need_update = true;
}
if (need_update) {
if (r < 0)
return r;
}
return 0;
}
static bool enable_name_policy(void) {
_cleanup_free_ char *line;
char *w, *state;
int r;
size_t l;
if (r < 0) {
return true; /* something is very wrong, let's not make it worse */
}
if (strneq(w, "net.ifnames=0", l))
return false;
return true;
}
int r, ifindex;
if (!name)
return -EINVAL;
if (config->description) {
if (r < 0)
log_warning("Could not set description of %s to '%s': %s",
else
}
if (r < 0)
log_warning("Could not set speed or duplex of %s to %u Mbytes (%s): %s",
else
}
if (r < 0)
log_warning("Could not set WakeOnLan of %s to %s: %s",
else
}
if (ifindex <= 0) {
log_warning("Could not find ifindex");
return -ENODEV;
}
char **policy;
if (new_name)
break;
if (new_name)
break;
if (new_name)
break;
if (new_name)
break;
} else
}
}
if (r < 0) {
return r;
}
return 0;
}