Skip to content

Commit

Permalink
datapath-windows: Define new multicast conntrack events and netlink p…
Browse files Browse the repository at this point in the history
…rotocol

The Hyper-V datapath supports NETLINK_GENERIC and NETLINK_NETFILTER
protocols for netlink communication. Define these two protocols in the
datapath.

Define new Conntrack events (new and delete) and add support for
subscribing to these events. Parse out OVS_NL_ATTR_MCAST_GRP and store it
as part of OVS_EVENT_SUBSCRIBE structure.

Signed-off-by: Sairam Venugopal <[email protected]>
Acked-By: Yin Lin <[email protected]>
Acked-by: Alin Gabriel Serdean <[email protected]>
Signed-off-by: Gurucharan Shetty <[email protected]>
  • Loading branch information
Sairam Venugopal authored and shettyg committed Jul 29, 2016
1 parent 3265452 commit 1f3dd67
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
21 changes: 18 additions & 3 deletions datapath-windows/ovsext/Datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,11 +1273,12 @@ OvsSubscribeEventCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
OVS_EVENT_SUBSCRIBE request;
BOOLEAN rc;
UINT8 join;
UINT32 mcastGrp;
PNL_ATTR attrs[2];
const NL_POLICY policy[] = {
[OVS_NL_ATTR_MCAST_GRP] = {.type = NL_A_U32 },
[OVS_NL_ATTR_MCAST_JOIN] = {.type = NL_A_U8 },
};
};

UNREFERENCED_PARAMETER(replyLen);

Expand All @@ -1293,11 +1294,25 @@ OvsSubscribeEventCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
goto done;
}

/* XXX Ignore the MC group for now */
mcastGrp = NlAttrGetU32(attrs[OVS_NL_ATTR_MCAST_GRP]);
join = NlAttrGetU8(attrs[OVS_NL_ATTR_MCAST_JOIN]);
request.dpNo = msgIn->ovsHdr.dp_ifindex;
request.subscribe = join;
request.mask = OVS_EVENT_MASK_ALL;
request.mcastGrp = mcastGrp;
request.protocol = instance->protocol;
request.mask = 0;

/* We currently support Vport and CT related events */
if (instance->protocol == NETLINK_GENERIC) {
request.mask = OVS_EVENT_MASK_ALL;
} else if (instance->protocol == NETLINK_NETFILTER) {
if (mcastGrp == NFNLGRP_CONNTRACK_NEW) {
request.mask = OVS_EVENT_CT_NEW;
}
if (mcastGrp == NFNLGRP_CONNTRACK_DESTROY) {
request.mask = OVS_EVENT_CT_DELETE;
}
}

status = OvsSubscribeEventIoctl(instance->fileObject, &request,
sizeof request);
Expand Down
3 changes: 2 additions & 1 deletion datapath-windows/ovsext/Datapath.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ typedef struct _OVS_OPEN_INSTANCE {
PVOID eventQueue;
POVS_USER_PACKET_QUEUE packetQueue;
UINT32 pid;
UINT32 protocol; /* Refers to NETLINK Family (eg. NETLINK_GENERIC)*/
UINT32 protocol; /* Refers to NETLINK Family (eg. NETLINK_GENERIC)*/
UINT32 mcastMask; /* Mask of subscribed Mcast Groups */

struct {
POVS_MESSAGE ovsMsg; /* OVS message passed during dump start. */
Expand Down
16 changes: 16 additions & 0 deletions datapath-windows/ovsext/DpInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ typedef struct _OVS_EVENT_SUBSCRIBE {
uint32_t dpNo;
uint32_t subscribe;
uint32_t mask;
uint32_t mcastGrp;
uint32_t protocol;
} OVS_EVENT_SUBSCRIBE, *POVS_EVENT_SUBSCRIBE;

typedef struct _OVS_EVENT_POLL {
Expand All @@ -327,6 +329,20 @@ enum {
OVS_EVENT_MASK_ALL = 0x3f,
};

enum {
OVS_EVENT_CT_NEW = (1 << 0),
OVS_EVENT_CT_DELETE = (1 << 1),
OVS_EVENT_CT_MASK_ALL = 0x3
};

/* Supported mcast event groups */
enum OVS_MCAST_EVENT_TYPES {
OVS_MCAST_VPORT_EVENT,
OVS_MCAST_CT_EVENT,
__OVS_MCAST_EVENT_TYPES_MAX
};
#define OVS_MCAST_EVENT_TYPES_MAX (__OVS_MCAST_EVENT_TYPES_MAX \
- OVS_MCAST_VPORT_EVENT)

typedef struct _OVS_VPORT_EVENT_ENTRY {
UINT32 portNo;
Expand Down
3 changes: 3 additions & 0 deletions datapath-windows/ovsext/Netlink/NetlinkProto.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,7 @@ BUILD_ASSERT_DECL(sizeof(NL_ATTR) == 4);
#define OVS_HDRLEN NLMSG_ALIGN(sizeof(OVS_HDR))
#define NLA_HDRLEN ((INT) NLA_ALIGN(sizeof(NL_ATTR)))

#define NETLINK_NETFILTER 12
#define NETLINK_GENERIC 16

#endif /* NetlinProto.h */

0 comments on commit 1f3dd67

Please sign in to comment.