Skip to content

Commit

Permalink
netdev-windows: New module.
Browse files Browse the repository at this point in the history
In this patch, we add a lib/netdev-windows.c which mostly contains stub
code and in subsequent patches, would use the netlink interface to query
netdev information for a vport.

The code implements netdev functionality for "internal" and "system"
types of vports.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-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>
  • Loading branch information
nithinrajub authored and blp committed Oct 6, 2014
1 parent 83cc9d5 commit 078eedf
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/automake.mk
Expand Up @@ -334,6 +334,7 @@ if WIN32
lib_libopenvswitch_la_SOURCES += \
lib/dpif-netlink.c \
lib/dpif-netlink.h \
lib/netdev-windows.c \
lib/netlink-notifier.c \
lib/netlink-notifier.h \
lib/netlink-protocol.h \
Expand Down
9 changes: 6 additions & 3 deletions lib/netdev-provider.h
Expand Up @@ -705,12 +705,15 @@ struct netdev_class {
int netdev_register_provider(const struct netdev_class *);
int netdev_unregister_provider(const char *type);

extern const struct netdev_class netdev_linux_class;
extern const struct netdev_class netdev_internal_class;
extern const struct netdev_class netdev_tap_class;
#if defined(__FreeBSD__) || defined(__NetBSD__)
extern const struct netdev_class netdev_bsd_class;
#elif defined(_WIN32)
extern const struct netdev_class netdev_windows_class;
#else
extern const struct netdev_class netdev_linux_class;
#endif
extern const struct netdev_class netdev_internal_class;
extern const struct netdev_class netdev_tap_class;

#ifdef __cplusplus
}
Expand Down
137 changes: 137 additions & 0 deletions lib/netdev-windows.c
@@ -0,0 +1,137 @@
/*
* Copyright (c) 2014 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <stdlib.h>
#include <config.h>
#include <errno.h>

#include <net/if.h>

#include "coverage.h"
#include "fatal-signal.h"
#include "netdev-provider.h"
#include "ofpbuf.h"
#include "poll-loop.h"
#include "shash.h"
#include "svec.h"
#include "vlog.h"
#include "odp-netlink.h"
#include "netlink-socket.h"
#include "netlink.h"

VLOG_DEFINE_THIS_MODULE(netdev_windows);
static struct vlog_rate_limit error_rl = VLOG_RATE_LIMIT_INIT(9999, 5);

enum {
VALID_ETHERADDR = 1 << 0,
VALID_MTU = 1 << 1,
VALID_IFFLAG = 1 << 5,
};

/* Caches the information of a netdev. */
struct netdev_windows {
struct netdev up;
int32_t dev_type;
uint32_t port_no;

unsigned int change_seq;

unsigned int cache_valid;
int ifindex;
uint8_t mac[ETH_ADDR_LEN];
uint32_t mtu;
unsigned int ifi_flags;
};

/* Utility structure for netdev commands. */
struct netdev_windows_netdev_info {
/* Generic Netlink header. */
uint8_t cmd;

/* Information that is relevant to ovs. */
uint32_t dp_ifindex;
uint32_t port_no;
uint32_t ovs_type;

/* General information of a network device. */
const char *name;
uint8_t mac_address[ETH_ADDR_LEN];
uint32_t mtu;
uint32_t ifi_flags;
};

static int
netdev_windows_init(void)
{
return EINVAL;
}

static struct netdev *
netdev_windows_alloc(void)
{
return NULL;
}

static int
netdev_windows_system_construct(struct netdev *netdev_)
{
return EINVAL;
}

static void
netdev_windows_dealloc(struct netdev *netdev_)
{
}

static int
netdev_windows_get_etheraddr(const struct netdev *netdev_, uint8_t mac[6])
{
return EINVAL;
}

static int
netdev_windows_get_mtu(const struct netdev *netdev_, int *mtup)
{
return EINVAL;
}


static int
netdev_windows_internal_construct(struct netdev *netdev_)
{
return netdev_windows_system_construct(netdev_);
}


#define NETDEV_WINDOWS_CLASS(NAME, CONSTRUCT) \
{ \
.type = NAME, \
.init = netdev_windows_init, \
.alloc = netdev_windows_alloc, \
.construct = CONSTRUCT, \
.dealloc = netdev_windows_dealloc, \
.get_etheraddr = netdev_windows_get_etheraddr, \
}

const struct netdev_class netdev_windows_class =
NETDEV_WINDOWS_CLASS(
"system",
netdev_windows_system_construct);

const struct netdev_class netdev_internal_class =
NETDEV_WINDOWS_CLASS(
"internal",
netdev_windows_internal_construct);
5 changes: 5 additions & 0 deletions lib/netdev.c
Expand Up @@ -143,6 +143,11 @@ netdev_initialize(void)
#if defined(__FreeBSD__) || defined(__NetBSD__)
netdev_register_provider(&netdev_tap_class);
netdev_register_provider(&netdev_bsd_class);
#endif
#ifdef _WIN32
netdev_register_provider(&netdev_windows_class);
netdev_register_provider(&netdev_internal_class);
netdev_vport_tunnel_register();
#endif
netdev_dpdk_register();

Expand Down

0 comments on commit 078eedf

Please sign in to comment.