[ovs-dev] About " openvswitch " Name

2016-07-25 Thread neil
  
(Please forward this to your CEO or President, because this is urgent. )

Dear President & CEO,


This email is from China IPR Office, which mainly deal with trademark and 
domain name registration internationally. We received an application from RMZJ 
Industries Ltd. They want to register "openvswitch" as their International 
Trademark and some Domain(.asia/.cn/.com.cn/.hk/.com.hk/.tw/.com.tw). 

We checked and found the keyword is your company's registered trademark. But 
have not yet registered internationally. So we inform you to confirm whether 
this registration will affect and conflict your company. If this registration 
will not affect and conflict your company, then we can finish registering for 
them as per our duty. If this registration will affect and conflict your 
company. Please contact us by telephone or email within 10 workdays, so we can 
better handle the issue.


Neil Ren

International Department/Manager
China IPR/China Intellectual Property Office
Add:3/F,1st Building ZongFu Street No.47,Jinjiang District, ChengDu, China.
Tel: (+86) 28 8777 5008|Fax: (+86) 28 6246 5008|Web: http://www.cn-nic.asia
P Please consider the environment before you print this e-mail.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 0/6] Remove some compat code for Linux older than 3.10

2016-07-25 Thread pravin shelar
On Thu, Jul 21, 2016 at 11:14 AM, Thadeu Lima de Souza Cascardo
 wrote:
> The following patches remove compatibility code for Linux versions older than
> Linux 3.10.
>

series applied.

Thanks,
Pravin.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2 0/7] Windows: Add support for sending Conntrack events

2016-07-25 Thread Yin Lin
Cannot find patch 6. Can you send it out again?

On Mon, Jul 25, 2016 at 5:04 PM, Sairam Venugopal 
wrote:

> Add support for sending out Conntrack events on Windows (if subscribed).
> This meant adding support for handling multiple event queues.
>
> v2: Address review comments and squashed the 9 series patch to 7.
>
> The following gives an overview of the design:
> 1. Currently we only support subscribing/unsubscribing to Vport related
> events.
> 2. Event.c maintains a single queue of Event entries that are then read by
> user space.
> 3. In order to add support for multiple events, I modified the event queue
> into an array (size 2). The size of the event queue array is driven by
> value of enum (we explicitly add new event types here).
> 4. I decided to make Event Queue an array to avoid creating new ones for
> every event type. This also meant smaller code changes and not having
> multiple if-else in the code.
> 5. Each event queue can be uniquely identified based on the mcast
> EventType and hence the requirement for multiple locks based on the event
> type.
> 6. Though we may not have multiple event queues subscribed for 1 socket, I
> still wanted to ensure that we have support for it if it were ever
> requested.
> 7. In future, as we add support for new events, we can add it to the enum
> OVS_MCAST_EVENT_TYPES and subtypes can be represent by means of masks (eg:
> vport up/down, ct delete/add/update etc.,)
>
>
>
> Sairam Venugopal (7):
>   datapath-windows: Explicitly name vport related event to vportEvent
>   datapath-windows: Fix bugs in Event.c around subscribe and lock
>   datapath-windows: Define new multicast conntrack events and netlink
> protocol
>   datapath-windows: Modify OvsCreateNlMsgFromCtEntry to make it reusable
>   datapath-windows: Add support for multiple event queue in Event.c
>   datapath-windows: Update OvsReadEventCmdHandler in Datapath.c to
> support different events
>   datapath-windows: Post Conntrack delete and new events
>
>  datapath-windows/ovsext/Conntrack.c|  44 +++-
>  datapath-windows/ovsext/Conntrack.h|   9 +
>  datapath-windows/ovsext/Datapath.c |  95 +++--
>  datapath-windows/ovsext/Datapath.h |   3 +-
>  datapath-windows/ovsext/DpInternal.h   |  26 ++-
>  datapath-windows/ovsext/Event.c| 279
> -
>  datapath-windows/ovsext/Event.h|  22 +-
>  datapath-windows/ovsext/Netlink/NetlinkProto.h |   3 +
>  datapath-windows/ovsext/Vport.c|  12 +-
>  9 files changed, 395 insertions(+), 98 deletions(-)
>
> --
> 2.9.0.windows.1
>
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] OVSDB replication related memory leak

2016-07-25 Thread Andy Zhou
On Mon, Jul 25, 2016 at 8:26 AM, William Tu  wrote:

> Hi,
>
> Valgrind reports definitely memory leak in the testcase
> 1826: ovsdb-server.at:1081 insert monitored table, update excluded
> table
> Can someone take at look? Thank you~
>
> ==52969== 144 (48 direct, 96 indirect) bytes in 1 blocks are
> definitely lost in loss record 306 of 373
> ==52969==at 0x4C2AA98: calloc (vg_replace_malloc.c:711)
> ==52969==by 0x434C52: xcalloc (util.c:95)
> ==52969==by 0x420EA9: jsonrpc_msg_from_json (jsonrpc.c:686)
> ==52969==by 0x420FDF: jsonrpc_parse_received_message (jsonrpc.c:471)
> ==52969==by 0x420FDF: jsonrpc_recv.part.8 (jsonrpc.c:337)
> ==52969==by 0x42124B: jsonrpc_recv (jsonrpc.c:296)
> ==52969==by 0x42124B: jsonrpc_recv_block (jsonrpc.c:401)
> ==52969==by 0x41388E: get_initial_db_state (replication.c:363)
> ==52969==by 0x41388E: send_monitor_requests (replication.c:350)
> ==52969==by 0x41388E: replication_run (replication.c:107)
> ==52969==by 0x407E0B: main_loop (ovsdb-server.c:165)
> ==52969==by 0x407E0B: main (ovsdb-server.c:361)
> ==52969==
> ==52969== 620 (600 direct, 20 indirect) bytes in 1 blocks are
> definitely lost in loss record 333 of 373
> ==52969==at 0x4C2AA98: calloc (vg_replace_malloc.c:711)
> ==52969==by 0x434C52: xcalloc (util.c:95)
> ==52969==by 0x420737: jsonrpc_open (jsonrpc.c:86)
> ==52969==by 0x412BA4: open_jsonrpc (replication.c:214)
> ==52969==by 0x413461: replication_run (replication.c:101)
> ==52969==by 0x407E0B: main_loop (ovsdb-server.c:165)
> ==52969==by 0x407E0B: main (ovsdb-server.c:361)
> ==52969==
> ==52969== 620 (600 direct, 20 indirect) bytes in 1 blocks are
> definitely lost in loss record 334 of 373
> ==52969==at 0x4C2AA98: calloc (vg_replace_malloc.c:711)
> ==52969==by 0x434C52: xcalloc (util.c:95)
> ==52969==by 0x420737: jsonrpc_open (jsonrpc.c:86)
> ==52969==by 0x412BA4: open_jsonrpc (replication.c:214)
> ==52969==by 0x413990: check_for_notifications (replication.c:394)
> ==52969==by 0x413990: replication_run (replication.c:110)
> ==52969==by 0x407E0B: main_loop (ovsdb-server.c:165)
> ==52969==by 0x407E0B: main (ovsdb-server.c:361)
>
> Thanks, I am working on a fix.

> Regards,
> William
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2 7/7] datapath-windows: Post Conntrack delete and new events

2016-07-25 Thread Yin Lin
Acked-By: Yin Lin 

On Mon, Jul 25, 2016 at 5:04 PM, Sairam Venugopal 
wrote:

