mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 22:35:15 +00:00
netdev: Add 'errp' to set_config().
Since 55e075e65ef9("netdev-dpdk: Arbitrary 'dpdk' port naming"), set_config() is used to identify a DPDK device, so it's better to report its detailed error message to the user. Tunnel devices and patch ports rely a lot on set_config() as well. This commit adds a param to set_config() that can be used to return an error message and makes use of that in netdev-dpdk and netdev-vport. Before this patch: $ ovs-vsctl add-port br0 dpdk0 -- set Interface dpdk0 type=dpdk ovs-vsctl: Error detected while setting up 'dpdk0': dpdk0: could not set configuration (Invalid argument). See ovs-vswitchd log for details. ovs-vsctl: The default log directory is "/var/log/openvswitch/". $ ovs-vsctl add-port br0 p+ -- set Interface p+ type=patch ovs-vsctl: Error detected while setting up 'p+': p+: could not set configuration (Invalid argument). See ovs-vswitchd log for details. ovs-vsctl: The default log directory is "/var/log/openvswitch/". $ ovs-vsctl add-port br0 gnv0 -- set Interface gnv0 type=geneve ovs-vsctl: Error detected while setting up 'gnv0': gnv0: could not set configuration (Invalid argument). See ovs-vswitchd log for details. ovs-vsctl: The default log directory is "/var/log/openvswitch/". After this patch: $ ovs-vsctl add-port br0 dpdk0 -- set Interface dpdk0 type=dpdk ovs-vsctl: Error detected while setting up 'dpdk0': 'dpdk0' is missing 'options:dpdk-devargs'. The old 'dpdk<port_id>' names are not supported. See ovs-vswitchd log for details. ovs-vsctl: The default log directory is "/var/log/openvswitch/". $ ovs-vsctl add-port br0 p+ -- set Interface p+ type=patch ovs-vsctl: Error detected while setting up 'p+': p+: patch type requires valid 'peer' argument. See ovs-vswitchd log for details. ovs-vsctl: The default log directory is "/var/log/openvswitch/". $ ovs-vsctl add-port br0 gnv0 -- set Interface gnv0 type=geneve ovs-vsctl: Error detected while setting up 'gnv0': gnv0: geneve type requires valid 'remote_ip' argument. See ovs-vswitchd log for details. ovs-vsctl: The default log directory is "/var/log/openvswitch/". CC: Ciara Loftus <ciara.loftus@intel.com> CC: Kevin Traynor <ktraynor@redhat.com> Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Acked-by: Kevin Traynor <ktraynor@redhat.com> Tested-by: Ciara Loftus <ciara.loftus@intel.com>
This commit is contained in:
@@ -1132,7 +1132,7 @@ netdev_dpdk_lookup_by_port_id(int port_id)
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -1145,7 +1145,7 @@ netdev_dpdk_process_devargs(const char *devargs)
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1184,7 +1184,8 @@ dpdk_process_queue_size(struct netdev *netdev, const struct smap *args,
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -1225,7 +1226,7 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args)
|
||||
* 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) {
|
||||
@@ -1235,10 +1236,10 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args)
|
||||
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);
|
||||
@@ -1251,7 +1252,9 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args)
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
@@ -1288,7 +1291,8 @@ out:
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -1301,7 +1305,8 @@ netdev_dpdk_ring_set_config(struct netdev *netdev, const struct smap *args)
|
||||
|
||||
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;
|
||||
|
Reference in New Issue
Block a user