summaryrefslogtreecommitdiff
path: root/lib/netdev-windows.c
diff options
context:
space:
mode:
authorNithin Raju <nithin@vmware.com>2014-10-28 10:01:22 -0700
committerBen Pfaff <blp@nicira.com>2014-10-28 10:46:07 -0700
commitee4dac3bb6dcef43c51f7ddf3ad954eab4c9ed0f (patch)
tree0152ca32739624f000456a20bb2b8c1042f0f071 /lib/netdev-windows.c
parent30bc81536d74f0dbc9fade5ec469412b22419a3d (diff)
downloadopenvswitch-ee4dac3bb6dcef43c51f7ddf3ad954eab4c9ed0f.tar.gz
netdev-windows: Fix bugs in flag update and MAC address copy functions.
The .update_flags function in netdev-windows was dummy. But we need to return the existing flags for link status to be shown as up in the confdb. There was a bug in copying the MAC address. We fix these two issues in this patch. Signed-off-by: Nithin Raju <nithin@vmware.com> Co-Authored-by: Ankur Sharma <ankursharma@vmware.com> Signed-off-by: Ankur Sharma <ankursharma@vmware.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/netdev-windows.c')
-rw-r--r--lib/netdev-windows.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/lib/netdev-windows.c b/lib/netdev-windows.c
index 75380e4ad..465f0c5c9 100644
--- a/lib/netdev-windows.c
+++ b/lib/netdev-windows.c
@@ -74,7 +74,6 @@ struct netdev_windows_netdev_info {
uint32_t ifi_flags;
};
-static int refresh_port_status(struct netdev_windows *netdev);
static int query_netdev(const char *devname,
struct netdev_windows_netdev_info *reply,
struct ofpbuf **bufp);
@@ -133,6 +132,22 @@ netdev_windows_alloc(void)
return netdev ? &netdev->up : NULL;
}
+static uint32_t
+dp_to_netdev_ifi_flags(uint32_t dp_flags)
+{
+ uint32_t nd_flags = 0;
+
+ if (dp_flags && OVS_WIN_NETDEV_IFF_UP) {
+ nd_flags |= NETDEV_UP;
+ }
+
+ if (dp_flags && OVS_WIN_NETDEV_IFF_PROMISC) {
+ nd_flags |= NETDEV_PROMISC;
+ }
+
+ return nd_flags;
+}
+
static int
netdev_windows_system_construct(struct netdev *netdev_)
{
@@ -160,7 +175,7 @@ netdev_windows_system_construct(struct netdev *netdev_)
netdev->mtu = info.mtu;
netdev->cache_valid |= VALID_MTU;
- netdev->ifi_flags = info.ifi_flags;
+ netdev->ifi_flags = dp_to_netdev_ifi_flags(info.ifi_flags);
netdev->cache_valid |= VALID_IFFLAG;
VLOG_DBG("construct device %s, ovs_type: %u.",
@@ -233,8 +248,8 @@ netdev_windows_netdev_from_ofpbuf(struct netdev_windows_netdev_info *info,
info->port_no = nl_attr_get_odp_port(a[OVS_WIN_NETDEV_ATTR_PORT_NO]);
info->ovs_type = nl_attr_get_u32(a[OVS_WIN_NETDEV_ATTR_TYPE]);
info->name = nl_attr_get_string(a[OVS_WIN_NETDEV_ATTR_NAME]);
- memcpy(info->mac_address, nl_attr_get_string(a[OVS_WIN_NETDEV_ATTR_NAME]),
- sizeof(info->mac_address));
+ memcpy(info->mac_address, nl_attr_get_unspec(a[OVS_WIN_NETDEV_ATTR_MAC_ADDR],
+ sizeof(info->mac_address)), sizeof(info->mac_address));
info->mtu = nl_attr_get_u32(a[OVS_WIN_NETDEV_ATTR_MTU]);
info->ifi_flags = nl_attr_get_u32(a[OVS_WIN_NETDEV_ATTR_IF_FLAGS]);
@@ -338,25 +353,26 @@ netdev_windows_set_etheraddr(const struct netdev *netdev_,
return 0;
}
-/* We do not really have to update anything in kernel. */
-static int
-netdev_win_set_flag(const char *name, uint32_t flags)
-{
- return 0;
-}
-
/* This functionality is not really required by the datapath.
* But vswitchd bringup expects this to be implemented. */
static int
-netdev_win_update_flags_system(struct netdev *netdev_,
- enum netdev_flags off,
- enum netdev_flags on,
- enum netdev_flags *old_flagsp)
+netdev_windows_update_flags(struct netdev *netdev_,
+ enum netdev_flags off,
+ enum netdev_flags on,
+ enum netdev_flags *old_flagsp)
{
+ struct netdev_windows *netdev = netdev_windows_cast(netdev_);
+
+ ovs_assert((netdev->cache_valid & VALID_IFFLAG) != 0);
+ if (netdev->cache_valid & VALID_IFFLAG) {
+ *old_flagsp = netdev->ifi_flags;
+ /* Setting the interface flags is not supported. */
+ } else {
+ return EINVAL;
+ }
return 0;
}
-
static int
netdev_windows_internal_construct(struct netdev *netdev_)
{
@@ -373,7 +389,7 @@ netdev_windows_internal_construct(struct netdev *netdev_)
.dealloc = netdev_windows_dealloc, \
.get_etheraddr = netdev_windows_get_etheraddr, \
.set_etheraddr = netdev_windows_set_etheraddr, \
- .update_flags = netdev_win_update_flags_system, \
+ .update_flags = netdev_windows_update_flags, \
}
const struct netdev_class netdev_windows_class =