> Post Conntrack delete and create events when entries are deleted or
> created.
>
> v2: Added Acked-By
>
> Signed-off-by: Sairam Venugopal 
> Acked-by: Paul Boca 
> Acked-by: Alin Gabriel Serdean 
> ---
>  datapath-windows/ovsext/Conntrack.c | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/datapath-windows/ovsext/Conntrack.c
> b/datapath-windows/ovsext/Conntrack.c
> index 382c13d..af3d966 100644
> --- a/datapath-windows/ovsext/Conntrack.c
> +++ b/datapath-windows/ovsext/Conntrack.c
> @@ -23,6 +23,7 @@
>  #include "Jhash.h"
>  #include "PacketParser.h"
>  #include "Debug.h"
> +#include "Event.h"
>
>  #define WINDOWS_TICK 1000
>  #define SEC_TO_UNIX_EPOCH 11644473600LL
> @@ -154,6 +155,15 @@ OvsCtUpdateFlowKey(struct OvsFlowKey *key,
>  }
>
>  static __inline VOID
> +OvsPostCtEventEntry(POVS_CT_ENTRY entry, UINT8 type)
> +{
> +OVS_CT_EVENT_ENTRY ctEventEntry = {0};
> +NdisMoveMemory(, entry, sizeof(OVS_CT_ENTRY));
> +ctEventEntry.type = type;
> +OvsPostCtEvent();
> +}
> +
> +static __inline VOID
>  OvsCtAddEntry(POVS_CT_ENTRY entry, OvsConntrackKeyLookupCtx *ctx, UINT64
> now)
>  {
>  NdisMoveMemory(>key, >key, sizeof (OVS_CT_KEY));
> @@ -162,6 +172,7 @@ OvsCtAddEntry(POVS_CT_ENTRY entry,
> OvsConntrackKeyLookupCtx *ctx, UINT64 now)
>  entry->timestampStart = now;
>  InsertHeadList([ctx->hash & CT_HASH_TABLE_MASK],
> >link);
> +OvsPostCtEventEntry(entry, OVS_EVENT_CT_NEW);
>  ctTotalEntries++;
>  }
>
> @@ -253,6 +264,7 @@ OvsCtUpdateEntry(OVS_CT_ENTRY* entry,
>  static __inline VOID
>  OvsCtEntryDelete(POVS_CT_ENTRY entry)
>  {
> +OvsPostCtEventEntry(entry, OVS_EVENT_CT_DELETE);
>  RemoveEntryList(>link);
>  OvsFreeMemoryWithTag(entry, OVS_CT_POOL_TAG);
>  ctTotalEntries--;
> --
> 2.9.0.windows.1
>
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2 5/7] datapath-windows: Add support for multiple event queue in Event.c

2016-07-25 Thread Yin Lin
Acked-By: Yin Lin 

On Mon, Jul 25, 2016 at 5:04 PM, Sairam Venugopal 
wrote:

> Update Event.c to have multiple event queues and mechanism to retrieve the
> associated queue. Introduce OvsPostCtEvent and OvsRemoveCtEventEntry
> similar to OvsPostVportEvent and OvsRemoveVportEventEntry.
>
> v2: Added Acked-By
>
> Signed-off-by: Sairam Venugopal 
> Acked-by: Paul Boca 
> Acked-by: Alin Gabriel Serdean 
> ---
>  datapath-windows/ovsext/Event.c | 265
> +---
>  datapath-windows/ovsext/Event.h |  17 ++-
>  2 files changed, 239 insertions(+), 43 deletions(-)
>
> diff --git a/datapath-windows/ovsext/Event.c
> b/datapath-windows/ovsext/Event.c
> index 8ff0322..cb0dc92 100644
> --- a/datapath-windows/ovsext/Event.c
> +++ b/datapath-windows/ovsext/Event.c
> @@ -26,36 +26,62 @@
>  #define OVS_DBG_MOD OVS_DBG_EVENT
>  #include "Debug.h"
>
> -LIST_ENTRY ovsEventQueue;
> -static NDIS_SPIN_LOCK eventQueueLock;
> -UINT32 ovsNumEventQueue;
> +LIST_ENTRY ovsEventQueueArr[OVS_MCAST_EVENT_TYPES_MAX];
> +static NDIS_SPIN_LOCK eventQueueLockArr[OVS_MCAST_EVENT_TYPES_MAX];
> +UINT32 ovsNumEventQueueArr[OVS_MCAST_EVENT_TYPES_MAX];
>
>  NTSTATUS
>  OvsInitEventQueue()
>  {
> -InitializeListHead();
> -NdisAllocateSpinLock();
> +for (int i = 0; i < OVS_MCAST_EVENT_TYPES_MAX; i++) {
> +InitializeListHead([i]);
> +NdisAllocateSpinLock([i]);
> +}
>  return STATUS_SUCCESS;
>  }
>
>  VOID
>  OvsCleanupEventQueue()
>  {
> -ASSERT(IsListEmpty());
> -ASSERT(ovsNumEventQueue == 0);
> -NdisFreeSpinLock();
> +for (int i = 0; i < OVS_MCAST_EVENT_TYPES_MAX; i++) {
> +ASSERT(IsListEmpty([i]));
> +ASSERT(ovsNumEventQueueArr[i] == 0);
> +NdisFreeSpinLock([i]);
> +}
>  }
>
>  static __inline VOID
> -OvsAcquireEventQueueLock()
> +OvsAcquireEventQueueLock(int eventId)
>  {
> -NdisAcquireSpinLock();
> +NdisAcquireSpinLock([eventId]);
>  }
>
>  static __inline VOID
> -OvsReleaseEventQueueLock()
> +OvsReleaseEventQueueLock(int eventId)
>  {
> -   NdisReleaseSpinLock();
> +   NdisReleaseSpinLock([eventId]);
> +}
> +
> +NDIS_STATUS
> +OvsGetMcastEventId(UINT32 protocol, UINT32 mcastMask, UINT32 *eventId)
> +{
> +switch (protocol) {
> +case NETLINK_GENERIC:
> +*eventId = OVS_MCAST_VPORT_EVENT;
> +return NDIS_STATUS_SUCCESS;
> +case NETLINK_NETFILTER:
> +if ((mcastMask & OVS_EVENT_CT_NEW)
> +|| (mcastMask & OVS_EVENT_CT_DELETE)) {
> +*eventId =  OVS_MCAST_CT_EVENT;
> +return NDIS_STATUS_SUCCESS;
> +}
> +break;
> +default:
> +goto error;
> +}
> +
> +error:
> +return NDIS_STATUS_INVALID_PARAMETER;
>  }
>
>  /*
> @@ -68,14 +94,17 @@ OvsCleanupEvent(POVS_OPEN_INSTANCE instance)
>  {
>  POVS_EVENT_QUEUE queue;
>  PIRP irp = NULL;
> +UINT32 eventId;
>  queue = (POVS_EVENT_QUEUE)instance->eventQueue;
>  if (queue) {
>  POVS_EVENT_QUEUE_ELEM elem;
>  PLIST_ENTRY link, next;
>
> -OvsAcquireEventQueueLock();
> +/* Handle the error */
> +OvsGetMcastEventId(instance->protocol, instance->mcastMask,
> );
> +OvsAcquireEventQueueLock(eventId);
>  RemoveEntryList(>queueLink);
> -ovsNumEventQueue--;
> +ovsNumEventQueueArr[eventId]--;
>  if (queue->pendingIrp) {
>  PDRIVER_CANCEL cancelRoutine;
>  irp = queue->pendingIrp;
> @@ -86,7 +115,7 @@ OvsCleanupEvent(POVS_OPEN_INSTANCE instance)
>  }
>  }
>  instance->eventQueue = NULL;
> -OvsReleaseEventQueueLock();
> +OvsReleaseEventQueueLock(eventId);
>  if (irp) {
>  OvsCompleteIrpRequest(irp, 0, STATUS_SUCCESS);
>  }
> @@ -115,7 +144,7 @@ OvsPostVportEvent(POVS_VPORT_EVENT_ENTRY event)
>  POVS_EVENT_QUEUE queue;
>  PLIST_ENTRY link;
>  LIST_ENTRY list;
> -   PLIST_ENTRY entry;
> +PLIST_ENTRY entry;
>  PIRP irp;
>
>  InitializeListHead();
> @@ -123,9 +152,9 @@ OvsPostVportEvent(POVS_VPORT_EVENT_ENTRY event)
>  OVS_LOG_TRACE("Enter: portNo: %#x, status: %#x", event->portNo,
>event->type);
>
> -OvsAcquireEventQueueLock();
> +OvsAcquireEventQueueLock(OVS_MCAST_VPORT_EVENT);
>
> -LIST_FORALL(, link) {
> +LIST_FORALL([OVS_MCAST_VPORT_EVENT], link) {
>  queue = CONTAINING_RECORD(link, OVS_EVENT_QUEUE, queueLink);
>  if ((event->type & queue->mask) == 0) {
>  continue;
> @@ -137,7 +166,7 @@ OvsPostVportEvent(POVS_VPORT_EVENT_ENTRY event)
>
>  if (elem == NULL) {
>  OVS_LOG_WARN("Fail to allocate memory for event");
> -OvsReleaseEventQueueLock();
> +OvsReleaseEventQueueLock(OVS_MCAST_VPORT_EVENT);
>  return;
>  }
>
> @@ -157,7 +186,7 @@ 

Re: [ovs-dev] [PATCH v2 4/7] datapath-windows: Modify OvsCreateNlMsgFromCtEntry to make it reusable

2016-07-25 Thread Yin Lin
Acked-By: Yin Lin 

On Mon, Jul 25, 2016 at 5:04 PM, Sairam Venugopal 
wrote:

> Tweak the OvsCreateNlMsgFromCtEntry() method to reuse it for creating
> netlink messages from other files. Also define the function in Conntrack.h
> to make it accessible.
>
> v2: Added Acked-By
>
> Signed-off-by: Sairam Venugopal 
> Acked-By: Yin Lin 
> Acked-by: Alin Gabriel Serdean 
> ---
>  datapath-windows/ovsext/Conntrack.c | 32 ++--
>  datapath-windows/ovsext/Conntrack.h |  9 +
>  2 files changed, 31 insertions(+), 10 deletions(-)
>
> diff --git a/datapath-windows/ovsext/Conntrack.c
> b/datapath-windows/ovsext/Conntrack.c
> index 90b59ce..382c13d 100644
> --- a/datapath-windows/ovsext/Conntrack.c
> +++ b/datapath-windows/ovsext/Conntrack.c
> @@ -934,12 +934,15 @@ WindowsTickToUnixSeconds(long long windowsTicks)
>  - SEC_TO_UNIX_EPOCH));
>  }
>
> -static NTSTATUS
> +NTSTATUS
>  OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry,
> -  POVS_MESSAGE msgIn,
>PVOID outBuffer,
>UINT32 outBufLen,
> -  int dpIfIndex)
> +  UINT8 eventType,
> +  UINT32 nlmsgSeq,
> +  UINT32 nlmsgPid,
> +  UINT8 nfGenVersion,
> +  UINT32 dpIfIndex)
>  {
>  NL_BUFFER nlBuf;
>  BOOLEAN ok;
> @@ -947,6 +950,7 @@ OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry,
>  UINT32 timeout;
>  NDIS_STATUS status;
>  UINT64 currentTime, expiration;
> +UINT16 nlmsgType;
>  NdisGetCurrentSystemTime((LARGE_INTEGER *));
>  UINT8 nfgenFamily = 0;
>  if (entry->key.dl_type == htons(ETH_TYPE_IPV4)) {
> @@ -957,13 +961,17 @@ OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry,
>
>  NlBufInit(, outBuffer, outBufLen);
>  /* Mimic netfilter */
> -UINT16 nlmsgType = (NFNL_SUBSYS_CTNETLINK << 8 | IPCTNL_MSG_CT_NEW);
> +if (eventType == OVS_EVENT_CT_NEW) {
> +nlmsgType = (UINT16) (NFNL_SUBSYS_CTNETLINK << 8 |
> IPCTNL_MSG_CT_NEW);
> +} else if (eventType == OVS_EVENT_CT_DELETE) {
> +nlmsgType = (UINT16) (NFNL_SUBSYS_CTNETLINK << 8 |
> IPCTNL_MSG_CT_DELETE);
> +} else {
> +return STATUS_INVALID_PARAMETER;
> +}
> +
>  ok = NlFillOvsMsgForNfGenMsg(, nlmsgType, NLM_F_CREATE,
> - msgIn->nlMsg.nlmsgSeq,
> - msgIn->nlMsg.nlmsgPid,
> - nfgenFamily,
> - msgIn->nfGenMsg.version,
> - dpIfIndex);
> + nlmsgSeq, nlmsgPid, nfgenFamily,
> + nfGenVersion, dpIfIndex);
>  if (!ok) {
>  return STATUS_INVALID_BUFFER_SIZE;
>  }
> @@ -1130,9 +1138,13 @@ OvsCtDumpCmdHandler(POVS_USER_PARAMS_CONTEXT
> usrParamsCtx,
>  if (outIndex >= inIndex) {
>  entry = CONTAINING_RECORD(link, OVS_CT_ENTRY, link);
>
> -rc = OvsCreateNlMsgFromCtEntry(entry, msgIn,
> +rc = OvsCreateNlMsgFromCtEntry(entry,
>
> usrParamsCtx->outputBuffer,
>
> usrParamsCtx->outputLength,
> +   OVS_EVENT_CT_NEW,
> +   msgIn->nlMsg.nlmsgSeq,
> +   msgIn->nlMsg.nlmsgPid,
> +
>  msgIn->nfGenMsg.version,
> 0);
>
>  if (rc != NDIS_STATUS_SUCCESS) {
> diff --git a/datapath-windows/ovsext/Conntrack.h
> b/datapath-windows/ovsext/Conntrack.h
> index 6d573c8..4995ff4 100644
> --- a/datapath-windows/ovsext/Conntrack.h
> +++ b/datapath-windows/ovsext/Conntrack.h
> @@ -116,4 +116,13 @@ enum CT_UPDATE_RES
> OvsConntrackUpdateTcpEntry(OVS_CT_ENTRY* conn_,
>  enum ct_update_res OvsConntrackUpdateOtherEntry(OVS_CT_ENTRY *conn_,
>  BOOLEAN reply,
>  UINT64 now);
> +NTSTATUS
> +OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry,
> +  PVOID outBuffer,
> +  UINT32 outBufLen,
> +  UINT8 eventType,
> +  UINT32 nlmsgSeq,
> +  UINT32 nlmsgPid,
> +  UINT8 nfGenVersion,
> +  UINT32 dpIfIndex);
>  #endif /* __OVS_CONNTRACK_H_ */
> --
> 2.9.0.windows.1
>
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2 3/7] datapath-windows: Define new multicast conntrack events and netlink protocol

2016-07-25 Thread Yin Lin
Acked-By: Yin Lin 

On Mon, Jul 25, 2016 at 5:04 PM, Sairam Venugopal 
wrote:

> 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.
>
> v2: Squashed patches 2/9 and 5/9 into one. Addressed review comments from
> Yin Lin and Alin Serdean
>
> Signed-off-by: Sairam Venugopal 
> ---
>  datapath-windows/ovsext/Datapath.c | 21 ++---
>  datapath-windows/ovsext/Datapath.h |  3 ++-
>  datapath-windows/ovsext/DpInternal.h   | 16 
>  datapath-windows/ovsext/Netlink/NetlinkProto.h |  3 +++
>  4 files changed, 39 insertions(+), 4 deletions(-)
>
> diff --git a/datapath-windows/ovsext/Datapath.c
> b/datapath-windows/ovsext/Datapath.c
> index 75f133a..f9f965c 100644
> --- a/datapath-windows/ovsext/Datapath.c
> +++ b/datapath-windows/ovsext/Datapath.c
> @@ -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);
>
> @@ -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, ,
>  sizeof request);
> diff --git a/datapath-windows/ovsext/Datapath.h
> b/datapath-windows/ovsext/Datapath.h
> index 2b41d82..57b483a 100644
> --- a/datapath-windows/ovsext/Datapath.h
> +++ b/datapath-windows/ovsext/Datapath.h
> @@ -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.
> */
> diff --git a/datapath-windows/ovsext/DpInternal.h
> b/datapath-windows/ovsext/DpInternal.h
> index 8abe61d..22599a0 100644
> --- a/datapath-windows/ovsext/DpInternal.h
> +++ b/datapath-windows/ovsext/DpInternal.h
> @@ -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 {
> @@ -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;
> diff --git a/datapath-windows/ovsext/Netlink/NetlinkProto.h
> b/datapath-windows/ovsext/Netlink/NetlinkProto.h
> index beb14d5..5175311 100644
> --- a/datapath-windows/ovsext/Netlink/NetlinkProto.h
> +++ b/datapath-windows/ovsext/Netlink/NetlinkProto.h
> @@ -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 */
> --
> 

Re: [ovs-dev] [PATCH v2 2/7] datapath-windows: Fix bugs in Event.c around subscribe and lock

2016-07-25 Thread Yin Lin
Acked-By: Yin Lin 

On Mon, Jul 25, 2016 at 5:04 PM, Sairam Venugopal 
wrote:

> When userspace tries to resubscribe to an existing queue, return
> STATUS_INVALID_PARAMETER since it's not supported. The current bug
> overwrites status to STATUS_SUCCESS.
>
> The second bug fix is around releasing the EventQueue lock if an open
> instance couldn't be found. The current version returns back without
> releasing the lock. Moving the OvsAcquireEventQueueLock() after the
> instance is verified.
>
> OvsGetOpenInstance does not enforce a safe read for
> gOvsSwitchContext->dpNo. Use the gOvsSwitchContext->dispatchLock for
> accessing the parameter.
>
> v2: Address review comments from Alin Serdean and Yin Lin (around keeping
> OvsGetOpenInstance safe).
>
> Signed-off-by: Sairam Venugopal 
> ---
>  datapath-windows/ovsext/Datapath.c | 7 ++-
>  datapath-windows/ovsext/Event.c| 6 ++
>  2 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/datapath-windows/ovsext/Datapath.c
> b/datapath-windows/ovsext/Datapath.c
> index e4d6ab1..75f133a 100644
> --- a/datapath-windows/ovsext/Datapath.c
> +++ b/datapath-windows/ovsext/Datapath.c
> @@ -521,12 +521,17 @@ POVS_OPEN_INSTANCE
>  OvsGetOpenInstance(PFILE_OBJECT fileObject,
> UINT32 dpNo)
>  {
> +LOCK_STATE_EX lockState;
>  POVS_OPEN_INSTANCE instance =
> (POVS_OPEN_INSTANCE)fileObject->FsContext;
>  ASSERT(instance);
>  ASSERT(instance->fileObject == fileObject);
> +NdisAcquireRWLockWrite(gOvsSwitchContext->dispatchLock, ,
> 0);
> +
>  if (gOvsSwitchContext->dpNo != dpNo) {
> -return NULL;
> +instance = NULL;
>  }
> +
> +NdisReleaseRWLock(gOvsSwitchContext->dispatchLock, );
>  return instance;
>  }
>
> diff --git a/datapath-windows/ovsext/Event.c
> b/datapath-windows/ovsext/Event.c
> index 8c7c3ec..8ff0322 100644
> --- a/datapath-windows/ovsext/Event.c
> +++ b/datapath-windows/ovsext/Event.c
> @@ -217,9 +217,8 @@ OvsSubscribeEventIoctl(PFILE_OBJECT fileObject,
>  if (queue->mask != request->mask) {
>  status = STATUS_INVALID_PARAMETER;
>  OVS_LOG_WARN("Can not chnage mask when the queue is
> subscribed");
> +goto done_event_subscribe;
>  }
> -status = STATUS_SUCCESS;
> -goto done_event_subscribe;
>  } else if (!request->subscribe && queue == NULL) {
>  status = STATUS_SUCCESS;
>  goto done_event_subscribe;
> @@ -356,8 +355,6 @@ OvsWaitEventIoctl(PIRP irp,
>  }
>  poll = (POVS_EVENT_POLL)inputBuffer;
>
> -OvsAcquireEventQueueLock();
> -
>  instance = OvsGetOpenInstance(fileObject, poll->dpNo);
>  if (instance == NULL) {
>  OVS_LOG_TRACE("Exit: Can not find open instance, dpNo: %d",
> @@ -365,6 +362,7 @@ OvsWaitEventIoctl(PIRP irp,
>  return STATUS_INVALID_PARAMETER;
>  }
>
> +OvsAcquireEventQueueLock();
>  queue = (POVS_EVENT_QUEUE)instance->eventQueue;
>  if (queue == NULL) {
>  OVS_LOG_TRACE("Exit: Event queue does not exist");
> --
> 2.9.0.windows.1
>
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2 1/7] datapath-windows: Explicitly name vport related event to vportEvent

2016-07-25 Thread Yin Lin
Acked-By: Yin Lin 

On Mon, Jul 25, 2016 at 5:04 PM, Sairam Venugopal 
wrote:

> OVS_EVENT_ENTRY currently handles only Vport related events. Updating the
> name of the struct to OVS_VPORT_EVENT_ENTRY. Remove OVS_EVENT_STATUS since
> it's currently not in use. Update the datapath to refer to events as
> vportEvents. This will aid in the introduction of other events.
>
> v2: Squash 1/9 and 3/9 into one commit. Added Acked-by.
>
> Signed-off-by: Sairam Venugopal 
> Acked-By: Yin Lin 
> Acked-by: Alin Gabriel Serdean 
> ---
>  datapath-windows/ovsext/Datapath.c   |  7 ---
>  datapath-windows/ovsext/DpInternal.h | 10 ++
>  datapath-windows/ovsext/Event.c  | 10 +-
>  datapath-windows/ovsext/Event.h  |  7 ---
>  datapath-windows/ovsext/Vport.c  | 12 ++--
>  5 files changed, 21 insertions(+), 25 deletions(-)
>
> diff --git a/datapath-windows/ovsext/Datapath.c
> b/datapath-windows/ovsext/Datapath.c
> index 4f47be5..e4d6ab1 100644
> --- a/datapath-windows/ovsext/Datapath.c
> +++ b/datapath-windows/ovsext/Datapath.c
> @@ -1582,7 +1582,7 @@ MapIrpOutputBuffer(PIRP irp,
>   */
>  static NTSTATUS
>  OvsPortFillInfo(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
> -POVS_EVENT_ENTRY eventEntry,
> +POVS_VPORT_EVENT_ENTRY eventEntry,
>  PNL_BUFFER nlBuf)
>  {
>  NTSTATUS status;
> @@ -1659,7 +1659,7 @@ OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT
> usrParamsCtx,
>  #endif
>  NL_BUFFER nlBuf;
>  NTSTATUS status;
> -OVS_EVENT_ENTRY eventEntry;
> +OVS_VPORT_EVENT_ENTRY eventEntry;
>
>  ASSERT(usrParamsCtx->devOp == OVS_READ_DEV_OP);
>
> @@ -1675,7 +1675,8 @@ OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT
> usrParamsCtx,
>  NlBufInit(, usrParamsCtx->outputBuffer,
> usrParamsCtx->outputLength);
>
>  /* remove an event entry from the event queue */
> -status = OvsRemoveEventEntry(usrParamsCtx->ovsInstance, );
> +status = OvsRemoveVportEventEntry(usrParamsCtx->ovsInstance,
> +  );
>  if (status != STATUS_SUCCESS) {
>  /* If there were not elements, read should return no data. */
>  status = STATUS_SUCCESS;
> diff --git a/datapath-windows/ovsext/DpInternal.h
> b/datapath-windows/ovsext/DpInternal.h
> index 42b5ec9..8abe61d 100644
> --- a/datapath-windows/ovsext/DpInternal.h
> +++ b/datapath-windows/ovsext/DpInternal.h
> @@ -328,19 +328,13 @@ enum {
>  };
>
>
> -typedef struct _OVS_EVENT_ENTRY {
> +typedef struct _OVS_VPORT_EVENT_ENTRY {
>  UINT32 portNo;
>  OVS_VPORT_TYPE ovsType;
>  UINT32 upcallPid;
>  CHAR ovsName[OVS_MAX_PORT_NAME_LENGTH];
>  UINT32 type;
> -} OVS_EVENT_ENTRY, *POVS_EVENT_ENTRY;
> -
> -
> -typedef struct _OVS_EVENT_STATUS {
> -uint32_t numberEntries;
> -OVS_EVENT_ENTRY eventEntries[0];
> -} OVS_EVENT_STATUS, *POVS_EVENT_STATUS;
> +} OVS_VPORT_EVENT_ENTRY, *POVS_VPORT_EVENT_ENTRY;
>
>  #pragma pack(pop)
>
> diff --git a/datapath-windows/ovsext/Event.c
> b/datapath-windows/ovsext/Event.c
> index f9bea7f..8c7c3ec 100644
> --- a/datapath-windows/ovsext/Event.c
> +++ b/datapath-windows/ovsext/Event.c
> @@ -109,7 +109,7 @@ OvsCleanupEvent(POVS_OPEN_INSTANCE instance)
>   *
> --
>   */
>  VOID
> -OvsPostEvent(POVS_EVENT_ENTRY event)
> +OvsPostVportEvent(POVS_VPORT_EVENT_ENTRY event)
>  {
>  POVS_EVENT_QUEUE_ELEM elem;
>  POVS_EVENT_QUEUE queue;
> @@ -141,7 +141,7 @@ OvsPostEvent(POVS_EVENT_ENTRY event)
>  return;
>  }
>
> -RtlCopyMemory(>event, event, sizeof elem->event);
> +RtlCopyMemory(>vportEvent, event, sizeof elem->vportEvent);
>  InsertTailList(>elemList, >link);
>  queue->numElems++;
>  OVS_LOG_INFO("Queue: %p, numElems: %d",
> @@ -409,8 +409,8 @@ unlock:
>   *
> --
>   */
>  NTSTATUS
> -OvsRemoveEventEntry(POVS_OPEN_INSTANCE instance,
> -POVS_EVENT_ENTRY entry)
> +OvsRemoveVportEventEntry(POVS_OPEN_INSTANCE instance,
> + POVS_VPORT_EVENT_ENTRY entry)
>  {
>  NTSTATUS status = STATUS_UNSUCCESSFUL;
>  POVS_EVENT_QUEUE queue;
> @@ -427,7 +427,7 @@ OvsRemoveEventEntry(POVS_OPEN_INSTANCE instance,
>
>  if (queue->numElems) {
>  elem = (POVS_EVENT_QUEUE_ELEM)RemoveHeadList(>elemList);
> -*entry = elem->event;
> +*entry = elem->vportEvent;
>  OvsFreeMemoryWithTag(elem, OVS_EVENT_POOL_TAG);
>  queue->numElems--;
>  status = STATUS_SUCCESS;
> diff --git a/datapath-windows/ovsext/Event.h
> b/datapath-windows/ovsext/Event.h
> index b087875..255594c 100644
> --- a/datapath-windows/ovsext/Event.h
> +++ b/datapath-windows/ovsext/Event.h
> @@ -19,7 +19,7 @@
>
>  typedef struct 

Re: [ovs-dev] [PATACH]ovn: fix bug of dropping flows building in build_lrouter_flows

2016-07-25 Thread Ryan Moats
"dev"  wrote on 07/25/2016 08:49:38 PM:

> From: Dongjun 
> To: "dev@openvswitch.org" 
> Date: 07/25/2016 08:45 PM
> Subject: [ovs-dev] [PATACH]ovn: fix bug of dropping flows building
> in build_lrouter_flows
> Sent by: "dev" 
>
> In build_lrouter_flows, it says that:" Drop ip traffic to this router,
> unless the router ip is used as SNAT ip. "
> But there is a bug, the "continue" only effect the inner loop, dropping
> flows is still built.
>
> Example: Dropping flow c8726aed-0dd0-41b6-bb8c-13ca1e2164c9 should not
> be exist for "ct_snat(192.168.246.200);".
> _uuid   actions external_idslogical_datapathmatch
> pipelineprioritytable_id
> a29d2785-af1d-45ec-ae60-677356c48f24"drop;"
> {stage-name=lr_in_ip_input} 1915535e-7738-43db-8341-2306221b0691
> "ip4.dst == {169.254.128.1}"ingress 60  1
> c8726aed-0dd0-41b6-bb8c-13ca1e2164c9"drop;"
> {stage-name=lr_in_ip_input} 1915535e-7738-43db-8341-2306221b0691
> "ip4.dst == {192.168.246.200}"  ingress 60  1
> 0dd66b7e-d11b-4d13-86d1-55ebe9d7e85f "ct_snat(192.168.246.200);"
> {stage-name=lr_out_snat} 1915535e-7738-43db-8341-2306221b0691"ip &&
> ip4.src == 101.0.0.0/24" egress  25  0
> c3d56ca6-38c6-4943-8d89-2c39cbc3cd9b"next;" {stage-name=lr_out_snat}
> 1915535e-7738-43db-8341-2306221b0691"1" egress  0   0
>
> This commit fixed this bug.
> NAT configured, the flows:
> a29d2785-af1d-45ec-ae60-677356c48f24"drop;"
> {stage-name=lr_in_ip_input} 1915535e-7738-43db-8341-2306221b0691
> "ip4.dst == {169.254.128.1}"ingress 60  1
> 0dd66b7e-d11b-4d13-86d1-55ebe9d7e85f "ct_snat(192.168.246.200);"
> {stage-name=lr_out_snat} 1915535e-7738-43db-8341-2306221b0691"ip &&
> ip4.src == 101.0.0.0/24" egress  25  0
> c3d56ca6-38c6-4943-8d89-2c39cbc3cd9b"next;" {stage-name=lr_out_snat}
> 1915535e-7738-43db-8341-2306221b0691"1" egress  0   0
> NAT not configured, the flows:
> a29d2785-af1d-45ec-ae60-677356c48f24"drop;"
> {stage-name=lr_in_ip_input} 1915535e-7738-43db-8341-2306221b0691
> "ip4.dst == {169.254.128.1}"ingress 60  1
> c8726aed-0dd0-41b6-bb8c-13ca1e2164c9"drop;"
> {stage-name=lr_in_ip_input} 1915535e-7738-43db-8341-2306221b0691
> "ip4.dst == {192.168.246.200}"  ingress 60  1
> c3d56ca6-38c6-4943-8d89-2c39cbc3cd9b"next;" {stage-name=lr_out_snat}
> 1915535e-7738-43db-8341-2306221b0691"1" egress  0   0
>
>
> Signed-off-by: Dongjun 
>
> diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
> old mode 100644
> new mode 100755
> index a3d1672..0e4fc93
> --- a/ovn/northd/ovn-northd.c
> +++ b/ovn/northd/ovn-northd.c
> @@ -2324,6 +2324,16 @@ op_put_networks(struct ds *ds, const struct
> ovn_port *op, bool add_bcast)
>   ds_put_cstr(ds, "}");
>   }
>
> +static bool
> +has_ip(ovs_be32 *ips, size_t size, ovs_be32 ip){
> +for (int i = 0; i < size; i++) {
> +if (ip == ips[i]) {
> +return true;
> +}
> +}
> +return false;
> +}
> +
>   static void
>   build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
>   struct hmap *lflows)
> @@ -2543,10 +2553,8 @@ build_lrouter_flows(struct hmap *datapaths,
> struct hmap *ports,
>   ds_put_cstr(, "ip4.dst == {");
>   bool has_drop_ips = false;
>   for (int i = 0; i < op->lrp_networks.n_ipv4_addrs; i++) {
> -for (int j = 0; j < n_nat_ips; j++) {
> -if (op->lrp_networks.ipv4_addrs[i].addr == nat_ips[j]) {
> -continue;
> -}
> +if(has_ip(nat_ips, n_nat_ips,
> op->lrp_networks.ipv4_addrs[i].addr)){
> +continue;
>   }
>   ds_put_format(, "%s, ",
> op->lrp_networks.ipv4_addrs[i].addr_s);

Since there is a bug claimed here, is there a unit test that currently
fails without this patch that then passes with it?  If there isn't one
could you please add one to the next version of the patch?

Ryan
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] dev@openvswitch.org

2016-07-25 Thread Automatic Email Delivery Software


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v3 3/3] dpif-netdev: Introduce pmd-rxq-affinity.

2016-07-25 Thread Daniele Di Proietto
Thanks for the patch.

I haven't been able to apply this without the XPS patch.

This looks like a perfect chance to add more tests to pmd.at.  I can do it if 
you want

I started taking a look at this patch and I have a few comments inline.  I'll 
keep looking at it tomorrow

Thanks,

Daniele


On 15/07/2016 04:54, "Ilya Maximets"  wrote:

>New 'other_config:pmd-rxq-affinity' field for Interface table to
>perform manual pinning of RX queues to desired cores.
>
>This functionality is required to achieve maximum performance because
>all kinds of ports have different cost of rx/tx operations and
>only user can know about expected workload on different ports.
>
>Example:
>   # ./bin/ovs-vsctl set interface dpdk0 options:n_rxq=4 \
> other_config:pmd-rxq-affinity="0:3,1:7,3:8"
>   Queue #0 pinned to core 3;
>   Queue #1 pinned to core 7;
>   Queue #2 not pinned.
>   Queue #3 pinned to core 8;
>
>It's decided to automatically isolate cores that have rxq explicitly
>assigned to them because it's useful to keep constant polling rate on
>some performance critical ports while adding/deleting other ports
>without explicit pinning of all ports.
>
>Signed-off-by: Ilya Maximets 
>---
> INSTALL.DPDK.md  |  49 +++-
> NEWS |   2 +
> lib/dpif-netdev.c| 218 ++-
> tests/pmd.at |   6 ++
> vswitchd/vswitch.xml |  23 ++
> 5 files changed, 257 insertions(+), 41 deletions(-)
>
>diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
>index 5407794..7609aa7 100644
>--- a/INSTALL.DPDK.md
>+++ b/INSTALL.DPDK.md
>@@ -289,14 +289,57 @@ advanced install guide [INSTALL.DPDK-ADVANCED.md]
>  # Check current stats
>ovs-appctl dpif-netdev/pmd-stats-show
> 
>+ # Clear previous stats
>+   ovs-appctl dpif-netdev/pmd-stats-clear
>+ ```
>+
>+  7. Port/rxq assigment to PMD threads
>+
>+ ```
>  # Show port/rxq assignment
>ovs-appctl dpif-netdev/pmd-rxq-show
>+ ```
> 
>- # Clear previous stats
>-   ovs-appctl dpif-netdev/pmd-stats-clear
>+ To change default rxq assignment to pmd threads rxqs may be manually
>+ pinned to desired cores using:
>+
>+ ```
>+ ovs-vsctl set Interface  \
>+   other_config:pmd-rxq-affinity=
>  ```
>+ where:
>+
>+ ```
>+  ::= NULL | 
>+  ::=  |
>+   , 
>+  ::=  : 
>+ ```
>+
>+ Example:
>+
>+ ```
>+ ovs-vsctl set interface dpdk0 options:n_rxq=4 \
>+   other_config:pmd-rxq-affinity="0:3,1:7,3:8"
>+
>+ Queue #0 pinned to core 3;
>+ Queue #1 pinned to core 7;
>+ Queue #2 not pinned.
>+ Queue #3 pinned to core 8;
>+ ```
>+
>+ After that PMD threads on cores where RX queues was pinned will become
>+ `isolated`. This means that this thread will poll only pinned RX queues.
>+
>+ WARNING: If there are no `non-isolated` PMD threads, `non-pinned` RX 
>queues
>+ will not be polled. Also, if provided `core_id` is not available (ex. 
>this
>+ `core_id` not in `pmd-cpu-mask`), RX queue will not be polled by any
>+ PMD thread.
>+
>+ Isolation of PMD threads also can be checked using
>+ `ovs-appctl dpif-netdev/pmd-rxq-show` command.
> 
>-  7. Stop vswitchd & Delete bridge
>+  8. Stop vswitchd & Delete bridge
> 
>  ```
>  ovs-appctl -t ovs-vswitchd exit
>diff --git a/NEWS b/NEWS
>index 6496dc1..9ccc1f5 100644
>--- a/NEWS
>+++ b/NEWS
>@@ -44,6 +44,8 @@ Post-v2.5.0
>Old 'other_config:n-dpdk-rxqs' is no longer supported.
>Not supported by vHost interfaces. For them number of rx and tx queues
>is applied from connected virtio device.
>+ * New 'other_config:pmd-rxq-affinity' field for PMD interfaces, that
>+   allows to pin port's rx queues to desired cores.
>  * New appctl command 'dpif-netdev/pmd-rxq-show' to check the port/rxq
>assignment.
>  * Type of log messages from PMD threads changed from INFO to DBG.
>diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
>index 18ce316..e5a8dec 100644
>--- a/lib/dpif-netdev.c
>+++ b/lib/dpif-netdev.c
>@@ -63,6 +63,7 @@
> #include "random.h"
> #include "seq.h"
> #include "shash.h"
>+#include "smap.h"
> #include "sset.h"
> #include "timeval.h"
> #include "tnl-neigh-cache.h"
>@@ -250,6 +251,12 @@ enum pmd_cycles_counter_type {
> 
> #define XPS_TIMEOUT_MS 500LL
> 
>+/* Contained by struct dp_netdev_port's 'rxqs' member.  */
>+struct dp_netdev_rxq {
>+struct netdev_rxq *rxq;
>+unsigned core_id;   /* Сore to which this queue is pinned. */
>+};
>+
> /* A port in a netdev-based datapath. */
> struct dp_netdev_port {
> odp_port_t port_no;
>@@ -257,10 +264,11 @@ struct dp_netdev_port {
> struct hmap_node node;  /* Node in dp_netdev's 'ports'. */
> struct netdev_saved_flags *sf;
> unsigned n_rxq; /* Number of elements in 'rxq' */
>-

Re: [ovs-dev] [PATCH v3 2/3] util: Expose function nullable_string_is_equal.

2016-07-25 Thread Daniele Di Proietto
Nice!

Applied to master, thanks



On 15/07/2016 04:54, "Ilya Maximets"  wrote:

>Implementation of 'nullable_string_is_equal()' moved to util.c and
>reused inside dpif-netdev.
>
>Signed-off-by: Ilya Maximets 
>---
> lib/dpif-netdev.c| 14 ++
> lib/util.c   |  6 ++
> lib/util.h   |  1 +
> ofproto/ofproto-dpif-ipfix.c |  6 --
> ofproto/ofproto-dpif-sflow.c |  6 --
> 5 files changed, 9 insertions(+), 24 deletions(-)
>
>diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
>index 4643cce..18ce316 100644
>--- a/lib/dpif-netdev.c
>+++ b/lib/dpif-netdev.c
>@@ -2524,16 +2524,6 @@ dpif_netdev_operate(struct dpif *dpif, struct dpif_op 
>**ops, size_t n_ops)
> }
> }
> 
>-static bool
>-cmask_equals(const char *a, const char *b)
>-{
>-if (a && b) {
>-return !strcmp(a, b);
>-}
>-
>-return a == NULL && b == NULL;
>-}
>-
> /* Changes the number or the affinity of pmd threads.  The changes are 
> actually
>  * applied in dpif_netdev_run(). */
> static int
>@@ -2541,7 +2531,7 @@ dpif_netdev_pmd_set(struct dpif *dpif, const char *cmask)
> {
> struct dp_netdev *dp = get_dp_netdev(dpif);
> 
>-if (!cmask_equals(dp->requested_pmd_cmask, cmask)) {
>+if (!nullable_string_is_equal(dp->requested_pmd_cmask, cmask)) {
> free(dp->requested_pmd_cmask);
> dp->requested_pmd_cmask = nullable_xstrdup(cmask);
> }
>@@ -2756,7 +2746,7 @@ dpif_netdev_run(struct dpif *dpif)
> 
> dp_netdev_pmd_unref(non_pmd);
> 
>-if (!cmask_equals(dp->pmd_cmask, dp->requested_pmd_cmask)
>+if (!nullable_string_is_equal(dp->pmd_cmask, dp->requested_pmd_cmask)
> || ports_require_restart(dp)) {
> reconfigure_pmd_threads(dp);
> }
>diff --git a/lib/util.c b/lib/util.c
>index e1dc3d2..241a7f1 100644
>--- a/lib/util.c
>+++ b/lib/util.c
>@@ -157,6 +157,12 @@ nullable_xstrdup(const char *s)
> return s ? xstrdup(s) : NULL;
> }
> 
>+bool
>+nullable_string_is_equal(const char *a, const char *b)
>+{
>+return a ? b && !strcmp(a, b) : !b;
>+}
>+
> char *
> xvasprintf(const char *format, va_list args)
> {
>diff --git a/lib/util.h b/lib/util.h
>index e738c9f..6a61dde 100644
>--- a/lib/util.h
>+++ b/lib/util.h
>@@ -113,6 +113,7 @@ void *xmemdup(const void *, size_t) MALLOC_LIKE;
> char *xmemdup0(const char *, size_t) MALLOC_LIKE;
> char *xstrdup(const char *) MALLOC_LIKE;
> char *nullable_xstrdup(const char *) MALLOC_LIKE;
>+bool nullable_string_is_equal(const char *a, const char *b);
> char *xasprintf(const char *format, ...) OVS_PRINTF_FORMAT(1, 2) MALLOC_LIKE;
> char *xvasprintf(const char *format, va_list) OVS_PRINTF_FORMAT(1, 0) 
> MALLOC_LIKE;
> void *x2nrealloc(void *p, size_t *n, size_t s);
>diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
>index 5744abb..d9069cb 100644
>--- a/ofproto/ofproto-dpif-ipfix.c
>+++ b/ofproto/ofproto-dpif-ipfix.c
>@@ -464,12 +464,6 @@ static void get_export_time_now(uint64_t *, uint32_t *);
> static void dpif_ipfix_cache_expire_now(struct dpif_ipfix_exporter *, bool);
> 
> static bool
>-nullable_string_is_equal(const char *a, const char *b)
>-{
>-return a ? b && !strcmp(a, b) : !b;
>-}
>-
>-static bool
> ofproto_ipfix_bridge_exporter_options_equal(
> const struct ofproto_ipfix_bridge_exporter_options *a,
> const struct ofproto_ipfix_bridge_exporter_options *b)
>diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
>index 7d0aa36..8ede492 100644
>--- a/ofproto/ofproto-dpif-sflow.c
>+++ b/ofproto/ofproto-dpif-sflow.c
>@@ -92,12 +92,6 @@ static void dpif_sflow_del_port__(struct dpif_sflow *,
> static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
> 
> static bool
>-nullable_string_is_equal(const char *a, const char *b)
>-{
>-return a ? b && !strcmp(a, b) : !b;
>-}
>-
>-static bool
> ofproto_sflow_options_equal(const struct ofproto_sflow_options *a,
>  const struct ofproto_sflow_options *b)
> {
>-- 
>2.7.4
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v3 1/3] bridge: Pass interface's configuration to datapath.

2016-07-25 Thread Daniele Di Proietto
Thanks for the patch

It looks good to me, a few minor comments inline


On 15/07/2016 04:54, "Ilya Maximets"  wrote:

>This commit adds functionality to pass value of 'other_config' column
>of 'Interface' table to datapath.
>
>This may be used to pass not directly connected with netdev options and
>configure behaviour of the datapath for different ports.
>For example: pinning of rx queues to polling threads in dpif-netdev.
>
>Signed-off-by: Ilya Maximets 
>---
> lib/dpif-netdev.c  |  1 +
> lib/dpif-netlink.c |  1 +
> lib/dpif-provider.h|  5 +
> lib/dpif.c | 17 +
> lib/dpif.h |  1 +
> ofproto/ofproto-dpif.c | 16 
> ofproto/ofproto-provider.h |  5 +
> ofproto/ofproto.c  | 29 +
> ofproto/ofproto.h  |  2 ++
> vswitchd/bridge.c  |  2 ++
> 10 files changed, 79 insertions(+)
>
>diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
>index 6345944..4643cce 100644
>--- a/lib/dpif-netdev.c
>+++ b/lib/dpif-netdev.c
>@@ -4295,6 +4295,7 @@ const struct dpif_class dpif_netdev_class = {
> dpif_netdev_get_stats,
> dpif_netdev_port_add,
> dpif_netdev_port_del,
>+NULL,   /* port_set_config */
> dpif_netdev_port_query_by_number,
> dpif_netdev_port_query_by_name,
> NULL,   /* port_get_pid */
>diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
>index e2bea23..2f939ae 100644
>--- a/lib/dpif-netlink.c
>+++ b/lib/dpif-netlink.c
>@@ -2348,6 +2348,7 @@ const struct dpif_class dpif_netlink_class = {
> dpif_netlink_get_stats,
> dpif_netlink_port_add,
> dpif_netlink_port_del,
>+NULL,   /* port_set_config */
> dpif_netlink_port_query_by_number,
> dpif_netlink_port_query_by_name,
> dpif_netlink_port_get_pid,
>diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h
>index 25f4280..21fb0ba 100644
>--- a/lib/dpif-provider.h
>+++ b/lib/dpif-provider.h
>@@ -167,6 +167,11 @@ struct dpif_class {
> /* Removes port numbered 'port_no' from 'dpif'. */
> int (*port_del)(struct dpif *dpif, odp_port_t port_no);
> 
>+/* Refreshes configuration of 'dpif's port. The implementation might
>+ * postpone applying the changes until run() is called. */
>+int (*port_set_config)(struct dpif *dpif, odp_port_t port_no,
>+   const struct smap *cfg);
>+
> /* Queries 'dpif' for a port with the given 'port_no' or 'devname'.
>  * If 'port' is not null, stores information about the port into
>  * '*port' if successful.
>diff --git a/lib/dpif.c b/lib/dpif.c
>index 5f1be41..f6e5338 100644
>--- a/lib/dpif.c
>+++ b/lib/dpif.c
>@@ -610,6 +610,23 @@ dpif_port_exists(const struct dpif *dpif, const char 
>*devname)
> return !error;
> }
> 
>+/* Refreshes configuration of 'dpif's port. */
>+int
>+dpif_port_set_config(struct dpif *dpif, odp_port_t port_no,
>+ const struct smap *cfg)
>+{
>+int error = 0;
>+
>+if (dpif->dpif_class->port_set_config) {
>+error = dpif->dpif_class->port_set_config(dpif, port_no, cfg);
>+if (error) {
>+log_operation(dpif, "port_set_config", error);
>+}
>+}
>+
>+return error;
>+}
>+
> /* Looks up port number 'port_no' in 'dpif'.  On success, returns 0 and
>  * initializes '*port' appropriately; on failure, returns a positive errno
>  * value.
>diff --git a/lib/dpif.h b/lib/dpif.h
>index 981868c..a7c5097 100644
>--- a/lib/dpif.h
>+++ b/lib/dpif.h
>@@ -839,6 +839,7 @@ void dpif_register_upcall_cb(struct dpif *, 
>upcall_callback *, void *aux);
> int dpif_recv_set(struct dpif *, bool enable);
> int dpif_handlers_set(struct dpif *, uint32_t n_handlers);
> int dpif_poll_threads_set(struct dpif *, const char *cmask);
>+int dpif_port_set_config(struct dpif *, odp_port_t, const struct smap *cfg);
> int dpif_recv(struct dpif *, uint32_t handler_id, struct dpif_upcall *,
>   struct ofpbuf *);
> void dpif_recv_purge(struct dpif *);
>diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
>index ce9383a..97510a9 100644
>--- a/ofproto/ofproto-dpif.c
>+++ b/ofproto/ofproto-dpif.c
>@@ -3542,6 +3542,21 @@ port_del(struct ofproto *ofproto_, ofp_port_t ofp_port)
> }
> 
> static int
>+port_set_config(struct ofproto *ofproto_, ofp_port_t ofp_port,
>+const struct smap *cfg)

Can we change this to directly take struct ofport_dpif *ofport instead of 
ofp_port_t?

>+{
>+struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
>+struct ofport_dpif *ofport = ofp_port_to_ofport(ofproto, ofp_port);
>+
>+if (!ofport || sset_contains(>ghost_ports,
>+ netdev_get_name(ofport->up.netdev))) {
>+return 0;
>+}
>+
>+return dpif_port_set_config(ofproto->backer->dpif, ofport->odp_port, cfg);
>+}
>+
>+static int
> port_get_stats(const struct ofport *ofport_, 

[ovs-dev] [PATACH]ovn: fix bug of dropping flows building in build_lrouter_flows

2016-07-25 Thread Dongjun
In build_lrouter_flows, it says that:" Drop ip traffic to this router, 
unless the router ip is used as SNAT ip. "
But there is a bug, the "continue" only effect the inner loop, dropping 
flows is still built.


Example: Dropping flow c8726aed-0dd0-41b6-bb8c-13ca1e2164c9 should not 
be exist for "ct_snat(192.168.246.200);".
_uuid   actions external_idslogical_datapathmatch 
pipelineprioritytable_id
a29d2785-af1d-45ec-ae60-677356c48f24"drop;" 
{stage-name=lr_in_ip_input} 1915535e-7738-43db-8341-2306221b0691
"ip4.dst == {169.254.128.1}"ingress 60  1
c8726aed-0dd0-41b6-bb8c-13ca1e2164c9"drop;" 
{stage-name=lr_in_ip_input} 1915535e-7738-43db-8341-2306221b0691
"ip4.dst == {192.168.246.200}"  ingress 60  1
0dd66b7e-d11b-4d13-86d1-55ebe9d7e85f "ct_snat(192.168.246.200);" 
{stage-name=lr_out_snat} 1915535e-7738-43db-8341-2306221b0691"ip && 
ip4.src == 101.0.0.0/24" egress  25  0
c3d56ca6-38c6-4943-8d89-2c39cbc3cd9b"next;" {stage-name=lr_out_snat} 
1915535e-7738-43db-8341-2306221b0691"1" egress  0   0


This commit fixed this bug.
NAT configured, the flows:
a29d2785-af1d-45ec-ae60-677356c48f24"drop;" 
{stage-name=lr_in_ip_input} 1915535e-7738-43db-8341-2306221b0691
"ip4.dst == {169.254.128.1}"ingress 60  1
0dd66b7e-d11b-4d13-86d1-55ebe9d7e85f "ct_snat(192.168.246.200);" 
{stage-name=lr_out_snat} 1915535e-7738-43db-8341-2306221b0691"ip && 
ip4.src == 101.0.0.0/24" egress  25  0
c3d56ca6-38c6-4943-8d89-2c39cbc3cd9b"next;" {stage-name=lr_out_snat} 
1915535e-7738-43db-8341-2306221b0691"1" egress  0   0

NAT not configured, the flows:
a29d2785-af1d-45ec-ae60-677356c48f24"drop;" 
{stage-name=lr_in_ip_input} 1915535e-7738-43db-8341-2306221b0691
"ip4.dst == {169.254.128.1}"ingress 60  1
c8726aed-0dd0-41b6-bb8c-13ca1e2164c9"drop;" 
{stage-name=lr_in_ip_input} 1915535e-7738-43db-8341-2306221b0691
"ip4.dst == {192.168.246.200}"  ingress 60  1
c3d56ca6-38c6-4943-8d89-2c39cbc3cd9b"next;" {stage-name=lr_out_snat} 
1915535e-7738-43db-8341-2306221b0691"1" egress  0   0



Signed-off-by: Dongjun 

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
old mode 100644
new mode 100755
index a3d1672..0e4fc93
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -2324,6 +2324,16 @@ op_put_networks(struct ds *ds, const struct 
ovn_port *op, bool add_bcast)

 ds_put_cstr(ds, "}");
 }

+static bool
+has_ip(ovs_be32 *ips, size_t size, ovs_be32 ip){
+for (int i = 0; i < size; i++) {
+if (ip == ips[i]) {
+return true;
+}
+}
+return false;
+}
+
 static void
 build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
 struct hmap *lflows)
@@ -2543,10 +2553,8 @@ build_lrouter_flows(struct hmap *datapaths, 
struct hmap *ports,

 ds_put_cstr(, "ip4.dst == {");
 bool has_drop_ips = false;
 for (int i = 0; i < op->lrp_networks.n_ipv4_addrs; i++) {
-for (int j = 0; j < n_nat_ips; j++) {
-if (op->lrp_networks.ipv4_addrs[i].addr == nat_ips[j]) {
-continue;
-}
+if(has_ip(nat_ips, n_nat_ips, 
op->lrp_networks.ipv4_addrs[i].addr)){

+continue;
 }
 ds_put_format(, "%s, ",
op->lrp_networks.ipv4_addrs[i].addr_s);

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] datapath: Add support for kernel 4.6

2016-07-25 Thread Pravin B Shelar
Most of patch iron out USE_UPSTREAM_TUNNEL case where datapath
directly use upstream tunneling modules.

Signed-off-by: Pravin B Shelar 
---
 acinclude.m4 |  7 +++---
 datapath/linux/compat/geneve.c   |  4 ++--
 datapath/linux/compat/include/linux/if_ether.h   |  3 +--
 datapath/linux/compat/include/net/dst_cache.h|  5 -
 datapath/linux/compat/include/net/dst_metadata.h |  3 ++-
 datapath/linux/compat/include/net/ip_tunnels.h   |  7 +++---
 datapath/linux/compat/include/net/udp_tunnel.h   | 26 ++-
 datapath/linux/compat/lisp.c | 27 ++--
 8 files changed, 49 insertions(+), 33 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 5f38539..04d5fb3 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -134,10 +134,10 @@ AC_DEFUN([OVS_CHECK_LINUX], [
 AC_MSG_RESULT([$kversion])
 
 if test "$version" -ge 4; then
-   if test "$version" = 4 && test "$patchlevel" -le 5; then
+   if test "$version" = 4 && test "$patchlevel" -le 6; then
   : # Linux 4.x
else
-  AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version 
newer than 4.5.x is not supported (please refer to the FAQ for advice)])
+  AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version 
newer than 4.6.x is not supported (please refer to the FAQ for advice)])
fi
 elif test "$version" = 3 && test "$patchlevel" -ge 10; then
: # Linux 3.x
@@ -393,7 +393,6 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
 
   OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [eth_hw_addr_random])
   OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [ether_addr_copy])
-  OVS_GREP_IFELSE([$KSRC/nclude/linux/if_ether.h], [inner_eth_hdr])
 
   OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_link.h], [IFLA_GENEVE_TOS])
   OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_link.h], [rtnl_link_stats64])
@@ -641,6 +640,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
   OVS_GREP_IFELSE([$KSRC/include/net/udp.h], [udp_v4_check])
   OVS_GREP_IFELSE([$KSRC/include/net/udp.h], [udp_set_csum])
   OVS_GREP_IFELSE([$KSRC/include/net/udp_tunnel.h], [udp_tunnel_gro_complete])
+  OVS_GREP_IFELSE([$KSRC/include/net/udp_tunnel.h], 
[sk_buff.*udp_tunnel_handle_offloads],
+  [OVS_DEFINE([HAVE_UDP_TUNNEL_HANDLE_OFFLOAD_RET_SKB])])
   OVS_FIND_FIELD_IFELSE([$KSRC/include/net/udp_tunnel.h], 
[udp_tunnel_sock_cfg],
 [gro_receive])
 
diff --git a/datapath/linux/compat/geneve.c b/datapath/linux/compat/geneve.c
index f782606..834b34c 100644
--- a/datapath/linux/compat/geneve.c
+++ b/datapath/linux/compat/geneve.c
@@ -757,7 +757,7 @@ static int geneve_build_skb(struct rtable *rt, struct 
sk_buff *skb,
if (unlikely(err))
goto free_rt;
 
-   err = udp_tunnel_handle_offloads(skb, udp_sum, false);
+   err = udp_tunnel_handle_offloads(skb, udp_sum);
if (err)
goto free_rt;
 
@@ -790,7 +790,7 @@ static int geneve6_build_skb(struct dst_entry *dst, struct 
sk_buff *skb,
if (unlikely(err))
goto free_dst;
 
-   err = udp_tunnel_handle_offloads(skb, udp_sum, false);
+   err = udp_tunnel_handle_offloads(skb, udp_sum);
if (err)
goto free_dst;
 
diff --git a/datapath/linux/compat/include/linux/if_ether.h 
b/datapath/linux/compat/include/linux/if_ether.h
index b2cb56d..ac0f1ed 100644
--- a/datapath/linux/compat/include/linux/if_ether.h
+++ b/datapath/linux/compat/include/linux/if_ether.h
@@ -11,10 +11,9 @@
 #define ETH_P_8021AD0x88A8  /* 802.1ad Service VLAN */
 #endif
 
-#ifndef HAVE_INNER_ETH_HDR
+#define inner_eth_hdr rpl_inner_eth_hdr
 static inline struct ethhdr *inner_eth_hdr(const struct sk_buff *skb)
 {
return (struct ethhdr *)skb_inner_mac_header(skb);
 }
 #endif
-#endif
diff --git a/datapath/linux/compat/include/net/dst_cache.h 
b/datapath/linux/compat/include/net/dst_cache.h
index 53ca42a..ff4d83b 100644
--- a/datapath/linux/compat/include/net/dst_cache.h
+++ b/datapath/linux/compat/include/net/dst_cache.h
@@ -7,7 +7,10 @@
 #include 
 #endif
 
-#ifndef USE_UPSTREAM_TUNNEL
+#ifdef USE_UPSTREAM_TUNNEL
+#include_next 
+
+#else
 struct dst_cache {
struct dst_cache_pcpu __percpu *cache;
unsigned long reset_ts;
diff --git a/datapath/linux/compat/include/net/dst_metadata.h 
b/datapath/linux/compat/include/net/dst_metadata.h
index 6660dfc..279b714 100644
--- a/datapath/linux/compat/include/net/dst_metadata.h
+++ b/datapath/linux/compat/include/net/dst_metadata.h
@@ -48,7 +48,6 @@ static inline struct metadata_dst *metadata_dst_alloc(u8 
optslen, gfp_t flags)
 }
 
 #define skb_tunnel_info ovs_skb_tunnel_info
-#endif
 
 static inline void ovs_tun_rx_dst(struct metadata_dst *md_dst, int optslen)
 {
@@ -100,6 +99,8 @@ static inline void ovs_ipv6_tun_rx_dst(struct metadata_dst 
*md_dst,
info->key.label = 

[ovs-dev] [PATCH 1/2] rhel: Fix ifup-ovs to delete ports first.

2016-07-25 Thread Flavio Leitner
When ifdown isn't executed (system didn't shut down properly),
ports remain in the openvswitch's database.  In that case, an
inconsitency is left behind when the ifcfg was modified because
ovs-vsctl won't do anything to update existing port's configuration
in the database.

The ifup/ifdown will operate only on configured interfaces, so
this patch fixes the issue by deleting the port from the database
before attempt to configure it with fresh configuration.

Signed-off-by: Flavio Leitner 
---
 rhel/etc_sysconfig_network-scripts_ifup-ovs | 39 +++--
 1 file changed, 31 insertions(+), 8 deletions(-)

diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs 
b/rhel/etc_sysconfig_network-scripts_ifup-ovs
index f3fc05e..6850c9f 100755
--- a/rhel/etc_sysconfig_network-scripts_ifup-ovs
+++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs
@@ -130,7 +130,10 @@ case "$TYPE" in
;;
OVSIntPort)
ifup_ovs_bridge
-   ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" 
"$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=internal ${OVS_EXTRA+-- 
$OVS_EXTRA}
+   ovs-vsctl -t ${TIMEOUT} \
+   -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" \
+   -- add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS \
+   -- set Interface "$DEVICE" type=internal ${OVS_EXTRA+-- 
$OVS_EXTRA}
if [ -n "${OVSDHCPINTERFACES}" ]; then
for _iface in ${OVSDHCPINTERFACES}; do
/sbin/ifup ${_iface}
@@ -143,32 +146,52 @@ case "$TYPE" in
for _iface in $BOND_IFACES; do
/sbin/ifup ${_iface}
done
-   ovs-vsctl -t ${TIMEOUT} -- --may-exist add-bond "$OVS_BRIDGE" 
"$DEVICE" ${BOND_IFACES} $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+   ovs-vsctl -t ${TIMEOUT} \
+   -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" \
+   -- add-bond "$OVS_BRIDGE" "$DEVICE" ${BOND_IFACES} 
$OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
OVSINTF=${DEVICE} /sbin/ifup "$OVS_BRIDGE"
;;
OVSTunnel)
ifup_ovs_bridge
-   ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" 
"$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=$OVS_TUNNEL_TYPE 
$OVS_TUNNEL_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+   ovs-vsctl -t ${TIMEOUT} \
+   -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" \
+   -- add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS \
+   -- set Interface "$DEVICE" type=$OVS_TUNNEL_TYPE 
$OVS_TUNNEL_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
;;
OVSPatchPort)
ifup_ovs_bridge
-   ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" 
"$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=patch 
options:peer="${OVS_PATCH_PEER}" ${OVS_EXTRA+-- $OVS_EXTRA}
+   ovs-vsctl -t ${TIMEOUT} \
+   -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" \
+   -- add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS \
+   -- set Interface "$DEVICE" type=patch 
options:peer="${OVS_PATCH_PEER}" ${OVS_EXTRA+-- $OVS_EXTRA}
;;
OVSDPDKPort)
ifup_ovs_bridge
-   ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" 
"$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=dpdk ${OVS_EXTRA+-- 
$OVS_EXTRA}
+   ovs-vsctl -t ${TIMEOUT} \
+   -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" \
+   -- add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS \
+   -- set Interface "$DEVICE" type=dpdk ${OVS_EXTRA+-- 
$OVS_EXTRA}
;;
OVSDPDKRPort)
ifup_ovs_bridge
-   ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" 
"$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=dpdkr ${OVS_EXTRA+-- 
$OVS_EXTRA}
+   ovs-vsctl -t ${TIMEOUT} \
+   -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" \
+   -- add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS \
+   -- set Interface "$DEVICE" type=dpdkr ${OVS_EXTRA+-- 
$OVS_EXTRA}
;;
OVSDPDVhostPort)
ifup_ovs_bridge
-   ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" 
"$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=dpdkvhost ${OVS_EXTRA+-- 
$OVS_EXTRA}
+   ovs-vsctl -t ${TIMEOUT} \
+   -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" \
+   -- add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS \
+   -- set Interface "$DEVICE" type=dpdkvhost 
${OVS_EXTRA+-- $OVS_EXTRA}
;;
OVSDPDKVhostUserPort)

[ovs-dev] [PATCH 2/2] rhel: Allow openvswitch to get parent information

2016-07-25 Thread Flavio Leitner
Updates SELinux to allow ovs-vsctl to get parent process
information and log that to the database:

record 241: 2016-07-26 00:59:47.418 "ovs-vsctl (invoked by /bin/bash
(pid 1589)): ovs-vsctl -t 10 -- --if-exist ...

Jul 25 12:57:35 localhost.localdomain audit[830]: AVC avc:  denied  {
search } for  pid=830 comm="ovs-vsctl" name="731" dev="proc" ino=14140
scontext=system_u:system_r:openvswitch_t:s0
tcontext=system_u:system_r:initrc_t:s0 tclass=dir permissive=0

Signed-off-by: Flavio Leitner 
---
 selinux/openvswitch-custom.te | 5 +
 1 file changed, 5 insertions(+)

diff --git a/selinux/openvswitch-custom.te b/selinux/openvswitch-custom.te
index fc32b97..5739595 100644
--- a/selinux/openvswitch-custom.te
+++ b/selinux/openvswitch-custom.te
@@ -2,8 +2,13 @@ module openvswitch-custom 1.0;
 
 require {
 type openvswitch_t;
+attribute domain;
 class netlink_socket { setopt getopt create connect getattr write read 
};
+class dir { search };
+class file { open getattr read };
 }
 
 #= openvswitch_t ==
 allow openvswitch_t self:netlink_socket { setopt getopt create connect getattr 
write read };
+allow openvswitch_t domain:dir { search };
+allow openvswitch_t domain:file { open getattr read };
-- 
2.7.4

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 0/2] rhel: Fix ifup-ovs to delete ports first

2016-07-25 Thread Flavio Leitner
The configuration is stored on ifcfg files, so it makes sense
to start fresh every time, but that uncovers a SELinux issue
where ovs-vsctl fails to get parent information.

The first patch fixes the config issue.

The second patch fixes the SELinux issue.

Thanks,

Flavio Leitner (2):
  rhel: Fix ifup-ovs to delete ports first.
  rhel: Allow openvswitch to get parent information

 rhel/etc_sysconfig_network-scripts_ifup-ovs | 39 +++--
 selinux/openvswitch-custom.te   |  5 
 2 files changed, 36 insertions(+), 8 deletions(-)

-- 
2.7.4

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 3/3] datapath: compat: simplify ip_local_out().

2016-07-25 Thread Pravin B Shelar
Signed-off-by: Pravin B Shelar 
---
 datapath/linux/compat/gso.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/datapath/linux/compat/gso.c b/datapath/linux/compat/gso.c
index 8368c6a..de9c8e1 100644
--- a/datapath/linux/compat/gso.c
+++ b/datapath/linux/compat/gso.c
@@ -266,17 +266,13 @@ static int output_ip(struct sk_buff *skb)
 int rpl_ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
int ret = NETDEV_TX_OK;
-   int id = -1;
+   int id;
 
if (!OVS_GSO_CB(skb)->fix_segment)
return output_ip(skb);
 
skb->encapsulation = false;
if (skb_is_gso(skb)) {
-   struct iphdr *iph;
-
-   iph = ip_hdr(skb);
-   id = ntohs(iph->id);
skb = tnl_skb_gso_segment(skb, 0, false, AF_INET);
if (!skb || IS_ERR(skb))
return 0;
@@ -286,17 +282,15 @@ int rpl_ip_local_out(struct net *net, struct sock *sk, 
struct sk_buff *skb)
err = skb_checksum_help(skb);
if (unlikely(err))
return 0;
+   return output_ip(skb);
}
 
+   id = ntohs(ip_hdr(skb)->id);
while (skb) {
struct sk_buff *next_skb = skb->next;
-   struct iphdr *iph;
 
skb->next = NULL;
-
-   iph = ip_hdr(skb);
-   if (id >= 0)
-   iph->id = htons(id++);
+   ip_hdr(skb)->id = htons(id++);
 
ret = output_ip(skb);
skb = next_skb;
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 2/3] datapath: compat: unset skb encapsulation bit

2016-07-25 Thread Pravin B Shelar
OVS compat layer can handle tunnel GSO packets. but it does
keep skb encapsulation on for packet handled in GSO. This can
confuse some NIC drivers. I have seen this issue on intel devices:

  i40e :42:00.0: TX driver issue detected, PF reset issued

Following patch resets this bit in case compat layer handles the packet.

VMware-BZ: 1698877
Signed-off-by: Pravin B Shelar 
---
 datapath/linux/compat/gso.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/datapath/linux/compat/gso.c b/datapath/linux/compat/gso.c
index 92f5441..8368c6a 100644
--- a/datapath/linux/compat/gso.c
+++ b/datapath/linux/compat/gso.c
@@ -271,6 +271,7 @@ int rpl_ip_local_out(struct net *net, struct sock *sk, 
struct sk_buff *skb)
if (!OVS_GSO_CB(skb)->fix_segment)
return output_ip(skb);
 
+   skb->encapsulation = false;
if (skb_is_gso(skb)) {
struct iphdr *iph;
 
@@ -325,6 +326,7 @@ int rpl_ip6_local_out(struct net *net, struct sock *sk, 
struct sk_buff *skb)
if (!OVS_GSO_CB(skb)->fix_segment)
return output_ipv6(skb);
 
+   skb->encapsulation = false;
if (skb_is_gso(skb)) {
skb = tnl_skb_gso_segment(skb, 0, false, AF_INET6);
if (!skb || IS_ERR(skb))
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 0/3] datapath: tunneling fixes.

2016-07-25 Thread Pravin B Shelar
First two patches fixes to issues related to geneva and vxlan tunnel.
Third patch is just code improvement.

Pravin B Shelar (3):
  datapath: compat: fix udp checksum calculation
  datapath: compat: unset skb encapsulation bit
  datapath: compat: simplify ip_local_out().

 datapath/linux/compat/gso.c | 16 ++--
 datapath/linux/compat/udp.c |  3 ++-
 2 files changed, 8 insertions(+), 11 deletions(-)

-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 1/3] datapath: compat: fix udp checksum calculation

2016-07-25 Thread Pravin B Shelar
In upstream linux kernel networking stack udp_set_csum() is called
with only udp header applied but in case of compat layer it can
be called with IP header. So following patch take the offset into
account.

Signed-off-by: Pravin B Shelar 
---
 datapath/linux/compat/udp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/datapath/linux/compat/udp.c b/datapath/linux/compat/udp.c
index f0362b6..0152830 100644
--- a/datapath/linux/compat/udp.c
+++ b/datapath/linux/compat/udp.c
@@ -26,12 +26,13 @@ void rpl_udp_set_csum(bool nocheck, struct sk_buff *skb,
skb->csum_offset = offsetof(struct udphdr, check);
uh->check = ~udp_v4_check(len, saddr, daddr, 0);
} else {
+   int l4_offset = skb_transport_offset(skb);
__wsum csum;
 
BUG_ON(skb->ip_summed == CHECKSUM_PARTIAL);
 
uh->check = 0;
-   csum = skb_checksum(skb, 0, len, 0);
+   csum = skb_checksum(skb, l4_offset, len, 0);
uh->check = udp_v4_check(len, saddr, daddr, csum);
if (uh->check == 0)
uh->check = CSUM_MANGLED_0;
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] rhel/openvswitch.spec: Add SELinux policy.

2016-07-25 Thread Flavio Leitner
On Mon, Jul 25, 2016 at 02:09:26PM -0700, Joe Stringer wrote:
> Commit 9b897c9125ef ("rhel: provide our own SELinux custom policy
> package") added the SELinux policy to the fedora packaging as a
> subpackage. This patch makes the corresponding change to
> openvswitch.spec, so that users of that specfile can generate the
> selinux policy package without having to build all of the fedora
> packages.
> 
> Signed-off-by: Joe Stringer 
> ---

Thanks Joe!
Acked-by: Flavio Leitner 


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] JSON serialization via Python's json lib

2016-07-25 Thread Terry Wilson
There is no particularly good reason to use our own Python JSON
serialization implementation when serialization can be done faster
with Python's built-in JSON library.

A few tests were changed due to Python's default JSON library
returning slightly more precise floating point numbers.

Signed-off-by: Terry Wilson 
---
 python/ovs/json.py | 106 +
 tests/json.at  |  26 ++---
 2 files changed, 30 insertions(+), 102 deletions(-)

diff --git a/python/ovs/json.py b/python/ovs/json.py
index ea0400a..ddf5dd2 100644
--- a/python/ovs/json.py
+++ b/python/ovs/json.py
@@ -12,11 +12,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import absolute_import
+import functools
+import json
 import re
 import sys
 
 import six
-from six.moves import range
 
 try:
 import ovs._json
@@ -25,112 +27,24 @@ except ImportError:
 
 __pychecker__ = 'no-stringiter'
 
-escapes = {ord('"'): u"\\\"",
-   ord("\\"): u"",
-   ord("\b"): u"\\b",
-   ord("\f"): u"\\f",
-   ord("\n"): u"\\n",
-   ord("\r"): u"\\r",
-   ord("\t"): u"\\t"}
-for esc in range(32):
-if esc not in escapes:
-escapes[esc] = u"\\u%04x" % esc
-
 SPACES_PER_LEVEL = 2
-
-
-class _Serializer(object):
-def __init__(self, stream, pretty, sort_keys):
-self.stream = stream
-self.pretty = pretty
-self.sort_keys = sort_keys
-self.depth = 0
-
-def __serialize_string(self, s):
-self.stream.write(u'"%s"' % ''.join(escapes.get(ord(c), c) for c in s))
-
-def __indent_line(self):
-if self.pretty:
-self.stream.write('\n')
-self.stream.write(' ' * (SPACES_PER_LEVEL * self.depth))
-
-def serialize(self, obj):
-if obj is None:
-self.stream.write(u"null")
-elif obj is False:
-self.stream.write(u"false")
-elif obj is True:
-self.stream.write(u"true")
-elif isinstance(obj, six.integer_types):
-self.stream.write(u"%d" % obj)
-elif isinstance(obj, float):
-self.stream.write("%.15g" % obj)
-elif isinstance(obj, six.text_type):
-# unicode() on Python 2, or str() in Python 3 (always unicode)
-self.__serialize_string(obj)
-elif isinstance(obj, str):
-# This is for Python 2, where this comes out to unicode(str()).
-# For Python 3, it's str(str()), but it's harmless.
-self.__serialize_string(six.text_type(obj))
-elif isinstance(obj, dict):
-self.stream.write(u"{")
-
-self.depth += 1
-self.__indent_line()
-
-if self.sort_keys:
-items = sorted(obj.items())
-else:
-items = six.iteritems(obj)
-for i, (key, value) in enumerate(items):
-if i > 0:
-self.stream.write(u",")
-self.__indent_line()
-self.__serialize_string(six.text_type(key))
-self.stream.write(u":")
-if self.pretty:
-self.stream.write(u' ')
-self.serialize(value)
-
-self.stream.write(u"}")
-self.depth -= 1
-elif isinstance(obj, (list, tuple)):
-self.stream.write(u"[")
-self.depth += 1
-
-if obj:
-self.__indent_line()
-
-for i, value in enumerate(obj):
-if i > 0:
-self.stream.write(u",")
-self.__indent_line()
-self.serialize(value)
-
-self.depth -= 1
-self.stream.write(u"]")
-else:
-raise Exception("can't serialize %s as JSON" % obj)
+dumper = functools.partial(json.dumps, separators=(",", ":"),
+   ensure_ascii=False)
 
 
 def to_stream(obj, stream, pretty=False, sort_keys=True):
-_Serializer(stream, pretty, sort_keys).serialize(obj)
+stream.write(dumper(obj, indent=SPACES_PER_LEVEL if pretty else None,
+sort_keys=sort_keys))
 
 
 def to_file(obj, name, pretty=False, sort_keys=True):
-stream = open(name, "w")
-try:
+with open(name, "w") as stream:
 to_stream(obj, stream, pretty, sort_keys)
-finally:
-stream.close()
 
 
 def to_string(obj, pretty=False, sort_keys=True):
-output = six.StringIO()
-to_stream(obj, output, pretty, sort_keys)
-s = output.getvalue()
-output.close()
-return s
+return dumper(obj, indent=SPACES_PER_LEVEL if pretty else None,
+  sort_keys=sort_keys)
 
 
 def from_stream(stream):
diff --git a/tests/json.at b/tests/json.at
index 32d7fff..ba7d4bb 100644
--- a/tests/json.at
+++ b/tests/json.at
@@ -1,4 +1,4 @@

[ovs-dev] [PATCH] JSON serialization via Python's json lib

2016-07-25 Thread Terry Wilson
This patch removes the json extension build system changes since they
aren't even related to the serialization change, which is pure-Python.

Terry Wilson (1):
  JSON serialization via Python's json lib

 python/ovs/json.py | 106 +
 tests/json.at  |  26 ++---
 2 files changed, 30 insertions(+), 102 deletions(-)

-- 
1.8.3.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 5/7] datapath-windows: Add support for multiple event queue in Event.c

2016-07-25 Thread Sairam Venugopal
Update Event.c to have multiple event queues and mechanism to retrieve the
associated queue. Introduce OvsPostCtEvent and OvsRemoveCtEventEntry
similar to OvsPostVportEvent and OvsRemoveVportEventEntry.

v2: Added Acked-By

Signed-off-by: Sairam Venugopal 
Acked-by: Paul Boca 
Acked-by: Alin Gabriel Serdean 
---
 datapath-windows/ovsext/Event.c | 265 +---
 datapath-windows/ovsext/Event.h |  17 ++-
 2 files changed, 239 insertions(+), 43 deletions(-)

diff --git a/datapath-windows/ovsext/Event.c b/datapath-windows/ovsext/Event.c
index 8ff0322..cb0dc92 100644
--- a/datapath-windows/ovsext/Event.c
+++ b/datapath-windows/ovsext/Event.c
@@ -26,36 +26,62 @@
 #define OVS_DBG_MOD OVS_DBG_EVENT
 #include "Debug.h"
 
-LIST_ENTRY ovsEventQueue;
-static NDIS_SPIN_LOCK eventQueueLock;
-UINT32 ovsNumEventQueue;
+LIST_ENTRY ovsEventQueueArr[OVS_MCAST_EVENT_TYPES_MAX];
+static NDIS_SPIN_LOCK eventQueueLockArr[OVS_MCAST_EVENT_TYPES_MAX];
+UINT32 ovsNumEventQueueArr[OVS_MCAST_EVENT_TYPES_MAX];
 
 NTSTATUS
 OvsInitEventQueue()
 {
-InitializeListHead();
-NdisAllocateSpinLock();
+for (int i = 0; i < OVS_MCAST_EVENT_TYPES_MAX; i++) {
+InitializeListHead([i]);
+NdisAllocateSpinLock([i]);
+}
 return STATUS_SUCCESS;
 }
 
 VOID
 OvsCleanupEventQueue()
 {
-ASSERT(IsListEmpty());
-ASSERT(ovsNumEventQueue == 0);
-NdisFreeSpinLock();
+for (int i = 0; i < OVS_MCAST_EVENT_TYPES_MAX; i++) {
+ASSERT(IsListEmpty([i]));
+ASSERT(ovsNumEventQueueArr[i] == 0);
+NdisFreeSpinLock([i]);
+}
 }
 
 static __inline VOID
-OvsAcquireEventQueueLock()
+OvsAcquireEventQueueLock(int eventId)
 {
-NdisAcquireSpinLock();
+NdisAcquireSpinLock([eventId]);
 }
 
 static __inline VOID
-OvsReleaseEventQueueLock()
+OvsReleaseEventQueueLock(int eventId)
 {
-   NdisReleaseSpinLock();
+   NdisReleaseSpinLock([eventId]);
+}
+
+NDIS_STATUS
+OvsGetMcastEventId(UINT32 protocol, UINT32 mcastMask, UINT32 *eventId)
+{
+switch (protocol) {
+case NETLINK_GENERIC:
+*eventId = OVS_MCAST_VPORT_EVENT;
+return NDIS_STATUS_SUCCESS;
+case NETLINK_NETFILTER:
+if ((mcastMask & OVS_EVENT_CT_NEW)
+|| (mcastMask & OVS_EVENT_CT_DELETE)) {
+*eventId =  OVS_MCAST_CT_EVENT;
+return NDIS_STATUS_SUCCESS;
+}
+break;
+default:
+goto error;
+}
+
+error:
+return NDIS_STATUS_INVALID_PARAMETER;
 }
 
 /*
@@ -68,14 +94,17 @@ OvsCleanupEvent(POVS_OPEN_INSTANCE instance)
 {
 POVS_EVENT_QUEUE queue;
 PIRP irp = NULL;
+UINT32 eventId;
 queue = (POVS_EVENT_QUEUE)instance->eventQueue;
 if (queue) {
 POVS_EVENT_QUEUE_ELEM elem;
 PLIST_ENTRY link, next;
 
-OvsAcquireEventQueueLock();
+/* Handle the error */
+OvsGetMcastEventId(instance->protocol, instance->mcastMask, );
+OvsAcquireEventQueueLock(eventId);
 RemoveEntryList(>queueLink);
-ovsNumEventQueue--;
+ovsNumEventQueueArr[eventId]--;
 if (queue->pendingIrp) {
 PDRIVER_CANCEL cancelRoutine;
 irp = queue->pendingIrp;
@@ -86,7 +115,7 @@ OvsCleanupEvent(POVS_OPEN_INSTANCE instance)
 }
 }
 instance->eventQueue = NULL;
-OvsReleaseEventQueueLock();
+OvsReleaseEventQueueLock(eventId);
 if (irp) {
 OvsCompleteIrpRequest(irp, 0, STATUS_SUCCESS);
 }
@@ -115,7 +144,7 @@ OvsPostVportEvent(POVS_VPORT_EVENT_ENTRY event)
 POVS_EVENT_QUEUE queue;
 PLIST_ENTRY link;
 LIST_ENTRY list;
-   PLIST_ENTRY entry;
+PLIST_ENTRY entry;
 PIRP irp;
 
 InitializeListHead();
@@ -123,9 +152,9 @@ OvsPostVportEvent(POVS_VPORT_EVENT_ENTRY event)
 OVS_LOG_TRACE("Enter: portNo: %#x, status: %#x", event->portNo,
   event->type);
 
-OvsAcquireEventQueueLock();
+OvsAcquireEventQueueLock(OVS_MCAST_VPORT_EVENT);
 
-LIST_FORALL(, link) {
+LIST_FORALL([OVS_MCAST_VPORT_EVENT], link) {
 queue = CONTAINING_RECORD(link, OVS_EVENT_QUEUE, queueLink);
 if ((event->type & queue->mask) == 0) {
 continue;
@@ -137,7 +166,7 @@ OvsPostVportEvent(POVS_VPORT_EVENT_ENTRY event)
 
 if (elem == NULL) {
 OVS_LOG_WARN("Fail to allocate memory for event");
-OvsReleaseEventQueueLock();
+OvsReleaseEventQueueLock(OVS_MCAST_VPORT_EVENT);
 return;
 }
 
@@ -157,7 +186,7 @@ OvsPostVportEvent(POVS_VPORT_EVENT_ENTRY event)
 }
 }
 }
-OvsReleaseEventQueueLock();
+OvsReleaseEventQueueLock(OVS_MCAST_VPORT_EVENT);
 while (!IsListEmpty()) {
 entry = RemoveHeadList();
 irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.ListEntry);
@@ -189,17 +218,25 @@ OvsSubscribeEventIoctl(PFILE_OBJECT fileObject,
 NTSTATUS status = STATUS_SUCCESS;
 

[ovs-dev] [PATCH v2 3/7] datapath-windows: Define new multicast conntrack events and netlink protocol

2016-07-25 Thread Sairam Venugopal
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.

v2: Squashed patches 2/9 and 5/9 into one. Addressed review comments from
Yin Lin and Alin Serdean

Signed-off-by: Sairam Venugopal 
---
 datapath-windows/ovsext/Datapath.c | 21 ++---
 datapath-windows/ovsext/Datapath.h |  3 ++-
 datapath-windows/ovsext/DpInternal.h   | 16 
 datapath-windows/ovsext/Netlink/NetlinkProto.h |  3 +++
 4 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c 
b/datapath-windows/ovsext/Datapath.c
index 75f133a..f9f965c 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -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);
 
@@ -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, ,
 sizeof request);
diff --git a/datapath-windows/ovsext/Datapath.h 
b/datapath-windows/ovsext/Datapath.h
index 2b41d82..57b483a 100644
--- a/datapath-windows/ovsext/Datapath.h
+++ b/datapath-windows/ovsext/Datapath.h
@@ -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. */
diff --git a/datapath-windows/ovsext/DpInternal.h 
b/datapath-windows/ovsext/DpInternal.h
index 8abe61d..22599a0 100644
--- a/datapath-windows/ovsext/DpInternal.h
+++ b/datapath-windows/ovsext/DpInternal.h
@@ -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 {
@@ -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;
diff --git a/datapath-windows/ovsext/Netlink/NetlinkProto.h 
b/datapath-windows/ovsext/Netlink/NetlinkProto.h
index beb14d5..5175311 100644
--- a/datapath-windows/ovsext/Netlink/NetlinkProto.h
+++ b/datapath-windows/ovsext/Netlink/NetlinkProto.h
@@ -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 */
-- 
2.9.0.windows.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 7/7] datapath-windows: Post Conntrack delete and new events

2016-07-25 Thread Sairam Venugopal
Post Conntrack delete and create events when entries are deleted or
created.

v2: Added Acked-By

Signed-off-by: Sairam Venugopal 
Acked-by: Paul Boca 
Acked-by: Alin Gabriel Serdean 
---
 datapath-windows/ovsext/Conntrack.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/datapath-windows/ovsext/Conntrack.c 
b/datapath-windows/ovsext/Conntrack.c
index 382c13d..af3d966 100644
--- a/datapath-windows/ovsext/Conntrack.c
+++ b/datapath-windows/ovsext/Conntrack.c
@@ -23,6 +23,7 @@
 #include "Jhash.h"
 #include "PacketParser.h"
 #include "Debug.h"
+#include "Event.h"
 
 #define WINDOWS_TICK 1000
 #define SEC_TO_UNIX_EPOCH 11644473600LL
@@ -154,6 +155,15 @@ OvsCtUpdateFlowKey(struct OvsFlowKey *key,
 }
 
 static __inline VOID
+OvsPostCtEventEntry(POVS_CT_ENTRY entry, UINT8 type)
+{
+OVS_CT_EVENT_ENTRY ctEventEntry = {0};
+NdisMoveMemory(, entry, sizeof(OVS_CT_ENTRY));
+ctEventEntry.type = type;
+OvsPostCtEvent();
+}
+
+static __inline VOID
 OvsCtAddEntry(POVS_CT_ENTRY entry, OvsConntrackKeyLookupCtx *ctx, UINT64 now)
 {
 NdisMoveMemory(>key, >key, sizeof (OVS_CT_KEY));
@@ -162,6 +172,7 @@ OvsCtAddEntry(POVS_CT_ENTRY entry, OvsConntrackKeyLookupCtx 
*ctx, UINT64 now)
 entry->timestampStart = now;
 InsertHeadList([ctx->hash & CT_HASH_TABLE_MASK],
>link);
+OvsPostCtEventEntry(entry, OVS_EVENT_CT_NEW);
 ctTotalEntries++;
 }
 
@@ -253,6 +264,7 @@ OvsCtUpdateEntry(OVS_CT_ENTRY* entry,
 static __inline VOID
 OvsCtEntryDelete(POVS_CT_ENTRY entry)
 {
+OvsPostCtEventEntry(entry, OVS_EVENT_CT_DELETE);
 RemoveEntryList(>link);
 OvsFreeMemoryWithTag(entry, OVS_CT_POOL_TAG);
 ctTotalEntries--;
-- 
2.9.0.windows.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 4/7] datapath-windows: Modify OvsCreateNlMsgFromCtEntry to make it reusable

2016-07-25 Thread Sairam Venugopal
Tweak the OvsCreateNlMsgFromCtEntry() method to reuse it for creating
netlink messages from other files. Also define the function in Conntrack.h
to make it accessible.

v2: Added Acked-By

Signed-off-by: Sairam Venugopal 
Acked-By: Yin Lin 
Acked-by: Alin Gabriel Serdean 
---
 datapath-windows/ovsext/Conntrack.c | 32 ++--
 datapath-windows/ovsext/Conntrack.h |  9 +
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/datapath-windows/ovsext/Conntrack.c 
b/datapath-windows/ovsext/Conntrack.c
index 90b59ce..382c13d 100644
--- a/datapath-windows/ovsext/Conntrack.c
+++ b/datapath-windows/ovsext/Conntrack.c
@@ -934,12 +934,15 @@ WindowsTickToUnixSeconds(long long windowsTicks)
 - SEC_TO_UNIX_EPOCH));
 }
 
