}
static int
-netdev_dpdk_process_devargs(const char *devargs)
+netdev_dpdk_process_devargs(const char *devargs, char **errp)
{
uint8_t new_port_id = UINT8_MAX;
VLOG_INFO("Device '%s' attached to DPDK", devargs);
} else {
/* Attach unsuccessful */
- VLOG_INFO("Error attaching device '%s' to DPDK", devargs);
+ VLOG_WARN_BUF(errp, "Error attaching device '%s' to DPDK", devargs);
return -1;
}
}
}
static int
-netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args)
+netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args,
+ char **errp)
{
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
bool rx_fc_en, tx_fc_en, autoneg;
* is valid */
if (!(dev->devargs && !strcmp(dev->devargs, new_devargs)
&& rte_eth_dev_is_valid_port(dev->port_id))) {
- int new_port_id = netdev_dpdk_process_devargs(new_devargs);
+ int new_port_id = netdev_dpdk_process_devargs(new_devargs, errp);
if (!rte_eth_dev_is_valid_port(new_port_id)) {
err = EINVAL;
} else if (new_port_id == dev->port_id) {
struct netdev_dpdk *dup_dev;
dup_dev = netdev_dpdk_lookup_by_port_id(new_port_id);
if (dup_dev) {
- VLOG_WARN("'%s' is trying to use device '%s' which is "
- "already in use by '%s'.",
- netdev_get_name(netdev), new_devargs,
- netdev_get_name(&dup_dev->up));
+ VLOG_WARN_BUF(errp, "'%s' is trying to use device '%s' "
+ "which is already in use by '%s'",
+ netdev_get_name(netdev), new_devargs,
+ netdev_get_name(&dup_dev->up));
err = EADDRINUSE;
} else {
int sid = rte_eth_dev_socket_id(new_port_id);
}
}
} else {
- /* dpdk-devargs unspecified - can't configure device */
+ VLOG_WARN_BUF(errp, "'%s' is missing 'options:dpdk-devargs'. "
+ "The old 'dpdk<port_id>' names are not supported",
+ netdev_get_name(netdev));
err = EINVAL;
}
}
static int
-netdev_dpdk_ring_set_config(struct netdev *netdev, const struct smap *args)
+netdev_dpdk_ring_set_config(struct netdev *netdev, const struct smap *args,
+ char **errp OVS_UNUSED)
{
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
static int
netdev_dpdk_vhost_client_set_config(struct netdev *netdev,
- const struct smap *args)
+ const struct smap *args,
+ char **errp OVS_UNUSED)
{
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
const char *path;
#include "netdev-native-tnl.h"
#include "netdev-provider.h"
#include "netdev-vport-private.h"
+#include "openvswitch/dynamic-string.h"
#include "ovs-router.h"
#include "packets.h"
#include "poll-loop.h"
}
static int
-set_tunnel_config(struct netdev *dev_, const struct smap *args)
+set_tunnel_config(struct netdev *dev_, const struct smap *args, char **errp)
{
struct netdev_vport *dev = netdev_vport_cast(dev_);
const char *name = netdev_get_name(dev_);
const char *type = netdev_get_type(dev_);
+ struct ds errors = DS_EMPTY_INITIALIZER;
bool needs_dst_port, has_csum;
uint16_t dst_proto = 0, src_proto = 0;
struct netdev_tunnel_config tnl_cfg;
struct smap_node *node;
+ int err;
has_csum = strstr(type, "gre") || strstr(type, "geneve") ||
strstr(type, "stt") || strstr(type, "vxlan");
SMAP_FOR_EACH (node, args) {
if (!strcmp(node->key, "remote_ip")) {
- int err;
err = parse_tunnel_ip(node->value, false, &tnl_cfg.ip_dst_flow,
&tnl_cfg.ipv6_dst, &dst_proto);
switch (err) {
case ENOENT:
- VLOG_WARN("%s: bad %s 'remote_ip'", name, type);
+ ds_put_format(&errors, "%s: bad %s 'remote_ip'\n", name, type);
break;
case EINVAL:
- VLOG_WARN("%s: multicast remote_ip=%s not allowed",
- name, node->value);
- return EINVAL;
+ ds_put_format(&errors,
+ "%s: multicast remote_ip=%s not allowed\n",
+ name, node->value);
+ goto out;
}
} else if (!strcmp(node->key, "local_ip")) {
- int err;
err = parse_tunnel_ip(node->value, true, &tnl_cfg.ip_src_flow,
&tnl_cfg.ipv6_src, &src_proto);
switch (err) {
case ENOENT:
- VLOG_WARN("%s: bad %s 'local_ip'", name, type);
+ ds_put_format(&errors, "%s: bad %s 'local_ip'\n", name, type);
break;
}
} else if (!strcmp(node->key, "tos")) {
if (*endptr == '\0' && tos == (tos & IP_DSCP_MASK)) {
tnl_cfg.tos = tos;
} else {
- VLOG_WARN("%s: invalid TOS %s", name, node->value);
+ ds_put_format(&errors, "%s: invalid TOS %s\n", name,
+ node->value);
}
}
} else if (!strcmp(node->key, "ttl")) {
if (!strcmp(type, "vxlan") && !strcmp(ext, "gbp")) {
tnl_cfg.exts |= (1 << OVS_VXLAN_EXT_GBP);
} else {
- VLOG_WARN("%s: unknown extension '%s'", name, ext);
+ ds_put_format(&errors, "%s: unknown extension '%s'\n",
+ name, ext);
}
ext = strtok_r(NULL, ",", &save_ptr);
free(str);
} else {
- VLOG_WARN("%s: unknown %s argument '%s'", name, type, node->key);
+ ds_put_format(&errors, "%s: unknown %s argument '%s'\n",
+ name, type, node->key);
}
}
if (!ipv6_addr_is_set(&tnl_cfg.ipv6_dst) && !tnl_cfg.ip_dst_flow) {
- VLOG_ERR("%s: %s type requires valid 'remote_ip' argument",
- name, type);
- return EINVAL;
+ ds_put_format(&errors,
+ "%s: %s type requires valid 'remote_ip' argument\n",
+ name, type);
+ err = EINVAL;
+ goto out;
}
if (tnl_cfg.ip_src_flow && !tnl_cfg.ip_dst_flow) {
- VLOG_ERR("%s: %s type requires 'remote_ip=flow' with 'local_ip=flow'",
- name, type);
- return EINVAL;
+ ds_put_format(&errors,
+ "%s: %s type requires 'remote_ip=flow' "
+ "with 'local_ip=flow'\n",
+ name, type);
+ err = EINVAL;
+ goto out;
}
if (src_proto && dst_proto && src_proto != dst_proto) {
- VLOG_ERR("%s: 'remote_ip' and 'local_ip' has to be of the same address family",
- name);
- return EINVAL;
+ ds_put_format(&errors,
+ "%s: 'remote_ip' and 'local_ip' "
+ "has to be of the same address family\n",
+ name);
+ err = EINVAL;
+ goto out;
}
if (!tnl_cfg.ttl) {
tnl_cfg.ttl = DEFAULT_TTL;
}
ovs_mutex_unlock(&dev->mutex);
- return 0;
+ err = 0;
+
+out:
+ ds_chomp(&errors, '\n');
+ VLOG_WARN("%s", ds_cstr(&errors));
+ if (err) {
+ *errp = ds_steal_cstr(&errors);
+ }
+
+ ds_destroy(&errors);
+
+ return err;
}
static int
}
static int
-set_patch_config(struct netdev *dev_, const struct smap *args)
+set_patch_config(struct netdev *dev_, const struct smap *args, char **errp)
{
struct netdev_vport *dev = netdev_vport_cast(dev_);
const char *name = netdev_get_name(dev_);
peer = smap_get(args, "peer");
if (!peer) {
- VLOG_ERR("%s: patch type requires valid 'peer' argument", name);
+ VLOG_ERR_BUF(errp, "%s: patch type requires valid 'peer' argument",
+ name);
return EINVAL;
}
if (smap_count(args) > 1) {
- VLOG_ERR("%s: patch type takes only a 'peer' argument", name);
+ VLOG_ERR_BUF(errp, "%s: patch type takes only a 'peer' argument",
+ name);
return EINVAL;
}
if (!strcmp(name, peer)) {
- VLOG_ERR("%s: patch peer must not be self", name);
+ VLOG_ERR_BUF(errp, "%s: patch peer must not be self", name);
return EINVAL;
}