int teamd_config_load(struct teamd_context *ctx)
{
	json_error_t jerror;
	size_t jflags = JSON_REJECT_DUPLICATES;

	if (!ctx->config_text && !ctx->config_file) {
		ctx->config_text = strdup(TEAMD_IMPLICIT_CONFIG);
		if (!ctx->config_text)
			return -ENOMEM;
	}
	if (ctx->config_text) {
		if (ctx->config_file)
			teamd_log_warn("Command line config string is present, ignoring given config file.");
		ctx->config_json = json_loads(ctx->config_text, jflags,
					      &jerror);
	} else if (ctx->config_file) {
		ctx->config_json = json_load_file(ctx->config_file, jflags,
						  &jerror);
	}
	if (!ctx->config_json) {
		teamd_log_err("Failed to parse config: %s on line %d, column %d",
			      jerror.text, jerror.line, jerror.column);
		return -EIO;
	}

	return 0;
}
Exemple #2
0
static int teamd_sriov_event_watch_port_added(struct teamd_context *ctx,
					      struct teamd_port *tdport,
					      void *priv)
{
	struct pcie_addr physfnaddr;
	struct pcie_addr cur_physfnaddr;
	struct teamd_port *cur_tdport;
	int err;

	err = teamd_sriov_physfn_addr(&physfnaddr, tdport->ifname);
	if (err)
		return 0;

	teamd_for_each_tdport(cur_tdport, ctx) {
		if (cur_tdport == tdport)
			continue;
		err = teamd_sriov_physfn_addr(&cur_physfnaddr,
					      cur_tdport->ifname);
		if (err)
			continue;
		if (!memcmp(&physfnaddr, &cur_physfnaddr, sizeof(physfnaddr)))
			teamd_log_warn("%s: port is virtual function of same physical function as port %s. Note that teaming virtual functions of the same physical function makes no sense.",
				       tdport->ifname, cur_tdport->ifname);
	}
	return 0;
}
Exemple #3
0
static void usock_send(struct usock_ops_priv *usock_ops_priv,
		       char *buf, size_t buflen)
{
	int ret;

	ret = send(usock_ops_priv->sock, buf, buflen, 0);
	if (ret == -1)
		teamd_log_warn("Usock send failed: %s", strerror(errno));
}
Exemple #4
0
static int handle_period_fd(int fd)
{
	ssize_t ret;
	uint64_t exp;

	ret = read(fd, &exp, sizeof(uint64_t));
	if (ret == -1) {
		if (errno == EINTR || errno == EAGAIN)
			return 0;
		teamd_log_err("read() failed.");
		return -errno;
	}
	if (ret != sizeof(uint64_t)) {
		teamd_log_err("read() returned unexpected number of bytes.");
		return -EINVAL;
	}
	if (exp > 1)
		teamd_log_warn("some periodic function calls missed (%" PRIu64 ")",
			       exp - 1);
	return 0;
}