-static NTSTATUS
+NTSTATUS
 OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry,
-  POVS_MESSAGE msgIn,
   PVOID outBuffer,
   UINT32 outBufLen,
-  int dpIfIndex)
+  UINT8 eventType,
+  UINT32 nlmsgSeq,
+  UINT32 nlmsgPid,
+  UINT8 nfGenVersion,
+  UINT32 dpIfIndex)
 {
 NL_BUFFER nlBuf;
 BOOLEAN ok;
@@ -947,6 +950,7 @@ OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry,
 UINT32 timeout;
 NDIS_STATUS status;
 UINT64 currentTime, expiration;
+UINT16 nlmsgType;
 NdisGetCurrentSystemTime((LARGE_INTEGER *));
 UINT8 nfgenFamily = 0;
 if (entry->key.dl_type == htons(ETH_TYPE_IPV4)) {
@@ -957,13 +961,17 @@ OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry,
 
 NlBufInit(, outBuffer, outBufLen);
 /* Mimic netfilter */
-UINT16 nlmsgType = (NFNL_SUBSYS_CTNETLINK << 8 | IPCTNL_MSG_CT_NEW);
+if (eventType == OVS_EVENT_CT_NEW) {
+nlmsgType = (UINT16) (NFNL_SUBSYS_CTNETLINK << 8 | IPCTNL_MSG_CT_NEW);
+} else if (eventType == OVS_EVENT_CT_DELETE) {
+nlmsgType = (UINT16) (NFNL_SUBSYS_CTNETLINK << 8 | 
IPCTNL_MSG_CT_DELETE);
+} else {
+return STATUS_INVALID_PARAMETER;
+}
+
 ok = NlFillOvsMsgForNfGenMsg(, nlmsgType, NLM_F_CREATE,
- msgIn->nlMsg.nlmsgSeq,
- msgIn->nlMsg.nlmsgPid,
- nfgenFamily,
- msgIn->nfGenMsg.version,
- dpIfIndex);
+ nlmsgSeq, nlmsgPid, nfgenFamily,
+ nfGenVersion, dpIfIndex);
 if (!ok) {
 return STATUS_INVALID_BUFFER_SIZE;
 }
@@ -1130,9 +1138,13 @@ OvsCtDumpCmdHandler(POVS_USER_PARAMS_CONTEXT 
usrParamsCtx,
 if (outIndex >= inIndex) {
 entry = CONTAINING_RECORD(link, OVS_CT_ENTRY, link);
 
-rc = OvsCreateNlMsgFromCtEntry(entry, msgIn,
+rc = OvsCreateNlMsgFromCtEntry(entry,
usrParamsCtx->outputBuffer,
usrParamsCtx->outputLength,
+   OVS_EVENT_CT_NEW,
+   msgIn->nlMsg.nlmsgSeq,
+   msgIn->nlMsg.nlmsgPid,
+   msgIn->nfGenMsg.version,
0);
 
 if (rc != NDIS_STATUS_SUCCESS) {
diff --git a/datapath-windows/ovsext/Conntrack.h 
b/datapath-windows/ovsext/Conntrack.h
index 6d573c8..4995ff4 100644
--- a/datapath-windows/ovsext/Conntrack.h
+++ b/datapath-windows/ovsext/Conntrack.h
@@ -116,4 +116,13 @@ enum CT_UPDATE_RES 
OvsConntrackUpdateTcpEntry(OVS_CT_ENTRY* conn_,
 enum ct_update_res OvsConntrackUpdateOtherEntry(OVS_CT_ENTRY *conn_,
 BOOLEAN reply,
 UINT64 now);
+NTSTATUS
+OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry,
+  PVOID outBuffer,
+  UINT32 outBufLen,
+  UINT8 eventType,
+  UINT32 nlmsgSeq,
+  UINT32 nlmsgPid,
+  UINT8 nfGenVersion,
+  UINT32 dpIfIndex);
 #endif /* __OVS_CONNTRACK_H_ */
-- 
2.9.0.windows.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 1/7] datapath-windows: Explicitly name vport related event to vportEvent

2016-07-25 Thread Sairam Venugopal
OVS_EVENT_ENTRY currently handles only Vport related events. Updating the
name of the struct to OVS_VPORT_EVENT_ENTRY. Remove OVS_EVENT_STATUS since
it's currently not in use. Update the datapath to refer to events as
vportEvents. This will aid in the introduction of other events.

v2: Squash 1/9 and 3/9 into one commit. Added Acked-by.

Signed-off-by: Sairam Venugopal 
Acked-By: Yin Lin 
Acked-by: Alin Gabriel Serdean 
---
 datapath-windows/ovsext/Datapath.c   |  7 ---
 datapath-windows/ovsext/DpInternal.h | 10 ++
 datapath-windows/ovsext/Event.c  | 10 +-
 datapath-windows/ovsext/Event.h  |  7 ---
 datapath-windows/ovsext/Vport.c  | 12 ++--
 5 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c 
b/datapath-windows/ovsext/Datapath.c
index 4f47be5..e4d6ab1 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -1582,7 +1582,7 @@ MapIrpOutputBuffer(PIRP irp,
  */
 static NTSTATUS
 OvsPortFillInfo(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
-POVS_EVENT_ENTRY eventEntry,
+POVS_VPORT_EVENT_ENTRY eventEntry,
 PNL_BUFFER nlBuf)
 {
 NTSTATUS status;
@@ -1659,7 +1659,7 @@ OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT 
usrParamsCtx,
 #endif
 NL_BUFFER nlBuf;
 NTSTATUS status;
-OVS_EVENT_ENTRY eventEntry;
+OVS_VPORT_EVENT_ENTRY eventEntry;
 
 ASSERT(usrParamsCtx->devOp == OVS_READ_DEV_OP);
 
@@ -1675,7 +1675,8 @@ OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT 
usrParamsCtx,
 NlBufInit(, usrParamsCtx->outputBuffer, usrParamsCtx->outputLength);
 
 /* remove an event entry from the event queue */
-status = OvsRemoveEventEntry(usrParamsCtx->ovsInstance, );
+status = OvsRemoveVportEventEntry(usrParamsCtx->ovsInstance,
+  );
 if (status != STATUS_SUCCESS) {
 /* If there were not elements, read should return no data. */
 status = STATUS_SUCCESS;
diff --git a/datapath-windows/ovsext/DpInternal.h 
b/datapath-windows/ovsext/DpInternal.h
index 42b5ec9..8abe61d 100644
--- a/datapath-windows/ovsext/DpInternal.h
+++ b/datapath-windows/ovsext/DpInternal.h
@@ -328,19 +328,13 @@ enum {
 };
 
 
-typedef struct _OVS_EVENT_ENTRY {
+typedef struct _OVS_VPORT_EVENT_ENTRY {
 UINT32 portNo;
 OVS_VPORT_TYPE ovsType;
 UINT32 upcallPid;
 CHAR ovsName[OVS_MAX_PORT_NAME_LENGTH];
 UINT32 type;
-} OVS_EVENT_ENTRY, *POVS_EVENT_ENTRY;
-
-
-typedef struct _OVS_EVENT_STATUS {
-uint32_t numberEntries;
-OVS_EVENT_ENTRY eventEntries[0];
-} OVS_EVENT_STATUS, *POVS_EVENT_STATUS;
+} OVS_VPORT_EVENT_ENTRY, *POVS_VPORT_EVENT_ENTRY;
 
 #pragma pack(pop)
 
diff --git a/datapath-windows/ovsext/Event.c b/datapath-windows/ovsext/Event.c
index f9bea7f..8c7c3ec 100644
--- a/datapath-windows/ovsext/Event.c
+++ b/datapath-windows/ovsext/Event.c
@@ -109,7 +109,7 @@ OvsCleanupEvent(POVS_OPEN_INSTANCE instance)
  * --
  */
 VOID
-OvsPostEvent(POVS_EVENT_ENTRY event)
+OvsPostVportEvent(POVS_VPORT_EVENT_ENTRY event)
 {
 POVS_EVENT_QUEUE_ELEM elem;
 POVS_EVENT_QUEUE queue;
@@ -141,7 +141,7 @@ OvsPostEvent(POVS_EVENT_ENTRY event)
 return;
 }
 
-RtlCopyMemory(>event, event, sizeof elem->event);
+RtlCopyMemory(>vportEvent, event, sizeof elem->vportEvent);
 InsertTailList(>elemList, >link);
 queue->numElems++;
 OVS_LOG_INFO("Queue: %p, numElems: %d",
@@ -409,8 +409,8 @@ unlock:
  * --
  */
 NTSTATUS
-OvsRemoveEventEntry(POVS_OPEN_INSTANCE instance,
-POVS_EVENT_ENTRY entry)
+OvsRemoveVportEventEntry(POVS_OPEN_INSTANCE instance,
+ POVS_VPORT_EVENT_ENTRY entry)
 {
 NTSTATUS status = STATUS_UNSUCCESSFUL;
 POVS_EVENT_QUEUE queue;
@@ -427,7 +427,7 @@ OvsRemoveEventEntry(POVS_OPEN_INSTANCE instance,
 
 if (queue->numElems) {
 elem = (POVS_EVENT_QUEUE_ELEM)RemoveHeadList(>elemList);
-*entry = elem->event;
+*entry = elem->vportEvent;
 OvsFreeMemoryWithTag(elem, OVS_EVENT_POOL_TAG);
 queue->numElems--;
 status = STATUS_SUCCESS;
diff --git a/datapath-windows/ovsext/Event.h b/datapath-windows/ovsext/Event.h
index b087875..255594c 100644
--- a/datapath-windows/ovsext/Event.h
+++ b/datapath-windows/ovsext/Event.h
@@ -19,7 +19,7 @@
 
 typedef struct _OVS_EVENT_QUEUE_ELEM {
 LIST_ENTRY link;
-OVS_EVENT_ENTRY event;
+OVS_VPORT_EVENT_ENTRY vportEvent;
 } OVS_EVENT_QUEUE_ELEM, *POVS_EVENT_QUEUE_ELEM;
 
 typedef struct _OVS_EVENT_QUEUE {
@@ -38,7 +38,7 @@ VOID OvsCleanupEventQueue(VOID);
 struct _OVS_OPEN_INSTANCE;
 
 VOID OvsCleanupEvent(struct _OVS_OPEN_INSTANCE *instance);
-VOID OvsPostEvent(POVS_EVENT_ENTRY 

[ovs-dev] [PATCH v2 0/7] Windows: Add support for sending Conntrack events

2016-07-25 Thread Sairam Venugopal
Add support for sending out Conntrack events on Windows (if subscribed). This 
meant adding support for handling multiple event queues.

v2: Address review comments and squashed the 9 series patch to 7.

The following gives an overview of the design:
1. Currently we only support subscribing/unsubscribing to Vport related events.
2. Event.c maintains a single queue of Event entries that are then read by user 
space.
3. In order to add support for multiple events, I modified the event queue into 
an array (size 2). The size of the event queue array is driven by value of enum 
(we explicitly add new event types here).
4. I decided to make Event Queue an array to avoid creating new ones for every 
event type. This also meant smaller code changes and not having multiple 
if-else in the code.
5. Each event queue can be uniquely identified based on the mcast EventType and 
hence the requirement for multiple locks based on the event type.
6. Though we may not have multiple event queues subscribed for 1 socket, I 
still wanted to ensure that we have support for it if it were ever requested.
7. In future, as we add support for new events, we can add it to the enum 
OVS_MCAST_EVENT_TYPES and subtypes can be represent by means of masks (eg: 
vport up/down, ct delete/add/update etc.,)



Sairam Venugopal (7):
  datapath-windows: Explicitly name vport related event to vportEvent
  datapath-windows: Fix bugs in Event.c around subscribe and lock
  datapath-windows: Define new multicast conntrack events and netlink
protocol
  datapath-windows: Modify OvsCreateNlMsgFromCtEntry to make it reusable
  datapath-windows: Add support for multiple event queue in Event.c
  datapath-windows: Update OvsReadEventCmdHandler in Datapath.c to
support different events
  datapath-windows: Post Conntrack delete and new events

 datapath-windows/ovsext/Conntrack.c|  44 +++-
 datapath-windows/ovsext/Conntrack.h|   9 +
 datapath-windows/ovsext/Datapath.c |  95 +++--
 datapath-windows/ovsext/Datapath.h |   3 +-
 datapath-windows/ovsext/DpInternal.h   |  26 ++-
 datapath-windows/ovsext/Event.c| 279 -
 datapath-windows/ovsext/Event.h|  22 +-
 datapath-windows/ovsext/Netlink/NetlinkProto.h |   3 +
 datapath-windows/ovsext/Vport.c|  12 +-
 9 files changed, 395 insertions(+), 98 deletions(-)

-- 
2.9.0.windows.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 6/7] datapath-windows: Update OvsReadEventCmdHandler in Datapath.c to support different events

2016-07-25 Thread Sairam Venugopal
OvsReadEventCmdHandler must now reflect the right event being read. If the
event is a Conntrack related event, then convert the entry to netlink
format and send it to userspace. If it's Vport event, retain the existing
workflow.

v2: Address review comments from Alin Serdean (Not default values to 0 and
instead read from msgIn). Added Acked-By

Signed-off-by: Sairam Venugopal 
Acked-by: Paul Boca 
---
 datapath-windows/ovsext/Datapath.c | 66 +-
 1 file changed, 50 insertions(+), 16 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c 
b/datapath-windows/ovsext/Datapath.c
index f9f965c..745cdb6 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -1672,14 +1672,12 @@ static NTSTATUS
 OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
UINT32 *replyLen)
 {
-#ifdef DBG
 POVS_MESSAGE msgOut = (POVS_MESSAGE)usrParamsCtx->outputBuffer;
+POVS_MESSAGE msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer;
 POVS_OPEN_INSTANCE instance =
 (POVS_OPEN_INSTANCE)usrParamsCtx->ovsInstance;
-#endif
 NL_BUFFER nlBuf;
 NTSTATUS status;
-OVS_VPORT_EVENT_ENTRY eventEntry;
 
 ASSERT(usrParamsCtx->devOp == OVS_READ_DEV_OP);
 
@@ -1692,21 +1690,57 @@ OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT 
usrParamsCtx,
 /* Output buffer has been validated while validating read dev op. */
 ASSERT(msgOut != NULL && usrParamsCtx->outputLength >= sizeof *msgOut);
 
-NlBufInit(, usrParamsCtx->outputBuffer, usrParamsCtx->outputLength);
+if (instance->protocol == NETLINK_NETFILTER) {
+if (!instance->mcastMask) {
+status = STATUS_SUCCESS;
+*replyLen = 0;
+goto cleanup;
+}
 
-/* remove an event entry from the event queue */
-status = OvsRemoveVportEventEntry(usrParamsCtx->ovsInstance,
-  );
-if (status != STATUS_SUCCESS) {
-/* If there were not elements, read should return no data. */
-status = STATUS_SUCCESS;
-*replyLen = 0;
-goto cleanup;
-}
+OVS_CT_EVENT_ENTRY ctEventEntry;
+status = OvsRemoveCtEventEntry(usrParamsCtx->ovsInstance,
+   );
 
-status = OvsPortFillInfo(usrParamsCtx, , );
-if (status == NDIS_STATUS_SUCCESS) {
-*replyLen = NlBufSize();
+if (status != STATUS_SUCCESS) {
+/* If there were not elements, read should return no data. */
+status = STATUS_SUCCESS;
+*replyLen = 0;
+goto cleanup;
+}
+
+status = OvsCreateNlMsgFromCtEntry(,
+   usrParamsCtx->outputBuffer,
+   usrParamsCtx->outputLength,
+   ctEventEntry.type,
+   msgIn->nlMsg.nlmsgSeq,
+   usrParamsCtx->ovsInstance->pid,
+   NFNETLINK_V0,
+   gOvsSwitchContext->dpNo);
+if (status == NDIS_STATUS_SUCCESS) {
+*replyLen = msgOut->nlMsg.nlmsgLen;
+}
+} else if (instance->protocol == NETLINK_GENERIC) {
+NlBufInit(,
+  usrParamsCtx->outputBuffer,
+  usrParamsCtx->outputLength);
+
+OVS_VPORT_EVENT_ENTRY eventEntry;
+/* remove vport event entry from the vport event queue */
+status = OvsRemoveVportEventEntry(usrParamsCtx->ovsInstance,
+  );
+if (status != STATUS_SUCCESS) {
+/* If there were not elements, read should return no data. */
+status = STATUS_SUCCESS;
+*replyLen = 0;
+goto cleanup;
+}
+
+status = OvsPortFillInfo(usrParamsCtx, , );
+if (status == NDIS_STATUS_SUCCESS) {
+*replyLen = NlBufSize();
+}
+} else {
+status = STATUS_INVALID_PARAMETER;
 }
 
 cleanup:
-- 
2.9.0.windows.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 2/7] datapath-windows: Fix bugs in Event.c around subscribe and lock

2016-07-25 Thread Sairam Venugopal
When userspace tries to resubscribe to an existing queue, return
STATUS_INVALID_PARAMETER since it's not supported. The current bug
overwrites status to STATUS_SUCCESS.

The second bug fix is around releasing the EventQueue lock if an open
instance couldn't be found. The current version returns back without
releasing the lock. Moving the OvsAcquireEventQueueLock() after the
instance is verified.

OvsGetOpenInstance does not enforce a safe read for
gOvsSwitchContext->dpNo. Use the gOvsSwitchContext->dispatchLock for
accessing the parameter.

v2: Address review comments from Alin Serdean and Yin Lin (around keeping
OvsGetOpenInstance safe).

Signed-off-by: Sairam Venugopal 
---
 datapath-windows/ovsext/Datapath.c | 7 ++-
 datapath-windows/ovsext/Event.c| 6 ++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c 
b/datapath-windows/ovsext/Datapath.c
index e4d6ab1..75f133a 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -521,12 +521,17 @@ POVS_OPEN_INSTANCE
 OvsGetOpenInstance(PFILE_OBJECT fileObject,
UINT32 dpNo)
 {
+LOCK_STATE_EX lockState;
 POVS_OPEN_INSTANCE instance = (POVS_OPEN_INSTANCE)fileObject->FsContext;
 ASSERT(instance);
 ASSERT(instance->fileObject == fileObject);
+NdisAcquireRWLockWrite(gOvsSwitchContext->dispatchLock, , 0);
+
 if (gOvsSwitchContext->dpNo != dpNo) {
-return NULL;
+instance = NULL;
 }
+
+NdisReleaseRWLock(gOvsSwitchContext->dispatchLock, );
 return instance;
 }
 
diff --git a/datapath-windows/ovsext/Event.c b/datapath-windows/ovsext/Event.c
index 8c7c3ec..8ff0322 100644
--- a/datapath-windows/ovsext/Event.c
+++ b/datapath-windows/ovsext/Event.c
@@ -217,9 +217,8 @@ OvsSubscribeEventIoctl(PFILE_OBJECT fileObject,
 if (queue->mask != request->mask) {
 status = STATUS_INVALID_PARAMETER;
 OVS_LOG_WARN("Can not chnage mask when the queue is subscribed");
+goto done_event_subscribe;
 }
-status = STATUS_SUCCESS;
-goto done_event_subscribe;
 } else if (!request->subscribe && queue == NULL) {
 status = STATUS_SUCCESS;
 goto done_event_subscribe;
@@ -356,8 +355,6 @@ OvsWaitEventIoctl(PIRP irp,
 }
 poll = (POVS_EVENT_POLL)inputBuffer;
 
-OvsAcquireEventQueueLock();
-
 instance = OvsGetOpenInstance(fileObject, poll->dpNo);
 if (instance == NULL) {
 OVS_LOG_TRACE("Exit: Can not find open instance, dpNo: %d",
@@ -365,6 +362,7 @@ OvsWaitEventIoctl(PIRP irp,
 return STATUS_INVALID_PARAMETER;
 }
 
+OvsAcquireEventQueueLock();
 queue = (POVS_EVENT_QUEUE)instance->eventQueue;
 if (queue == NULL) {
 OVS_LOG_TRACE("Exit: Event queue does not exist");
-- 
2.9.0.windows.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] Backport Request: dpif-netdev: Remove PMD latency on seq_mutex

2016-07-25 Thread Flavio Leitner
On Mon, Jul 25, 2016 at 06:22:59PM +, Daniele Di Proietto wrote:
> Fair point, I guess this looks more like a bug fix than a new features.
> 
> After discussing offline with Ben and having another set of eyes on
> the changes I backported this to branch-2.5.

Thanks guys!
fbl


> 
> Thanks,
> 
> Daniele
> 
> 
> On 25/07/2016 02:29, "Loftus, Ciara"  wrote:
> 
> >> 
> >> Thanks Flavio for checking and Daniel for your consideration.
> >> Indeed the issue exists in 2.5 branch.
> >> 
> >> We are treating this more in the bucket of a performance bug fix than a
> >> feature.
> >> 
> >> Any specific testing that you would like to see run to help reduce
> >> your concern related to changes to the core modules ?
> >> 
> >> Ciara, what's your opinion on these changes for a backport ?
> >
> >I'm of the same opinion as yourself and Flavio that this is more a fix than 
> >a feature. I'd like to see it backported.
> >But I understand there may be some risk associated with due to the nature of 
> >the changes.
> >
> >Thanks,
> >Ciara
> >
> >> 
> >> Thanks
> >> Vinod
> >> 
> >> 
> >> 
> >> -Original Message-
> >> From: Daniele Di Proietto [mailto:diproiet...@vmware.com]
> >> Sent: Friday, July 22, 2016 3:49 PM
> >> To: Flavio Leitner ; Vinod, Chegu
> >> 
> >> Cc: kris...@redhat.com; ovs-dev ; Loftus, Ciara
> >> 
> >> Subject: Re: Backport Request: dpif-netdev: Remove PMD latency on
> >> seq_mutex
> >> 
> >> I'm not sure I'm 100% comfortable back porting this to branch-2.5
> >> 
> >> I see the change more as a feature rather than a bugfix.
> >> 
> >> Also it touches some core modules (seq and rcu) in a non trivial way.
> >> 
> >> 
> >> What do you guys think?
> >> 
> >> Thanks,
> >> 
> >> Daniele
> >> 
> >> On 22/07/2016 15:03, "Flavio Leitner"  wrote:
> >> 
> >> >(adding ovs-dev mailing list and more people interesting on the
> >> >backport to CC)
> >> >
> >> >On Mon, Jul 18, 2016 at 05:31:52AM +, Vinod, Chegu wrote:
> >> >> Hi Flavio, Karl,
> >> >>
> >> >> Is there a version of the following fix available that is compatible 
> >> >> with OVS
> >> 2.5?
> >> >>
> >> >>
> >> https://github.com/openvswitch/ovs/commit/9dede5cff553d7c4e074f04c52
> >> 5
> >> >> c1417eb209363
> >> >>
> >> >> If yes can it backported to the 2.5 branch ?
> >> >
> >> >branch-2.5 is affected by the same issue.  I tested the patch from
> >> >branch master (cherry-pick) and it solved the issue.
> >> >
> >> >Daniele,
> >> >
> >> >What do you think? If you agree, do you need me to post the backported
> >> >patch or is it enough for you to cherry-pick?
> >> >
> >> >Thanks,
> >> >--
> >> >fbl
> >
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev

-- 
fbl

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] selinux: Allow ovs-ctl force-reload-kmod.

2016-07-25 Thread Flavio Leitner
On Fri, Jul 22, 2016 at 02:10:51PM -0700, Joe Stringer wrote:
> When invoking ovs-ctl force-reload-kmod via '/etc/init.d/openvswitch
> force-reload-kmod', spurious errors would output related to 'hostname'
> and 'ip', and the system's selinux audit log would complain about some
> of the invocations such as those listed at the end of this commit message.
> 
> This patch loosens restrictions for openvswitch_t (used for ovs-ctl, as
> well as all of the OVS daemons) to allow it to execute 'hostname' and
> 'ip' commands, and also to execute temporary files created as
> openvswitch_tmp_t. This allows force-reload-kmod to run correctly.
> 
> Example audit logs:
> type=AVC msg=audit(1468515192.912:16720): avc:  denied  { getattr } for
> pid=11687 comm="ovs-ctl" path="/usr/bin/hostname" dev="dm-1"
> ino=33557805 scontext=system_u:system_r:openvswitch_t:s0
> tcontext=system_u:object_r:hostname_exec_t:s0 tclass=file
> 
> type=AVC msg=audit(1468519445.766:16829): avc:  denied  { getattr } for
> pid=13920 comm="ovs-save" path="/usr/sbin/ip" dev="dm-1" ino=67572988
> scontext=unconfined_u:system_r:openvswitch_t:s0
> tcontext=system_u:object_r:ifconfig_exec_t:s0 tclass=file
> 
> type=AVC msg=audit(1468519445.890:16833): avc:  denied  { execute } for
> pid=13849 comm="ovs-ctl" name="tmp.jdEGHntG3Z" dev="dm-1" ino=106876762
> scontext=unconfined_u:system_r:openvswitch_t:s0
> tcontext=unconfined_u:object_r:openvswitch_tmp_t:s0 tclass=file
> 
> Signed-off-by: Joe Stringer 
> ---

LGTM.
Acked-by: Flavio Leitner 


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v5] JSON serialization via Python's json lib

2016-07-25 Thread Terry Wilson
Sigh. And of course I had libopenvswitch installed on the system as
well and removing it breaks building the extensions with the above
patch. This is the kind of thing that would be much easier if the
Python lib was its own project with its own test suite and it could
just always assume libopenvswitch was installed on the system as a
build dependency.

There is much to say about why all of this is a pain, but the main
takeaway is that I'm going to split out the serialization part of this
patch from the build system stuff because there is no reason for one
part to hold up the other.

Terry

On Fri, Jul 22, 2016 at 9:57 PM, Terry Wilson  wrote:
> There is no particularly good reason to use our own Python JSON
> serialization implementation when serialization can be done faster
> with Python's built-in JSON library.
>
> A few tests were changed due to Python's default JSON library
> returning slightly more precise floating point numbers.
>
> Signed-off-by: Terry Wilson 
> ---
>  configure.ac   |   2 +
>  m4/openvswitch.m4  |  47 
>  python/automake.mk |  27 +-
>  python/ovs/json.py | 106 
> +
>  tests/json.at  |  26 ++---
>  5 files changed, 104 insertions(+), 104 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 05d80d5..5472a52 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -96,6 +96,8 @@ OVS_CHECK_LIBCAPNG
>  OVS_CHECK_LOGDIR
>  OVS_CHECK_PYTHON
>  OVS_CHECK_PYTHON3
> +OVS_CHECK_PYTHON_HEADERS
> +OVS_CHECK_PYTHON3_HEADERS
>  OVS_CHECK_FLAKE8
>  OVS_CHECK_DOT
>  OVS_CHECK_IF_PACKET
> diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
> index a448223..60ae114 100644
> --- a/m4/openvswitch.m4
> +++ b/m4/openvswitch.m4
> @@ -589,3 +589,50 @@ AC_DEFUN([OVS_CHECK_PRAGMA_MESSAGE],
>   [AC_DEFINE(HAVE_PRAGMA_MESSAGE,1,[Define if compiler supports #pragma
>   message directive])])
>])
> +
> +dnl OVS_CHECK_PYTHON_HEADERS
> +AC_DEFUN([OVS_CHECK_PYTHON_HEADERS],
> +  [AC_REQUIRE([OVS_CHECK_PYTHON])
> +AC_PATH_PROG([PYTHON_CONFIG], python-config, no)
> +if test "$PYTHON_CONFIG" != no; then
> +  PYTHON_INCLUDES=`$PYTHON_CONFIG --includes`
> +  PYTHON_LIBS=`$PYTHON_CONFIG --libs`
> +  PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
> +  save_LIBS="$LIBS"
> +  save_CPPFLAGS="$CPPFLAGS"
> +  save_LDFLAGS="$LDFLAGS"
> +  LIBS="$PYTHON_LIBS"
> +  LDFLAGS="$PYTHON_LDFLAGS"
> +  CPPFLAGS="$PYTHON_INCLUDES"
> +  AC_LINK_IFELSE(
> +[AC_LANG_PROGRAM([#include ],[])],
> + [have_py_headers=true])
> +  LIBS="$save_LIBS"
> +  CPPFLAGS="$save_CPPFLAGS"
> +  LDFLAGS="$save_LDFLAGS"
> +fi
> +   AM_CONDITIONAL([HAVE_PYTHON_HEADERS], [test "$have_py_headers" = 
> "true"])])
> +  ])
> +
> +AC_DEFUN([OVS_CHECK_PYTHON3_HEADERS],
> +  [AC_REQUIRE([OVS_CHECK_PYTHON3])
> +AC_PATH_PROG([PYTHON3_CONFIG], python3-config, no)
> +if test "$PYTHON3_CONFIG" != no; then
> +  PYTHON3_INCLUDES=`$PYTHON3_CONFIG --includes`
> +  PYTHON3_LIBS=`$PYTHON3_CONFIG --libs`
> +  PYTHON3_LDFLAGS=`$PYTHON3_CONFIG --ldflags`
> +  save_LIBS="$LIBS"
> +  save_CPPFLAGS="$CPPFLAGS"
> +  save_LDFLAGS="$LDFLAGS"
> +  LIBS="$PYTHON3_LIBS"
> +  LDFLAGS="$PYTHON3_LDFLAGS"
> +  CPPFLAGS="$PYTHON3_INCLUDES"
> +  AC_LINK_IFELSE(
> +[AC_LANG_PROGRAM([#include ],[])],
> + [have_py3_headers=true])
> +  LIBS="$save_LIBS"
> +  CPPFLAGS="$save_CPPFLAGS"
> +  LDFLAGS="$save_LDFLAGS"
> +fi
> +   AM_CONDITIONAL([HAVE_PYTHON3_HEADERS], [test "$have_py3_headers" = 
> "true"])])
> +  ])
> diff --git a/python/automake.mk b/python/automake.mk
> index ecad39d..874a178 100644
> --- a/python/automake.mk
> +++ b/python/automake.mk
> @@ -79,10 +79,10 @@ ovs-install-data-local:
> rm python/ovs/dirs.py.tmp
>
>  python-sdist: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) 
> python/ovs/dirs.py
> -   (cd python/ && $(PYTHON) setup.py sdist)
> +   cd $(srcdir)/python/ && $(PYTHON) setup.py sdist
>
>  pypi-upload: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) 
> python/ovs/dirs.py
> -   (cd python/ && $(PYTHON) setup.py sdist upload)
> +   cd $(srcdir)/python/ && $(PYTHON) setup.py sdist upload
>  else
>  ovs-install-data-local:
> @:
> @@ -112,3 +112,26 @@ $(srcdir)/python/ovs/dirs.py: python/ovs/dirs.py.template
> < $? > $@.tmp && \
> mv $@.tmp $@
>  EXTRA_DIST += python/ovs/dirs.py.template
> +
> +.PHONY : clean_python_extensions
> +clean_python_extensions:
> +   cd $(srcdir)/python/ && rm -f ovs/*.so
> +
> +SETUPPY_CFLAGS = -I$(abs_top_srcdir)/include -I$(abs_top_builddir)/include
> +if HAVE_PYTHON_HEADERS
> +$(srcdir)/python/ovs/_json.so: lib/libopenvswitch.la
> +   cd $(srcdir)/python/ && CFLAGS="$(SETUPPY_CFLAGS)" $(PYTHON) setup.py 
> build_ext --inplace
> +
> +ALL_LOCAL += 

Re: [ovs-dev] [PATCH v3] netdev-dpdk: Set pmd thread priority

2016-07-25 Thread Daniele Di Proietto
I agree with Mark's comments, other than that this looks good to me.

If you agree with the comments would you mind sending an updates version?

Thanks,

Daniele

2016-07-19 7:04 GMT-07:00 Kavanagh, Mark B :

> >
>
> Hi Bhanu,
>
> Thanks for the patch - some comments inline.
>
> Cheers,
> Mark
>
> >Set the DPDK pmd thread scheduling policy to SCHED_RR and static
> >priority to highest priority value of the policy. This is to deal with
> >pmd thread starvation case where another cpu hogging process can get
> >scheduled/affinitized on to the same core the pmd thread is running
> >there by significantly impacting the datapath performance.
> >
> >Setting the realtime scheduling policy to the pmd threads is one step
> >towards Fastpath Service Assurance in OVS DPDK.
> >
> >The realtime scheduling policy is applied only when CPU mask is passed
> >to 'pmd-cpu-mask'. For example:
> >
> >* In the absence of pmd-cpu-mask, one pmd thread shall be created
> >  and default scheduling policy and prority gets applied.
>
> Typo above - 'prority'
>
> >
> >* If pmd-cpu-mask is specified, one ore more pmd threads shall be
>
> Typo above - 'ore'
>
> >  spawned on the corresponding core(s) in the mask and real time
> >  scheduling policy SCHED_RR and highest priority of the policy is
> >  applied to the pmd thread(s).
> >
> >To reproduce the pmd thread starvation case:
> >
> >ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=6
> >taskset 0x2 cat /dev/zero > /dev/null &
> >
> >With this commit OVS control threads and pmd threads can't have same
> >affinity ('dpdk-lcore-mask','pmd-cpu-mask' should be non-overlapping).
> >Also other processes with same affinity as PMD thread will be
> unresponsive.
> >
> >Signed-off-by: Bhanuprakash Bodireddy 
> >---
> >
> >v2->v3:
> >* Move set_priority() function to lib/ovs-numa.c
> >* Apply realtime scheduling policy and priority to pmd thread only if
> >  pmd-cpu-mask is passed.
> >* Update INSTALL.DPDK-ADVANCED.
> >
> >v1->v2:
> >* Removed #ifdef and introduced dummy function "pmd_thread_setpriority"
> >  in netdev-dpdk.h
> >* Rebase
> >
> >
> > INSTALL.DPDK-ADVANCED.md | 15 +++
> > lib/dpif-netdev.c|  9 +
> > lib/ovs-numa.c   | 18 ++
> > lib/ovs-numa.h   |  1 +
> > 4 files changed, 39 insertions(+), 4 deletions(-)
> >
> >diff --git a/INSTALL.DPDK-ADVANCED.md b/INSTALL.DPDK-ADVANCED.md
> >index 9ae536d..d828290 100644
> >--- a/INSTALL.DPDK-ADVANCED.md
> >+++ b/INSTALL.DPDK-ADVANCED.md
> >@@ -205,8 +205,10 @@ needs to be affinitized accordingly.
> > pmd thread is CPU bound, and needs to be affinitized to isolated
> > cores for optimum performance.
> >
> >-By setting a bit in the mask, a pmd thread is created and pinned
> >-to the corresponding CPU core. e.g. to run a pmd thread on core 2
> >+By setting a bit in the mask, a pmd thread is created, pinned
> >+to the corresponding CPU core and the scheduling policy SCHED_RR
> >+along with maximum priority of the policy applied to the pmd thread.
> >+e.g. to pin a pmd thread on core 2
> >
> > `ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=4`
> >
> >@@ -234,8 +236,10 @@ needs to be affinitized accordingly.
> >   responsible for different ports/rxq's. Assignment of ports/rxq's to
> >   pmd threads is done automatically.
> >
> >-  A set bit in the mask means a pmd thread is created and pinned
> >-  to the corresponding CPU core. e.g. to run pmd threads on core 1 and 2
> >+  A set bit in the mask means a pmd thread is created, pinned to the
> >+  corresponding CPU core and the scheduling policy SCHED_RR with highest
> >+  priority of the scheduling policy applied to pmd thread.
> >+  e.g. to run pmd threads on core 1 and 2
>
> There's some repetition in the last paragraph - I'm reviewing this patch
> in isolation, so the text may make sense/be required in the full document.
>
> >
> >   `ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=6`
> >
> >@@ -246,6 +250,9 @@ needs to be affinitized accordingly.
> >
> >   NIC port0 <-> OVS <-> VM <-> OVS <-> NIC port 1
> >
> >+  Note: 'dpdk-lcore-mask' and 'pmd-cpu-mask' cpu mask settings should be
> >+  non-overlapping.
>
> Although it's mentioned in the commit message, it might be worth
> mentioning here the consequences of attempting to pin non-PMD processes to
> a pmd-cpu-mask core (i.e. CPU starvation)
>
> >+
> > ### 4.3 DPDK physical port Rx Queues
> >
> >   `ovs-vsctl set Interface  options:n_rxq=`
> >diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> >index e0107b7..805d0ae 100644
> >--- a/lib/dpif-netdev.c
> >+++ b/lib/dpif-netdev.c
> >@@ -2851,6 +2851,15 @@ pmd_thread_main(void *f_)
> > ovs_numa_thread_setaffinity_core(pmd->core_id);
> > dpdk_set_lcore_id(pmd->core_id);
> > poll_cnt = pmd_load_queues_and_ports(pmd, _list);
> >+
> >+/* When cpu affinity mask explicitly set using 

Re: [ovs-dev] [PATCH 3/4] netdev-dpdk: Add vHost User PMD

2016-07-25 Thread Daniele Di Proietto
Thanks for the patch

This needs a little bit of rebasing, I did it myself to review, but it'd be
nice to have an updated version.

I like the simplification that this brings especially to the fast path.

If we merge this before we merge the DPDK 16.07 we won't have to deal with
the vid change.

Thanks,

Daniele

2016-07-15 7:26 GMT-07:00 Ciara Loftus :

> DPDK 16.04 introduces the vHost PMD which allows 'dpdkvhostuser' ports
> to be controlled by the librte_ether API, like physical 'dpdk' ports and
> IVSHM 'dpdkr' ports. This commit integrates this PMD into OVS and
> removes direct calls to the librte_vhost DPDK library.
>
> This commit removes extended statistics support for vHost User ports
> until such a time that this becomes available in the vHost PMD in a
> DPDK release supported by OVS.
>
> Signed-off-by: Ciara Loftus 
> ---
>  INSTALL.DPDK.md   |  10 +
>  NEWS  |   2 +
>  lib/netdev-dpdk.c | 856
> ++
>  3 files changed, 302 insertions(+), 566 deletions(-)
>
> diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
> index 5407794..29b6f91 100644
> --- a/INSTALL.DPDK.md
> +++ b/INSTALL.DPDK.md
> @@ -561,6 +561,16 @@ can be found in [Vhost Walkthrough].
>
>  http://dpdk.org/doc/guides/rel_notes/release_16_04.html
>
> +  - dpdk, dpdkr and dpdkvhostuser ports are 'eth' type ports in the
> context of
> +DPDK as they are all managed by the rte_ether API. This means that
> they
> +adhere to the DPDK configuration option CONFIG_RTE_MAX_ETHPORTS which
> by
> +default is set to 32. This means by default the combined total number
> of
> +dpdk, dpdkr and dpdkvhostuser ports allowable in OVS with DPDK is 32.
> This
> +value can be changed if desired by modifying the configuration file in
> +DPDK, or by overriding the default value on the command line when
> building
> +DPDK. eg.
> +
> +`make install CONFIG_RTE_MAX_ETHPORTS=64`
>

Again, I hope this doesn't cause problems to a lot of users.  I'd like to
see the limit increased by default, but I think we can merge this patch as
it is.


>
>  Bug Reporting:
>  --
> diff --git a/NEWS b/NEWS
> index aa1b915..b3791ed 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -59,6 +59,8 @@ Post-v2.5.0
> node that device memory is located on if
> CONFIG_RTE_LIBRTE_VHOST_NUMA
> is enabled in DPDK.
>   * Remove dpdkvhostcuse port type.
> + * vHost PMD integration brings vhost-user ports under control of the
> +   rte_ether DPDK API.
> - Increase number of registers to 16.
> - ovs-benchmark: This utility has been removed due to lack of use and
>   bitrot.
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index b4f82af..5de806a 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -56,6 +56,7 @@
>  #include "unixctl.h"
>
>  #include "rte_config.h"
> +#include "rte_eth_vhost.h"
>  #include "rte_mbuf.h"
>  #include "rte_meter.h"
>  #include "rte_virtio_net.h"
> @@ -141,6 +142,11 @@ static char *vhost_sock_dir = NULL;   /* Location of
> vhost-user sockets */
>
>  #define VHOST_ENQ_RETRY_NUM 8
>
> +/* Array that tracks the used & unused vHost user driver IDs */
> +static unsigned int vhost_drv_ids[RTE_MAX_ETHPORTS];
> +/* Maximum string length allowed to provide to rte_eth_attach function */
> +#define DEVARGS_MAX (RTE_ETH_NAME_MAX_LEN + PATH_MAX + 18)
> +
>

I think this is not needed if we use xasprintf() below.


>  static const struct rte_eth_conf port_conf = {
>  .rxmode = {
>  .mq_mode = ETH_MQ_RX_RSS,
> @@ -353,12 +359,15 @@ struct netdev_dpdk {
>   * always true.  */
>  bool txq_needs_locking;
>
> -/* virtio-net structure for vhost device */
> -OVSRCU_TYPE(struct virtio_net *) virtio_dev;
> +/* Number of virtqueue pairs reported by the guest */
> +uint32_t vhost_qp_nb;
>
>  /* Identifier used to distinguish vhost devices from each other */
>  char vhost_id[PATH_MAX];
>
> +/* ID of vhost user port given to the PMD driver */
> +unsigned int vhost_pmd_id;
> +
>  /* In dpdk_list. */
>  struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
>
> @@ -389,16 +398,25 @@ struct netdev_rxq_dpdk {
>  static bool dpdk_thread_is_pmd(void);
>
>  static int netdev_dpdk_construct(struct netdev *);
> +static int netdev_dpdk_vhost_construct(struct netdev *);
>
>  struct virtio_net * netdev_dpdk_get_virtio(const struct netdev_dpdk *dev);
>
>  struct ingress_policer *
>  netdev_dpdk_get_ingress_policer(const struct netdev_dpdk *dev);
>
> +void link_status_changed_callback(uint8_t port_id,
> +enum rte_eth_event_type type OVS_UNUSED, void *param OVS_UNUSED);
> +void vring_state_changed_callback(uint8_t port_id,
> +enum rte_eth_event_type type OVS_UNUSED, void *param OVS_UNUSED);
>

Minor: I think we can avoid OVS_UNUSED on the declaration and keep it only
on the definition.

Also, these two function can be static


> +static void 

Re: [ovs-dev] [PATCH 2/4] netdev-dpdk: Consistent naming for vhost functions

2016-07-25 Thread Daniele Di Proietto
Looks like every caller of NETDEV_DPDK_CLASS() passes NULL as INIT param.
Maybe we can remove that?

Acked-by: Daniele Di Proietto 

2016-07-15 7:26 GMT-07:00 Ciara Loftus :

> A mix of vhost_user_ and vhost_ is used when naming vhost functions. The
> 'user_' has been dropped for consistency. Also remove empty
> 'vhost_user_class_init' function.
>
> Signed-off-by: Ciara Loftus 
> ---
>  lib/netdev-dpdk.c | 20 +++-
>  1 file changed, 7 insertions(+), 13 deletions(-)
>
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index faf93e0..b4f82af 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -811,7 +811,7 @@ dpdk_dev_parse_name(const char dev_name[], const char
> prefix[],
>  }
>
>  static int
> -netdev_dpdk_vhost_user_construct(struct netdev *netdev)
> +netdev_dpdk_vhost_construct(struct netdev *netdev)
>  {
>  struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
>  const char *name = netdev->name;
> @@ -2408,12 +2408,6 @@ dpdk_vhost_class_init(void)
>  return 0;
>  }
>
> -static int
> -dpdk_vhost_user_class_init(void)
> -{
> -return 0;
> -}
> -
>  static void
>  dpdk_common_init(void)
>  {
> @@ -2809,7 +2803,7 @@ out:
>  }
>
>  static int
> -netdev_dpdk_vhost_user_reconfigure(struct netdev *netdev)
> +netdev_dpdk_vhost_reconfigure(struct netdev *netdev)
>  {
>  struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
>  struct virtio_net *virtio_dev = netdev_dpdk_get_virtio(dev);
> @@ -3326,11 +3320,11 @@ static const struct netdev_class dpdk_ring_class =
>  netdev_dpdk_reconfigure,
>  netdev_dpdk_rxq_recv);
>
> -static const struct netdev_class OVS_UNUSED dpdk_vhost_user_class =
> +static const struct netdev_class OVS_UNUSED dpdk_vhost_class =
>  NETDEV_DPDK_CLASS(
>  "dpdkvhostuser",
> -dpdk_vhost_user_class_init,
> -netdev_dpdk_vhost_user_construct,
> +NULL,
> +netdev_dpdk_vhost_construct,
>  netdev_dpdk_vhost_destruct,
>  NULL,
>  NULL,
> @@ -3339,7 +,7 @@ static const struct netdev_class OVS_UNUSED
> dpdk_vhost_user_class =
>  netdev_dpdk_vhost_get_stats,
>  NULL,
>  NULL,
> -netdev_dpdk_vhost_user_reconfigure,
> +netdev_dpdk_vhost_reconfigure,
>  netdev_dpdk_vhost_rxq_recv);
>
>  void
> @@ -3348,7 +3342,7 @@ netdev_dpdk_register(void)
>  dpdk_common_init();
>  netdev_register_provider(_class);
>  netdev_register_provider(_ring_class);
> -netdev_register_provider(_vhost_user_class);
> +netdev_register_provider(_vhost_class);
>  }
>
>  void
> --
> 2.4.3
>
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 1/4] netdev-dpdk: Remove dpdkvhostcuse ports

2016-07-25 Thread Daniele Di Proietto
Acked-by: Daniele Di Proietto 

2016-07-15 7:26 GMT-07:00 Ciara Loftus :

> This commit removes the 'dpdkvhostcuse' port type from the userspace
> datapath. vhost-cuse ports are quickly becoming obsolete as the
> vhost-user port type begins to support a greater feature-set thanks to
> the addition of things like vhost-user multiqueue and potential
> upcoming features like vhost-user client-mode and vhost-user reconnect.
> The feature is also expected to be removed from DPDK soon.
>
> One potential drawback of the removal of this support is that a
> userspace vHost port type is not available in OVS for use with older
> versions of QEMU (pre v2.2). Considering v2.2 is nearly two years old
> this should however be a low impact change.
>
> Signed-off-by: Ciara Loftus 
> Acked-by: Flavio Leitner 
> ---
>  INSTALL.DPDK-ADVANCED.md | 241 -
>  NEWS |   1 +
>  acinclude.m4 |  12 --
>  lib/netdev-dpdk.c| 101 +---
>  rhel/README.RHEL |   2 -
>  utilities/automake.mk|   1 -
>  utilities/qemu-wrap.py   | 389
> ---
>  vswitchd/vswitch.xml |  12 --
>  8 files changed, 5 insertions(+), 754 deletions(-)
>  delete mode 100755 utilities/qemu-wrap.py
>
> diff --git a/INSTALL.DPDK-ADVANCED.md b/INSTALL.DPDK-ADVANCED.md
> index 9ae536d..fb37584 100644
> --- a/INSTALL.DPDK-ADVANCED.md
> +++ b/INSTALL.DPDK-ADVANCED.md
> @@ -374,12 +374,6 @@ For users wanting to do packet forwarding using
> kernel stack below are the steps
>
>  ##  6. Vhost Walkthrough
>
> -DPDK 16.04 supports two types of vhost:
> -
> -1. vhost-user - enabled default
> -
> -2. vhost-cuse - Legacy, disabled by default
> -
>  ### 6.1 vhost-user
>
>- Prerequisites:
> @@ -533,241 +527,6 @@ DPDK 16.04 supports two types of vhost:
>
>Note: For information on libvirt and further tuning refer [libvirt].
>
> -### 6.2 vhost-cuse
> -
> -  - Prerequisites:
> -
> -QEMU version >= 2.2
> -
> -  - Enable vhost-cuse support
> -
> -1. Enable vhost cuse support in DPDK
> -
> -   Set `CONFIG_RTE_LIBRTE_VHOST_USER=n` in config/common_linuxapp and
> follow the
> -   steps in 2.2 section of INSTALL.DPDK guide to build DPDK with cuse
> support.
> -   OVS will detect that DPDK has vhost-cuse libraries compiled and in
> turn will enable
> -   support for it in the switch and disable vhost-user support.
> -
> -2. Insert the Cuse module
> -
> -   `modprobe cuse`
> -
> -3. Build and insert the `eventfd_link` module
> -
> -   ```
> -   cd $DPDK_DIR/lib/librte_vhost/eventfd_link/
> -   make
> -   insmod $DPDK_DIR/lib/librte_vhost/eventfd_link.ko
> -   ```
> -
> -  - Adding vhost-cuse ports to Switch
> -
> -Unlike DPDK ring ports, DPDK vhost-cuse ports can have arbitrary
> names.
> -For vhost-cuse, the name of the port type is `dpdkvhostcuse`
> -
> -```
> -ovs-vsctl add-port br0 vhost-cuse-1 -- set Interface vhost-cuse-1
> -type=dpdkvhostcuse
> -```
> -
> -When attaching vhost-cuse ports to QEMU, the name provided during the
> -add-port operation must match the ifname parameter on the QEMU cmd
> line.
> -
> -  - Adding vhost-cuse ports to VM
> -
> -vhost-cuse ports use a Linux* character device to communicate with
> QEMU.
> -By default it is set to `/dev/vhost-net`. It is possible to reuse this
> -standard device for DPDK vhost, which makes setup a little simpler
> but it
> -is better practice to specify an alternative character device in
> order to
> -avoid any conflicts if kernel vhost is to be used in parallel.
> -
> -1. This step is only needed if using an alternative character device.
> -
> -   ```
> -   ./utilities/ovs-vsctl --no-wait set Open_vSwitch . \
> -other_config:cuse-dev-name=my-vhost-net
> -   ```
> -
> -   In the example above, the character device to be used will be
> -   `/dev/my-vhost-net`.
> -
> -2. In case of reusing kernel vhost character device, there would be
> conflict
> -   user should remove it.
> -
> -   `rm -rf /dev/vhost-net`
> -
> -3. Configure virtio-net adapters
> -
> -   The following parameters must be passed to the QEMU binary, repeat
> -   the below parameters for multiple devices.
> -
> -   ```
> -   -netdev tap,id=,script=no,downscript=no,ifname=,vhost=on
> -   -device virtio-net-pci,netdev=net1,mac=
> -   ```
> -
> -   The DPDK vhost library will negotiate its own features, so they
> -   need not be passed in as command line params. Note that as offloads
> -   are disabled this is the equivalent of setting
> -
> -   `csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off`
> -
> -   When using an alternative character device, it must be explicitly
> -   passed to QEMU using the `vhostfd` argument
> -
> -   

Re: [ovs-dev] [PATCH 8/9] datapath-windows: Update OvsReadEventCmdHandler in Datapath.c to support different events

2016-07-25 Thread Sairam Venugopal
Will address this in v2.

Thanks,
Sairam

On 7/22/16, 6:20 PM, "Alin Serdean" 
wrote:

>Just one comment inlined.
>
>
>
>> -Mesaj original-
>
>> De la: dev [mailto:dev-boun...@openvswitch.org] În numele Sairam
>
>> Venugopal
>
>> Trimis: Thursday, July 14, 2016 2:39 AM
>
>> Către: dev@openvswitch.org
>
>> Subiect: [ovs-dev] [PATCH 8/9] datapath-windows: Update
>
>> OvsReadEventCmdHandler in Datapath.c to support different events
>
>> 
>
>> OvsReadEventCmdHandler must now reflect the right event being read. If
>
>> the event is a Conntrack related event, then convert the entry to
>>netlink
>
>> format and send it to userspace. If it's Vport event, retain the
>>existing
>
>> workflow.
>
>> 
>
>> Signed-off-by: Sairam Venugopal 
>
>> ---
>
>>  datapath-windows/ovsext/Datapath.c | 59
>
>> +-
>
>>  1 file changed, 45 insertions(+), 14 deletions(-)
>
>> 
>
>> diff --git a/datapath-windows/ovsext/Datapath.c b/datapath-
>
>> windows/ovsext/Datapath.c
>
>> index a5a0b35..fff788a 100644
>
>> --- a/datapath-windows/ovsext/Datapath.c
>
>> +++ b/datapath-windows/ovsext/Datapath.c
>
>> @@ -1674,7 +1674,6 @@
>
>> OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
>
>> #endif
>
>>  NL_BUFFER nlBuf;
>
>>  NTSTATUS status;
>
>> -OVS_VPORT_EVENT_ENTRY eventEntry;
>
>> 
>
>>  ASSERT(usrParamsCtx->devOp == OVS_READ_DEV_OP);
>
>> 
>
>> @@ -1687,21 +1686,53 @@
>
>> OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
>
>>  /* Output buffer has been validated while validating read dev op.
>>*/
>
>>  ASSERT(msgOut != NULL && usrParamsCtx->outputLength >= sizeof
>
>> *msgOut);
>
>> 
>
>> -NlBufInit(, usrParamsCtx->outputBuffer, usrParamsCtx-
>
>> >outputLength);
>
>> +if (instance->protocol == NETLINK_NETFILTER) {
>
>> +if (!instance->mcastMask) {
>
>> +status = STATUS_SUCCESS;
>
>> +*replyLen = 0;
>
>> +goto cleanup;
>
>> +}
>
>> 
>
>> -/* remove an event entry from the event queue */
>
>> -status = OvsRemoveVportEventEntry(usrParamsCtx->ovsInstance,
>
>> -  );
>
>> -if (status != STATUS_SUCCESS) {
>
>> -/* If there were not elements, read should return no data. */
>
>> -status = STATUS_SUCCESS;
>
>> -*replyLen = 0;
>
>> -goto cleanup;
>
>> -}
>
>> +OVS_CT_EVENT_ENTRY ctEventEntry;
>
>> +status = OvsRemoveCtEventEntry(usrParamsCtx->ovsInstance,
>
>> + );
>
>> 
>
>> -status = OvsPortFillInfo(usrParamsCtx, , );
>
>> -if (status == NDIS_STATUS_SUCCESS) {
>
>> -*replyLen = NlBufSize();
>
>> +if (status != STATUS_SUCCESS) {
>
>> +/* If there were not elements, read should return no data.
>>*/
>
>> +status = STATUS_SUCCESS;
>
>> +*replyLen = 0;
>
>> +goto cleanup;
>
>> +}
>
>> +
>
>> +status = OvsCreateNlMsgFromCtEntry(,
>
>> +   usrParamsCtx->outputBuffer,
>
>> +   usrParamsCtx->outputLength,
>
>> +   ctEventEntry.type,
>
>> +   0,
>
>[Alin Gabriel Serdean: ] Why hard zero for the sequence instead of using
>the input
>
>> +   
>>usrParamsCtx->ovsInstance->pid,
>
>> +   NFNETLINK_V0,
>
>> +   0);
>
>[Alin Gabriel Serdean: ] Again why hard use of constants for the reply
>message?
>
>> +if (status == NDIS_STATUS_SUCCESS) {
>
>> +*replyLen = msgOut->nlMsg.nlmsgLen;
>
>> +}
>
>> +} else if (instance->protocol == NETLINK_GENERIC) {
>
>> +NlBufInit(, usrParamsCtx->outputBuffer,
>
>> + usrParamsCtx->outputLength);
>
>> +
>
>> +OVS_VPORT_EVENT_ENTRY eventEntry;
>
>> +/* remove vport event entry from the vport event queue */
>
>> +status = OvsRemoveVportEventEntry(usrParamsCtx->ovsInstance,
>
>> );
>
>> +if (status != STATUS_SUCCESS) {
>
>> +/* If there were not elements, read should return no data.
>>*/
>
>> +status = STATUS_SUCCESS;
>
>> +*replyLen = 0;
>
>> +goto cleanup;
>
>> +}
>
>> +
>
>> +status = OvsPortFillInfo(usrParamsCtx, , );
>
>> +if (status == NDIS_STATUS_SUCCESS) {
>
>> +*replyLen = NlBufSize();
>
>> +}
>
>> +} else {
>
>> +status = STATUS_INVALID_PARAMETER;
>
>>  }
>
>> 
>
>>  cleanup:
>
>> --
>
>> 2.9.0.windows.1
>
>> 
>
>> ___
>
>> dev mailing list
>
>> dev@openvswitch.org
>
>> 
>>https://urldefense.proofpoint.com/v2/url?u=http-3A__openvswitch.org_mailm
>>an_listinfo_dev=CwIGaQ=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs=

Re: [ovs-dev] [PATCH] Windows: daemon-windows lockfile

2016-07-25 Thread Sairam Venugopal

Acked-by: Sairam Venugopal 



On 7/25/16, 2:58 PM, "Alin Serdean" 
wrote:

>_get_osfhandle returns an errno value not a GetLastErrorValue.
>(https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_e
>n-2Dus_library_ks2530z6-28v-3Dvs.120-29.aspx=CwIGaQ=Sqcl0Ez6M0X8aeM67L
>KIiDJAXVeAw-YihVMNtXt-uEs=Dcruz40PROJ40ROzSpxyQSLw6fcrOWpJgEcEmNR3JEQ=
>eoYj3TrkB5OnllBARR7u9dbNPOyruvsz_ohCjrjgEOw=9zmLE02fla7YB6YcWaovbvNeztub
>j-5OUN9HKBgVcJA= )
>
>Signed-off-by: Alin Gabriel Serdean 
>---
> lib/daemon-windows.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/lib/daemon-windows.c b/lib/daemon-windows.c
>index d77724e..7e2e9da 100644
>--- a/lib/daemon-windows.c
>+++ b/lib/daemon-windows.c
>@@ -417,7 +417,7 @@ flock(FILE* fd, int operation)
> hFile = (HANDLE)_get_osfhandle(fileno(fd));
> if (hFile == INVALID_HANDLE_VALUE) {
> VLOG_FATAL("Failed to get PID file handle (%s).",
>-   ovs_lasterror_to_string());
>+   ovs_strerror(errno));
> }
> 
> if (operation & LOCK_UNLOCK) {
>-- 
>1.9.5.msysgit.0
>___
>dev mailing list
>dev@openvswitch.org
>https://urldefense.proofpoint.com/v2/url?u=http-3A__openvswitch.org_mailma
>n_listinfo_dev=CwIGaQ=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs=Dc
>ruz40PROJ40ROzSpxyQSLw6fcrOWpJgEcEmNR3JEQ=eoYj3TrkB5OnllBARR7u9dbNPOyruv
>sz_ohCjrjgEOw=T2gQ2b0DClEq6c2UUOB6zlJxRbj2v_lBydDR_CNtS2Y= 

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] move ovn/lib/<lex|actions|expr>.h to include/ovn

2016-07-25 Thread Aaron Rosen
FYI: this patch is rebased on top of (patch below) which is not yet merged
into ovs.

commit ee61acf6202c6575033ea050b63271af49936da5
Author: Terry Wilson 
Date:   Fri Jul 22 21:57:20 2016 -0500

JSON serialization via Python's json lib

There is no particularly good reason to use our own Python JSON
serialization implementation when serialization can be done faster
with Python's built-in JSON library.

A few tests were changed due to Python's default JSON library
returning slightly more precise floating point numbers.

Signed-off-by: Terry Wilson 




On Mon, Jul 25, 2016 at 3:04 PM, Aaron Rosen  wrote:

> This patch is done to enable in tree building of the ovn-utils python
> wrapper. This is similar to what was done in:
> ee89ea7b477bb4fd05137de03b2e8443807ed9f4
>
> Signed-off-by: Aaron Rosen 
> ---
>  include/automake.mk |   1 +
>  include/ovn/actions.h   | 141 
>  include/ovn/automake.mk |   5 +
>  include/ovn/expr.h  | 474
> 
>  include/ovn/lex.h   | 139 
>  ovn/controller/lflow.c  |   4 +-
>  ovn/controller/ofctrl.c |   2 +-
>  ovn/controller/ovn-controller.c |   2 +-
>  ovn/controller/pinctrl.c|   2 +-
>  ovn/lib/actions.c   |   6 +-
>  ovn/lib/actions.h   | 141 
>  ovn/lib/automake.mk |   3 -
>  ovn/lib/expr.c  |   4 +-
>  ovn/lib/expr.h  | 474
> 
>  ovn/lib/lex.c   |   2 +-
>  ovn/lib/lex.h   | 139 
>  ovn/northd/ovn-northd.c |   2 +-
>  tests/test-ovn.c|   6 +-
>  18 files changed, 775 insertions(+), 772 deletions(-)
>  create mode 100644 include/ovn/actions.h
>  create mode 100644 include/ovn/automake.mk
>  create mode 100644 include/ovn/expr.h
>  create mode 100644 include/ovn/lex.h
>  delete mode 100644 ovn/lib/actions.h
>  delete mode 100644 ovn/lib/expr.h
>  delete mode 100644 ovn/lib/lex.h
>
> diff --git a/include/automake.mk b/include/automake.mk
> index 6a4cf86..37903fd 100644
> --- a/include/automake.mk
> +++ b/include/automake.mk
> @@ -6,6 +6,7 @@ include/odp-netlink.h:
> datapath/linux/compat/include/linux/openvswitch.h \
>  EXTRA_DIST += build-aux/extract-odp-netlink-h
>  CLEANFILES += include/odp-netlink.h
>
> +include include/ovn/automake.mk
>  include include/openflow/automake.mk
>  include include/openvswitch/automake.mk
>  include include/sparse/automake.mk
> diff --git a/include/ovn/actions.h b/include/ovn/actions.h
> new file mode 100644
> index 000..114c71e
> --- /dev/null
> +++ b/include/ovn/actions.h
> @@ -0,0 +1,141 @@
> +/*
> + * Copyright (c) 2015, 2016 Nicira, 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.
> + */
> +
> +#ifndef OVN_ACTIONS_H
> +#define OVN_ACTIONS_H 1
> +
> +#include 
> +#include 
> +#include "compiler.h"
> +#include "openvswitch/hmap.h"
> +#include "openvswitch/dynamic-string.h"
> +#include "util.h"
> +
> +struct expr;
> +struct lexer;
> +struct ofpbuf;
> +struct shash;
> +struct simap;
> +
> +#define MAX_OVN_GROUPS 65535
> +
> +struct group_table {
> +unsigned long *group_ids;  /* Used as a bitmap with value set
> +* for allocated group ids in either
> +* desired_groups or existing_groups. */
> +struct hmap desired_groups;
> +struct hmap existing_groups;
> +};
> +
> +struct group_info {
> +struct hmap_node hmap_node;
> +struct ds group;
> +uint32_t group_id;
> +};
> +
> +enum action_opcode {
> +/* "arp { ...actions... }".
> + *
> + * The actions, in OpenFlow 1.3 format, follow the action_header.
> + */
> +ACTION_OPCODE_ARP,
> +
> +/* "put_arp(port, ip, mac)"
> + *
> + * Arguments are passed through the packet metadata and data, as
> follows:
> + *
> + * MFF_REG0 = ip
> + * MFF_LOG_INPORT = port
> + * MFF_ETH_SRC = mac
> + */
> +ACTION_OPCODE_PUT_ARP,
> +
> +/* "result = put_dhcp_opts(offer_ip, option, ...)".
> + *
> + * Arguments follow the action_header, in this format:
> + *   - A 32-bit or 64-bit OXM header designating the result field.
> + *   - A 32-bit integer specifying a bit offset within 

Re: [ovs-dev] [PATCH v4] ovn: expose c validator to python

2016-07-25 Thread Aaron Rosen
Note: this patch is rebased on top of : [PATCH] move
ovn/lib/.h to include/ovn


On Mon, Jul 25, 2016 at 3:07 PM, Aaron Rosen  wrote:

> This patch exposes the c function expr_parse_string() to be called via
> python. The motivation for this is so that clients interfacing with
> ovn can call this method in order to validate the data they are writting
> to ovn.
>
> Previously, there were several bugs in the neutron/ovn integration
> that went unnoticed due to the client writing invalid data. This should
> hopefully help catch errors like this earlier as it can now be detected on
> the client side and an error can be raised.
>
> Signed-off-by: Aaron Rosen 
> ---
>  include/ovn/expr.h  |   1 +
>  ovn/lib/expr.c  | 107
> +
>  python/automake.mk  |   4 +-
>  python/ovs/_ovn-utils.c | 104 
>  python/setup.py |  31 +-
>  tests/automake.mk   |   4 +-
>  tests/test-ovn-utils.at |  15 +++
>  tests/test-ovn-utils.py |  33 ++
>  tests/test-ovn.c| 112
> +---
>  tests/testsuite.at  |   1 +
>  10 files changed, 299 insertions(+), 113 deletions(-)
>  create mode 100644 python/ovs/_ovn-utils.c
>  create mode 100644 tests/test-ovn-utils.at
>  create mode 100644 tests/test-ovn-utils.py
>
> diff --git a/include/ovn/expr.h b/include/ovn/expr.h
> index d790c49..381e32f 100644
> --- a/include/ovn/expr.h
> +++ b/include/ovn/expr.h
> @@ -470,5 +470,6 @@ void expr_macros_add(struct shash *macros, const char
> *name,
>   const char * const *values, size_t n_values);
>  void expr_macros_remove(struct shash *macros, const char *name);
>  void expr_macros_destroy(struct shash *macros);
> +void create_symtab_helper(struct shash *symtab);
>
>  #endif /* ovn/expr.h */
> diff --git a/ovn/lib/expr.c b/ovn/lib/expr.c
> index 288aae2..94b93c5 100644
> --- a/ovn/lib/expr.c
> +++ b/ovn/lib/expr.c
> @@ -3008,3 +3008,110 @@ expr_parse_constant_set(struct lexer *lexer, const
> struct shash *symtab,
>  parse_constant_set(, cs);
>  return ctx.error;
>  }
> +
> +/* create_symtab_helper() is used for testing purposes and in the
> ovn_utils
> + * python package. */
> +void
> +create_symtab_helper(struct shash *symtab)
> +{
> +shash_init(symtab);
> +
> +/* Reserve a pair of registers for the logical inport and outport.  A
> full
> + * 32-bit register each is bigger than we need, but the expression
> code
> + * doesn't yet support string fields that occupy less than a full
> OXM. */
> +expr_symtab_add_string(symtab, "inport", MFF_REG6, NULL);
> +expr_symtab_add_string(symtab, "outport", MFF_REG7, NULL);
> +
> +expr_symtab_add_field(symtab, "xreg0", MFF_XREG0, NULL, false);
> +expr_symtab_add_field(symtab, "xreg1", MFF_XREG1, NULL, false);
> +expr_symtab_add_field(symtab, "xreg2", MFF_XREG2, NULL, false);
> +
> +expr_symtab_add_subfield(symtab, "reg0", NULL, "xreg0[32..63]");
> +expr_symtab_add_subfield(symtab, "reg1", NULL, "xreg0[0..31]");
> +expr_symtab_add_subfield(symtab, "reg2", NULL, "xreg1[32..63]");
> +expr_symtab_add_subfield(symtab, "reg3", NULL, "xreg1[0..31]");
> +expr_symtab_add_subfield(symtab, "reg4", NULL, "xreg2[32..63]");
> +expr_symtab_add_subfield(symtab, "reg5", NULL, "xreg2[0..31]");
> +
> +expr_symtab_add_field(symtab, "eth.src", MFF_ETH_SRC, NULL, false);
> +expr_symtab_add_field(symtab, "eth.dst", MFF_ETH_DST, NULL, false);
> +expr_symtab_add_field(symtab, "eth.type", MFF_ETH_TYPE, NULL, true);
> +
> +expr_symtab_add_field(symtab, "vlan.tci", MFF_VLAN_TCI, NULL, false);
> +expr_symtab_add_predicate(symtab, "vlan.present", "vlan.tci[12]");
> +expr_symtab_add_subfield(symtab, "vlan.pcp", "vlan.present",
> + "vlan.tci[13..15]");
> +expr_symtab_add_subfield(symtab, "vlan.vid", "vlan.present",
> + "vlan.tci[0..11]");
> +
> +expr_symtab_add_predicate(symtab, "ip4", "eth.type == 0x800");
> +expr_symtab_add_predicate(symtab, "ip6", "eth.type == 0x86dd");
> +expr_symtab_add_predicate(symtab, "ip", "ip4 || ip6");
> +expr_symtab_add_field(symtab, "ip.proto", MFF_IP_PROTO, "ip", true);
> +expr_symtab_add_field(symtab, "ip.dscp", MFF_IP_DSCP, "ip", false);
> +expr_symtab_add_field(symtab, "ip.ecn", MFF_IP_ECN, "ip", false);
> +expr_symtab_add_field(symtab, "ip.ttl", MFF_IP_TTL, "ip", false);
> +
> +expr_symtab_add_field(symtab, "ip4.src", MFF_IPV4_SRC, "ip4", false);
> +expr_symtab_add_field(symtab, "ip4.dst", MFF_IPV4_DST, "ip4", false);
> +
> +expr_symtab_add_predicate(symtab, "icmp4", "ip4 && ip.proto == 1");
> +expr_symtab_add_field(symtab, "icmp4.type", MFF_ICMPV4_TYPE, "icmp4",
> +  false);
> +expr_symtab_add_field(symtab, "icmp4.code", 

Re: [ovs-dev] [PATCH V13] Function tracer to trace all function calls

2016-07-25 Thread Nirapada Ghosh


Ryan Moats/Omaha/IBM wrote on 07/25/2016 01:44:44 PM:

> From: Ryan Moats/Omaha/IBM
> To: Nirapada Ghosh/San Jose/IBM@IBMUS
> Cc: "Ben Pfaff" , dev@openvswitch.org
> Date: 07/25/2016 01:44 PM
> Subject: Re: [ovs-dev] [PATCH V13] Function tracer to trace all function
calls
>
> Nirapada Ghosh/San Jose/IBM wrote on 07/25/2016 03:32:29 PM:
>
> > From: Nirapada Ghosh/San Jose/IBM
> > To: Ryan Moats/Omaha/IBM@IBMUS
> > Cc: "Ben Pfaff" , dev@openvswitch.org
> > Date: 07/25/2016 03:32 PM
> > Subject: Re: [ovs-dev] [PATCH V13] Function tracer to trace all
> function calls
> >
> > Hi Ryan,
> >
> > Thanks for your detailed review.
> >
> > I will be happy to implement your suggestions but I think your
> > suggestions [first two comments] assume that I can control when the
> > instrumentation is started [ft_begin() is called]. Unfortunately,
> > this constructor is called by C compiler even before main() is
> > invoked. So, when the code is compiled with the -finstrument-functions
> > flag, the code/functions have been already instrumented with the
> > entry/exit hooks in place and call to constructor [ft_begin] in
> > place. Only thing we could control at runtime is -- when to log
> > [from entry/exit routines].  So, I do not think we can control these
> > entry/exit calls in it's bare minimal form [just check a flag and do
> > nothing] when the code is compiled with that option. That's what I
> > was trying to do with my patch. I would love to hear your thoughts
> > again on this. I might be missing something here, please let me know.
> >
> > In regards to your other comments:
> >
> > Yes, I agree.  The way log file name is constructed and timestamps
> > are calculated can be made much simpler as you mentioned, will work
> > on those ASAP.
> >
> > Regards,
> > Nirapada
> >
> > From: Ryan Moats/Omaha/IBM
> > To: Nirapada Ghosh/San Jose/IBM@IBMUS, "Ben Pfaff" 
> > Cc: dev@openvswitch.org
> > Date: 07/24/2016 08:34 AM
> > Subject: Re: [ovs-dev] [PATCH V13] Function tracer to trace all
> function calls
> >
> > "dev"  wrote on 07/08/2016 07:04:06 PM:
> >
> > > From: Nirapada Ghosh/San Jose/IBM@IBMUS
> > > To: dev@openvswitch.org
> > > Date: 07/08/2016 07:04 PM
> > > Subject: [ovs-dev] [PATCH V13] Function tracer to trace all function
calls
> > > Sent by: "dev" 
> > >
> > > From: Nirapada Ghosh 
> > >
> > > In some circumstances, we might need to figure out where in
> > > code, the CPU time is being spent most, so as to pinpoint
> > > the bottleneck and thereby resolve it with proper changes.
> > > Using '-finstrument-functions' flag, that can be achieved, and
> > > this patch exactly does that.
> > >
> > > There is a python file [generate_ft_report.py] with the patch,
> > > that may be used to convert this trace output to a human readable
> > > format with symbol names instead of address and their execution
> > > times. This tool uses addr2line that expects the executable to
> > > be built with -g flag.
> > >
> > > To enable this feature, ovs needs needs to be configured with
> > > "--enable-ft" command line argument [i.e. configure --enable-ft]
> > >
> > > This instrumentation logs the tracing output in separate log files
> > > namely func_trace_.log. It does not use VLOG mechanism for
> > > logging as that will make the patch very complicated to avoid
> > > recursion in the trace routine.
> > >
> > > This feature starts dumping output, only in debug mode, which means
> > > ovs-appctl -t  vlog/set any:any:dbg should be used to enable
> > > this logging.
> > >
> > > Currently, only ovn-northd, ovn-controller, vswitchd are
instrumented.
> > >
> > > It is intended to be used for debugging purposes.
> > > Signed-off-by: Nirapada Ghosh 
> > > ---
> >
> > Rather than go through line by line for style, I'm going to
> > review the approach this patch takes.  One of my personal
> > mantras about instrumentation is that the implementation
> > has be really clean and minimalist, so as to not impact
> > performance when it isn't being used.  Given that mantra,
> > there is (IMHO) way too much calculation going on in this
> > patch set:
> >
> > - Rather than calculate a log directory to use in determining
> >   the output filename for holding instrumentation information,
> >   simply supply that filename via the command line or
> >   ovs-appctl and use that as an additional check before
> >   logging instrumentation info.  This would allow running
> >   code that is exhibiting odd behavior to be placed into
> >   instrumentation mode in-sitsu, rather than requiring a
> >   restart and then waiting for the same situation to occur.
> > - Rather than asking the instrumentation code to search for
> >   a magic symbol to see when to start, just have daemonize_start
> >   signal the instrumentation code via ft_begin() as its last
> >   instruction.  Note that this implies instrumenting more that
> >   

[ovs-dev] [PATCH v4] ovn: expose c validator to python

2016-07-25 Thread Aaron Rosen
This patch exposes the c function expr_parse_string() to be called via
python. The motivation for this is so that clients interfacing with
ovn can call this method in order to validate the data they are writting
to ovn.

Previously, there were several bugs in the neutron/ovn integration
that went unnoticed due to the client writing invalid data. This should
hopefully help catch errors like this earlier as it can now be detected on
the client side and an error can be raised.

Signed-off-by: Aaron Rosen 
---
 include/ovn/expr.h  |   1 +
 ovn/lib/expr.c  | 107 +
 python/automake.mk  |   4 +-
 python/ovs/_ovn-utils.c | 104 
 python/setup.py |  31 +-
 tests/automake.mk   |   4 +-
 tests/test-ovn-utils.at |  15 +++
 tests/test-ovn-utils.py |  33 ++
 tests/test-ovn.c| 112 +---
 tests/testsuite.at  |   1 +
 10 files changed, 299 insertions(+), 113 deletions(-)
 create mode 100644 python/ovs/_ovn-utils.c
 create mode 100644 tests/test-ovn-utils.at
 create mode 100644 tests/test-ovn-utils.py

diff --git a/include/ovn/expr.h b/include/ovn/expr.h
index d790c49..381e32f 100644
--- a/include/ovn/expr.h
+++ b/include/ovn/expr.h
@@ -470,5 +470,6 @@ void expr_macros_add(struct shash *macros, const char *name,
  const char * const *values, size_t n_values);
 void expr_macros_remove(struct shash *macros, const char *name);
 void expr_macros_destroy(struct shash *macros);
+void create_symtab_helper(struct shash *symtab);
 
 #endif /* ovn/expr.h */
diff --git a/ovn/lib/expr.c b/ovn/lib/expr.c
index 288aae2..94b93c5 100644
--- a/ovn/lib/expr.c
+++ b/ovn/lib/expr.c
@@ -3008,3 +3008,110 @@ expr_parse_constant_set(struct lexer *lexer, const 
struct shash *symtab,
 parse_constant_set(, cs);
 return ctx.error;
 }
+
+/* create_symtab_helper() is used for testing purposes and in the ovn_utils
+ * python package. */
+void
+create_symtab_helper(struct shash *symtab)
+{
+shash_init(symtab);
+
+/* Reserve a pair of registers for the logical inport and outport.  A full
+ * 32-bit register each is bigger than we need, but the expression code
+ * doesn't yet support string fields that occupy less than a full OXM. */
+expr_symtab_add_string(symtab, "inport", MFF_REG6, NULL);
+expr_symtab_add_string(symtab, "outport", MFF_REG7, NULL);
+
+expr_symtab_add_field(symtab, "xreg0", MFF_XREG0, NULL, false);
+expr_symtab_add_field(symtab, "xreg1", MFF_XREG1, NULL, false);
+expr_symtab_add_field(symtab, "xreg2", MFF_XREG2, NULL, false);
+
+expr_symtab_add_subfield(symtab, "reg0", NULL, "xreg0[32..63]");
+expr_symtab_add_subfield(symtab, "reg1", NULL, "xreg0[0..31]");
+expr_symtab_add_subfield(symtab, "reg2", NULL, "xreg1[32..63]");
+expr_symtab_add_subfield(symtab, "reg3", NULL, "xreg1[0..31]");
+expr_symtab_add_subfield(symtab, "reg4", NULL, "xreg2[32..63]");
+expr_symtab_add_subfield(symtab, "reg5", NULL, "xreg2[0..31]");
+
+expr_symtab_add_field(symtab, "eth.src", MFF_ETH_SRC, NULL, false);
+expr_symtab_add_field(symtab, "eth.dst", MFF_ETH_DST, NULL, false);
+expr_symtab_add_field(symtab, "eth.type", MFF_ETH_TYPE, NULL, true);
+
+expr_symtab_add_field(symtab, "vlan.tci", MFF_VLAN_TCI, NULL, false);
+expr_symtab_add_predicate(symtab, "vlan.present", "vlan.tci[12]");
+expr_symtab_add_subfield(symtab, "vlan.pcp", "vlan.present",
+ "vlan.tci[13..15]");
+expr_symtab_add_subfield(symtab, "vlan.vid", "vlan.present",
+ "vlan.tci[0..11]");
+
+expr_symtab_add_predicate(symtab, "ip4", "eth.type == 0x800");
+expr_symtab_add_predicate(symtab, "ip6", "eth.type == 0x86dd");
+expr_symtab_add_predicate(symtab, "ip", "ip4 || ip6");
+expr_symtab_add_field(symtab, "ip.proto", MFF_IP_PROTO, "ip", true);
+expr_symtab_add_field(symtab, "ip.dscp", MFF_IP_DSCP, "ip", false);
+expr_symtab_add_field(symtab, "ip.ecn", MFF_IP_ECN, "ip", false);
+expr_symtab_add_field(symtab, "ip.ttl", MFF_IP_TTL, "ip", false);
+
+expr_symtab_add_field(symtab, "ip4.src", MFF_IPV4_SRC, "ip4", false);
+expr_symtab_add_field(symtab, "ip4.dst", MFF_IPV4_DST, "ip4", false);
+
+expr_symtab_add_predicate(symtab, "icmp4", "ip4 && ip.proto == 1");
+expr_symtab_add_field(symtab, "icmp4.type", MFF_ICMPV4_TYPE, "icmp4",
+  false);
+expr_symtab_add_field(symtab, "icmp4.code", MFF_ICMPV4_CODE, "icmp4",
+  false);
+
+expr_symtab_add_field(symtab, "ip6.src", MFF_IPV6_SRC, "ip6", false);
+expr_symtab_add_field(symtab, "ip6.dst", MFF_IPV6_DST, "ip6", false);
+expr_symtab_add_field(symtab, "ip6.label", MFF_IPV6_LABEL, "ip6", false);
+
+expr_symtab_add_predicate(symtab, "icmp6", "ip6 && ip.proto == 58");
+expr_symtab_add_field(symtab, 

[ovs-dev] [PATCH] move ovn/lib/<lex|actions|expr>.h to include/ovn

2016-07-25 Thread Aaron Rosen
This patch is done to enable in tree building of the ovn-utils python
wrapper. This is similar to what was done in:
ee89ea7b477bb4fd05137de03b2e8443807ed9f4

Signed-off-by: Aaron Rosen 
---
 include/automake.mk |   1 +
 include/ovn/actions.h   | 141 
 include/ovn/automake.mk |   5 +
 include/ovn/expr.h  | 474 
 include/ovn/lex.h   | 139 
 ovn/controller/lflow.c  |   4 +-
 ovn/controller/ofctrl.c |   2 +-
 ovn/controller/ovn-controller.c |   2 +-
 ovn/controller/pinctrl.c|   2 +-
 ovn/lib/actions.c   |   6 +-
 ovn/lib/actions.h   | 141 
 ovn/lib/automake.mk |   3 -
 ovn/lib/expr.c  |   4 +-
 ovn/lib/expr.h  | 474 
 ovn/lib/lex.c   |   2 +-
 ovn/lib/lex.h   | 139 
 ovn/northd/ovn-northd.c |   2 +-
 tests/test-ovn.c|   6 +-
 18 files changed, 775 insertions(+), 772 deletions(-)
 create mode 100644 include/ovn/actions.h
 create mode 100644 include/ovn/automake.mk
 create mode 100644 include/ovn/expr.h
 create mode 100644 include/ovn/lex.h
 delete mode 100644 ovn/lib/actions.h
 delete mode 100644 ovn/lib/expr.h
 delete mode 100644 ovn/lib/lex.h

diff --git a/include/automake.mk b/include/automake.mk
index 6a4cf86..37903fd 100644
--- a/include/automake.mk
+++ b/include/automake.mk
@@ -6,6 +6,7 @@ include/odp-netlink.h: 
datapath/linux/compat/include/linux/openvswitch.h \
 EXTRA_DIST += build-aux/extract-odp-netlink-h
 CLEANFILES += include/odp-netlink.h
 
+include include/ovn/automake.mk
 include include/openflow/automake.mk
 include include/openvswitch/automake.mk
 include include/sparse/automake.mk
diff --git a/include/ovn/actions.h b/include/ovn/actions.h
new file mode 100644
index 000..114c71e
--- /dev/null
+++ b/include/ovn/actions.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2015, 2016 Nicira, 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.
+ */
+
+#ifndef OVN_ACTIONS_H
+#define OVN_ACTIONS_H 1
+
+#include 
+#include 
+#include "compiler.h"
+#include "openvswitch/hmap.h"
+#include "openvswitch/dynamic-string.h"
+#include "util.h"
+
+struct expr;
+struct lexer;
+struct ofpbuf;
+struct shash;
+struct simap;
+
+#define MAX_OVN_GROUPS 65535
+
+struct group_table {
+unsigned long *group_ids;  /* Used as a bitmap with value set
+* for allocated group ids in either
+* desired_groups or existing_groups. */
+struct hmap desired_groups;
+struct hmap existing_groups;
+};
+
+struct group_info {
+struct hmap_node hmap_node;
+struct ds group;
+uint32_t group_id;
+};
+
+enum action_opcode {
+/* "arp { ...actions... }".
+ *
+ * The actions, in OpenFlow 1.3 format, follow the action_header.
+ */
+ACTION_OPCODE_ARP,
+
+/* "put_arp(port, ip, mac)"
+ *
+ * Arguments are passed through the packet metadata and data, as follows:
+ *
+ * MFF_REG0 = ip
+ * MFF_LOG_INPORT = port
+ * MFF_ETH_SRC = mac
+ */
+ACTION_OPCODE_PUT_ARP,
+
+/* "result = put_dhcp_opts(offer_ip, option, ...)".
+ *
+ * Arguments follow the action_header, in this format:
+ *   - A 32-bit or 64-bit OXM header designating the result field.
+ *   - A 32-bit integer specifying a bit offset within the result field.
+ *   - The 32-bit DHCP offer IP.
+ *   - Any number of DHCP options.
+ */
+ACTION_OPCODE_PUT_DHCP_OPTS,
+
+/* "na { ...actions... }".
+ *
+ * The actions, in OpenFlow 1.3 format, follow the action_header.
+ */
+ACTION_OPCODE_NA,
+};
+
+/* Header. */
+struct action_header {
+ovs_be32 opcode;/* One of ACTION_OPCODE_* */
+uint8_t pad[4];
+};
+BUILD_ASSERT_DECL(sizeof(struct action_header) == 8);
+
+struct action_params {
+/* A table of "struct expr_symbol"s to support (as one would provide to
+ * expr_parse()). */
+const struct shash *symtab;
+
+/* hmap of 'struct dhcp_opts_map'  to support 'put_dhcp_opts' action */
+const struct hmap *dhcp_opts;
+
+/* Looks up logical port 'port_name'.  If found, stores its port number in
+ * '*portp' and returns true; otherwise, returns false. */
+bool (*lookup_port)(const void *aux, const char 

Re: [ovs-dev] [PATCH 5/9] datapath-windows: Define new multicast conntrack events

2016-07-25 Thread Yin Lin
Hi Sai,

After looking at your follow up patches, I feel it's better to rename
OVS_MCAST_EVENT_ENTRIES
as OVS_MCAST_EVENT_TYPE, and rename OVS_MCAST_EVENT_ENTRIES_MAX as
OVS_MCAST_EVENT_TYPES_MAX.
At first glance, event_entries_max seems to suggest the maximum number of
events in a queue, which is not the case.

Best regards,
Yin Lin

On Wed, Jul 13, 2016 at 4:38 PM, Sairam Venugopal 
wrote:

> 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 
> ---
>  datapath-windows/ovsext/Datapath.c   | 21 ++---
>  datapath-windows/ovsext/Datapath.h   |  3 ++-
>  datapath-windows/ovsext/DpInternal.h | 15 +++
>  3 files changed, 35 insertions(+), 4 deletions(-)
>
> diff --git a/datapath-windows/ovsext/Datapath.c
> b/datapath-windows/ovsext/Datapath.c
> index e4d6ab1..a5a0b35 100644
> --- a/datapath-windows/ovsext/Datapath.c
> +++ b/datapath-windows/ovsext/Datapath.c
> @@ -1268,11 +1268,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);
>
> @@ -1288,11 +1289,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, ,
>  sizeof request);
> diff --git a/datapath-windows/ovsext/Datapath.h
> b/datapath-windows/ovsext/Datapath.h
> index 2b41d82..57b483a 100644
> --- a/datapath-windows/ovsext/Datapath.h
> +++ b/datapath-windows/ovsext/Datapath.h
> @@ -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.
> */
> diff --git a/datapath-windows/ovsext/DpInternal.h
> b/datapath-windows/ovsext/DpInternal.h
> index 8abe61d..9641bf6 100644
> --- a/datapath-windows/ovsext/DpInternal.h
> +++ b/datapath-windows/ovsext/DpInternal.h
> @@ -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 {
> @@ -327,6 +329,19 @@ enum {
>  OVS_EVENT_MASK_ALL  = 0x3f,
>  };
>
> +enum {
> +OVS_EVENT_CT_NEW= ((uint32_t)0x1 << 0),
> +OVS_EVENT_CT_DELETE = ((uint32_t)0x1 << 1),
> +OVS_EVENT_CT_MASK_ALL   = 0x3
> +};
> +
> +/* Supported mcast event groups */
> +enum OVS_MCAST_EVENT_ENTRIES {
> +OVS_MCAST_VPORT_EVENT,
> +OVS_MCAST_CT_EVENT,
> +__OVS_MCAST_EVENT_ENTRIES_MAX
> +};
> +#define OVS_MCAST_EVENT_ENTRIES_MAX (__OVS_MCAST_EVENT_ENTRIES_MAX -
> OVS_MCAST_VPORT_EVENT)
>
>  typedef struct _OVS_VPORT_EVENT_ENTRY {
>  UINT32 portNo;
> --
> 2.9.0.windows.1
>
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] Windows: daemon-windows lockfile

2016-07-25 Thread Alin Serdean
_get_osfhandle returns an errno value not a GetLastErrorValue.
(https://msdn.microsoft.com/en-us/library/ks2530z6(v=vs.120).aspx)

Signed-off-by: Alin Gabriel Serdean 
---
 lib/daemon-windows.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/daemon-windows.c b/lib/daemon-windows.c
index d77724e..7e2e9da 100644
--- a/lib/daemon-windows.c
+++ b/lib/daemon-windows.c
@@ -417,7 +417,7 @@ flock(FILE* fd, int operation)
 hFile = (HANDLE)_get_osfhandle(fileno(fd));
 if (hFile == INVALID_HANDLE_VALUE) {
 VLOG_FATAL("Failed to get PID file handle (%s).",
-   ovs_lasterror_to_string());
+   ovs_strerror(errno));
 }
 
 if (operation & LOCK_UNLOCK) {
-- 
1.9.5.msysgit.0
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 7/9] datapath-windows: Add support for multiple event queue in Event.c

2016-07-25 Thread Alin Serdean
Thanks a lot for the info. It would be nice to have it in the initial cover 
letter just to know the broader idea about the intent :).
From the code I could see the direction you want to go with it, but I wanted 
some confirmation.

Acked-by: Alin Gabriel Serdean 

> -Mesaj original-
> De la: Sairam Venugopal [mailto:vsai...@vmware.com]
> Trimis: Monday, July 25, 2016 11:19 PM
> Către: Alin Serdean ;
> dev@openvswitch.org
> Subiect: Re: [ovs-dev] [PATCH 7/9] datapath-windows: Add support for
> multiple event queue in Event.c
> 
> I added the padding to keep the sizeof(OVS_CT_EVENT_ENTRY) ==
> sizeof(OVS_VPORT_EVENT_ENTRY)
> 
> 
> I should have sent this as part of Patch 0. This is the general idea:
> 
> 1. Currently we only support subscribing/unsubscribing to Vport related
> events. Even for VPORT, we only care about the VPORT-Down event.
> 2. Event.c maintains a single queue of Event entries that are then read by
> user space. This worked because we only supported 1 event type.
> 3. In order to add support for multiple events, I modified the event queue
> into an array (size 2). The size of the event queue array is driven by value 
> of
> enum (we explicitly add new event types here).
> 4. I decided to make Event Queue an array to avoid creating new ones for
> every event type. This also meant smaller code changes and not having
> multiple if-else in the code.
> 5. Each event queue can be uniquely identified based on the mcast
> EventType and hence the requirement for multiple locks based on the event
> id.
> 6. Though we may not have multiple event queues subscribed for 1 socket, I
> still wanted to ensure that we have support for it if it were ever requested.
[Alin Gabriel Serdean: ] That was my main concern because it can be added in 
the future. Good call :).
> 7. Each event type will be added to the underlying enum and subtypes can
> be represent by means of masks (eg: vport up/down, ct delete/add/update
> etc.,)
> /* Supported mcast event groups */
> enum OVS_MCAST_EVENT_ENTRIES {
> OVS_MCAST_VPORT_EVENT,
> OVS_MCAST_CT_EVENT,
> __OVS_MCAST_EVENT_ENTRIES_MAX
> };
> 
> 
> I hope this clarifies the questions.
> 
> Thanks,
> Sairam
> 
> On 7/22/16, 6:10 PM, "Alin Serdean" 
> wrote:
> 
> >Looks good. Just a few questions from my side so I get up to speed with
> >the changes in events.
> >Why do we need a lock per eventid ?
> >
> >> +typedef struct _OVS_CT_EVENT_ENTRY {
> >> +OVS_CT_ENTRY entry;
> >> +UINT8 type;
> >> +UINT64 pad[10];
> >> +} OVS_CT_EVENT_ENTRY, *POVS_CT_EVENT_ENTRY;
> >
> >Why such a big pad?
> >
> >Thanks,
> >Alin.
> >
> >> -Mesaj original-
> >> De la: dev [mailto:dev-boun...@openvswitch.org] În numele Sairam
> >>Venugopal
> >> Trimis: Thursday, July 14, 2016 2:39 AM
> >> Către: dev@openvswitch.org
> >> Subiect: [ovs-dev] [PATCH 7/9] datapath-windows: Add support for
> >>multiple  event queue in Event.c
> >>
> >> Update Event.c to have multiple event queues and mechanism to
> >> retrieve the associated queue. Introduce OvsPostCtEvent and
> >> OvsRemoveCtEventEntry similar to OvsPostVportEvent and
> >> OvsRemoveVportEventEntry.

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] rhel/openvswitch.spec: Add SELinux policy.

2016-07-25 Thread Joe Stringer
Commit 9b897c9125ef ("rhel: provide our own SELinux custom policy
package") added the SELinux policy to the fedora packaging as a
subpackage. This patch makes the corresponding change to
openvswitch.spec, so that users of that specfile can generate the
selinux policy package without having to build all of the fedora
packages.

Signed-off-by: Joe Stringer 
---
As per the reasoning in the link below, I've just duplicated the
subpackage lines from the fedora specfile rather than refactoring these
lines into a separate specfile.

http://openvswitch.org/pipermail/dev/2016-January/065134.html
---
 rhel/openvswitch.spec.in | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/rhel/openvswitch.spec.in b/rhel/openvswitch.spec.in
index ec555a74a901..fbca1efcd17f 100644
--- a/rhel/openvswitch.spec.in
+++ b/rhel/openvswitch.spec.in
@@ -24,6 +24,7 @@ Source: openvswitch-%{version}.tar.gz
 Buildroot: /tmp/openvswitch-rpm
 Requires: logrotate, python >= 2.7, python-six
 BuildRequires: openssl-devel
+BuildRequires: checkpolicy, selinux-policy-devel
 
 %bcond_without check
 
@@ -39,6 +40,15 @@ Group:  Development/Libraries
 %description devel
 This package provides openvswitch headers and libopenvswitch for developers.
 
+%package selinux-policy
+Summary: Open vSwitch SELinux policy
+License: ASL 2.0
+BuildArch: noarch
+Requires: selinux-policy-targeted
+
+%description selinux-policy
+Tailored Open vSwitch SELinux policy
+
 %prep
 %setup -q
 
@@ -46,6 +56,8 @@ This package provides openvswitch headers and libopenvswitch 
for developers.
 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} \
 --libdir=%{_libdir} --enable-ssl --enable-shared
 make %{_smp_mflags}
+cd selinux
+make -f %{_datadir}/selinux/devel/Makefile
 
 %install
 rm -rf $RPM_BUILD_ROOT
@@ -63,6 +75,9 @@ rhel_cp etc_sysconfig_network-scripts_ifup-ovs 0755
 rhel_cp etc_sysconfig_network-scripts_ifdown-ovs 0755
 rhel_cp usr_share_openvswitch_scripts_sysconfig.template 0644
 
+install -p -m 644 -D selinux/openvswitch-custom.pp \
+$RPM_BUILD_ROOT%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
+
 # Get rid of stuff we don't want to make RPM happy.
 rm \
 $RPM_BUILD_ROOT/usr/bin/ovs-testcontroller \
@@ -132,6 +147,9 @@ fi
 /sbin/chkconfig --add openvswitch
 /sbin/chkconfig openvswitch on
 
+%post selinux-policy
+/usr/sbin/semodule -i 
%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp &> /dev/null || :
+
 %preun
 if [ "$1" = "0" ]; then # $1 = 0 for uninstall
 /sbin/service openvswitch stop
@@ -145,6 +163,11 @@ if [ "$1" = "0" ]; then # $1 = 0 for uninstall
 rm -f /etc/openvswitch/vswitchd.cacert
 fi
 
+%postun selinux-policy
+if [ $1 -eq 0 ] ; then
+  /usr/sbin/semodule -r openvswitch-custom &> /dev/null || :
+fi
+
 exit 0
 
 %files
@@ -216,3 +239,7 @@ exit 0
 %{_libdir}/lib*.a
 %{_libdir}/pkgconfig
 %{_includedir}/openvswitch/*
+
+%files selinux-policy
+%defattr(-,root,root)
+%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
-- 
2.9.0

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [ovs-dev,ovn-controller] Physical: persist tunnels

2016-07-25 Thread Flavio Fernandes

> On Jul 25, 2016, at 12:28 PM, Ryan Moats  wrote:
> 
> While commit ab39371d68842b7e4000cc5d8718e6fc04e92795
> (ovn-controller: Handle physical changes correctly) addressed
> unit test failures, it did so at the cost of performance: [1]
> notes that ovn-controller cpu usage is now pegged at 100%.
> 
> Root cause of this is that while the storage for tunnels is
> persisted, their creation is not (which the above changed
> incorrectly assumed was the case).  This patch persists
> tunneled data across invocations of physical_run.  A side
> effect is that renaming of localfvif_map_changed variable
> to physical_map_changed and extending its scope to include
> tunnel changes.
> 

I tested this fix by using a Vagrant file that stamps out vms as compute nodes.
To deploy ovn, call the script “/vagrant/scripts/setup-ovn-cluster.sh” and that
would render ovn-controller in compute nodes to peg the cpu at 100% before the
changes.

More info on _easily_ deploying this cluster is available here:
https://github.com/flavio-fernandes/just-ovn-nodes/blob/master/README.md


> [1] http://openvswitch.org/pipermail/dev/2016-July/076058.html
> 
> Signed-off-by: Ryan Moats 

Acked-by: Flavio Fernandes 
Tested-by: Flavio Fernandes 


> ---
> ovn/controller/physical.c | 59 +--
> 1 file changed, 37 insertions(+), 22 deletions(-)
> 
> diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c
> index a104e33..e788fe5 100644
> --- a/ovn/controller/physical.c
> +++ b/ovn/controller/physical.c
> @@ -605,8 +605,13 @@ physical_run(struct controller_ctx *ctx, enum 
> mf_field_id mff_ovn_geneve,
> uuid_generate(hc_uuid);
> }
> 
> +/* This bool tracks physical mapping changes. */
> +bool physical_map_changed = false;
> +
> struct simap new_localvif_to_ofport =
> SIMAP_INITIALIZER(_localvif_to_ofport);
> +struct simap new_tunnel_to_ofport =
> +SIMAP_INITIALIZER(_tunnel_to_ofport);
> for (int i = 0; i < br_int->n_ports; i++) {
> const struct ovsrec_port *port_rec = br_int->ports[i];
> if (!strcmp(port_rec->name, br_int->name)) {
> @@ -668,18 +673,23 @@ physical_run(struct controller_ctx *ctx, enum 
> mf_field_id mff_ovn_geneve,
> continue;
> }
> 
> -struct chassis_tunnel *tun = xmalloc(sizeof *tun);
> -hmap_insert(, >hmap_node,
> -hash_string(chassis_id, 0));
> -tun->chassis_id = chassis_id;
> -tun->ofport = u16_to_ofp(ofport);
> -tun->type = tunnel_type;
> -full_binding_processing = true;
> -binding_reset_processing();
> -
> -/* Reprocess logical flow table immediately. */
> -lflow_reset_processing();
> -poll_immediate_wake();
> +simap_put(_tunnel_to_ofport, chassis_id, ofport);
> +struct chassis_tunnel *tun;
> +if ((tun = chassis_tunnel_find(chassis_id))) {
> +/* If the tunnel's ofport has changed, update. */
> +if (tun->ofport != u16_to_ofp(ofport)) {
> +tun->ofport = u16_to_ofp(ofport);
> +physical_map_changed = true;
> +}
> +} else {
> +tun = xmalloc(sizeof *tun);
> +hmap_insert(, >hmap_node,
> +hash_string(chassis_id, 0));
> +tun->chassis_id = chassis_id;
> +tun->ofport = u16_to_ofp(ofport);
> +tun->type = tunnel_type;
> +physical_map_changed = true;
> +}
> break;
> } else {
> const char *iface_id = smap_get(_rec->external_ids,
> @@ -691,29 +701,38 @@ physical_run(struct controller_ctx *ctx, enum 
> mf_field_id mff_ovn_geneve,
> }
> }
> 
> +/* Remove tunnels that are no longer here. */
> +struct chassis_tunnel *tun, *tun_next;
> +HMAP_FOR_EACH_SAFE (tun, tun_next, hmap_node, ) {
> +if (!simap_find(_tunnel_to_ofport, tun->chassis_id)) {
> +hmap_remove(, >hmap_node);
> +physical_map_changed = true;
> +free(tun);
> +}
> +}
> +
> /* Capture changed or removed openflow ports. */
> -bool localvif_map_changed = false;
> struct simap_node *vif_name, *vif_name_next;
> SIMAP_FOR_EACH_SAFE (vif_name, vif_name_next, _to_ofport) {
> int newport;
> if ((newport = simap_get(_localvif_to_ofport, vif_name->name))) {
> if (newport != simap_get(_to_ofport, vif_name->name)) {
> simap_put(_to_ofport, vif_name->name, newport);
> -localvif_map_changed = true;
> +physical_map_changed = true;
>   

Re: [ovs-dev] [PATCH V13] Function tracer to trace all function calls

2016-07-25 Thread Ryan Moats
Nirapada Ghosh/San Jose/IBM wrote on 07/25/2016 03:32:29 PM:

> From: Nirapada Ghosh/San Jose/IBM
> To: Ryan Moats/Omaha/IBM@IBMUS
> Cc: "Ben Pfaff" , dev@openvswitch.org
> Date: 07/25/2016 03:32 PM
> Subject: Re: [ovs-dev] [PATCH V13] Function tracer to trace all function
calls
>
> Hi Ryan,
>
> Thanks for your detailed review.
>
> I will be happy to implement your suggestions but I think your
> suggestions [first two comments] assume that I can control when the
> instrumentation is started [ft_begin() is called]. Unfortunately,
> this constructor is called by C compiler even before main() is
> invoked. So, when the code is compiled with the -finstrument-functions
> flag, the code/functions have been already instrumented with the
> entry/exit hooks in place and call to constructor [ft_begin] in
> place. Only thing we could control at runtime is -- when to log
> [from entry/exit routines].  So, I do not think we can control these
> entry/exit calls in it's bare minimal form [just check a flag and do
> nothing] when the code is compiled with that option. That's what I
> was trying to do with my patch. I would love to hear your thoughts
> again on this. I might be missing something here, please let me know.
>
> In regards to your other comments:
>
> Yes, I agree.  The way log file name is constructed and timestamps
> are calculated can be made much simpler as you mentioned, will work
> on those ASAP.
>
> Regards,
> Nirapada
>
> From: Ryan Moats/Omaha/IBM
> To: Nirapada Ghosh/San Jose/IBM@IBMUS, "Ben Pfaff" 
> Cc: dev@openvswitch.org
> Date: 07/24/2016 08:34 AM
> Subject: Re: [ovs-dev] [PATCH V13] Function tracer to trace all function
calls
>
> "dev"  wrote on 07/08/2016 07:04:06 PM:
>
> > From: Nirapada Ghosh/San Jose/IBM@IBMUS
> > To: dev@openvswitch.org
> > Date: 07/08/2016 07:04 PM
> > Subject: [ovs-dev] [PATCH V13] Function tracer to trace all function
calls
> > Sent by: "dev" 
> >
> > From: Nirapada Ghosh 
> >
> > In some circumstances, we might need to figure out where in
> > code, the CPU time is being spent most, so as to pinpoint
> > the bottleneck and thereby resolve it with proper changes.
> > Using '-finstrument-functions' flag, that can be achieved, and
> > this patch exactly does that.
> >
> > There is a python file [generate_ft_report.py] with the patch,
> > that may be used to convert this trace output to a human readable
> > format with symbol names instead of address and their execution
> > times. This tool uses addr2line that expects the executable to
> > be built with -g flag.
> >
> > To enable this feature, ovs needs needs to be configured with
> > "--enable-ft" command line argument [i.e. configure --enable-ft]
> >
> > This instrumentation logs the tracing output in separate log files
> > namely func_trace_.log. It does not use VLOG mechanism for
> > logging as that will make the patch very complicated to avoid
> > recursion in the trace routine.
> >
> > This feature starts dumping output, only in debug mode, which means
> > ovs-appctl -t  vlog/set any:any:dbg should be used to enable
> > this logging.
> >
> > Currently, only ovn-northd, ovn-controller, vswitchd are instrumented.
> >
> > It is intended to be used for debugging purposes.
> > Signed-off-by: Nirapada Ghosh 
> > ---
>
> Rather than go through line by line for style, I'm going to
> review the approach this patch takes.  One of my personal
> mantras about instrumentation is that the implementation
> has be really clean and minimalist, so as to not impact
> performance when it isn't being used.  Given that mantra,
> there is (IMHO) way too much calculation going on in this
> patch set:
>
> - Rather than calculate a log directory to use in determining
>   the output filename for holding instrumentation information,
>   simply supply that filename via the command line or
>   ovs-appctl and use that as an additional check before
>   logging instrumentation info.  This would allow running
>   code that is exhibiting odd behavior to be placed into
>   instrumentation mode in-sitsu, rather than requiring a
>   restart and then waiting for the same situation to occur.
> - Rather than asking the instrumentation code to search for
>   a magic symbol to see when to start, just have daemonize_start
>   signal the instrumentation code via ft_begin() as its last
>   instruction.  Note that this implies instrumenting more that
>   this patch does, but since this patch doesn't instrument
>   ovsdb-server, I view it as incomplete anyway.
> - Once ft_begin is used for signalling to start tracing, the
>   code to check and open the instrumentation file can move
>   from __cyg_profile_func_enter and __cyg_profile_func_exit
>   calls to where ft_begin and changes to ovs-appctl would
>   invoke it.
> - There is already a built in function to get the wall clock
>   time in milliseconds (time_wall_msec).  I don't see a
>   

Re: [ovs-dev] [PATCH 7/9] datapath-windows: Add support for multiple event queue in Event.c

2016-07-25 Thread Sairam Venugopal
I added the padding to keep the sizeof(OVS_CT_EVENT_ENTRY) ==
sizeof(OVS_VPORT_EVENT_ENTRY)


I should have sent this as part of Patch 0. This is the general idea:

1. Currently we only support subscribing/unsubscribing to Vport related
events. Even for VPORT, we only care about the VPORT-Down event.
2. Event.c maintains a single queue of Event entries that are then read by
user space. This worked because we only supported 1 event type.
3. In order to add support for multiple events, I modified the event queue
into an array (size 2). The size of the event queue array is driven by
value of enum (we explicitly add new event types here).
4. I decided to make Event Queue an array to avoid creating new ones for
every event type. This also meant smaller code changes and not having
multiple if-else in the code.
5. Each event queue can be uniquely identified based on the mcast
EventType and hence the requirement for multiple locks based on the event
id.
6. Though we may not have multiple event queues subscribed for 1 socket, I
still wanted to ensure that we have support for it if it were ever
requested.
7. Each event type will be added to the underlying enum and subtypes can
be represent by means of masks (eg: vport up/down, ct delete/add/update
etc.,)
/* Supported mcast event groups */
enum OVS_MCAST_EVENT_ENTRIES {
OVS_MCAST_VPORT_EVENT,
OVS_MCAST_CT_EVENT,
__OVS_MCAST_EVENT_ENTRIES_MAX
};


I hope this clarifies the questions.

Thanks,
Sairam

On 7/22/16, 6:10 PM, "Alin Serdean" 
wrote:

>Looks good. Just a few questions from my side so I get up to speed with
>the changes in events.
>Why do we need a lock per eventid ?
>
>> +typedef struct _OVS_CT_EVENT_ENTRY {
>> +OVS_CT_ENTRY entry;
>> +UINT8 type;
>> +UINT64 pad[10];
>> +} OVS_CT_EVENT_ENTRY, *POVS_CT_EVENT_ENTRY;
>
>Why such a big pad?
>
>Thanks,
>Alin.
>
>> -Mesaj original-
>> De la: dev [mailto:dev-boun...@openvswitch.org] În numele Sairam
>> Venugopal
>> Trimis: Thursday, July 14, 2016 2:39 AM
>> Către: dev@openvswitch.org
>> Subiect: [ovs-dev] [PATCH 7/9] datapath-windows: Add support for
>>multiple
>> event queue in Event.c
>> 
>> Update Event.c to have multiple event queues and mechanism to retrieve
>> the associated queue. Introduce OvsPostCtEvent and
>> OvsRemoveCtEventEntry similar to OvsPostVportEvent and
>> OvsRemoveVportEventEntry.

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATACH]netdev-dpdk: remove duplicated code in netdev_dpdk_get_status

2016-07-25 Thread Daniele Di Proietto
Thanks for the patch!

I had to manually unwrap some long lines.  Could you maybe use git
send-email next time?

Anyway, I added you to AUTHORS and applied this to master

Thanks,

Daniele

2016-07-25 1:37 GMT-07:00 :

> From caeb84217c38ccd0b2076689fd36b578c00678ad Mon Sep 17 00:00:00 2001
> From: xubinbin 
> Date: Thu, 21 Jul 2016 21:52:29 +0800
> Subject: [PATCH] netdev-dpdk: remove duplicated code in
> netdev_dpdk_get_status
>
> Put "driver_name" into "args" twice, that's meaninglessness.
> So need to remove duplicated code.
>
> Signed-off-by: Binbin Xu 
> ---
>  lib/netdev-dpdk.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index 85b18fd..b515bee 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -2091,8 +2091,6 @@ netdev_dpdk_get_status(const struct netdev *netdev,
> struct smap *args)
>  rte_eth_dev_info_get(dev->port_id, _info);
>  ovs_mutex_unlock(>mutex);
>
> -smap_add_format(args, "driver_name", "%s", dev_info.driver_name);
> -
>  smap_add_format(args, "port_no", "%d", dev->port_id);
>  smap_add_format(args, "numa_id", "%d",
> rte_eth_dev_socket_id(dev->port_id));
>  smap_add_format(args, "driver_name", "%s", dev_info.driver_name);
> --
> 1.8.3.1
> 
> ZTE Information Security Notice: The information contained in this mail
> (and any attachment transmitted herewith) is privileged and confidential
> and is intended for the exclusive use of the addressee(s).  If you are not
> an intended recipient, any disclosure, reproduction, distribution or other
> dissemination or use of the information contained is strictly prohibited.
> If you have received this mail in error, please delete it and notify us
> immediately.
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] netdev-dpdk: Apply batch truncation API.

2016-07-25 Thread Daniele Di Proietto
Applied to master, thanks

2016-07-25 8:14 GMT-07:00 William Tu :

> Instead of looping into each packet and check whether to truncate, the
> patch moves it out of the loop and uses batch API.  If truncation is
> not set, checking 'trunc' in 'struct dp_packet_batch' at per-batch basis
> can skip the per-packet checking overhead.
>
> Signed-off-by: William Tu 
> ---
>  lib/netdev-dpdk.c | 11 ---
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index 7fb6457..22d547f 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -1411,6 +1411,8 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid,
> struct dp_packet_batch *batch)
>  ovs_mutex_lock(_mempool_mutex);
>  }
>
> +dp_packet_batch_apply_cutlen(batch);
> +
>  for (i = 0; i < batch->count; i++) {
>  int size = dp_packet_size(batch->packets[i]);
>
> @@ -1429,10 +1431,6 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid,
> struct dp_packet_batch *batch)
>  break;
>  }
>
> -/* Cut the size so only the truncated size is copied. */
> -size -= dp_packet_get_cutlen(batch->packets[i]);
> -dp_packet_reset_cutlen(batch->packets[i]);
> -
>  /* We have to do a copy for now */
>  memcpy(rte_pktmbuf_mtod(mbufs[newcnt], void *),
> dp_packet_data(batch->packets[i]), size);
> @@ -1506,12 +1504,11 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int
> qid,
>  unsigned int temp_cnt = 0;
>  int cnt = batch->count;
>
> +dp_packet_batch_apply_cutlen(batch);
> +
>  for (int i = 0; i < cnt; i++) {
>  int size = dp_packet_size(batch->packets[i]);
>
> -size -= dp_packet_get_cutlen(batch->packets[i]);
> -dp_packet_set_size(batch->packets[i], size);
> -
>  if (OVS_UNLIKELY(size > dev->max_packet_len)) {
>  if (next_tx_idx != i) {
>  temp_cnt = i - next_tx_idx;
> --
> 2.5.0
>
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] Backport Request: dpif-netdev: Remove PMD latency on seq_mutex

2016-07-25 Thread Vinod, Chegu
Thanks Daniele !

Vinod

-Original Message-
From: Daniele Di Proietto [mailto:diproiet...@vmware.com] 
Sent: Monday, July 25, 2016 11:23 AM
To: Loftus, Ciara ; Vinod, Chegu ; 
Flavio Leitner 
Cc: kris...@redhat.com; ovs-dev ; Phillips, John 
; Ben Pfaff 
Subject: Re: Backport Request: dpif-netdev: Remove PMD latency on seq_mutex

Fair point, I guess this looks more like a bug fix than a new features.

After discussing offline with Ben and having another set of eyes on the changes 
I backported this to branch-2.5.

Thanks,

Daniele


On 25/07/2016 02:29, "Loftus, Ciara"  wrote:

>> 
>> Thanks Flavio for checking and Daniel for your consideration.
>> Indeed the issue exists in 2.5 branch.
>> 
>> We are treating this more in the bucket of a performance bug fix than 
>> a feature.
>> 
>> Any specific testing that you would like to see run to help reduce 
>> your concern related to changes to the core modules ?
>> 
>> Ciara, what's your opinion on these changes for a backport ?
>
>I'm of the same opinion as yourself and Flavio that this is more a fix than a 
>feature. I'd like to see it backported.
>But I understand there may be some risk associated with due to the nature of 
>the changes.
>
>Thanks,
>Ciara
>
>> 
>> Thanks
>> Vinod
>> 
>> 
>> 
>> -Original Message-
>> From: Daniele Di Proietto [mailto:diproiet...@vmware.com]
>> Sent: Friday, July 22, 2016 3:49 PM
>> To: Flavio Leitner ; Vinod, Chegu 
>> 
>> Cc: kris...@redhat.com; ovs-dev ; Loftus, Ciara 
>> 
>> Subject: Re: Backport Request: dpif-netdev: Remove PMD latency on 
>> seq_mutex
>> 
>> I'm not sure I'm 100% comfortable back porting this to branch-2.5
>> 
>> I see the change more as a feature rather than a bugfix.
>> 
>> Also it touches some core modules (seq and rcu) in a non trivial way.
>> 
>> 
>> What do you guys think?
>> 
>> Thanks,
>> 
>> Daniele
>> 
>> On 22/07/2016 15:03, "Flavio Leitner"  wrote:
>> 
>> >(adding ovs-dev mailing list and more people interesting on the 
>> >backport to CC)
>> >
>> >On Mon, Jul 18, 2016 at 05:31:52AM +, Vinod, Chegu wrote:
>> >> Hi Flavio, Karl,
>> >>
>> >> Is there a version of the following fix available that is 
>> >> compatible with OVS
>> 2.5?
>> >>
>> >>
>> https://github.com/openvswitch/ovs/commit/9dede5cff553d7c4e074f04c52
>> 5
>> >> c1417eb209363
>> >>
>> >> If yes can it backported to the 2.5 branch ?
>> >
>> >branch-2.5 is affected by the same issue.  I tested the patch from 
>> >branch master (cherry-pick) and it solved the issue.
>> >
>> >Daniele,
>> >
>> >What do you think? If you agree, do you need me to post the 
>> >backported patch or is it enough for you to cherry-pick?
>> >
>> >Thanks,
>> >--
>> >fbl
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] python: Send old values of the updated cols in notify for update2

2016-07-25 Thread Numan Siddique
On Mon, Jul 25, 2016 at 10:10 PM, Russell Bryant  wrote:

>
> On Thu, Jul 21, 2016 at 6:21 AM, Numan Siddique 
> wrote:
>
>> When python IDL calls the "notify" function after processing the "update2"
>> message from ovsdb-server, it is suppose to send the old values of the
>> updated columns as the last parameter. But the recent commit "897c8064"
>> sends the updated values. This breaks the behaviour.
>> This patch fixes this issue. It also updates the description of
>> the 'updates' param of the notify function to make it more clear.
>>
>> Fixes: 897c8064 ("python: move Python idl to work with monitor_cond")
>> Signed-off-by: Numan Siddique 
>>
>
> Is there a test case that could be updated or expanded to catch this issue?
>
>
>
​I dont think there is any. I will add a new one.

​


> --
> Russell Bryant
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] Backport Request: dpif-netdev: Remove PMD latency on seq_mutex

2016-07-25 Thread Daniele Di Proietto
Fair point, I guess this looks more like a bug fix than a new features.

After discussing offline with Ben and having another set of eyes on the changes 
I backported this to branch-2.5.

Thanks,

Daniele


On 25/07/2016 02:29, "Loftus, Ciara"  wrote:

>> 
>> Thanks Flavio for checking and Daniel for your consideration.
>> Indeed the issue exists in 2.5 branch.
>> 
>> We are treating this more in the bucket of a performance bug fix than a
>> feature.
>> 
>> Any specific testing that you would like to see run to help reduce
>> your concern related to changes to the core modules ?
>> 
>> Ciara, what's your opinion on these changes for a backport ?
>
>I'm of the same opinion as yourself and Flavio that this is more a fix than a 
>feature. I'd like to see it backported.
>But I understand there may be some risk associated with due to the nature of 
>the changes.
>
>Thanks,
>Ciara
>
>> 
>> Thanks
>> Vinod
>> 
>> 
>> 
>> -Original Message-
>> From: Daniele Di Proietto [mailto:diproiet...@vmware.com]
>> Sent: Friday, July 22, 2016 3:49 PM
>> To: Flavio Leitner ; Vinod, Chegu
>> 
>> Cc: kris...@redhat.com; ovs-dev ; Loftus, Ciara
>> 
>> Subject: Re: Backport Request: dpif-netdev: Remove PMD latency on
>> seq_mutex
>> 
>> I'm not sure I'm 100% comfortable back porting this to branch-2.5
>> 
>> I see the change more as a feature rather than a bugfix.
>> 
>> Also it touches some core modules (seq and rcu) in a non trivial way.
>> 
>> 
>> What do you guys think?
>> 
>> Thanks,
>> 
>> Daniele
>> 
>> On 22/07/2016 15:03, "Flavio Leitner"  wrote:
>> 
>> >(adding ovs-dev mailing list and more people interesting on the
>> >backport to CC)
>> >
>> >On Mon, Jul 18, 2016 at 05:31:52AM +, Vinod, Chegu wrote:
>> >> Hi Flavio, Karl,
>> >>
>> >> Is there a version of the following fix available that is compatible with 
>> >> OVS
>> 2.5?
>> >>
>> >>
>> https://github.com/openvswitch/ovs/commit/9dede5cff553d7c4e074f04c52
>> 5
>> >> c1417eb209363
>> >>
>> >> If yes can it backported to the 2.5 branch ?
>> >
>> >branch-2.5 is affected by the same issue.  I tested the patch from
>> >branch master (cherry-pick) and it solved the issue.
>> >
>> >Daniele,
>> >
>> >What do you think? If you agree, do you need me to post the backported
>> >patch or is it enough for you to cherry-pick?
>> >
>> >Thanks,
>> >--
>> >fbl
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 5/9] datapath-windows: Define new multicast conntrack events

2016-07-25 Thread Sairam Venugopal
I will update the current one and make a note to update VPORT usage as
well.

On 7/22/16, 5:59 PM, "Alin Serdean" 
wrote:

>It looks like a mistake was done when setting them up, don't know if it
>such a good idea to propagate it.
>
>Thanks,
>Alin.
>
>> -Mesaj original-
>> De la: Sairam Venugopal [mailto:vsai...@vmware.com]
>> Trimis: Friday, July 22, 2016 11:15 PM
>> Către: Alin Serdean ;
>> dev@openvswitch.org
>> Subiect: Re: [ovs-dev] [PATCH 5/9] datapath-windows: Define new
>>multicast
>> conntrack events
>> 
>> Yes, I wanted to keep it similar to the VPORT events:
>> 
>> enum {
>> OVS_EVENT_CONNECT   = ((uint32_t)0x1 << 0),
>> OVS_EVENT_DISCONNECT= ((uint32_t)0x1 << 1),
>> OVS_EVENT_LINK_UP   = ((uint32_t)0x1 << 2),
>> OVS_EVENT_LINK_DOWN = ((uint32_t)0x1 << 3),
>> OVS_EVENT_MAC_CHANGE= ((uint32_t)0x1 << 4),
>> OVS_EVENT_MTU_CHANGE= ((uint32_t)0x1 << 5),
>> OVS_EVENT_MASK_ALL  = 0x3f,
>> };
>> 
>> 
>> 
>> 
>> As you can see, we need to update these EVENT_FOO to
>> EVENT_VPORT_FOO.
>> 
>> 
>> On 7/22/16, 10:11 AM, "Alin Serdean" 
>> wrote:
>> 
>> >Looks good just one question inlined.
>> >
>> >
>> >
>> >> -Mesaj original-
>> >
>> >> De la: dev [mailto:dev-boun...@openvswitch.org] În numele Sairam
>> >
>> >> Venugopal
>> >
>> >> Trimis: Thursday, July 14, 2016 2:39 AM
>> >
>> >> Către: dev@openvswitch.org
>> >
>> >> Subiect: [ovs-dev] [PATCH 5/9] datapath-windows: Define new multicast
>> >
>> >> conntrack events
>> >
>> >>
>> >
>> >> 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 
>> >
>> >> ---
>> >
>> >>  datapath-windows/ovsext/Datapath.c   | 21 ++---
>> >
>> >>  datapath-windows/ovsext/Datapath.h   |  3 ++-
>> >
>> >>  datapath-windows/ovsext/DpInternal.h | 15 +++
>> >
>> >>  3 files changed, 35 insertions(+), 4 deletions(-)
>> >
>> >>
>> >
>> >
>> >
>> >> +enum {
>> >
>> >> +OVS_EVENT_CT_NEW= ((uint32_t)0x1 << 0),
>> >
>> >> +OVS_EVENT_CT_DELETE = ((uint32_t)0x1 << 1),
>> >
>> >> +OVS_EVENT_CT_MASK_ALL   = 0x3
>> >
>> >
>> >
>> >[Alin Gabriel Serdean: ] Any particular reason for not using: 1 << 0, 1
>> ><< 1, 1 << 2, etc?
>> >
>> >> +};
>> >
>> >> +
>> >
>> >> +/* Supported mcast event groups */
>> >
>> >> +enum OVS_MCAST_EVENT_ENTRIES {
>> >
>> >> +OVS_MCAST_VPORT_EVENT,
>> >
>> >> +OVS_MCAST_CT_EVENT,
>> >
>> >> +__OVS_MCAST_EVENT_ENTRIES_MAX
>> >
>> >> +};
>> >
>> >> +#define OVS_MCAST_EVENT_ENTRIES_MAX
>> >
>> >> (__OVS_MCAST_EVENT_ENTRIES_MAX -
>> >
>> >> +OVS_MCAST_VPORT_EVENT)
>> >
>> >>
>> >
>> >>  typedef struct _OVS_VPORT_EVENT_ENTRY {
>> >
>> >>  UINT32 portNo;
>> >
>> >> --
>> >
>> >> 2.9.0.windows.1
>> >
>> >>
>> >
>> >> ___
>> >
>> >> dev mailing list
>> >
>> >> dev@openvswitch.org
>> >
>> >>
>> >>https://urldefense.proofpoint.com/v2/url?u=http-
>> 3A__openvswitch.org_ma
>> >>ilm
>> >>an_listinfo_dev=CwIGaQ=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-
>> YihVMNtXt-uEs
>> >>=
>> >>Dcruz40PROJ40ROzSpxyQSLw6fcrOWpJgEcEmNR3JEQ=iSTxSaNGMjpm
>> 4rJ9g61SytrF
>> >>DZZ
>> UmN9pPUtTtra_Jio=C57tzRDXzgUTFoJQMs5YrgcOVl_5UQLicoBzRg2b7lI
>> =
>> >
>

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 2/3] rhel/ovsdb-server.service: Rename the nonetwork service

2016-07-25 Thread Aaron Conole
Currently, openvswitch.service calls out to start
openvswitch-nonetwork.service.  However, openvswitch-nonetwork.service
will be called ovsdb-server, so that it is a bit more reflective of
the dependencies.  This commit does make the file a bit of a misnomer as
currently the ovsdb-server SERVICE will start the ovs-vswitchd service
as well.  A future commit will clean this up, and change the ifup
configuration in the process.

Signed-off-by: Aaron Conole 
Reviewed-by: Markos Chandras 
Acked-by: Flavio Leitner 
---
v2:
* No change (added tags, only)

 rhel/automake.mk  |  2 +-
 rhel/etc_sysconfig_network-scripts_ifdown-ovs |  6 +++---
 rhel/etc_sysconfig_network-scripts_ifup-ovs   |  6 +++---
 rhel/openvswitch-fedora.spec.in   |  4 ++--
 rhel/usr_lib_systemd_system_openvswitch-nonetwork.service | 15 ---
 rhel/usr_lib_systemd_system_openvswitch.service   |  4 ++--
 rhel/usr_lib_systemd_system_ovsdb-server.service  | 15 +++
 7 files changed, 26 insertions(+), 26 deletions(-)
 delete mode 100644 rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
 create mode 100644 rhel/usr_lib_systemd_system_ovsdb-server.service

diff --git a/rhel/automake.mk b/rhel/automake.mk
index dc30715..7907a87 100644
--- a/rhel/automake.mk
+++ b/rhel/automake.mk
@@ -26,7 +26,7 @@ EXTRA_DIST += \
rhel/usr_share_openvswitch_scripts_sysconfig.template \
rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
rhel/usr_lib_systemd_system_openvswitch.service \
-   rhel/usr_lib_systemd_system_openvswitch-nonetwork.service \
+   rhel/usr_lib_systemd_system_ovsdb-server.service \
rhel/usr_lib_systemd_system_ovn-controller.service \
rhel/usr_lib_systemd_system_ovn-controller-vtep.service \
rhel/usr_lib_systemd_system_ovn-northd.service
diff --git a/rhel/etc_sysconfig_network-scripts_ifdown-ovs 
b/rhel/etc_sysconfig_network-scripts_ifdown-ovs
index 46b6ca5..dd98d23 100755
--- a/rhel/etc_sysconfig_network-scripts_ifdown-ovs
+++ b/rhel/etc_sysconfig_network-scripts_ifdown-ovs
@@ -34,10 +34,10 @@ if [ ! -x ${OTHERSCRIPT} ]; then
 OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth"
 fi
 
-SERVICE_UNIT=/usr/lib/systemd/system/openvswitch-nonetwork.service
+SERVICE_UNIT=/usr/lib/systemd/system/ovsdb-server.service
 if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
-   if ! systemctl --quiet is-active openvswitch-nonetwork.service; then
-   systemctl start openvswitch-nonetwork.service
+   if ! systemctl --quiet is-active ovsdb-server.service; then
+   systemctl start ovsdb-server.service
fi
 else
if [ ! -f /var/lock/subsys/openvswitch ]; then
diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs 
b/rhel/etc_sysconfig_network-scripts_ifup-ovs
index f3fc05e..eb58c3a 100755
--- a/rhel/etc_sysconfig_network-scripts_ifup-ovs
+++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs
@@ -60,10 +60,10 @@ fi
fi
 done
 
-SERVICE_UNIT=/usr/lib/systemd/system/openvswitch-nonetwork.service
+SERVICE_UNIT=/usr/lib/systemd/system/ovsdb-server.service
 if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
-   if ! systemctl --quiet is-active openvswitch-nonetwork.service; then
-   systemctl start openvswitch-nonetwork.service
+   if ! systemctl --quiet is-active ovsdb-server.service; then
+   systemctl start ovsdb-server.service
fi
 else
if [ ! -f /var/lock/subsys/openvswitch ]; then
diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in
index 088afcb..253d5bc 100644
--- a/rhel/openvswitch-fedora.spec.in
+++ b/rhel/openvswitch-fedora.spec.in
@@ -189,7 +189,7 @@ install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch
 install -p -D -m 0644 \
 rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/openvswitch
-for service in openvswitch openvswitch-nonetwork \
+for service in openvswitch ovsdb-server \
ovn-controller ovn-controller-vtep ovn-northd; do
install -p -D -m 0644 \
rhel/usr_lib_systemd_system_${service}.service \
@@ -416,7 +416,7 @@ fi
 %config(noreplace) %{_sysconfdir}/sysconfig/openvswitch
 %config(noreplace) %{_sysconfdir}/logrotate.d/openvswitch
 %{_unitdir}/openvswitch.service
-%{_unitdir}/openvswitch-nonetwork.service
+%{_unitdir}/ovsdb-server.service
 %{_datadir}/openvswitch/scripts/openvswitch.init
 %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
 %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
diff --git a/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service 
b/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
deleted file mode 100644
index e4c2a66..000
--- a/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
+++ 

[ovs-dev] [PATCH v2 0/3] redhat: Improve the systemd integration

2016-07-25 Thread Aaron Conole
These patches make adjustments to the way systemd is done so that we have:

* one daemon started per service
* services which correspond to actual daemon names
* a single 'dummy' service to start all at once
* some convenient information to poll from systemd.

These have been tested on Fedora 23 and RHEL-7.

v2:
 * Cleanup ovs-lib.in to be consistent with other tests for Xno
 * Cleanup cleanup the rhel ovsdb-server service to not reference the
   vswitchd

Aaron Conole (3):
  utilities/ovs-ctl.in: Allow non-monitoring daemons
  rhel/ovsdb-server.service: Rename the nonetwork service
  Red Hat Systemd Integration

 rhel/automake.mk   |  3 ++-
 rhel/etc_sysconfig_network-scripts_ifdown-ovs  |  6 +++---
 rhel/etc_sysconfig_network-scripts_ifup-ovs|  6 +++---
 rhel/openvswitch-fedora.spec.in|  5 +++--
 ...sr_lib_systemd_system_openvswitch-nonetwork.service | 15 ---
 rhel/usr_lib_systemd_system_openvswitch.service|  6 --
 rhel/usr_lib_systemd_system_ovs-vswitchd.service   | 18 ++
 rhel/usr_lib_systemd_system_ovsdb-server.service   | 17 +
 utilities/ovs-ctl.8|  5 +
 utilities/ovs-ctl.in   |  1 +
 utilities/ovs-lib.in   |  3 ++-
 11 files changed, 58 insertions(+), 27 deletions(-)
 delete mode 100644 rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
 create mode 100644 rhel/usr_lib_systemd_system_ovs-vswitchd.service
 create mode 100644 rhel/usr_lib_systemd_system_ovsdb-server.service

-- 
2.5.5

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 1/3] utilities/ovs-ctl.in: Allow non-monitoring daemons

2016-07-25 Thread Aaron Conole
This commit allows the ovs-ctl command to spawn daemons without the
internal process monitor.  This is useful when integrating with,
ex. systemd, which provides its own monitoring facilities.

Signed-off-by: Aaron Conole 
Reviewed-by: Markos Chandras 
Acked-by: Ben Pfaff 
Acked-by: Flavio Fernandes 
Acked-by: Flavio Leitner 
---
v2:
* Quotes removed from the test for Xno

 utilities/ovs-ctl.8  | 5 +
 utilities/ovs-ctl.in | 1 +
 utilities/ovs-lib.in | 3 ++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8
index 662b83e..6b8fba7 100644
--- a/utilities/ovs-ctl.8
+++ b/utilities/ovs-ctl.8
@@ -162,6 +162,11 @@ after reboot, but other ports need to be persisted in the 
database.
 .PP
 The following options are less important:
 .
+.IP "\fB\-\-no\-monitor\fR"
+By default \fBovs\-ctl\fR passes \fB\-\-monitor\fR to \fBovs\-vswitchd\fR and
+\fBovsdb\-server\fR, requesting that it spawn a process monitor which will
+restart the daemon if it crashes.  This option suppresses that behavior.
+.
 .IP "\fB\-\-daemon-cwd=\fIdirectory\fR"
 Specifies the current working directory that the OVS daemons should
 run from.  The default is \fB/\fR (the root directory) if this option
diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index 8ec825b..d92cf3c 100755
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -499,6 +499,7 @@ set_defaults () {
 FORCE_COREFILES=yes
 MLOCKALL=yes
 SELF_CONFINEMENT=yes
+MONITOR=yes
 OVSDB_SERVER=yes
 OVS_VSWITCHD=yes
 OVSDB_SERVER_PRIORITY=-10
diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
index 7fcd734..cbad85a 100644
--- a/utilities/ovs-lib.in
+++ b/utilities/ovs-lib.in
@@ -167,7 +167,8 @@ start_daemon () {
 # pidfile and monitoring
 test -d "$rundir" || install -d -m 755 -o root -g root "$rundir"
 set "$@" --pidfile="$rundir/$daemon.pid"
-set "$@" --detach --monitor
+set "$@" --detach
+test X"$MONITOR" = Xno || set "$@" --monitor
 
 # wrapper
 case $wrapper in
-- 
2.5.5

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 3/3] rhel: Improved Systemd Integration

2016-07-25 Thread Aaron Conole
This commit builds upon some of the recent ovs-ctl changes to build a
more integrated systemd setup.  A new service (ovs-vswitchd) is
added to track the ovs-vswitchd, and ovsdb-server service is reserved
for the ovsdb-server daemon.  The systemd scripts still use ovs-ctl to
actually initialize the daemons.

Signed-off-by: Aaron Conole 
Reviewed-by: Markos Chandras 
---
v2:
 * Removed reference to ovs-vswitchd service from ovsdb-server service

 rhel/automake.mk |  1 +
 rhel/etc_sysconfig_network-scripts_ifup-ovs  |  6 +++---
 rhel/openvswitch-fedora.spec.in  |  3 ++-
 rhel/usr_lib_systemd_system_openvswitch.service  |  6 --
 rhel/usr_lib_systemd_system_ovs-vswitchd.service | 18 ++
 rhel/usr_lib_systemd_system_ovsdb-server.service | 16 +---
 6 files changed, 37 insertions(+), 13 deletions(-)
 create mode 100644 rhel/usr_lib_systemd_system_ovs-vswitchd.service

diff --git a/rhel/automake.mk b/rhel/automake.mk
index 7907a87..a3c180c 100644
--- a/rhel/automake.mk
+++ b/rhel/automake.mk
@@ -27,6 +27,7 @@ EXTRA_DIST += \
rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
rhel/usr_lib_systemd_system_openvswitch.service \
rhel/usr_lib_systemd_system_ovsdb-server.service \
+   rhel/usr_lib_systemd_system_ovs-vswitchd.service \
rhel/usr_lib_systemd_system_ovn-controller.service \
rhel/usr_lib_systemd_system_ovn-controller-vtep.service \
rhel/usr_lib_systemd_system_ovn-northd.service
diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs 
b/rhel/etc_sysconfig_network-scripts_ifup-ovs
index eb58c3a..6f1c891 100755
--- a/rhel/etc_sysconfig_network-scripts_ifup-ovs
+++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs
@@ -60,10 +60,10 @@ fi
fi
 done
 
-SERVICE_UNIT=/usr/lib/systemd/system/ovsdb-server.service
+SERVICE_UNIT=/usr/lib/systemd/system/openvswitch.service
 if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
-   if ! systemctl --quiet is-active ovsdb-server.service; then
-   systemctl start ovsdb-server.service
+   if ! systemctl --quiet is-active openvswitch.service; then
+   systemctl start openvswitch.service
fi
 else
if [ ! -f /var/lock/subsys/openvswitch ]; then
diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in
index 253d5bc..b1f07e7 100644
--- a/rhel/openvswitch-fedora.spec.in
+++ b/rhel/openvswitch-fedora.spec.in
@@ -189,7 +189,7 @@ install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch
 install -p -D -m 0644 \
 rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/openvswitch
-for service in openvswitch ovsdb-server \
+for service in openvswitch ovsdb-server ovs-vswitchd \
ovn-controller ovn-controller-vtep ovn-northd; do
install -p -D -m 0644 \
rhel/usr_lib_systemd_system_${service}.service \
@@ -417,6 +417,7 @@ fi
 %config(noreplace) %{_sysconfdir}/logrotate.d/openvswitch
 %{_unitdir}/openvswitch.service
 %{_unitdir}/ovsdb-server.service
+%{_unitdir}/ovs-vswitchd.service
 %{_datadir}/openvswitch/scripts/openvswitch.init
 %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
 %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
diff --git a/rhel/usr_lib_systemd_system_openvswitch.service 
b/rhel/usr_lib_systemd_system_openvswitch.service
index 96c697b..a44574b 100644
--- a/rhel/usr_lib_systemd_system_openvswitch.service
+++ b/rhel/usr_lib_systemd_system_openvswitch.service
@@ -1,11 +1,13 @@
 [Unit]
 Description=Open vSwitch
-After=syslog.target network.target ovsdb-server.service
-Requires=ovsdb-server.service
+PartOf=network.target
+BindsTo=ovsdb-server.service
+BindsTo=ovs-vswitchd.service
 
 [Service]
 Type=oneshot
 ExecStart=/bin/true
+ExecReload=/bin/true
 ExecStop=/bin/true
 RemainAfterExit=yes
 
diff --git a/rhel/usr_lib_systemd_system_ovs-vswitchd.service 
b/rhel/usr_lib_systemd_system_ovs-vswitchd.service
new file mode 100644
index 000..d3d020a
--- /dev/null
+++ b/rhel/usr_lib_systemd_system_ovs-vswitchd.service
@@ -0,0 +1,18 @@
+[Unit]
+Description=Open vSwitch Forwarding Unit
+After=ovsdb-server.service
+Requires=ovsdb-server.service
+ReloadPropagatedFrom=ovsdb-server.service
+AssertPathIsReadWrite=/var/run/openvswitch/db.sock
+PartOf=openvswitch.service
+
+[Service]
+Type=forking
+EnvironmentFile=-/etc/sysconfig/openvswitch
+ExecStart=/usr/share/openvswitch/scripts/ovs-ctl \
+  --no-ovsdb-server --no-monitor --system-id=random \
+  start $OPTIONS
+ExecStop=/usr/share/openvswitch/scripts/ovs-ctl --no-ovsdb-server stop
+ExecReload=/usr/share/openvswitch/scripts/ovs-ctl --no-ovsdb-server \
+  --no-monitor --system-id=random \
+  restart $OPTIONS
diff --git a/rhel/usr_lib_systemd_system_ovsdb-server.service 
b/rhel/usr_lib_systemd_system_ovsdb-server.service
index 

Re: [ovs-dev] [RFC 4/5] dpctl: uses open_type when calling netdev_open

2016-07-25 Thread Daniele Di Proietto
2016-07-25 9:57 GMT-07:00 Thadeu Lima de Souza Cascardo :

> On Fri, Jul 22, 2016 at 02:49:39PM -0700, Daniele Di Proietto wrote:
> > I would prefer if dpctl kept using the datapath types.  The translation
> > from database types to datapath type should happen in ofproto, dpctl is
> > supposed to be used to interact with the datapath directly.
> >
> > What do you guys think?
> >
> > The rest of the series looks good to me as well.
> >
> > Thanks,
> >
> > Daniele
> >
>
>
Hi Cascardo,

Thanks for the detailed analysis.  The problem is that there are three
types:

a) the database type
b) the port type in dpif-netdev
c) the netdev type

I was assuming that b and c are always equal, but they're not.  The only
case
when they're not equal is the "ovs-netdev" (or "ovs-dummy") port.

I think we can easily remove this case and make b and c always equal
with the following changes:

---8<---
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 787851d..effa7e0 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -941,7 +941,9 @@ create_dp_netdev(const char *name, const struct
dpif_class *class,
 ovs_mutex_lock(>port_mutex);
 dp_netdev_set_nonpmd(dp);

-error = do_add_port(dp, name, "internal", ODPP_LOCAL);
+error = do_add_port(dp, name, dpif_netdev_port_open_type(dp->class,
+ "internal"),
+ODPP_LOCAL);
 ovs_mutex_unlock(>port_mutex);
 if (error) {
 dp_netdev_free(dp);
@@ -1129,7 +1131,7 @@ hash_port_no(odp_port_t port_no)
 }

 static int
-port_create(const char *devname, const char *open_type, const char *type,
+port_create(const char *devname, const char *type,
 odp_port_t port_no, struct dp_netdev_port **portp)
 {
 struct netdev_saved_flags *sf;
@@ -1142,7 +1144,7 @@ port_create(const char *devname, const char
*open_type, const char *type,
 *portp = NULL;

 /* Open and validate network device. */
-error = netdev_open(devname, open_type, );
+error = netdev_open(devname, type, );
 if (error) {
 return error;
 }
@@ -1233,8 +1235,7 @@ do_add_port(struct dp_netdev *dp, const char
*devname, const char *type,
 return EEXIST;
 }

-error = port_create(devname, dpif_netdev_port_open_type(dp->class,
type),
-type, port_no, );
+error = port_create(devname, type, port_no, );
 if (error) {
 return error;
 }
root@diproiettod-dev:~/ovs# git diff
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 787851d..effa7e0 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -941,7 +941,9 @@ create_dp_netdev(const char *name, const struct
dpif_class *class,
 ovs_mutex_lock(>port_mutex);
 dp_netdev_set_nonpmd(dp);

-error = do_add_port(dp, name, "internal", ODPP_LOCAL);
+error = do_add_port(dp, name, dpif_netdev_port_open_type(dp->class,
+ "internal"),
+ODPP_LOCAL);
 ovs_mutex_unlock(>port_mutex);
 if (error) {
 dp_netdev_free(dp);
@@ -1129,7 +1131,7 @@ hash_port_no(odp_port_t port_no)
 }

 static int
-port_create(const char *devname, const char *open_type, const char *type,
+port_create(const char *devname, const char *type,
 odp_port_t port_no, struct dp_netdev_port **portp)
 {
 struct netdev_saved_flags *sf;
@@ -1142,7 +1144,7 @@ port_create(const char *devname, const char
*open_type, const char *type,
 *portp = NULL;

 /* Open and validate network device. */
-error = netdev_open(devname, open_type, );
+error = netdev_open(devname, type, );
 if (error) {
 return error;
 }
@@ -1233,8 +1235,7 @@ do_add_port(struct dp_netdev *dp, const char
*devname, const char *type,
 return EEXIST;
 }

-error = port_create(devname, dpif_netdev_port_open_type(dp->class,
type),
-type, port_no, );
+error = port_create(devname, type, port_no, );
 if (error) {
 return error;
 }
---8<---

With this incremental case 2 is covered, dpctl/show always shows the
datapath type.
(The incremental also requires some testsuite changes)

For case 1 and 3 is just a matter of deciding if we want to support database
types (in addition to netdev) in dpctl.  I would lean towards no: I find it
confusing
that both types are acceptable.

That said, I feel like I'm nitpicking, dpctl is a tool used for debugging
and I think
we should do whatever comes easier.

Thanks,

Daniele

Hi, Daniele.
>
> Thanks for the comment.
>
> The best example that breaks currently is the internal type on the netdev
> datapath.
>
> There are three scenarios in dpctl, and two of them are changed with this
> patch.
>
> 1) The user input type, given for add-if. In this particular case, the code
> would try to use the "internal" type, but thinks would break as the Linux
> internal type would not work for the netdev datapath. The 

[ovs-dev] [PATCH v5] JSON serialization via Python's json lib

2016-07-25 Thread Terry Wilson
There is no particularly good reason to use our own Python JSON
serialization implementation when serialization can be done faster
with Python's built-in JSON library.

A few tests were changed due to Python's default JSON library
returning slightly more precise floating point numbers.

Signed-off-by: Terry Wilson 
---
 configure.ac   |   2 +
 m4/openvswitch.m4  |  47 
 python/automake.mk |  27 +-
 python/ovs/json.py | 106 +
 tests/json.at  |  26 ++---
 5 files changed, 104 insertions(+), 104 deletions(-)

diff --git a/configure.ac b/configure.ac
index 05d80d5..5472a52 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,6 +96,8 @@ OVS_CHECK_LIBCAPNG
 OVS_CHECK_LOGDIR
 OVS_CHECK_PYTHON
 OVS_CHECK_PYTHON3
+OVS_CHECK_PYTHON_HEADERS
+OVS_CHECK_PYTHON3_HEADERS
 OVS_CHECK_FLAKE8
 OVS_CHECK_DOT
 OVS_CHECK_IF_PACKET
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index a448223..60ae114 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -589,3 +589,50 @@ AC_DEFUN([OVS_CHECK_PRAGMA_MESSAGE],
  [AC_DEFINE(HAVE_PRAGMA_MESSAGE,1,[Define if compiler supports #pragma
  message directive])])
   ])
+
+dnl OVS_CHECK_PYTHON_HEADERS
+AC_DEFUN([OVS_CHECK_PYTHON_HEADERS],
+  [AC_REQUIRE([OVS_CHECK_PYTHON])
+AC_PATH_PROG([PYTHON_CONFIG], python-config, no)
+if test "$PYTHON_CONFIG" != no; then
+  PYTHON_INCLUDES=`$PYTHON_CONFIG --includes`
+  PYTHON_LIBS=`$PYTHON_CONFIG --libs`
+  PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
+  save_LIBS="$LIBS"
+  save_CPPFLAGS="$CPPFLAGS"
+  save_LDFLAGS="$LDFLAGS"
+  LIBS="$PYTHON_LIBS"
+  LDFLAGS="$PYTHON_LDFLAGS"
+  CPPFLAGS="$PYTHON_INCLUDES"
+  AC_LINK_IFELSE(
+[AC_LANG_PROGRAM([#include ],[])],
+ [have_py_headers=true])
+  LIBS="$save_LIBS"
+  CPPFLAGS="$save_CPPFLAGS"
+  LDFLAGS="$save_LDFLAGS"
+fi
+   AM_CONDITIONAL([HAVE_PYTHON_HEADERS], [test "$have_py_headers" = "true"])])
+  ])
+
+AC_DEFUN([OVS_CHECK_PYTHON3_HEADERS],
+  [AC_REQUIRE([OVS_CHECK_PYTHON3])
+AC_PATH_PROG([PYTHON3_CONFIG], python3-config, no)
+if test "$PYTHON3_CONFIG" != no; then
+  PYTHON3_INCLUDES=`$PYTHON3_CONFIG --includes`
+  PYTHON3_LIBS=`$PYTHON3_CONFIG --libs`
+  PYTHON3_LDFLAGS=`$PYTHON3_CONFIG --ldflags`
+  save_LIBS="$LIBS"
+  save_CPPFLAGS="$CPPFLAGS"
+  save_LDFLAGS="$LDFLAGS"
+  LIBS="$PYTHON3_LIBS"
+  LDFLAGS="$PYTHON3_LDFLAGS"
+  CPPFLAGS="$PYTHON3_INCLUDES"
+  AC_LINK_IFELSE(
+[AC_LANG_PROGRAM([#include ],[])],
+ [have_py3_headers=true])
+  LIBS="$save_LIBS"
+  CPPFLAGS="$save_CPPFLAGS"
+  LDFLAGS="$save_LDFLAGS"
+fi
+   AM_CONDITIONAL([HAVE_PYTHON3_HEADERS], [test "$have_py3_headers" = 
"true"])])
+  ])
diff --git a/python/automake.mk b/python/automake.mk
index ecad39d..874a178 100644
--- a/python/automake.mk
+++ b/python/automake.mk
@@ -79,10 +79,10 @@ ovs-install-data-local:
rm python/ovs/dirs.py.tmp
 
 python-sdist: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) python/ovs/dirs.py
-   (cd python/ && $(PYTHON) setup.py sdist)
+   cd $(srcdir)/python/ && $(PYTHON) setup.py sdist
 
 pypi-upload: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) python/ovs/dirs.py
-   (cd python/ && $(PYTHON) setup.py sdist upload)
+   cd $(srcdir)/python/ && $(PYTHON) setup.py sdist upload
 else
 ovs-install-data-local:
@:
@@ -112,3 +112,26 @@ $(srcdir)/python/ovs/dirs.py: python/ovs/dirs.py.template
< $? > $@.tmp && \
mv $@.tmp $@
 EXTRA_DIST += python/ovs/dirs.py.template
+
+.PHONY : clean_python_extensions
+clean_python_extensions:
+   cd $(srcdir)/python/ && rm -f ovs/*.so
+
+SETUPPY_CFLAGS = -I$(abs_top_srcdir)/include -I$(abs_top_builddir)/include
+if HAVE_PYTHON_HEADERS
+$(srcdir)/python/ovs/_json.so: lib/libopenvswitch.la
+   cd $(srcdir)/python/ && CFLAGS="$(SETUPPY_CFLAGS)" $(PYTHON) setup.py 
build_ext --inplace
+
+ALL_LOCAL += $(srcdir)/python/ovs/_json.so
+endif
+
+if HAVE_PYTHON3_HEADERS
+PY3_EXT_NAME=$(srcdir)/python/ovs/_json$(shell $(PYTHON3) -c \
+"from distutils import 
sysconfig;print(sysconfig.get_config_var('EXT_SUFFIX'))")
+$(PY3_EXT_NAME): lib/libopenvswitch.la
+   cd $(srcdir)/python/ && CFLAGS="$(SETUPPY_CFLAGS)" $(PYTHON3) setup.py 
build_ext --inplace
+
+ALL_LOCAL += $(PY3_EXT_NAME)
+endif
+
+CLEAN_LOCAL += clean_python_extensions
diff --git a/python/ovs/json.py b/python/ovs/json.py
index ea0400a..ddf5dd2 100644
--- a/python/ovs/json.py
+++ b/python/ovs/json.py
@@ -12,11 +12,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import absolute_import
+import functools
+import json
 import re
 import sys
 
 import six
-from six.moves import range
 
 try:
 import ovs._json
@@ -25,112 +27,24 @@ except 

[ovs-dev] [PATCH] JSON serialization via Python's json lib

2016-07-25 Thread Terry Wilson
I noticed that with the previous patch, in testing 'make install'
with patch to move json.h, I had forgotten to remove the installed
headers. Removing the installed headers revealed that this patch
still didn't build properly from a separate build directory. This
time it *should* work.

Terry Wilson (1):
  JSON serialization via Python's json lib

 configure.ac   |   2 +
 m4/openvswitch.m4  |  47 
 python/automake.mk |  27 +-
 python/ovs/json.py | 106 +
 tests/json.at  |  26 ++---
 5 files changed, 104 insertions(+), 104 deletions(-)

-- 
1.8.3.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [RFC 0/5] netdev_open conflicting types

2016-07-25 Thread Thadeu Lima de Souza Cascardo
On Fri, Jul 22, 2016 at 01:10:33PM -0700, Ben Pfaff wrote:
> On Mon, Jul 18, 2016 at 02:00:20PM -0300, Thadeu Lima de Souza Cascardo wrote:
> > This series is a proposal to fix some users of netdev_open and
> > introduce a new behavior for netdev_open when called with a different
> > type than the one already opened.
> 
> These seem fine to me.  If you post them with signoffs I'll apply them.

Pending Daniele's comment on my proposal for patch 4, I will send them with
sign-offs.

This doesn't fix some scenarios involving the routing table, but it
significantly improves the situation.

Without the series, some successful netdev_open will cause trouble where the
user should have been alerted of the conflict.

I sent a small series yesterday fixing some of the routing table code, and there
are yet some other scenarios to fix, which I am working on. But I now have some
confidence that this series should go in.

However, some of the decisions I made could be made differently. That's one
reason not to document it as a design decision just yet. But I don't think now
those decisions reflect entire new behavior on the code. Real bugs seem to
improve (though not completely fixed) by this.

One example I have is when we add a new port with the same name as an existing
system interface, but with a type that is not system. With the routing table bug
fixed, there will be an open netdev with type system, and as netdev_open will
still succeed, there will be some trouble which I am still investigating, which
involves a NEWLINK in rtnetlink making bridge_reconfigure to be called again,
causing OVS to consume a lot of CPU.

With this series applied, instead, netdev_open will fail and that's it. The user
will see the failure in the database as "File exists". When the system device is
removed, there will be a race and the device might not be added as it should,
but that's something else I may work on after I fix some other edges.

Thanks.
Cascardo.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] releasing 2.6: branch Aug 1, release Sep 15

2016-07-25 Thread Daniele Di Proietto





On 25/07/2016 09:16, "Ben Pfaff"  wrote:

>On Mon, Jul 25, 2016 at 03:44:01PM +, Gray, Mark D wrote:
>> 
>> 
>> > -Original Message-
>> > From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Ben Pfaff
>> > Sent: Saturday, July 23, 2016 5:00 PM
>> > To: dev@openvswitch.org
>> > Subject: [ovs-dev] releasing 2.6: branch Aug 1, release Sep 15
>> > 
>> > The proposed Open vSwitch release schedule calls for branching 2.6 from
>> > master on Aug. 1, followed by a period of bug fixes and stabilization, with
>> > release on Sep. 15.  The proposed release schedule is posted here for
>> > review:
>> > https://patchwork.ozlabs.org/patch/650319/
>> > 
>> > I don't yet know of a reason to modify this schedule.
>> > 
>> > If you know of reasons to change it, now is an appropriate time to bring 
>> > it up
>> > for discussion.  In addition, if you have features planned for 2.6 that 
>> > risk
>> > hitting master somewhat late for the branch, it is also a good time to 
>> > bring
>> > these up for discussion, so that we can plan to backport them to the branch
>> > early on, or to delay the branch by a few days.
>> 
>> DPDK 16.07 should be released by early next week. Ciara has a patch to
>> enable it, could this be backported to the branch?
>
>I think that Daniele and Pravin should weigh in on that since they
>understand DPDK and its relationship to OVS much better.

I think we should use DPDK 16.07 for branch-2.6.  I hope to merge the patch
before we branch, otherwise we can always backport it.

Thanks,

Daniele
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [RFC 4/5] dpctl: uses open_type when calling netdev_open

2016-07-25 Thread Thadeu Lima de Souza Cascardo
On Fri, Jul 22, 2016 at 02:49:39PM -0700, Daniele Di Proietto wrote:
> I would prefer if dpctl kept using the datapath types.  The translation
> from database types to datapath type should happen in ofproto, dpctl is
> supposed to be used to interact with the datapath directly.
> 
> What do you guys think?
> 
> The rest of the series looks good to me as well.
> 
> Thanks,
> 
> Daniele
> 

Hi, Daniele.

Thanks for the comment.

The best example that breaks currently is the internal type on the netdev
datapath.

There are three scenarios in dpctl, and two of them are changed with this patch.

1) The user input type, given for add-if. In this particular case, the code
would try to use the "internal" type, but thinks would break as the Linux
internal type would not work for the netdev datapath. The user was expected to
use "tap" instead. We the patch applied, either way should work. So we are not
breaking behavior.

2) When the type is output to the user. The current patch does not change its
behavior, which basically prints what we get from dpif_port_query. However,
dpif-netdev uses a cache of the database type and returns that, not the netdev
type. That could be changed, but then the output to the user would be the real
dpif. Would that be acceptable? It could break scripts out there which look for
internal. Or would dpctl do the reverse mapping? That would require some new
code on the dpif level.

3) Using the dpif_port.type in netdev_open. We could use the same alternative
solution here as proposed for scenario 2. Make dpif_port_query return the real
netdev type. This would require the new reverse mapping in order to be used also
at the ofproto level, so ofproto_port_query uses the database type.

I have a patch that changes dpif-netdev to return the netdev open type. However,
as it broke dpctl output, I decided to provice this current patch instead, as I
realized a lot more would be needed on other code, and we risked breaking a lot
of behavior.

I would keep this patch as is in the series, as it keeps behavior, and improves
the case in add-if, without breaking it; and leave the dpif_port_query fix and
reverse mapping to another day.

What do you think?

Regards.
Cascardo.


> 2016-07-18 10:00 GMT-07:00 Thadeu Lima de Souza Cascardo <
> casca...@redhat.com>:
> 
> > dpctl uses a user or database defined type when calling netdev_open.
> > Instead, it
> > should use the type from dpif_port_open_type. Otherwise, when using the
> > internal
> > type, it could open it with that type instead of the correct one, which
> > would be
> > tap or dummy.
> > ---
> >  lib/dpctl.c | 17 -
> >  1 file changed, 12 insertions(+), 5 deletions(-)
> >
> > diff --git a/lib/dpctl.c b/lib/dpctl.c
> > index 003602a..f896161 100644
> > --- a/lib/dpctl.c
> > +++ b/lib/dpctl.c
> > @@ -274,7 +274,8 @@ dpctl_add_if(int argc OVS_UNUSED, const char *argv[],
> >  }
> >  }
> >
> > -error = netdev_open(name, type, );
> > +error = netdev_open(name, dpif_port_open_type(dpif_type(dpif),
> > type),
> > +);
> >  if (error) {
> >  dpctl_error(dpctl_p, error, "%s: failed to open network
> > device",
> >  name);
> > @@ -356,7 +357,8 @@ dpctl_set_if(int argc, const char *argv[], struct
> > dpctl_params *dpctl_p)
> >  dpif_port_destroy(_port);
> >
> >  /* Retrieve its existing configuration. */
> > -error = netdev_open(name, type, );
> > +error = netdev_open(name, dpif_port_open_type(dpif_type(dpif),
> > type),
> > +);
> >  if (error) {
> >  dpctl_error(dpctl_p, error, "%s: failed to open network
> > device",
> >  name);
> > @@ -558,10 +560,13 @@ show_dpif(struct dpif *dpif, struct dpctl_params
> > *dpctl_p)
> >  qsort(port_nos, n_port_nos, sizeof *port_nos, compare_port_nos);
> >
> >  for (int i = 0; i < n_port_nos; i++) {
> > +const char *type;
> >  if (dpif_port_query_by_number(dpif, port_nos[i], _port)) {
> >  continue;
> >  }
> >
> > +type = dpif_port_open_type(dpif_type(dpif), dpif_port.type);
> > +
> >  dpctl_print(dpctl_p, "\tport %u: %s",
> >  dpif_port.port_no, dpif_port.name);
> >
> > @@ -570,7 +575,7 @@ show_dpif(struct dpif *dpif, struct dpctl_params
> > *dpctl_p)
> >
> >  dpctl_print(dpctl_p, " (%s", dpif_port.type);
> >
> > -error = netdev_open(dpif_port.name, dpif_port.type, );
> > +error = netdev_open(dpif_port.name, type, );
> >  if (!error) {
> >  struct smap config;
> >
> > @@ -603,7 +608,7 @@ show_dpif(struct dpif *dpif, struct dpctl_params
> > *dpctl_p)
> >  struct netdev_stats s;
> >  int error;
> >
> > -error = netdev_open(dpif_port.name, dpif_port.type, );
> > +error = netdev_open(dpif_port.name, type, );
> >  

Re: [ovs-dev] [PATCH v4 1/4] Add support for 802.1ad (QinQ tunneling)

2016-07-25 Thread Ben Pfaff
On Tue, Jul 12, 2016 at 11:38:54PM +0800, Xiao Liang wrote:
> Flow key handleing changes:
> - Add VLAN header array in struct flow, to record multiple 802.1q VLAN
>   headers.
> - Add dpif multi-VLAN capability probing. If datapath supports multi-VLAN,
>   increase the maximum depth of nested OVS_KEY_ATTR_ENCAP.
> 
> Refacter VLAN handling in dpif-xlate:
> - Introduce 'xvlan' to track VLAN stack during flow processing.
> - Input and output VLAN translation according to the xbundle type.
> 
> Push VLAN action support:
> - Allow ethertype 0x88a8 in VLAN headers and push_vlan action.
> - Support push_vlan on dot1q packets.
> 
> Add new port VLAN mode "dot1q-tunnel":
> - Example:
> ovs-vsctl set Port p1 vlan_mode=dot1q-tunnel tag=100
>   Pushes another VLAN 100 header on packets (tagged and untagged) on ingress,
>   and pops it on egress.
> - Customer VLAN check:
> ovs-vsctl set Port p1 vlan_mode=dot1q-tunnel tag=100 cvlans=10,20
>   Only customer VLAN of 10 and 20 are allowed.
> 
> Signed-off-by: Xiao Liang 

The following incremental fixes some warnings from "sparse".  The one
from odp-util.c seems petty, but the others correct real conceptual
errors even if they would not be bugs in practice.

diff --git a/lib/odp-util.c b/lib/odp-util.c
index 46ff6de..56a6145 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -5047,7 +5047,7 @@ parse_8021q_onward(const struct nlattr 
*attrs[OVS_KEY_ATTR_MAX + 1],
 
 while (encaps < FLOW_MAX_VLAN_HEADERS &&
(is_mask?
-(src_flow->vlan[encaps].tci & htons(VLAN_CFI)) :
+(src_flow->vlan[encaps].tci & htons(VLAN_CFI)) != 0 :
 eth_type_vlan(flow->dl_type))) {
 /* Calculate fitness of outer attributes. */
 encap  = (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_ENCAP)
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index c4b656e..7184184 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -1666,7 +1666,7 @@ static void
 format_PUSH_VLAN(const struct ofpact_push_vlan *push_vlan, struct ds *s)
 {
 ds_put_format(s, "%spush_vlan:%s%#"PRIx16,
-  colors.param, colors.end, htons(push_vlan->ethertype));
+  colors.param, colors.end, ntohs(push_vlan->ethertype));
 }
 
 /* Action structure for OFPAT10_SET_DL_SRC/DST and OFPAT11_SET_DL_SRC/DST. */
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index fd41ac8..90cf74a 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1920,7 +1920,7 @@ xvlan_extract(const struct flow *flow, struct xvlan 
*xvlan)
 !(flow->vlan[i].tci & htons(VLAN_CFI))) {
 break;
 }
-xvlan[i].tpid = htons(flow->vlan[i].tpid);
+xvlan[i].tpid = ntohs(flow->vlan[i].tpid);
 xvlan[i].vid = vlan_tci_to_vid(flow->vlan[i].tci);
 xvlan[i].pcp = flow->vlan[i].tci & htons(VLAN_PCP_MASK);
 }
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] python: Send old values of the updated cols in notify for update2

2016-07-25 Thread Russell Bryant
On Thu, Jul 21, 2016 at 6:21 AM, Numan Siddique  wrote:

> When python IDL calls the "notify" function after processing the "update2"
> message from ovsdb-server, it is suppose to send the old values of the
> updated columns as the last parameter. But the recent commit "897c8064"
> sends the updated values. This breaks the behaviour.
> This patch fixes this issue. It also updates the description of
> the 'updates' param of the notify function to make it more clear.
>
> Fixes: 897c8064 ("python: move Python idl to work with monitor_cond")
> Signed-off-by: Numan Siddique 
>

Is there a test case that could be updated or expanded to catch this issue?


-- 
Russell Bryant
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] rhel: Fix ifup-ovs to delete bonds first.

2016-07-25 Thread Flavio Leitner
On Mon, Jul 25, 2016 at 01:08:01PM -0300, Flavio Leitner wrote:
> When ifdown isn't executed (system didn't shut down properly),
> bond interfaces remain in the openvswitch's database.  In that
> case, an inconsitency is left behind when the ifcfg was modified
> because ovs-vsctl won't do anything to update existing bond's
> configuration in the database.
> 
> The ifup/ifdown will operate only on configured interfaces, so
> this patch fixes the issue by deleting the bond from the database
> before attempt to configure it with fresh configuration.
> 
> Signed-off-by: Flavio Leitner 

Please drop this one.  I am working on a v2 fixing other interface
types as well.

fbl



___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH ovn-controller] Physical: persist tunnels

2016-07-25 Thread Ryan Moats
While commit ab39371d68842b7e4000cc5d8718e6fc04e92795
(ovn-controller: Handle physical changes correctly) addressed
unit test failures, it did so at the cost of performance: [1]
notes that ovn-controller cpu usage is now pegged at 100%.

Root cause of this is that while the storage for tunnels is
persisted, their creation is not (which the above changed
incorrectly assumed was the case).  This patch persists
tunneled data across invocations of physical_run.  A side
effect is that renaming of localfvif_map_changed variable
to physical_map_changed and extending its scope to include
tunnel changes.

[1] http://openvswitch.org/pipermail/dev/2016-July/076058.html

Signed-off-by: Ryan Moats 
---
 ovn/controller/physical.c | 59 +--
 1 file changed, 37 insertions(+), 22 deletions(-)

diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c
index a104e33..e788fe5 100644
--- a/ovn/controller/physical.c
+++ b/ovn/controller/physical.c
@@ -605,8 +605,13 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id 
mff_ovn_geneve,
 uuid_generate(hc_uuid);
 }
 
+/* This bool tracks physical mapping changes. */
+bool physical_map_changed = false;
+
 struct simap new_localvif_to_ofport =
 SIMAP_INITIALIZER(_localvif_to_ofport);
+struct simap new_tunnel_to_ofport = 
+SIMAP_INITIALIZER(_tunnel_to_ofport);
 for (int i = 0; i < br_int->n_ports; i++) {
 const struct ovsrec_port *port_rec = br_int->ports[i];
 if (!strcmp(port_rec->name, br_int->name)) {
@@ -668,18 +673,23 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id 
mff_ovn_geneve,
 continue;
 }
 
-struct chassis_tunnel *tun = xmalloc(sizeof *tun);
-hmap_insert(, >hmap_node,
-hash_string(chassis_id, 0));
-tun->chassis_id = chassis_id;
-tun->ofport = u16_to_ofp(ofport);
-tun->type = tunnel_type;
-full_binding_processing = true;
-binding_reset_processing();
-
-/* Reprocess logical flow table immediately. */
-lflow_reset_processing();
-poll_immediate_wake();
+simap_put(_tunnel_to_ofport, chassis_id, ofport);
+struct chassis_tunnel *tun;
+if ((tun = chassis_tunnel_find(chassis_id))) {
+/* If the tunnel's ofport has changed, update. */
+if (tun->ofport != u16_to_ofp(ofport)) {
+tun->ofport = u16_to_ofp(ofport);
+physical_map_changed = true;
+}
+} else {
+tun = xmalloc(sizeof *tun);
+hmap_insert(, >hmap_node,
+hash_string(chassis_id, 0));
+tun->chassis_id = chassis_id;
+tun->ofport = u16_to_ofp(ofport);
+tun->type = tunnel_type;
+physical_map_changed = true;
+}
 break;
 } else {
 const char *iface_id = smap_get(_rec->external_ids,
@@ -691,29 +701,38 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id 
mff_ovn_geneve,
 }
 }
 
+/* Remove tunnels that are no longer here. */
+struct chassis_tunnel *tun, *tun_next;
+HMAP_FOR_EACH_SAFE (tun, tun_next, hmap_node, ) {
+if (!simap_find(_tunnel_to_ofport, tun->chassis_id)) {
+hmap_remove(, >hmap_node);
+physical_map_changed = true;
+free(tun);
+}
+}
+
 /* Capture changed or removed openflow ports. */
-bool localvif_map_changed = false;
 struct simap_node *vif_name, *vif_name_next;
 SIMAP_FOR_EACH_SAFE (vif_name, vif_name_next, _to_ofport) {
 int newport;
 if ((newport = simap_get(_localvif_to_ofport, vif_name->name))) {
 if (newport != simap_get(_to_ofport, vif_name->name)) {
 simap_put(_to_ofport, vif_name->name, newport);
-localvif_map_changed = true;
+physical_map_changed = true;
 }
 } else {
 simap_find_and_delete(_to_ofport, vif_name->name);
-localvif_map_changed = true;
+physical_map_changed = true;
 }
 }
 SIMAP_FOR_EACH (vif_name, _localvif_to_ofport) {
 if (!simap_get(_to_ofport, vif_name->name)) {
 simap_put(_to_ofport, vif_name->name,
   simap_get(_localvif_to_ofport, vif_name->name));
-localvif_map_changed = true;
+physical_map_changed = true;
 }
 }
-if (localvif_map_changed) {
+if (physical_map_changed) {
 full_binding_processing = true;
 
 /* Reprocess logical flow table immediately. */
@@ -769,7 +788,6 @@ physical_run(struct 

[ovs-dev] [PATCH] ovn-northd: create patch ports when necessary.

2016-07-25 Thread nickcooper-zhangtonghao
If the logical router ports without 'peer' or the port named peer
is not created, it is unnecessary to insert the ports into the
southbound Port_Binding table.

Similarly, if logical switch ports of type 'router' don't contain 'router-port'
value, these ports will not be inserted.

This patch may optimize the process of 'build_ports'.

Signed-off-by: nickcooper-zhangtonghao 
---
 ovn/northd/ovn-northd.c | 32 
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index efc915c..f85eb2e 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -770,6 +770,22 @@ join_logical_ports(struct northd_context *ctx,
 }
 }
 
+static bool
+ovn_port_is_insert(const struct ovn_port *op)
+{
+if (op->nbsp) {
+/* The logical switch port is connected to router*/
+if (!strcmp(op->nbsp->type, "router")) {
+const char *router_port = smap_get(>nbsp->options,
+   "router-port");
+return router_port ? true : false;
+}
+return true;
+}
+/* Check the peer of the logical router port*/
+return op->peer ? true : false;
+}
+
 static void
 ovn_port_update_sbrec(const struct ovn_port *op)
 {
@@ -869,11 +885,19 @@ build_ports(struct northd_context *ctx, struct hmap 
*datapaths,
 continue;
 }
 
-op->sb = sbrec_port_binding_insert(ctx->ovnsb_txn);
-ovn_port_update_sbrec(op);
+/* If the logical router ports without 'peer' or the port named peer
+ * is not created, it is unnecessary to insert the ports into the 
+ * southbound Port_Binding table.
+ *
+ * Similarly, if logical switch ports of type 'router' lack 
'router-port'
+ * value, these ports will not be inserted. */
+if (ovn_port_is_insert(op)) {
+op->sb = sbrec_port_binding_insert(ctx->ovnsb_txn);
+ovn_port_update_sbrec(op);
 
-sbrec_port_binding_set_logical_port(op->sb, op->key);
-sbrec_port_binding_set_tunnel_key(op->sb, tunnel_key);
+sbrec_port_binding_set_logical_port(op->sb, op->key);
+sbrec_port_binding_set_tunnel_key(op->sb, tunnel_key);
+}
 }
 
 /* Delete southbound records without northbound matches. */
-- 
1.8.3.1



___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] release-process.md: Document OVS release process and propose a schedule.

2016-07-25 Thread Gray, Mark D


> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Monday, July 25, 2016 5:15 PM
> To: Gray, Mark D 
> Cc: dev@openvswitch.org
> Subject: Re: [ovs-dev] [PATCH] release-process.md: Document OVS release
> process and propose a schedule.
> 
> On Mon, Jul 25, 2016 at 03:45:25PM +, Gray, Mark D wrote:
> > > +Open vSwitch makes releases at the following six-month cadence,
> > > +which of course is subject to change.
> > > +
> > > +time
> > > +(months)  approx datesevent
> > > +  -   -
> > > +T Apr 1  Oct 1release cycle for version x.y begins
> > > +T + 4 Aug 1  Feb 1branch-x.y forks from master
> > > +T + 5.5   Sep 15 Mar 15   branch-x.y released as version x.y.0
> > > +
> > > +Contact
> > > +---
> >
> > What is the relevance of the dates? Are you aligning to another
> > software release?
> 
> The reason to adopt a planned release schedule is to give predictability to
> downstreams.  A six-month cadence seems useful and sustainable.
> 
> There are two reasons for these particular dates.  First, we've been saying 
> for
> some time that we want to freeze for 2.6 at the end of July; Aug. 1 is
> practically the same and easier to explain.  Then, we've often said in the 
> past
> that we have 6-week stabilization periods prior to release; I just rounded 
> that
> up to 45 days.  Finally, by leaving half a month of slack time at the end of 
> the
> cycle we get some leeway for delays in branching or releasing without
> delaying the following release cycle.
> 
> Second, these dates do line up well with OpenStack, which is especially
> important to the OVN sub-project.

Ok, this is what I was looking for. You are aligning to OpenStack which
makes sense. It won't align great for DPDK from next year but it is impossible
to find a date that aligns to everyone.

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] How can i modify Flow table in Openvswitch??

2016-07-25 Thread Ben Pfaff
On Mon, Jul 25, 2016 at 05:26:32PM +0900, Nam Bong Ha wrote:
> i want to modify Flow table in Openvswitch.
> 
> i know that there are two types of Flow table.
> (ex. hash-based flow table, wildcard-aware flow table)
> 
> i want to change the Matching filed in Flow table
> (ex. existing Matching filed = src ip, dst ip, vlan, etc...
>changed Matching filed = *index*, src ip, dst ip, vlan, etc... -> i
> inserted the *index* in there)
> 
> i saw lib/classifier.c and lib/hash.c
> 
> should i modify these sources?

The FAQ says:

### Q: How do I add support for a new field or header?

A: Add new members for your field to "struct flow" in lib/flow.h, and
   add new enumerations for your new field to "enum mf_field_id" in
   lib/meta-flow.h, following the existing pattern.  Also, add support
   to miniflow_extract() in lib/flow.c for extracting your new field
   from a packet into struct miniflow, and to nx_put_raw() in
   lib/nx-match.c to output your new field in OXM matches.  Then
   recompile and fix all of the new warnings, implementing new
   functionality for the new field or header as needed.  (If you
   configure with --enable-Werror, as described in [INSTALL.md], then
   it is impossible to miss any warnings.)

   If you want kernel datapath support for your new field, you also
   need to modify the kernel module for the operating systems you are
   interested in.  This isn't mandatory, since fields understood only
   by userspace work too (with a performance penalty), so it's
   reasonable to start development without it.  If you implement
   kernel module support for Linux, then the Linux kernel "netdev"
   mailing list is the place to submit that support first; please read
   up on the Linux kernel development process separately.  The Windows
   datapath kernel module support, on the other hand, is maintained
   within the OVS tree, so patches for that can go directly to
   ovs-dev.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] ovn-northd: Only peer router ports to other router ports.

2016-07-25 Thread nickcooper-zhangtonghao
Deletion of a logical router port, which may be an other
router peer, result in a WARN, because the "ports" variable
still contains the logical port deleted. This port exists
but should not have been initialized fully.

nbsp == NULL, nbrp == NULL

It is necessary to check 'nbsp'.

A router port's "peer", if set, must point to another router port, but the
code as written also accepted switch ports.  This caused problems when
switch ports were actually specified.

Reported-by: Gurucharan Shetty 
Reported-at: http://openvswitch.org/pipermail/dev/2016-July/075524.html
Signed-off-by: Ben Pfaff 
Acked-by: Gurucharan Shetty 
Signed-off-by: nickcooper-zhangtonghao 
---
 ovn/northd/ovn-northd.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index a3d1672..efc915c 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -746,9 +746,15 @@ join_logical_ports(struct northd_context *ctx,
 } else if (op->nbrp && op->nbrp->peer) {
 struct ovn_port *peer = ovn_port_find(ports, op->nbrp->peer);
 if (peer) {
+/* Deletion of a logical router port, which may be an other
+ * router peer, result in a WARN, because the "ports" variable
+ * still contains the logical port deleted. This port exists 
+ * but should not have been initialized fully.
+ *
+ * nbsp == NULL, nbrp == NULL */
 if (peer->nbrp) {
 op->peer = peer;
-} else {
+} else if (peer->nbsp) {
 /* An ovn_port for a switch port of type "router" does have
  * a router port as its peer (see the case above for
  * "router" ports), but this is set via options:router-port
-- 
1.8.3.1



___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] releasing 2.6: branch Aug 1, release Sep 15

2016-07-25 Thread Ben Pfaff
On Mon, Jul 25, 2016 at 03:44:01PM +, Gray, Mark D wrote:
> 
> 
> > -Original Message-
> > From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Ben Pfaff
> > Sent: Saturday, July 23, 2016 5:00 PM
> > To: dev@openvswitch.org
> > Subject: [ovs-dev] releasing 2.6: branch Aug 1, release Sep 15
> > 
> > The proposed Open vSwitch release schedule calls for branching 2.6 from
> > master on Aug. 1, followed by a period of bug fixes and stabilization, with
> > release on Sep. 15.  The proposed release schedule is posted here for
> > review:
> > https://patchwork.ozlabs.org/patch/650319/
> > 
> > I don't yet know of a reason to modify this schedule.
> > 
> > If you know of reasons to change it, now is an appropriate time to bring it 
> > up
> > for discussion.  In addition, if you have features planned for 2.6 that risk
> > hitting master somewhat late for the branch, it is also a good time to bring
> > these up for discussion, so that we can plan to backport them to the branch
> > early on, or to delay the branch by a few days.
> 
> DPDK 16.07 should be released by early next week. Ciara has a patch to
> enable it, could this be backported to the branch?

I think that Daniele and Pravin should weigh in on that since they
understand DPDK and its relationship to OVS much better.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] release-process.md: Document OVS release process and propose a schedule.

2016-07-25 Thread Ben Pfaff
On Mon, Jul 25, 2016 at 03:45:25PM +, Gray, Mark D wrote:
> > +Open vSwitch makes releases at the following six-month cadence, which
> > +of course is subject to change.
> > +
> > +time
> > +(months)  approx datesevent
> > +  -   -
> > +T Apr 1  Oct 1release cycle for version x.y begins
> > +T + 4 Aug 1  Feb 1branch-x.y forks from master
> > +T + 5.5   Sep 15 Mar 15   branch-x.y released as version x.y.0
> > +
> > +Contact
> > +---
> 
> What is the relevance of the dates? Are you aligning to another software
> release?

The reason to adopt a planned release schedule is to give predictability
to downstreams.  A six-month cadence seems useful and sustainable.

There are two reasons for these particular dates.  First, we've been
saying for some time that we want to freeze for 2.6 at the end of July;
Aug. 1 is practically the same and easier to explain.  Then, we've often
said in the past that we have 6-week stabilization periods prior to
release; I just rounded that up to 45 days.  Finally, by leaving half a
month of slack time at the end of the cycle we get some leeway for
delays in branching or releasing without delaying the following release
cycle.

Second, these dates do line up well with OpenStack, which is
especially important to the OVN sub-project.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] rhel: Fix ifup-ovs to delete bonds first.

2016-07-25 Thread Flavio Leitner
When ifdown isn't executed (system didn't shut down properly),
bond interfaces remain in the openvswitch's database.  In that
case, an inconsitency is left behind when the ifcfg was modified
because ovs-vsctl won't do anything to update existing bond's
configuration in the database.

The ifup/ifdown will operate only on configured interfaces, so
this patch fixes the issue by deleting the bond from the database
before attempt to configure it with fresh configuration.

Signed-off-by: Flavio Leitner 
---
 rhel/etc_sysconfig_network-scripts_ifup-ovs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs 
b/rhel/etc_sysconfig_network-scripts_ifup-ovs
index f3fc05e..150b264 100755
--- a/rhel/etc_sysconfig_network-scripts_ifup-ovs
+++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs
@@ -143,7 +143,9 @@ case "$TYPE" in
for _iface in $BOND_IFACES; do
/sbin/ifup ${_iface}
done
-   ovs-vsctl -t ${TIMEOUT} -- --may-exist add-bond "$OVS_BRIDGE" 
"$DEVICE" ${BOND_IFACES} $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+   ovs-vsctl -t ${TIMEOUT} \
+   -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" \
+   -- add-bond "$OVS_BRIDGE" "$DEVICE" ${BOND_IFACES} 
$OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
OVSINTF=${DEVICE} /sbin/ifup "$OVS_BRIDGE"
;;
OVSTunnel)
-- 
2.7.4

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v3] Windows: Local named pipe implementation

2016-07-25 Thread Paul Boca
Acked-by: Paul Boca 

> -Original Message-
> From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Alin Serdean
> Sent: Monday, July 25, 2016 5:29 AM
> To: dev@openvswitch.org
> Subject: [ovs-dev] [PATCH v3] Windows: Local named pipe implementation
> 
> Currently in the case of command line arguments punix/unix, on Windows
> we create a file, write a TCP port number to connect. This is a security
> concern.
> 
> This patch adds support for the command line arguments punix/unix trying
> to mimic AF_UNIX behind a local named pipe.
> 
> This patch drops the TCP socket implementation behind command line
> arguments punix/unix and switches to the local named pipe implementation.
> 
> Since we do not write anything to the file created by the punix/unix
> arguments, switch tests to plain file existence.
> 
> Man pages and code comments have been updated.
> 
> Signed-off-by: Alin Gabriel Serdean 
> ---
> v3: squash commits update documentation and code comments
> v2: Address comments, fix handle leaks.
> ---
>  lib/automake.mk  |   1 +
>  lib/stream-tcp.c | 115 --
>  lib/stream-windows.c | 587
> +++
>  lib/unixctl.c|   5 +-
>  lib/unixctl.man  |  12 +-
>  lib/vconn-active.man |   3 +-
>  ovsdb/remote-active.man  |   4 +-
>  ovsdb/remote-passive.man |   5 +-
>  tests/ovsdb-server.at|   6 +-
>  9 files changed, 608 insertions(+), 130 deletions(-)
>  create mode 100644 lib/stream-windows.c
> 
> diff --git a/lib/automake.mk b/lib/automake.mk
> index 71c9d41..9067c95 100644
> --- a/lib/automake.mk
> +++ b/lib/automake.mk
> @@ -293,6 +293,7 @@ lib_libopenvswitch_la_SOURCES += \
>   lib/latch-windows.c \
>   lib/route-table-stub.c \
>   lib/if-notifier-stub.c \
> + lib/stream-windows.c \
>   lib/strsep.c
>  else
>  lib_libopenvswitch_la_SOURCES += \
> diff --git a/lib/stream-tcp.c b/lib/stream-tcp.c
> index 2b57ca7..1749fad 100644
> --- a/lib/stream-tcp.c
> +++ b/lib/stream-tcp.c
> @@ -74,64 +74,6 @@ const struct stream_class tcp_stream_class = {
>  NULL,   /* run_wait */
>  NULL,   /* wait */
>  };
> -
> -#ifdef _WIN32
> -#include "dirs.h"
> -
> -static int
> -windows_open(const char *name, char *suffix, struct stream **streamp,
> - uint8_t dscp)
> -{
> -int error, port;
> -FILE *file;
> -char *suffix_new, *path;
> -
> -/* If the path does not contain a ':', assume it is relative to
> - * OVS_RUNDIR. */
> -if (!strchr(suffix, ':')) {
> -path = xasprintf("%s/%s", ovs_rundir(), suffix);
> -} else {
> -path = xstrdup(suffix);
> -}
> -
> -file = fopen(path, "r");
> -if (!file) {
> -error = errno;
> -VLOG_DBG("%s: could not open %s (%s)", name, suffix,
> - ovs_strerror(error));
> -return error;
> -}
> -
> -error = fscanf(file, "%d", );
> -if (error != 1) {
> -VLOG_ERR("failed to read port from %s", suffix);
> -fclose(file);
> -return EINVAL;
> -}
> -fclose(file);
> -
> -suffix_new = xasprintf("127.0.0.1:%d", port);
> -
> -error = tcp_open(name, suffix_new, streamp, dscp);
> -
> -free(suffix_new);
> -free(path);
> -return error;
> -}
> -
> -const struct stream_class windows_stream_class = {
> -"unix", /* name */
> -false,  /* needs_probes */
> -windows_open,  /* open */
> -NULL,   /* close */
> -NULL,   /* connect */
> -NULL,   /* recv */
> -NULL,   /* send */
> -NULL,   /* run */
> -NULL,   /* run_wait */
> -NULL,   /* wait */
> -};
> -#endif
>  

>  /* Passive TCP. */
> 
> @@ -198,60 +140,3 @@ const struct pstream_class ptcp_pstream_class = {
>  NULL,
>  NULL,
>  };
> -
> -#ifdef _WIN32
> -static int
> -pwindows_open(const char *name, char *suffix, struct pstream
> **pstreamp,
> -  uint8_t dscp)
> -{
> -int error;
> -char *suffix_new, *path;
> -FILE *file;
> -struct pstream *listener;
> -
> -suffix_new = xstrdup("0:127.0.0.1");
> -
> -/* If the path does not contain a ':', assume it is relative to
> - * OVS_RUNDIR. */
> -if (!strchr(suffix, ':')) {
> -path = xasprintf("%s/%s", ovs_rundir(), suffix);
> -} else {
> -path = xstrdup(suffix);
> -}
> -
> -error = new_pstream(suffix_new, name, pstreamp, dscp, path, false);
> -if (error) {
> -goto exit;
> -}
> -listener = *pstreamp;
> -
> -file = fopen(path, "w");
> -if (!file) {
> -error = errno;
> -VLOG_DBG("could not open %s (%s)", path, ovs_strerror(error));
> -goto exit;
> -}
> -
> -fprintf(file, 

Re: [ovs-dev] [PATCH] ovn-controller: Add incremental processing for multicast groups

2016-07-25 Thread Ryan Moats
Ryan Moats/Omaha/IBM@IBMUS wrote on 07/24/2016 02:33:19 PM:

> From: Ryan Moats/Omaha/IBM@IBMUS
> To: dev@openvswitch.org
> Cc: Ryan Moats/Omaha/IBM@IBMUS
> Date: 07/24/2016 02:33 PM
> Subject: [PATCH] ovn-controller: Add incremental processing for
> multicast groups
>
> The various fixes in handling physical and binding changes
> have addressed the problems that the original attempt to
> incrementally process the multicast group table ran into.
> So, re-add incremental processing of the multicast group
> table.
>
> Notes:
> - This patch renders the short term changes in [1] taken
>   for multicast group processing unnecessary (and so it
>   conflicts with [1]).
> - Running through the ovn unit tests 50 times with -j4
>   didn't show increased test case failures over the
>   baseline code prior to adding this patch.
>
> [1] http://patchwork.ozlabs.org/patch/652117/
>
> Signed-off-by: Ryan Moats 

Please disregard this patch, it is being abandoned for the
time being.

Ryan
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] releasing 2.6: branch Aug 1, release Sep 15

2016-07-25 Thread Gray, Mark D


> -Original Message-
> From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Ben Pfaff
> Sent: Saturday, July 23, 2016 5:00 PM
> To: dev@openvswitch.org
> Subject: [ovs-dev] releasing 2.6: branch Aug 1, release Sep 15
> 
> The proposed Open vSwitch release schedule calls for branching 2.6 from
> master on Aug. 1, followed by a period of bug fixes and stabilization, with
> release on Sep. 15.  The proposed release schedule is posted here for
> review:
> https://patchwork.ozlabs.org/patch/650319/
> 
> I don't yet know of a reason to modify this schedule.
> 
> If you know of reasons to change it, now is an appropriate time to bring it up
> for discussion.  In addition, if you have features planned for 2.6 that risk
> hitting master somewhat late for the branch, it is also a good time to bring
> these up for discussion, so that we can plan to backport them to the branch
> early on, or to delay the branch by a few days.
> 

Hi Ben, 

DPDK 16.07 should be released by early next week. Ciara has a patch to enable 
it,
could this be backported to the branch?

Thanks,
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] release-process.md: Document OVS release process and propose a schedule.

2016-07-25 Thread Gray, Mark D
> +Open vSwitch makes releases at the following six-month cadence, which
> +of course is subject to change.
> +
> +time
> +(months)  approx datesevent
> +  -   -
> +T Apr 1  Oct 1release cycle for version x.y begins
> +T + 4 Aug 1  Feb 1branch-x.y forks from master
> +T + 5.5   Sep 15 Mar 15   branch-x.y released as version x.y.0
> +
> +Contact
> +---

What is the relevance of the dates? Are you aligning to another software
release?

Thanks,

Mark
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] OVSDB replication related memory leak

2016-07-25 Thread William Tu
Hi,

Valgrind reports definitely memory leak in the testcase
1826: ovsdb-server.at:1081 insert monitored table, update excluded table
Can someone take at look? Thank you~

==52969== 144 (48 direct, 96 indirect) bytes in 1 blocks are
definitely lost in loss record 306 of 373
==52969==at 0x4C2AA98: calloc (vg_replace_malloc.c:711)
==52969==by 0x434C52: xcalloc (util.c:95)
==52969==by 0x420EA9: jsonrpc_msg_from_json (jsonrpc.c:686)
==52969==by 0x420FDF: jsonrpc_parse_received_message (jsonrpc.c:471)
==52969==by 0x420FDF: jsonrpc_recv.part.8 (jsonrpc.c:337)
==52969==by 0x42124B: jsonrpc_recv (jsonrpc.c:296)
==52969==by 0x42124B: jsonrpc_recv_block (jsonrpc.c:401)
==52969==by 0x41388E: get_initial_db_state (replication.c:363)
==52969==by 0x41388E: send_monitor_requests (replication.c:350)
==52969==by 0x41388E: replication_run (replication.c:107)
==52969==by 0x407E0B: main_loop (ovsdb-server.c:165)
==52969==by 0x407E0B: main (ovsdb-server.c:361)
==52969==
==52969== 620 (600 direct, 20 indirect) bytes in 1 blocks are
definitely lost in loss record 333 of 373
==52969==at 0x4C2AA98: calloc (vg_replace_malloc.c:711)
==52969==by 0x434C52: xcalloc (util.c:95)
==52969==by 0x420737: jsonrpc_open (jsonrpc.c:86)
==52969==by 0x412BA4: open_jsonrpc (replication.c:214)
==52969==by 0x413461: replication_run (replication.c:101)
==52969==by 0x407E0B: main_loop (ovsdb-server.c:165)
==52969==by 0x407E0B: main (ovsdb-server.c:361)
==52969==
==52969== 620 (600 direct, 20 indirect) bytes in 1 blocks are
definitely lost in loss record 334 of 373
==52969==at 0x4C2AA98: calloc (vg_replace_malloc.c:711)
==52969==by 0x434C52: xcalloc (util.c:95)
==52969==by 0x420737: jsonrpc_open (jsonrpc.c:86)
==52969==by 0x412BA4: open_jsonrpc (replication.c:214)
==52969==by 0x413990: check_for_notifications (replication.c:394)
==52969==by 0x413990: replication_run (replication.c:110)
==52969==by 0x407E0B: main_loop (ovsdb-server.c:165)
==52969==by 0x407E0B: main (ovsdb-server.c:361)

Regards,
William
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] (no subject)

2016-07-25 Thread Abdalla, Maisa


Kontaktieren Sie uns: jessmaar...@outlook.com

Wir bieten Darlehen zu einem Zinssatz von 2 % jährlich. Unser Darlehen ist 
erschwinglich und stressfrei. Kredit für alle Zwecke.

Kontaktieren Sie uns: jessmaar...@outlook.com
Vielen Dank

==

Contact us: jessmaar...@outlook.com

We offer loan at 2% interest rate annually. Our loan is affordable and stress 
free . Loan for all purposes .

Contact us: jessmaar...@outlook.com

Thanks

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may 
contain confidential and privileged information for the use of the designated 
recipients named above. If you are not the intended recipient, you are hereby 
notified that you have received this communication in error and that any 
review, disclosure, dissemination, distribution or copying of it or its 
contents is prohibited. If you have received this communication in error, 
please notify me immediately by replying to this message and destroy all copies 
of this communication and any attachments. Thank you.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] netdev-dpdk: Apply batch truncation API.

2016-07-25 Thread William Tu
Instead of looping into each packet and check whether to truncate, the
patch moves it out of the loop and uses batch API.  If truncation is
not set, checking 'trunc' in 'struct dp_packet_batch' at per-batch basis
can skip the per-packet checking overhead.

Signed-off-by: William Tu 
---
 lib/netdev-dpdk.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 7fb6457..22d547f 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1411,6 +1411,8 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct 
dp_packet_batch *batch)
 ovs_mutex_lock(_mempool_mutex);
 }
 
+dp_packet_batch_apply_cutlen(batch);
+
 for (i = 0; i < batch->count; i++) {
 int size = dp_packet_size(batch->packets[i]);
 
@@ -1429,10 +1431,6 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct 
dp_packet_batch *batch)
 break;
 }
 
-/* Cut the size so only the truncated size is copied. */
-size -= dp_packet_get_cutlen(batch->packets[i]);
-dp_packet_reset_cutlen(batch->packets[i]);
-
 /* We have to do a copy for now */
 memcpy(rte_pktmbuf_mtod(mbufs[newcnt], void *),
dp_packet_data(batch->packets[i]), size);
@@ -1506,12 +1504,11 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int qid,
 unsigned int temp_cnt = 0;
 int cnt = batch->count;
 
+dp_packet_batch_apply_cutlen(batch);
+
 for (int i = 0; i < cnt; i++) {
 int size = dp_packet_size(batch->packets[i]);
 
-size -= dp_packet_get_cutlen(batch->packets[i]);
-dp_packet_set_size(batch->packets[i], size);
-
 if (OVS_UNLIKELY(size > dev->max_packet_len)) {
 if (next_tx_idx != i) {
 temp_cnt = i - next_tx_idx;
-- 
2.5.0

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] [PATCH v1] ovs-dev: add set type for ovs.idl.data.Datum.from_python

2016-07-25 Thread Russell Bryant
On Thu, Jul 21, 2016 at 2:17 AM, Zong Kai LI  wrote:

> ovs.db.idl.Datum.from_python fails to handle set type value, while set
> type is also a common iterable sequence, just like list and tuple.
> No reason IDL caller must to turn set type parameters to list or tuple
> type. Otherwise, they will fail to insert data, but get no exception.
>
> Signed-off-by: Zong Kai LI 
> ---
>  python/ovs/db/data.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/python/ovs/db/data.py b/python/ovs/db/data.py
> index 747acd5..6d87f89 100644
> --- a/python/ovs/db/data.py
> +++ b/python/ovs/db/data.py
> @@ -521,7 +521,7 @@ class Datum(object):
>  ka = Atom.from_python(type_.key, row_to_uuid(k))
>  va = Atom.from_python(type_.value, row_to_uuid(v))
>  d[ka] = va
> -elif isinstance(value, (list, tuple)):
> +elif isinstance(value, (list, set, tuple)):
>  for k in value:
>  ka = Atom.from_python(type_.key, row_to_uuid(k))
>  d[ka] = None
>

Thanks, I applied this to master with some minor updates to the commit
message.

You posted this as a "v1", but it actually appears to be a v2 of an earlier
patch.  I included the Acked-by and Tested-by headers from v1.

-- 
Russell Bryant
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 1/3] utilities/ovs-ctl.in: Allow non-monitoring daemons

2016-07-25 Thread Aaron Conole
Flaviof  writes:

> On Wed, Jul 20, 2016 at 4:21 PM, Aaron Conole  wrote:
>
>  This commit allows the ovs-ctl command to spawn daemons without the
>  internal process monitor.  This is useful when integrating with,
>  ex. systemd, which provides its own monitoring facilities.
>
>  Signed-off-by: Aaron Conole 
>  Acked-by: Ben Pfaff 
>  Acked-by: Flavio Leitner 
>  ---
>   utilities/ovs-ctl.8  | 5 +
>   utilities/ovs-ctl.in | 1 +
>   utilities/ovs-lib.in | 3 ++-
>   3 files changed, 8 insertions(+), 1 deletion(-)
>
>  diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8
>  index 662b83e..6b8fba7 100644
>  --- a/utilities/ovs-ctl.8
>  +++ b/utilities/ovs-ctl.8
>  @@ -162,6 +162,11 @@ after reboot, but other ports need to be persisted in 
> the
>  database.
>   .PP
>   The following options are less important:
>   .
>  +.IP "\fB\-\-no\-monitor\fR"
>  +By default \fBovs\-ctl\fR passes \fB\-\-monitor\fR to \fBovs\-vswitchd\fR 
> and
>  +\fBovsdb\-server\fR, requesting that it spawn a process monitor which will
>  +restart the daemon if it crashes.  This option suppresses that behavior.
>  +.
>   .IP "\fB\-\-daemon-cwd=\fIdirectory\fR"
>   Specifies the current working directory that the OVS daemons should
>   run from.  The default is \fB/\fR (the root directory) if this option
>  diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
>  index 8ec825b..d92cf3c 100755
>  --- a/utilities/ovs-ctl.in
>  +++ b/utilities/ovs-ctl.in
>  @@ -499,6 +499,7 @@ set_defaults () {
>   FORCE_COREFILES=yes
>   MLOCKALL=yes
>   SELF_CONFINEMENT=yes
>  +MONITOR=yes
>   OVSDB_SERVER=yes
>   OVS_VSWITCHD=yes
>   OVSDB_SERVER_PRIORITY=-10
>  diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
>  index 773efb3..5f23269 100644
>  --- a/utilities/ovs-lib.in
>  +++ b/utilities/ovs-lib.in
>  @@ -151,7 +151,8 @@ start_daemon () {
>   # pidfile and monitoring
>   test -d "$rundir" || install -d -m 755 -o root -g root "$rundir"
>   set "$@" --pidfile="$rundir/$daemon.pid"
>  -set "$@" --detach --monitor
>  +set "$@" --detach
>  +test X"$MONITOR" = "Xno" || set "$@" --monitor
>
> There is no need for quotes around Xno.
> To be consistent with the other test lines in this file, consider doing that.

Sure thing!  Thank so much for the review, Flavio!

> Otherwise...
>
> Acked-by: Flavio Fernandes 
>
>  
>  
>   # wrapper
>   case $wrapper in
>  --
>  2.5.5
>
>  ___
>  dev mailing list
>  dev@openvswitch.org
>  http://openvswitch.org/mailman/listinfo/dev
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] ovsdb: Fix memory leak reported by valgrind.

2016-07-25 Thread William Tu
Looks good to me, thanks for fixing it!

Acked-by: William Tu 

On Mon, Jul 25, 2016 at 1:00 AM, Liran Schour  wrote:
> Destroy shash on destroy of session's condition structure.
> Reported here: http://openvswitch.org/pipermail/dev/2016-July/075968.html
>
> Signed-off-by: Liran Schour 
> ---
>  ovsdb/monitor.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c
> index 99083e1..9a6fbf5 100644
> --- a/ovsdb/monitor.c
> +++ b/ovsdb/monitor.c
> @@ -617,6 +617,7 @@ ovsdb_monitor_session_condition_destroy(
>  shash_delete(>tables, node);
>  free(mtc);
>  }
> +shash_destroy(>tables);
>  free(condition);
>  }
>
> --
> 2.1.4
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH V9] windows: Added lockf function and lock PID file

2016-07-25 Thread Guru Shetty
On 25 July 2016 at 05:50, Paul Boca  wrote:

> If the PID file isn't locked then appctl.py detects it as stale and
> bails out without doing anything. Because of this lots of Python tests
> fail.
> Also this protects the PID file from being overwritten.
>
> I used only shared lock, in order to be compatible with Python tests,
> which try to acquire the lock exclusively. On Windows if the exclusive lock
> is used, than the read access is denied too for other instances of this
> file.
>
> Signed-off-by: Paul-Daniel Boca 
> Acked-by: Alin Gabriel Serdean 
>

Thank you, applied!


> ---
> V2: No changes
> V3: No changes
> V4: No changes
> V5: Removed this patch from Python series.
> Removed unused constants and defined 0x as constant.
> Updated commit text.
> V6: flock returns now the error of GetLastError.
> Also it uses fd parameter instead of the global filep_pidfile.
> Removed unused local variable and unnecessary error message.
> V7: Keep a shared lock on PID file after the fopen.
> This ensures us that at most one process can write the same PID file.
> fopen with 'w' on Windows creates a file with FILE_SHARED_WRITE
> flag, so anyone with write access on file can write it.
> V8: Added LOCKFILE_FAIL_IMMEDIATELY flag when trying to get exclusive lock
> on PID file in order to avoid hangs of other daemons that try to
> acquire
> exclusive lock over the same PID file
> V9: Small fatal error message update and on constants used.
> Lock only the first byte in PID file, this is enough in our case.
> ---
>  lib/daemon-windows.c | 41 +
>  1 file changed, 41 insertions(+)
>
> diff --git a/lib/daemon-windows.c b/lib/daemon-windows.c
> index 8cf0fea..d77724e 100644
> --- a/lib/daemon-windows.c
> +++ b/lib/daemon-windows.c
> @@ -18,6 +18,7 @@
>  #include "daemon.h"
>  #include "daemon-private.h"
>  #include 
> +#include 
>  #include 
>  #include "dirs.h"
>  #include "ovs-thread.h"
> @@ -26,6 +27,10 @@
>
>  VLOG_DEFINE_THIS_MODULE(daemon_windows);
>
> +/* Constants for flock function */
> +#defineLOCK_SHARED 0x0 /* Shared lock. */
> +#defineLOCK_UNLOCK 0x8000  /* Unlock. Custom
> value. */
> +
>  static bool service_create;  /* Was --service specified? */
>  static bool service_started; /* Have we dispatched service to
> start? */
>
> @@ -404,9 +409,39 @@ detach_process(int argc, char *argv[])
>  }
>
>  static void
> +flock(FILE* fd, int operation)
> +{
> +HANDLE hFile;
> +OVERLAPPED ov = {0};
> +
> +hFile = (HANDLE)_get_osfhandle(fileno(fd));
> +if (hFile == INVALID_HANDLE_VALUE) {
> +VLOG_FATAL("Failed to get PID file handle (%s).",
> +   ovs_lasterror_to_string());
> +}
> +
> +if (operation & LOCK_UNLOCK) {
> +if (UnlockFileEx(hFile, 0, 1, 0, ) == 0) {
> +VLOG_FATAL("Failed to unlock PID file (%s).",
> +   ovs_lasterror_to_string());
> +}
> +} else {
> +   /* Use LOCKFILE_FAIL_IMMEDIATELY flag to avoid hang of another
> daemon that tries to
> +   acquire exclusive lock over the same PID file */
> +if (LockFileEx(hFile, operation | LOCKFILE_FAIL_IMMEDIATELY,
> +   0, 1, 0, ) == FALSE) {
> +VLOG_FATAL("Failed to lock PID file (%s).",
> +   ovs_lasterror_to_string());
> +}
> +}
> +}
> +
> +static void
>  unlink_pidfile(void)
>  {
>  if (filep_pidfile) {
> +/* Remove the shared lock on file */
> +flock(filep_pidfile, LOCK_UNLOCK);
>  fclose(filep_pidfile);
>  }
>  if (pidfile) {
> @@ -437,6 +472,8 @@ make_pidfile(void)
>  VLOG_FATAL("failed to open %s (%s)", pidfile,
> ovs_strerror(errno));
>  }
>
> +flock(filep_pidfile, LOCKFILE_EXCLUSIVE_LOCK);
> +
>  fatal_signal_add_hook(unlink_pidfile, NULL, NULL, true);
>
>  fprintf(filep_pidfile, "%d\n", _getpid());
> @@ -444,6 +481,10 @@ make_pidfile(void)
>  VLOG_FATAL("Failed to write into the pidfile %s", pidfile);
>  }
>
> +flock(filep_pidfile, LOCK_SHARED);
> +/* This will remove the exclusive lock. The shared lock will remain */
> +flock(filep_pidfile, LOCK_UNLOCK);
> +
>  /* Don't close the pidfile till the process exits. */
>  }
>
> --
> 2.7.2.windows.1
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] [PATCH v1] ovs python: add set type forfrom_python

2016-07-25 Thread Richard Theis
"dev"  wrote on 07/25/2016 07:58:03 AM:

> From: Ryan Moats/Omaha/IBM@IBMUS
> To: Zong Kai LI 
> Cc: dev@openvswitch.org
> Date: 07/25/2016 07:58 AM
> Subject: Re: [ovs-dev] [PATCH] [PATCH v1] ovs python: add set type 
> forfrom_python
> Sent by: "dev" 
> 
> "dev"  wrote on 07/19/2016 03:59:39 AM:
> 
> > From: Zong Kai LI 
> > To: dev@openvswitch.org
> > Date: 07/19/2016 04:03 AM
> > Subject: [ovs-dev] [PATCH] [PATCH v1] ovs python: add set type for
> from_python
> > Sent by: "dev" 
> >
> > In method from_python, when parameter 'value' is in list type or tuple
> > type, it will process per each element in 'value'. And indeed, it just
> > needs a iterable sequence here, no matter it's a list or tuple.
> > So set type should be considered too, it's also a basic, common 
iterable
> > sequence type from python.
> >
> > Signed-off-by: Zong Kai LI 
> 
> From Richard Theis :
> 
>   This patch is need to avoid the revert [1] in networking-ovn.  Without
>   this patch or the revert, networking-ovn is experiencing the bug
>   described in [2].
> 
> Acked-by: Richard Theis 
> 
> [1] http://review.openstack.org/344078
> [2] https://bugs.launchpad.net/networking-ovn/+bug/1605573
> 
> Ryan Moats

I ran the test reported in [2] to confirm the bug.  After applying the
revert [1], the reported bug was fixed.  That is, I was able to ssh 
between
my instances with the router setup described in [2].  I also confirmed 
that
the networks field was properly set for the logical router ports.  I then
removed the revert [1] and applied this patch.   This patch also worked.

Tested-by: Richard Theis 
> 
> 
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] ovn-controller: Handle physical changes correctly

2016-07-25 Thread Ryan Moats
Liran Schour/Haifa/IBM wrote on 07/25/2016 02:44:42 AM:

> From: Liran Schour/Haifa/IBM
> To: Ryan Moats 
> Cc: dev@openvswitch.org
> Date: 07/25/2016 02:44 AM
> Subject: Re: [ovs-dev] [PATCH] ovn-controller: Handle physical
> changes correctly
>
> > From: Ryan Moats 
> > To: dev@openvswitch.org
> > Date: 23/07/2016 12:57 AM
> > Subject: [ovs-dev] [PATCH] ovn-controller: Handle physical
changescorrectly
> > Sent by: "dev" 
> >
> > [1] reported increased failure rates in certain tests
> > with incremental processing (the numbers are the number of failures
> > seen in 100 tests):
> >
> >2  ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS
> >   10  ovn -- 2 HVs, 2 LS, 1 lport/LS, 2 peer LRs
> >   52  ovn -- 1 HV, 1 LS, 2 lport/LS, 1 LR
> >   45  ovn -- 1 HV, 2 LSs, 1 lport/LS, 1 LR
> >   23  ovn -- 2 HVs, 3 LS, 1 lport/LS, 2 peer LRs, static routes
> >   53  ovn -- 2 HVs, 3 LRs connected via LS, static routes
> >   32  ovn -- 2 HVs, 2 LRs connected via LS, gateway router
> >   50  ovn -- icmp_reply: 1 HVs, 2 LSs, 1 lport/LS, 1 LR
> >
> > These failures were caused by a combination of problems in
> > handling physical changes:
> >
> >   1. When a vif was removed, the localvif_to_ofport entry was not
> >  removed.
> >   2. When a physical change was detected, ovn-controller would wait
> >  a poll cycle before processing the logical flow table.
> >
> > This patch set addresses both of these issues while simultaneously
> > cleaning up the code in physical.c.  A side effect is a modification
> > of where OF flows are dumped in the gateway router case that allowed
> > the root causes of this issue to be found.
> >
> > With these changes, all of the above tests had a 100/100 success rate.
> >
> > [1] http://openvswitch.org/pipermail/dev/2016-July/075803.html
> >
> > Signed-off-by: Ryan Moats 
> > ---
>
> This patch really improves the tests however on my performance
> evaluation environment it results in a 100% CPU load on the
ovn-controllers.

I'm pretty sure I know what's causing that - let's see if I can revert
that without impacting test results...
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] [PATCH v1] ovs python: add set type forfrom_python

2016-07-25 Thread Ryan Moats
"dev"  wrote on 07/19/2016 03:59:39 AM:

> From: Zong Kai LI 
> To: dev@openvswitch.org
> Date: 07/19/2016 04:03 AM
> Subject: [ovs-dev] [PATCH] [PATCH v1] ovs python: add set type for
from_python
> Sent by: "dev" 
>
> In method from_python, when parameter 'value' is in list type or tuple
> type, it will process per each element in 'value'. And indeed, it just
> needs a iterable sequence here, no matter it's a list or tuple.
> So set type should be considered too, it's also a basic, common iterable
> sequence type from python.
>
> Signed-off-by: Zong Kai LI 

From Richard Theis :

  This patch is need to avoid the revert [1] in networking-ovn.  Without
  this patch or the revert, networking-ovn is experiencing the bug
  described in [2].

Acked-by: Richard Theis 

[1] http://review.openstack.org/344078
[2] https://bugs.launchpad.net/networking-ovn/+bug/1605573

Ryan Moats


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH V9] windows: Added lockf function and lock PID file

