aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoltan Kiss <zoltan.kiss@linaro.org>2016-04-14 13:06:09 +0100
committerZoltan Kiss <zoltan.kiss@linaro.org>2016-04-14 13:14:16 +0100
commitb8ae1737876d5eaef6e498fda332580e38f28df9 (patch)
tree3f6d419292e4fe02a4bb6be6871f02cba32900cb
parent8f98714b1bd818aaf97da0dfc338d963f3aec143 (diff)
downloadodp-ovs-b8ae1737876d5eaef6e498fda332580e38f28df9.tar.gz
netdev-odp: handle MAC address get and set
The current code is copied from OVS-DPDK, and it just sets a dumb value, which was never even initialized to the real address. This patch queries the real address, and fails if you try to set something else, as it is not supported by ODP. Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> Reported-by: Sudeep Kgoyal <sudeep.kgoyal@tcs.com>
-rw-r--r--lib/netdev-odp.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c
index d29147056..fc09b707d 100644
--- a/lib/netdev-odp.c
+++ b/lib/netdev-odp.c
@@ -72,7 +72,6 @@ struct netdev_odp {
struct ovs_mutex mutex OVS_ACQ_AFTER(odp_mutex);
- struct eth_addr hwaddr;
enum netdev_flags flags;
struct netdev_stats stats;
@@ -382,15 +381,18 @@ netdev_odp_set_etheraddr(struct netdev *netdev,
const struct eth_addr mac)
{
struct netdev_odp *dev = netdev_odp_cast(netdev);
+ int ret;
+ struct eth_addr odp_mac;
ovs_mutex_lock(&dev->mutex);
- if (!eth_addr_equals(dev->hwaddr, mac)) {
- dev->hwaddr = mac;
- netdev_change_seq_changed(netdev);
- }
+ ret = odp_pktio_mac_addr(dev->pktio, (void*)&odp_mac, sizeof(odp_mac));
+ if (ret == sizeof(struct eth_addr) && eth_addr_equals(odp_mac, mac))
+ ret = 0;
+ else
+ ret = -1;
ovs_mutex_unlock(&dev->mutex);
- return 0;
+ return ret;
}
static int
@@ -398,12 +400,13 @@ netdev_odp_get_etheraddr(const struct netdev *netdev,
struct eth_addr *mac)
{
struct netdev_odp *dev = netdev_odp_cast(netdev);
+ int ret;
ovs_mutex_lock(&dev->mutex);
- *mac = dev->hwaddr;
+ ret = odp_pktio_mac_addr(dev->pktio, (void*)mac, sizeof(*mac));
ovs_mutex_unlock(&dev->mutex);
- return 0;
+ return ret < 0 ? -1 : 0;
}
static int