2016-07-25 Thread Paul Boca
If the PID file isn't locked then appctl.py detects it as stale and
bails out without doing anything. Because of this lots of Python tests fail.
Also this protects the PID file from being overwritten.

I used only shared lock, in order to be compatible with Python tests,
which try to acquire the lock exclusively. On Windows if the exclusive lock
is used, than the read access is denied too for other instances of this file.

Signed-off-by: Paul-Daniel Boca 
Acked-by: Alin Gabriel Serdean 
---
V2: No changes
V3: No changes
V4: No changes
V5: Removed this patch from Python series.
Removed unused constants and defined 0x as constant.
Updated commit text.
V6: flock returns now the error of GetLastError.
Also it uses fd parameter instead of the global filep_pidfile.
Removed unused local variable and unnecessary error message.
V7: Keep a shared lock on PID file after the fopen.
This ensures us that at most one process can write the same PID file.
fopen with 'w' on Windows creates a file with FILE_SHARED_WRITE
flag, so anyone with write access on file can write it.
V8: Added LOCKFILE_FAIL_IMMEDIATELY flag when trying to get exclusive lock
on PID file in order to avoid hangs of other daemons that try to acquire
exclusive lock over the same PID file
V9: Small fatal error message update and on constants used.
Lock only the first byte in PID file, this is enough in our case.
---
 lib/daemon-windows.c | 41 +
 1 file changed, 41 insertions(+)

diff --git a/lib/daemon-windows.c b/lib/daemon-windows.c
index 8cf0fea..d77724e 100644
--- a/lib/daemon-windows.c
+++ b/lib/daemon-windows.c
@@ -18,6 +18,7 @@
 #include "daemon.h"
 #include "daemon-private.h"
 #include 
+#include 
 #include 
 #include "dirs.h"
 #include "ovs-thread.h"
@@ -26,6 +27,10 @@
 
 VLOG_DEFINE_THIS_MODULE(daemon_windows);
 
+/* Constants for flock function */
+#defineLOCK_SHARED 0x0 /* Shared lock. */
+#defineLOCK_UNLOCK 0x8000  /* Unlock. Custom 
value. */
+
 static bool service_create;  /* Was --service specified? */
 static bool service_started; /* Have we dispatched service to start? */
 
@@ -404,9 +409,39 @@ detach_process(int argc, char *argv[])
 }
 
 static void
+flock(FILE* fd, int operation)
+{
+HANDLE hFile;
+OVERLAPPED ov = {0};
+
+hFile = (HANDLE)_get_osfhandle(fileno(fd));
+if (hFile == INVALID_HANDLE_VALUE) {
+VLOG_FATAL("Failed to get PID file handle (%s).",
+   ovs_lasterror_to_string());
+}
+
+if (operation & LOCK_UNLOCK) {
+if (UnlockFileEx(hFile, 0, 1, 0, ) == 0) {
+VLOG_FATAL("Failed to unlock PID file (%s).",
+   ovs_lasterror_to_string());
+}
+} else {
+   /* Use LOCKFILE_FAIL_IMMEDIATELY flag to avoid hang of another daemon 
that tries to
+   acquire exclusive lock over the same PID file */
+if (LockFileEx(hFile, operation | LOCKFILE_FAIL_IMMEDIATELY,
+   0, 1, 0, ) == FALSE) {
+VLOG_FATAL("Failed to lock PID file (%s).",
+   ovs_lasterror_to_string());
+}
+}
+}
+
+static void
 unlink_pidfile(void)
 {
 if (filep_pidfile) {
+/* Remove the shared lock on file */
+flock(filep_pidfile, LOCK_UNLOCK);
 fclose(filep_pidfile);
 }
 if (pidfile) {
@@ -437,6 +472,8 @@ make_pidfile(void)
 VLOG_FATAL("failed to open %s (%s)", pidfile, ovs_strerror(errno));
 }
 
+flock(filep_pidfile, LOCKFILE_EXCLUSIVE_LOCK);
+
 fatal_signal_add_hook(unlink_pidfile, NULL, NULL, true);
 
 fprintf(filep_pidfile, "%d\n", _getpid());
@@ -444,6 +481,10 @@ make_pidfile(void)
 VLOG_FATAL("Failed to write into the pidfile %s", pidfile);
 }
 
+flock(filep_pidfile, LOCK_SHARED);
+/* This will remove the exclusive lock. The shared lock will remain */
+flock(filep_pidfile, LOCK_UNLOCK);
+
 /* Don't close the pidfile till the process exits. */
 }
 
-- 
2.7.2.windows.1
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] (no subject)

2016-07-25 Thread Tyrell May

Deep apology for my late reply

Upon your request, Company credit account is attached to this email.

*** Yours faithfully, Tyrell May
BT GROUP Phone: +1 (212) 440-04-39 ID: 
c75b4ef42e75851be9dff87a0756a20644d77deed57f
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH V8] windows: Added lockf function and lock PID file

2016-07-25 Thread Paul Boca
Hi!

Disregard this patch, I will send another one that addresses all the required 
changes.

Thanks,
Paul

> -Original Message-
> From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Paul Boca
> Sent: Friday, July 15, 2016 9:45 AM
> To: dev@openvswitch.org
> Subject: [ovs-dev] [PATCH V8] windows: Added lockf function and lock PID
> file
> 
> If the PID file isn't locked then appctl.py detects it as stale and
> bails out without doing anything. Because of this lots of Python tests fail.
> Also this protects the PID file from being overwritten.
> 
> I used only shared lock, in order to be compatible with Python tests,
> which try to acquire the lock exclusively. On Windows if the exclusive lock
> is used, than the read access is denied too for other instances of this file.
> 
> Signed-off-by: Paul-Daniel Boca 
> Acked-by: Alin Gabriel Serdean 
> ---
> V2: No changes
> V3: No changes
> V4: No changes
> V5: Removed this patch from Python series.
> Removed unused constants and defined 0x as constant.
> Updated commit text.
> V6: flock returns now the error of GetLastError.
> Also it uses fd parameter instead of the global filep_pidfile.
> Removed unused local variable and unnecessary error message.
> V7: Keep a shared lock on PID file after the fopen.
> This ensures us that at most one process can write the same PID file.
> fopen with 'w' on Windows creates a file with FILE_SHARED_WRITE
> flag, so anyone with write access on file can write it.
> V8: Added LOCKFILE_FAIL_IMMEDIATELY flag when trying to get exclusive
> lock
> on PID file in order to avoid hangs of other daemons that try to acquire
> exclusive lock over the same PID file
> ---
>  lib/daemon-windows.c | 44
> 
>  1 file changed, 44 insertions(+)
> 
> diff --git a/lib/daemon-windows.c b/lib/daemon-windows.c
> index 8cf0fea..350e8fc 100644
> --- a/lib/daemon-windows.c
> +++ b/lib/daemon-windows.c
> @@ -18,6 +18,7 @@
>  #include "daemon.h"
>  #include "daemon-private.h"
>  #include 
> +#include 
>  #include 
>  #include "dirs.h"
>  #include "ovs-thread.h"
> @@ -26,6 +27,14 @@
> 
>  VLOG_DEFINE_THIS_MODULE(daemon_windows);
> 
> +/* Constants for flock function */
> +#define  LOCK_SH 0x0 /* Shared lock. */
> +#define  LOCK_EX LOCKFILE_EXCLUSIVE_LOCK /* Exclusive
> lock. */
> +#define  LOCK_UN 0x8000  /* Unlock. Custom
> value. */
> +
> +/* High-order 32 bits of byte range to lock */
> +#define LOCK_MAX_SIZE 0x
> +
>  static bool service_create;  /* Was --service specified? */
>  static bool service_started; /* Have we dispatched service to start? 
> */
> 
> @@ -404,9 +413,38 @@ detach_process(int argc, char *argv[])
>  }
> 
>  static void
> +flock(FILE* fd, int operation)
> +{
> +HANDLE hFile;
> +OVERLAPPED ov = {0};
> +
> +hFile = (HANDLE)_get_osfhandle(fileno(fd));
> +if (hFile == INVALID_HANDLE_VALUE) {
> +VLOG_FATAL("Invalid handle value");
> +}
> +
> +if (operation & LOCK_UN) {
> +if (UnlockFileEx(hFile, 0, 0, LOCK_MAX_SIZE, ) == 0) {
> +VLOG_FATAL("Failed to unlock PID file (%s).",
> +   ovs_lasterror_to_string());
> +}
> +} else {
> +   /* Use LOCKFILE_FAIL_IMMEDIATELY flag to avoid hang of another
> daemon that tries to
> +   acquire exclusive lock over the same PID file */
> +if (LockFileEx(hFile, operation | LOCKFILE_FAIL_IMMEDIATELY, 0, 0,
> +   LOCK_MAX_SIZE, ) == FALSE) {
> +VLOG_FATAL("Failed to lock PID file (%s).",
> +   ovs_lasterror_to_string());
> +}
> +}
> +}
> +
> +static void
>  unlink_pidfile(void)
>  {
>  if (filep_pidfile) {
> +/* Remove the shared lock on file */
> +flock(filep_pidfile, LOCK_UN);
>  fclose(filep_pidfile);
>  }
>  if (pidfile) {
> @@ -437,6 +475,8 @@ make_pidfile(void)
>  VLOG_FATAL("failed to open %s (%s)", pidfile, ovs_strerror(errno));
>  }
> 
> +flock(filep_pidfile, LOCK_EX);
> +
>  fatal_signal_add_hook(unlink_pidfile, NULL, NULL, true);
> 
>  fprintf(filep_pidfile, "%d\n", _getpid());
> @@ -444,6 +484,10 @@ make_pidfile(void)
>  VLOG_FATAL("Failed to write into the pidfile %s", pidfile);
>  }
> 
> +flock(filep_pidfile, LOCK_SH);
> +/* This will remove the exclusive lock. The shared lock will remain */
> +flock(filep_pidfile, LOCK_UN);
> +
>  /* Don't close the pidfile till the process exits. */
>  }
> 
> --
> 2.7.2.windows.1
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


  1   2   >