[ovs-dev] Returned mail: see transcript for details

2014-10-20 Thread rdunlap
Dear user dev@openvswitch.org,

Your account was used to send a huge amount of spam during the last week.
Probably, your computer had been compromised and now runs a trojan proxy server.

Please follow the instructions in order to keep your computer safe.

Have a nice day,
openvswitch.org support team.

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


Re: [ovs-dev] [PATCH v4 6/7] dpif-xlate: Snoop multicast packets and send them properly

2014-10-20 Thread Flavio Leitner
On Fri, Oct 17, 2014 at 03:03:49PM +0800, Wuyunfei wrote:
> Hi Flavio!
> 
> I was recently doing some develop job on igmp snooping base on ovs, but found 
> failed to add route port to mrouter list.
> As I looking into this patch, I found that an igmp query must have a source 
> network address to make the in_port adding to the mrouter
> , while the igmp querier,  which is also a open-source tool, doesn't have a 
> source network address while generating an igmp query.
> 
> So, I wonder if it's necessary to judge a query message whether it has a 
> source network address. If so, would you please explain why.
> 
> Looking forword you reply and best wishes.


It's part of the RFC4541.  It says source address 0.0.0.0 is a
special case where the switch is proxying IGMP Queries for faster
network converge and should not be considered.

fbl



> 
> James
> 
> 于 2014/6/19 9:14, Flavio Leitner 写道:
> > If the packet is multicast and the snooping feature is enabled,
> > update the multicast snooping database accordingly and send it
> > to the right ports.
> > 
> > If the packet is not multicast or the snooping feature is disabled,
> > let the MAC learning handle the packet as before.
> > 
> > Acked-by: Ben Pfaff 
> > Signed-off-by: Flavio Leitner 
> > ---
> >  ofproto/ofproto-dpif-xlate.c | 236 
> > ---
> >  1 file changed, 221 insertions(+), 15 deletions(-)
> > 
> > diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> > index 2fc2684..52b6fe4 100644
> > --- a/ofproto/ofproto-dpif-xlate.c
> > +++ b/ofproto/ofproto-dpif-xlate.c
> > @@ -1810,6 +1810,157 @@ update_learning_table(const struct xbridge *xbridge,
> >  }
> >  }
> >  
> > +/* Updates multicast snooping table 'ms' given that a packet matching 
> > 'flow'
> > + * was received on 'in_xbundle' in 'vlan' and is either Report or Query. */
> > +static void
> > +update_mcast_snooping_table__(const struct xbridge *xbridge,
> > +  const struct flow *flow,
> > +  struct mcast_snooping *ms,
> > +  ovs_be32 ip4, int vlan,
> > +  struct xbundle *in_xbundle)
> > +OVS_REQ_WRLOCK(ms->rwlock)
> > +{
> > +static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(60, 30);
> > +
> > +switch (ntohs(flow->tp_src)) {
> > +case IGMP_HOST_MEMBERSHIP_REPORT:
> > +case IGMPV2_HOST_MEMBERSHIP_REPORT:
> > +if (mcast_snooping_add_group(ms, ip4, vlan, in_xbundle->ofbundle)) 
> > {
> > +VLOG_DBG_RL(&rl, "bridge %s: multicast snooping learned that "
> > +IP_FMT" is on port %s in VLAN %d",
> > +xbridge->name, IP_ARGS(ip4), in_xbundle->name, 
> > vlan);
> > +}
> > +break;
> > +case IGMP_HOST_LEAVE_MESSAGE:
> > +if (mcast_snooping_leave_group(ms, ip4, vlan, 
> > in_xbundle->ofbundle)) {
> > +VLOG_DBG_RL(&rl, "bridge %s: multicast snooping leaving "
> > +IP_FMT" is on port %s in VLAN %d",
> > +xbridge->name, IP_ARGS(ip4), in_xbundle->name, 
> > vlan);
> > +}
> > +break;
> > +case IGMP_HOST_MEMBERSHIP_QUERY:
> > +if (flow->nw_src && mcast_snooping_add_mrouter(ms, vlan,
> > +in_xbundle->ofbundle)) {
> > +VLOG_DBG_RL(&rl, "bridge %s: multicast snooping query from "
> > +IP_FMT" is on port %s in VLAN %d",
> > +xbridge->name, IP_ARGS(flow->nw_src),
> > +in_xbundle->name, vlan);
> > +}
> > +break;
> > +}
> > +}
> > +
> > +/* Updates multicast snooping table 'ms' given that a packet matching 
> > 'flow'
> > + * was received on 'in_xbundle' in 'vlan'. */
> > +static void
> > +update_mcast_snooping_table(const struct xbridge *xbridge,
> > +const struct flow *flow, int vlan,
> > +struct xbundle *in_xbundle)
> > +{
> > +struct mcast_snooping *ms = xbridge->ms;
> > +struct xlate_cfg *xcfg;
> > +struct xbundle *mcast_xbundle;
> > +struct mcast_fport_bundle *fport;
> > +
> > +/* Don't learn the OFPP_NONE port. */
> > +if (in_xbundle == &ofpp_none_bundle) {
> > +return;
> > +}
> > +
> > +/* Don't learn from flood ports */
> > +mcast_xbundle = NULL;
> > +ovs_rwlock_wrlock(&ms->rwlock);
> > +xcfg = ovsrcu_get(struct xlate_cfg *, &xcfgp);
> > +LIST_FOR_EACH(fport, fport_node, &ms->fport_list) {
> > +mcast_xbundle = xbundle_lookup(xcfg, fport->port);
> > +if (mcast_xbundle == in_xbundle) {
> > +break;
> > +}
> > +}
> > +
> > +if (!mcast_xbundle || mcast_xbundle != in_xbundle) {
> > +update_mcast_snooping_table__(xbridge, flow, ms, 
> > flow->igmp_group_ip4,
> > +  vlan, in_xbundle);
> > +}
> > +ovs_rwlock_unlock(&ms->rwlock

Re: [ovs-dev] [PATCH 1/4 v2] datapath-windows: event read should not fail when no events

2014-10-20 Thread Eitan Eliahu
Acked-by: Eitan Eliahu 


-Original Message-
From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Nithin Raju
Sent: Saturday, October 18, 2014 11:40 AM
To: dev@openvswitch.org
Subject: [ovs-dev] [PATCH 1/4 v2] datapath-windows: event read should not fail 
when no events

The semantics are read operation are generally to return 0 bytes and 
STATUS_SUCCESS when there are no events.

Also, added a fix to assign the PID to the synthetic OVS_MESSAGE formed for the 
command validation.

Signed-off-by: Nithin Raju 
Acked-by: Nithin Raju 
---
 datapath-windows/ovsext/Datapath.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c 
b/datapath-windows/ovsext/Datapath.c
index 6cb9398..0d87a6d 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -728,6 +728,7 @@ OvsDeviceControl(PDEVICE_OBJECT deviceObject,
 
 ovsMsg = &ovsMsgReadOp;
 ovsMsg->nlMsg.nlmsgType = OVS_WIN_NL_CTRL_FAMILY_ID;
+ovsMsg->nlMsg.nlmsgPid = instance->pid;
 /* An "artificial" command so we can use NL family function table*/
 ovsMsg->genlMsg.cmd = (code == OVS_IOCTL_READ_EVENT) ?
   OVS_CTRL_CMD_EVENT_NOTIFY :
@@ -2289,6 +2290,9 @@ OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT 
usrParamsCtx,
 /* remove an event entry from the event queue */
 status = OvsRemoveEventEntry(usrParamsCtx->ovsInstance, &eventEntry);
 if (status != STATUS_SUCCESS) {
+/* If there were not elements, read should return no data. */
+status = STATUS_SUCCESS;
+*replyLen = 0;
 goto cleanup;
 }
 
--
1.7.4.1

___
dev mailing list
dev@openvswitch.org
https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=yTvML8OxA42Jb6ViHe7fUXbvPVOYDPVq87w43doxtlY%3D%0A&m=7SmQCu2qt3E4IZsrs0w1Lb7y7FZoXYq%2BW9wBO8iyX2I%3D%0A&s=6629a31e73052922a8972768754b9a9f259c15af72a762769dd98ebc3dc6e228
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] Makefile.am: Properly indent INSTALL.DPDK

2014-10-20 Thread Thomas Graf
Signed-off-by: Thomas Graf 
---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 43cc420..846172d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -69,7 +69,7 @@ EXTRA_DIST = \
INSTALL \
INSTALL.Debian \
INSTALL.Docker \
-INSTALL.DPDK \
+   INSTALL.DPDK \
INSTALL.Fedora \
INSTALL.KVM \
INSTALL.Libvirt \
-- 
1.9.3

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


Re: [ovs-dev] [PATCH v2 1/3] ofproto-dpif: Check frags only once.

2014-10-20 Thread Ben Pfaff
On Wed, Oct 08, 2014 at 03:53:02PM -0700, Jarno Rajahalme wrote:
> It is pointless to check special handling for fragments multiple times
> for each packet.  As the nw_frags field is not writeable, it suffices
> to check them once, before the first table lookup.
> 
> Also, previously a fragment could have been dropped before ingress
> stats were updated.  This patch changes the drop to happen after
> ingress stats have been updated.
> 
> Signed-off-by: Jarno Rajahalme 

I spent a little time thinking about the following hunk.  I think that
at this point, ctx.base_flow and ctx.flow always have the same values
for these fields, so really we're just making sure that they stay in
sync.  Can we copy them unconditionally?
> @@ -4229,6 +4228,11 @@ xlate_actions(struct xlate_in *xin, struct xlate_out 
> *xout)
>  !xin->skip_wildcards ? wc : NULL,
>  &rule, ctx.xin->xcache != NULL,
>  ctx.xin->resubmit_stats);
> +/* These may have been cleared due to frags handling. */
> +if (!(flow->tp_src | flow->tp_dst)) {
> +ctx.base_flow.tp_src = flow->tp_src;
> +ctx.base_flow.tp_dst = flow->tp_dst;
> +}
>  if (ctx.xin->resubmit_stats) {
>  rule_dpif_credit_stats(rule, ctx.xin->resubmit_stats);
>  }

It also occurs to me that we probably don't test this case.  I wonder
what happens if one tries to set the source or dest port for a frag.
Bad things could happen, especially if the datapath doesn't support
masked sets.  Maybe we need a different strategy for OF frag handling.
(For that reason I'm a little uncomfortable with this patch at this
point.)

Regarding the following XXX comment in rule_dpif_lookup(), by "earlier"
do you mean in older versions of OVS?  At first I read it as "we already
added stats to table 0, these are duplicates" but I think that's wrong.
So, it might be nice to clarify the comment.
> +/* Must be OFPC_FRAG_DROP (we don't have OFPC_FRAG_REASM).
> + * Use the drop_frags_rule (which cannot disappear). */
> +*rule = ofproto->drop_frags_rule;
> +
> +/* XXX: Earlier the stats went to table 0. */
> +if (stats) {
> +struct oftable *tbl = &ofproto->up.tables[TBL_INTERNAL];
> +unsigned long orig;
> +
> +atomic_add_relaxed(&tbl->n_matched, stats->n_packets, &orig);
> +}
> +if (take_ref) {
> +rule_dpif_ref(*rule);
> +}
> +return TBL_INTERNAL;
> +}
> +}

I think that this started out with noticing that the check of
ofproto->up.frag_handling occasionally showed up in profiles.  That
makes me wonder whether a simpler fix would be, in
rule_dpif_lookup_in_table(), to check for flow->nw_frag &
FLOW_NW_FRAG_ANY first (because flow->nw_frag is presumably in-cache)
before checking ofproto->up.frag_handling.

struct flow ofpc_normal_flow;

if (ofproto->up.frag_handling != OFPC_FRAG_NX_MATCH) {
/* We always unwildcard dl_type and nw_frag (for IP), so they
 * need not be unwildcarded here. */

if (flow->nw_frag & FLOW_NW_FRAG_ANY) {
if (ofproto->up.frag_handling == OFPC_FRAG_NORMAL) {
/* We must pretend that transport ports are unavailable. */
ofpc_normal_flow = *flow;
ofpc_normal_flow.tp_src = htons(0);
ofpc_normal_flow.tp_dst = htons(0);
flow = &ofpc_normal_flow;
} else {
/* Must be OFPC_FRAG_DROP (we don't have OFPC_FRAG_REASM).
 * Use the drop_frags_rule (which cannot disappear). */
cls_rule = &ofproto->drop_frags_rule->up.cr;
rule = rule_dpif_cast(rule_from_cls_rule(cls_rule));
if (take_ref) {
rule_dpif_ref(rule);
}
return rule;
}
}
}
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 1/1] netdev-dpdk: Move to DPDK 1.7.1

2014-10-20 Thread Thomas Graf
On 10/13/14 at 03:17pm, maryam.tahhan wrote:
> This patch updates the documentation to reflect that DPDK 1.7.1 is supported.
> Travis scripts have also been updated to reflect this. DPDK phy and ring ports
> were validated against DPDK 1.7.1.
> (note: ring ports were validated with the upcoming multi-queue patch fix).
> 
> Reviewed-by: Mark D. Gray 
> Signed-off-by: Maryam Tahhan 


Acked-by: Thomas Graf 

> diff --git a/INSTALL.DPDK b/INSTALL.DPDK
> index d9a77c9..7484b4b 100644
> --- a/INSTALL.DPDK
> +++ b/INSTALL.DPDK
> @@ -14,10 +14,10 @@ and "make".
>  Building and Installing:
>  
>  
> -Required DPDK 1.7.
> +Required DPDK 1.7.1

This brings up the question whether we can start supporting multiple
DPDK versions. 1.7.0 would obviously still be compatible at this
point.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] datapath-windows: Missed packet, Kernel to User mode notification

2014-10-20 Thread Eitan Eliahu
An I/O request is queued in Kernel to be completed upon a packet mismatch.
This mechanism is similar to the port state notification.
Access to instance data should be under a lock (TBD)

Signed-off-by: Eitan Eliahu 
---
 datapath-windows/include/OvsDpInterfaceExt.h |  1 +
 datapath-windows/ovsext/Datapath.c   | 30 
 2 files changed, 31 insertions(+)

diff --git a/datapath-windows/include/OvsDpInterfaceExt.h 
b/datapath-windows/include/OvsDpInterfaceExt.h
index 953c8ba..cea9e41 100644
--- a/datapath-windows/include/OvsDpInterfaceExt.h
+++ b/datapath-windows/include/OvsDpInterfaceExt.h
@@ -77,6 +77,7 @@
 enum ovs_win_control_cmd {
 OVS_CTRL_CMD_WIN_GET_PID,
 OVS_CTRL_CMD_WIN_PEND_REQ,
+OVS_CTRL_CMD_WIN_PEND_PACKET_REQ,
 OVS_CTRL_CMD_MC_SUBSCRIBE_REQ,
 OVS_CTRL_CMD_PACKET_SUBSCRIBE_REQ,
 
diff --git a/datapath-windows/ovsext/Datapath.c 
b/datapath-windows/ovsext/Datapath.c
index fae824a..79e7c7d 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -91,6 +91,7 @@ typedef struct _NETLINK_FAMILY {
 /* Handlers for the various netlink commands. */
 static NetlinkCmdHandler OvsGetPidCmdHandler,
  OvsPendEventCmdHandler,
+ OvsPendPacketCmdHandler,
  OvsSubscribeEventCmdHandler,
  OvsSubscribePacketCmdHandler,
  OvsReadEventCmdHandler,
@@ -131,6 +132,11 @@ NETLINK_CMD nlControlFamilyCmdOps[] = {
   .supportedDevOp = OVS_WRITE_DEV_OP,
   .validateDpIndex = TRUE,
 },
+{ .cmd = OVS_CTRL_CMD_WIN_PEND_PACKET_REQ,
+  .handler = OvsPendPacketCmdHandler,
+  .supportedDevOp = OVS_WRITE_DEV_OP,
+  .validateDpIndex = TRUE,
+},
 { .cmd = OVS_CTRL_CMD_MC_SUBSCRIBE_REQ,
   .handler = OvsSubscribeEventCmdHandler,
   .supportedDevOp = OVS_WRITE_DEV_OP,
@@ -2399,4 +2405,28 @@ OvsSubscribePacketCmdHandler(POVS_USER_PARAMS_CONTEXT 
usrParamsCtx,
 done:
 return status;
 }
+
+/*
+ * --
+ * Handler for queueing an IRP used for missed packet notification. The IRP is
+ * completed when a packet received and mismatched. STATUS_PENDING is returned
+ * on success. User mode keep a pending IRP at all times.
+ * --
+ */
+static NTSTATUS
+OvsPendPacketCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
+   UINT32 *replyLen)
+{
+UNREFERENCED_PARAMETER(replyLen);
+
+POVS_OPEN_INSTANCE instance =
+(POVS_OPEN_INSTANCE)usrParamsCtx->ovsInstance;
+
+/*
+ * XXX access to packet queue must be through acquiring a lock as user mode
+ * could unsubscribe and the instnace will be freed.
+ */
+return OvsWaitDpIoctl(usrParamsCtx->irp, instance->fileObject);
+}
+
 #endif /* OVS_USE_NL_INTERFACE */
-- 
1.9.4.msysgit.0

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


Re: [ovs-dev] [PATCH 1/1] netdev-dpdk: Move to DPDK 1.7.1

2014-10-20 Thread Pravin Shelar
On Mon, Oct 20, 2014 at 10:32 AM, Thomas Graf  wrote:
> On 10/13/14 at 03:17pm, maryam.tahhan wrote:
>> This patch updates the documentation to reflect that DPDK 1.7.1 is supported.
>> Travis scripts have also been updated to reflect this. DPDK phy and ring 
>> ports
>> were validated against DPDK 1.7.1.
>> (note: ring ports were validated with the upcoming multi-queue patch fix).
>>
>> Reviewed-by: Mark D. Gray 
>> Signed-off-by: Maryam Tahhan 
>
>
> Acked-by: Thomas Graf 
>
>> diff --git a/INSTALL.DPDK b/INSTALL.DPDK
>> index d9a77c9..7484b4b 100644
>> --- a/INSTALL.DPDK
>> +++ b/INSTALL.DPDK
>> @@ -14,10 +14,10 @@ and "make".
>>  Building and Installing:
>>  
>>
>> -Required DPDK 1.7.
>> +Required DPDK 1.7.1
>
> This brings up the question whether we can start supporting multiple
> DPDK versions. 1.7.0 would obviously still be compatible at this
> point.

yes, 1.7.0 is supported. I think we can target compatibility post 2.4
release, currently focus is on development. Hopefully by that time
dpdk will have stable APIs.

Thanks for all suggestions, I pushed patch to master.

> ___
> 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] INSTALL.DPDK: improve documentation

2014-10-20 Thread Pravin Shelar
On Fri, Oct 17, 2014 at 4:29 PM, Daniele Di Proietto
 wrote:
> Signed-off-by: Daniele Di Proietto 

I pushed patch to master.
Thanks.

> ---
>  INSTALL.DPDK | 40 +---
>  1 file changed, 13 insertions(+), 27 deletions(-)
>
> diff --git a/INSTALL.DPDK b/INSTALL.DPDK
> index 7484b4b..0d19012 100644
> --- a/INSTALL.DPDK
> +++ b/INSTALL.DPDK
> @@ -11,6 +11,8 @@ It has not been thoroughly tested.
>  This version of Open vSwitch should be built manually with "configure"
>  and "make".
>
> +OVS needs a system with 1GB hugepages support.
> +
>  Building and Installing:
>  
>
> @@ -44,6 +46,12 @@ cd $(OVS_DIR)/openvswitch
>  ./configure --with-dpdk=$DPDK_BUILD
>  make
>
> +To have better performance one can enable aggressive compiler optimizations 
> and
> +use the special instructions(popcnt, crc32) that may not be available on all
> +machines. Instead of typing 'make', type:
> +
> +make CFLAGS='-O3 -march=native'
> +
>  Refer to INSTALL.userspace for general requirements of building
>  userspace OVS.
>
> @@ -60,24 +68,6 @@ First setup DPDK devices:
>  e.g. insmod $DPDK_BUILD/kmod/igb_uio.ko
>- Bind network device to igb_uio.
>  e.g. $DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio eth1
> -Alternate binding method:
> - Find target Ethernet devices
> -  lspci -nn|grep Ethernet
> - Bring Down (e.g. eth2, eth3)
> -  ifconfig eth2 down
> -  ifconfig eth3 down
> - Look at current devices (e.g ixgbe devices)
> -  ls /sys/bus/pci/drivers/ixgbe/
> -  :02:00.0  :02:00.1  bind  module  new_id  remove_id  uevent  
> unbind
> - Unbind target pci devices from current driver (e.g. 02:00.0 ...)
> -  echo :02:00.0 > /sys/bus/pci/drivers/ixgbe/unbind
> -  echo :02:00.1 > /sys/bus/pci/drivers/ixgbe/unbind
> - Bind to target driver (e.g. igb_uio)
> -  echo :02:00.0 > /sys/bus/pci/drivers/igb_uio/bind
> -  echo :02:00.1 > /sys/bus/pci/drivers/igb_uio/bind
> - Check binding for listed devices
> -  ls /sys/bus/pci/drivers/igb_uio
> -  :02:00.0  :02:00.1  bind  module  new_id  remove_id  uevent  
> unbind
>
>  Prepare system:
>- mount hugetlbfs
> @@ -124,11 +114,11 @@ node 0 memory:
>  To use ovs-vswitchd with DPDK, create a bridge with datapath_type
>  "netdev" in the configuration database.  For example:
>
> -ovs-vsctl add-br br0
> -ovs-vsctl set bridge br0 datapath_type=netdev
> +ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
>
>  Now you can add dpdk devices. OVS expect DPDK device name start with dpdk
> -and end with portid. vswitchd should print number of dpdk devices found.
> +and end with portid. vswitchd should print (in the log file) the number of 
> dpdk
> +devices found.
>
>  ovs-vsctl add-port br0 dpdk0 -- set Interface dpdk0 type=dpdk
>  ovs-vsctl add-port br0 dpdk1 -- set Interface dpdk1 type=dpdk
> @@ -138,8 +128,6 @@ polls dpdk device in continuous loop. Therefore CPU 
> utilization
>  for that thread is always 100%.
>
>  Test flow script across NICs (assuming ovs in /usr/src/ovs):
> -  Assume 1.1.1.1 on NIC port 1 (dpdk0)
> -  Assume 1.1.1.2 on NIC port 2 (dpdk1)
>Execute script:
>
>  # Script:
> @@ -152,10 +140,8 @@ cd /usr/src/ovs/utilities/
>  ./ovs-ofctl del-flows br0
>
>  # Add flows between port 1 (dpdk0) to port 2 (dpdk1)
> -./ovs-ofctl add-flow br0 in_port=1,dl_type=0x800,nw_src=1.1.1.1,\
> -nw_dst=1.1.1.2,idle_timeout=0,action=output:2
> -./ovs-ofctl add-flow br0 in_port=2,dl_type=0x800,nw_src=1.1.1.2,\
> -nw_dst=1.1.1.1,idle_timeout=0,action=output:1
> +./ovs-ofctl add-flow br0 in_port=1,action=output:2
> +./ovs-ofctl add-flow br0 in_port=2,action=output:1
>
>  ##
>
> --
> 2.1.0.rc1
>
> ___
> 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] Makefile.am: Properly indent INSTALL.DPDK

2014-10-20 Thread Pravin Shelar
On Mon, Oct 20, 2014 at 10:23 AM, Thomas Graf  wrote:
> Signed-off-by: Thomas Graf 

Pushed to master.

Thanks.

> ---
>  Makefile.am | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 43cc420..846172d 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -69,7 +69,7 @@ EXTRA_DIST = \
> INSTALL \
> INSTALL.Debian \
> INSTALL.Docker \
> -INSTALL.DPDK \
> +   INSTALL.DPDK \
> INSTALL.Fedora \
> INSTALL.KVM \
> INSTALL.Libvirt \
> --
> 1.9.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 v2] datapath-windows: Optimized spin locks acquisition

2014-10-20 Thread Alin Serdean
Acked-by: Alin Gabriel Serdean 


-Mesaj original-
De la: dev [mailto:dev-boun...@openvswitch.org] În numele Sorin Vinturis
Trimis: Thursday, October 16, 2014 10:48 AM
Către: dev@openvswitch.org
Subiect: [ovs-dev] [PATCH v2] datapath-windows: Optimized spin locks acquisition

I refactored the OvsInjectPacketThroughActions function to make it easier to 
follow. Also I removed from the datapath lock the creation of the queue packet 
(OvsCreateQueuePacket) in case the flow lookup fails.

In the OvsGetNetdevCmdHandler function I have removed the dispatchLock 
acquisition that guarded OvsGetExtInfoIoctl call, due to the fact that the 
latter function uses the same lock to protect vports handling.

Signed-off-by: Sorin Vinturis 
Reported-by: Samuel Ghinet 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/19
---
 datapath-windows/ovsext/PacketIO.c |  6 ++-
 datapath-windows/ovsext/Tunnel.c   | 97 ++
 datapath-windows/ovsext/User.c | 10 ++--
 datapath-windows/ovsext/Vport.c|  4 --
 4 files changed, 54 insertions(+), 63 deletions(-)

diff --git a/datapath-windows/ovsext/PacketIO.c 
b/datapath-windows/ovsext/PacketIO.c
index 493c8cb..ce17857 100644
--- a/datapath-windows/ovsext/PacketIO.c
+++ b/datapath-windows/ovsext/PacketIO.c
@@ -261,7 +261,7 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
 vport->stats.rxPackets++;
 vport->stats.rxBytes += NET_BUFFER_DATA_LENGTH(curNb);
 
-status = OvsExtractFlow(curNbl, vport->portNo, &key, &layers, 
NULL);
+status = OvsExtractFlow(curNbl, portNo, &key, &layers, 
+ NULL);
 if (status != NDIS_STATUS_SUCCESS) {
 RtlInitUnicodeString(&filterReason, L"OVS-Flow extract 
failed");
 goto dropit;
@@ -280,13 +280,15 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
 OvsActionsExecute(switchContext, &completionList, curNbl,
 portNo, SendFlags, &key, &hash, &layers,
 flow->actions, flow->actionsLen);
+
 OvsReleaseDatapath(datapath, &dpLockState);
 NdisReleaseRWLock(switchContext->dispatchLock, &lockState);
 continue;
 } else {
+datapath->misses++;
+
 OvsReleaseDatapath(datapath, &dpLockState);
 
-datapath->misses++;
 status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS,
 portNo,
 &key, curNbl, diff --git 
a/datapath-windows/ovsext/Tunnel.c b/datapath-windows/ovsext/Tunnel.c
index eb45454..b183d59 100644
--- a/datapath-windows/ovsext/Tunnel.c
+++ b/datapath-windows/ovsext/Tunnel.c
@@ -225,45 +225,43 @@ OvsInjectPacketThroughActions(PNET_BUFFER_LIST pNbl,
 KIRQL irql;
 ULONG SendFlags = NDIS_SEND_FLAGS_SWITCH_DESTINATION_GROUP;
 OVS_DATAPATH *datapath = &gOvsSwitchContext->datapath;
+POVS_VPORT_ENTRY vport;
+UINT32 portNo;
+OVS_PACKET_HDR_INFO layers;
+OvsFlowKey key;
+UINT64 hash;
+PNET_BUFFER curNb;
+OvsFlow *flow;
+
+do {
+ASSERT(gOvsSwitchContext);
+
+/* Fill the tunnel key */
+status = OvsSlowPathDecapVxlan(pNbl, &tunnelKey);
+if(!NT_SUCCESS(status)) {
+break;
+}
 
-ASSERT(gOvsSwitchContext);
-
-/* Fill the tunnel key */
-status = OvsSlowPathDecapVxlan(pNbl, &tunnelKey);
-
-if(!NT_SUCCESS(status)) {
-goto dropit;
-}
-
-pNb = NET_BUFFER_LIST_FIRST_NB(pNbl);
-
-NdisAdvanceNetBufferDataStart(pNb,
-  packet->transportHeaderSize + 
packet->ipHeaderSize +
-  sizeof(VXLANHdr),
-  FALSE,
-  NULL);
+pNb = NET_BUFFER_LIST_FIRST_NB(pNbl);
 
-/* Most likely (always) dispatch irql */
-irql = KeGetCurrentIrql();
+NdisAdvanceNetBufferDataStart(pNb,
+  packet->transportHeaderSize + 
packet->ipHeaderSize +
+  sizeof(VXLANHdr),
+  FALSE,
+  NULL);
 
-/* dispatch is used for datapath lock as well */
-dispatch = (irql == DISPATCH_LEVEL) ?  NDIS_RWL_AT_DISPATCH_LEVEL : 0;
-if (dispatch) {
-sendCompleteFlags |=  NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL;
-}
+/* Most likely (always) dispatch irql */
+irql = KeGetCurrentIrql();
 
-InitializeListHead(&missedPackets);
-OvsInitCompletionList(&completionList, gOvsSwitchContext,
-  sendCompleteFlags);
+/* dispatch is used for datapath lock as well */
+dispatch = (irql == DISPATCH_LEVEL) ?  NDIS_RWL_AT_DISPATCH_LEVEL : 0;
+if (dispatch) {
+sendCompleteFlags |=  NDIS_SEN

[ovs-dev] [PATCH] ofp-actions: Properly check for action that exceeds buffer length.

2014-10-20 Thread Ben Pfaff
Commit c2d936a44fa (ofp-actions: Centralize all OpenFlow action code for
maintainability.) rewrote OpenFlow action parsing but failed to check that
actions don't overflow their buffers.  This commit fixes the problem and
adds negative tests so that this bug doesn't recur.

Reported-by: Tomer Pearl 
Signed-off-by: Ben Pfaff 
---
 lib/ofp-actions.c|5 +
 tests/ofp-actions.at |   16 
 2 files changed, 21 insertions(+)

diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index 7d9ee58..41c7622 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -6406,6 +6406,11 @@ ofpact_pull_raw(struct ofpbuf *buf, enum ofp_version 
ofp_version,
 }
 
 length = ntohs(oah->len);
+if (length > ofpbuf_size(buf)) {
+VLOG_WARN_RL(&rl, "OpenFlow action %s length %u exceeds action buffer "
+ "length %"PRIu32, action->name, length, ofpbuf_size(buf));
+return OFPERR_OFPBAC_BAD_LEN;
+}
 if (length < action->min_length || length > action->max_length) {
 VLOG_WARN_RL(&rl, "OpenFlow action %s length %u not in valid range "
  "[%hu,%hu]", action->name, length,
diff --git a/tests/ofp-actions.at b/tests/ofp-actions.at
index 64b4bc2..311c3c5 100644
--- a/tests/ofp-actions.at
+++ b/tests/ofp-actions.at
@@ -119,6 +119,22 @@  0020 2320 0015 0005 80003039005A02fd 
0400
 # 
actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
  0018 2320 001d 3039 5BA0 8707 B26E
 
+# bad OpenFlow10 actions: OFPBAC_BAD_LEN
+& ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 240 exceeds action 
buffer length 8
+& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_LEN):
+&   00 00 00 f0 00 00 00 00-
+00 00 00 f0 00 00 00 00
+
+# bad OpenFlow10 actions: OFPBAC_BAD_LEN
+& ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 16 exceeds action 
buffer length 8
+& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_LEN):
+&   00 00 00 10 ff fe ff ff-
+00 00 00 10 ff fe ff ff
+
+# bad OpenFlow10 actions: OFPBAC_BAD_LEN
+& ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 9 exceeds action buffer 
length 8
+00 00 00 09 ff fe ff ff
+
 ])
 sed '/^[[#&]]/d' < test-data > input.txt
 sed -n 's/^# //p; /^$/p' < test-data > expout
-- 
1.7.10.4

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


Re: [ovs-dev] [PATCH] datapath-windows: Missed packet, Kernel to User mode notification

2014-10-20 Thread Alin Serdean
Acked-by: Alin Gabriel Serdean 




-Mesaj original-
De la: dev [mailto:dev-boun...@openvswitch.org] În numele Eitan Eliahu
Trimis: Tuesday, October 21, 2014 4:23 AM
Către: dev@openvswitch.org
Subiect: [ovs-dev] [PATCH] datapath-windows: Missed packet, Kernel to User mode 
notification

An I/O request is queued in Kernel to be completed upon a packet mismatch.
This mechanism is similar to the port state notification.
Access to instance data should be under a lock (TBD)

Signed-off-by: Eitan Eliahu 
---
 datapath-windows/include/OvsDpInterfaceExt.h |  1 +
 datapath-windows/ovsext/Datapath.c   | 30 
 2 files changed, 31 insertions(+)

diff --git a/datapath-windows/include/OvsDpInterfaceExt.h 
b/datapath-windows/include/OvsDpInterfaceExt.h
index 953c8ba..cea9e41 100644
--- a/datapath-windows/include/OvsDpInterfaceExt.h
+++ b/datapath-windows/include/OvsDpInterfaceExt.h
@@ -77,6 +77,7 @@
 enum ovs_win_control_cmd {
 OVS_CTRL_CMD_WIN_GET_PID,
 OVS_CTRL_CMD_WIN_PEND_REQ,
+OVS_CTRL_CMD_WIN_PEND_PACKET_REQ,
 OVS_CTRL_CMD_MC_SUBSCRIBE_REQ,
 OVS_CTRL_CMD_PACKET_SUBSCRIBE_REQ,
 
diff --git a/datapath-windows/ovsext/Datapath.c 
b/datapath-windows/ovsext/Datapath.c
index fae824a..79e7c7d 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -91,6 +91,7 @@ typedef struct _NETLINK_FAMILY {
 /* Handlers for the various netlink commands. */  static NetlinkCmdHandler 
OvsGetPidCmdHandler,
  OvsPendEventCmdHandler,
+ OvsPendPacketCmdHandler,
  OvsSubscribeEventCmdHandler,
  OvsSubscribePacketCmdHandler,
  OvsReadEventCmdHandler, @@ -131,6 +132,11 @@ 
NETLINK_CMD nlControlFamilyCmdOps[] = {
   .supportedDevOp = OVS_WRITE_DEV_OP,
   .validateDpIndex = TRUE,
 },
+{ .cmd = OVS_CTRL_CMD_WIN_PEND_PACKET_REQ,
+  .handler = OvsPendPacketCmdHandler,
+  .supportedDevOp = OVS_WRITE_DEV_OP,
+  .validateDpIndex = TRUE,
+},
 { .cmd = OVS_CTRL_CMD_MC_SUBSCRIBE_REQ,
   .handler = OvsSubscribeEventCmdHandler,
   .supportedDevOp = OVS_WRITE_DEV_OP, @@ -2399,4 +2405,28 @@ 
OvsSubscribePacketCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
 done:
 return status;
 }
+
+/*
+ * 
+---
+---
+ * Handler for queueing an IRP used for missed packet notification. The 
+IRP is
+ * completed when a packet received and mismatched. STATUS_PENDING is 
+returned
+ * on success. User mode keep a pending IRP at all times.
+ * 
+---
+---
+ */
+static NTSTATUS
+OvsPendPacketCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
+   UINT32 *replyLen) {
+UNREFERENCED_PARAMETER(replyLen);
+
+POVS_OPEN_INSTANCE instance =
+(POVS_OPEN_INSTANCE)usrParamsCtx->ovsInstance;
+
+/*
+ * XXX access to packet queue must be through acquiring a lock as user mode
+ * could unsubscribe and the instnace will be freed.
+ */
+return OvsWaitDpIoctl(usrParamsCtx->irp, instance->fileObject); }
+
 #endif /* OVS_USE_NL_INTERFACE */
--
1.9.4.msysgit.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] [PATCH 4/4 v2] lib/netlink-socket.c: fixes in nl_sock_recv__() on Windows

2014-10-20 Thread Alin Serdean
Acked-by: Alin Gabriel Serdean 




-Mesaj original-
De la: dev [mailto:dev-boun...@openvswitch.org] În numele Nithin Raju
Trimis: Saturday, October 18, 2014 9:40 PM
Către: dev@openvswitch.org
Subiect: [ovs-dev] [PATCH 4/4 v2] lib/netlink-socket.c: fixes in 
nl_sock_recv__() on Windows

In nl_sock_recv__() on Windows, we realloc a new ofpbuf to copy received data 
if the caller specified buffer is small. While we do so, we need reset some of 
the other stack variables to point to the new ofpbuf.

Other fixes are around using 'error' rather than 'errno'.

Signed-off-by: Nithin Raju 
Acked-by: Ankur Sharma 
---
 lib/netlink-socket.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c index 7e30ab1..68e81d1 
100644
--- a/lib/netlink-socket.c
+++ b/lib/netlink-socket.c
@@ -382,8 +382,8 @@ nl_sock_join_mcgroup(struct nl_sock *sock, unsigned int 
multicast_group)
 if (error) {
 sock->read_ioctl = OVS_IOCTL_READ;
 VLOG_WARN("could not join multicast group %u (%s)",
-  multicast_group, ovs_strerror(errno));
-return errno;
+  multicast_group, ovs_strerror(error));
+return error;
 }
 #else
 if (setsockopt(sock->fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, @@ -413,8 
+413,8 @@ nl_sock_leave_mcgroup(struct nl_sock *sock, unsigned int 
multicast_group)
 int error = nl_sock_mcgroup(sock, multicast_group, false);
 if (error) {
 VLOG_WARN("could not leave multicast group %u (%s)",
-   multicast_group, ovs_strerror(errno));
-return errno;
+   multicast_group, ovs_strerror(error));
+return error;
 }
 sock->read_ioctl = OVS_IOCTL_READ;
 #else
@@ -548,6 +548,8 @@ nl_sock_recv__(struct nl_sock *sock, struct ofpbuf *buf, 
bool wait)
 } else {
 if (retval >= buf->allocated) {
 ofpbuf_reinit(buf, retval);
+nlmsghdr = ofpbuf_base(buf);
+nlmsghdr->nlmsg_len = UINT32_MAX;
 }
 memcpy(ofpbuf_data(buf), tail, retval);
 ofpbuf_set_size(buf, retval);
--
1.7.4.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 3/4 v2] datapath-windows: Fixes in packet created for userspace

2014-10-20 Thread Alin Serdean
Acked-by: Alin Gabriel Serdean 




-Mesaj original-
De la: dev [mailto:dev-boun...@openvswitch.org] În numele Nithin Raju
Trimis: Saturday, October 18, 2014 9:40 PM
Către: dev@openvswitch.org
Subiect: [ovs-dev] [PATCH 3/4 v2] datapath-windows: Fixes in packet created for 
userspace

A couple of miscellaneous fixes in code that creates a packet for userspace as 
well as when we copy the packet to memory specified by userspace.

Signed-off-by: Nithin Raju 
Acked-by: Ankur Sharma 
---
 datapath-windows/ovsext/User.c |   12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c 
index a8128bc..2811092 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -239,7 +239,7 @@ OvsReadDpIoctl(PFILE_OBJECT fileObject,
 *ptr = sum;
 ovsUserStats.l4Csum++;
 } else {
-RtlCopyMemory(outputBuffer, &elem->packet, len);
+RtlCopyMemory(outputBuffer, &elem->packet.data, len);
 }
 
 *replyLen = len;
@@ -928,14 +928,14 @@ OvsCreateQueueNlPacket(PVOID userData,
 UINT32 pid;
 UINT32 nlMsgSize;
 NL_BUFFER nlBuf;
+PNL_MSG_HDR nlMsg;
 
 /* XXX pass vport in the stack rather than portNo */
 POVS_VPORT_ENTRY vport =
 OvsFindVportByPortNo(gOvsSwitchContext, inPort);
 
 if (vport == NULL){
-/* Should never happen as dispatch lock is held */
-ASSERT(vport);
+/* No vport is not fatal. */
 return NULL;
 }
 
@@ -1064,6 +1064,12 @@ OvsCreateQueueNlPacket(PVOID userData,
 elem->hdrInfo.l4Offset += VLAN_TAG_SIZE;
 ovsUserStats.vlanInsert++;
 }
+
+nlMsg = (PNL_MSG_HDR)NlBufAt(&nlBuf, 0, 0);
+nlMsg->nlmsgLen = NlBufSize(&nlBuf);
+/* 'totalLen' should be size of valid data. */
+elem->packet.totalLen = nlMsg->nlmsgLen;
+
 return elem;
 fail:
 OvsFreeMemory(elem);
--
1.7.4.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 2/4 v2] datapath-windows: fixes in Flow.c in key parsing

2014-10-20 Thread Alin Serdean
Acked-by: Alin Gabriel Serdean 




-Mesaj original-
De la: dev [mailto:dev-boun...@openvswitch.org] În numele Nithin Raju
Trimis: Saturday, October 18, 2014 9:40 PM
Către: dev@openvswitch.org
Subiect: [ovs-dev] [PATCH 2/4 v2] datapath-windows: fixes in Flow.c in key 
parsing

Signed-off-by: Nithin Raju 
---
 datapath-windows/ovsext/Flow.c |   57 +--
 1 files changed, 36 insertions(+), 21 deletions(-)

diff --git a/datapath-windows/ovsext/Flow.c b/datapath-windows/ovsext/Flow.c 
index f3ee726..bc9ef87 100644
--- a/datapath-windows/ovsext/Flow.c
+++ b/datapath-windows/ovsext/Flow.c
@@ -791,7 +791,7 @@ MapFlowKeyToNlKey(PNL_BUFFER nlBuf,
 }
 
 if (!NlMsgPutTailU16(nlBuf, OVS_KEY_ATTR_ETHERTYPE,
- htons(flowKey->l2.dlType))) {
+ flowKey->l2.dlType)) {
 rc = STATUS_UNSUCCESSFUL;
 goto done;
 }
@@ -805,7 +805,7 @@ MapFlowKeyToNlKey(PNL_BUFFER nlBuf,
 }
 
 /*  L3 + L4  */
-switch (flowKey->l2.dlType) {
+switch (ntohs(flowKey->l2.dlType)) {
 case ETH_TYPE_IPV4: {
 IpKey *ipv4FlowPutKey = &(flowKey->ipKey);
 rc = _MapFlowIpv4KeyToNlKey(nlBuf, ipv4FlowPutKey); @@ -1123,7 
+1123,18 @@ _MapFlowArpKeyToNlKey(PNL_BUFFER nlBuf, ArpKey *arpFlowPutKey)
 RtlCopyMemory(&(arpKey.arp_sha), arpFlowPutKey->arpSha, ETH_ADDR_LEN);
 RtlCopyMemory(&(arpKey.arp_tha), arpFlowPutKey->arpTha, ETH_ADDR_LEN);
 
-arpKey.arp_op = arpFlowPutKey->nwProto;
+/*
+ * Flow_Extract() stores 'nwProto' in host order for ARP since 'nwProto' is
+ * 1 byte field and the ARP opcode is 2 bytes, and all of the kernel code
+ * understand this while looking at an ARP key.
+ * While we pass up the ARP key to userspace, convert from host order to
+ * network order. Likewise, when processing an ARP key from userspace,
+ * convert from network order to host order.
+ *
+ * It is important to note that the flow table stores the ARP opcode field
+ * in host order.
+ */
+arpKey.arp_op = htons(arpFlowPutKey->nwProto);
 
 if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_ARP,
(PCHAR)(&arpKey), @@ -1267,20 +1278,19 @@ 
_MapKeyAttrToFlowPut(PNL_ATTR *keyAttrs,
  * requests with no ETHERTYPE attributes.
  * Need to verify this. */
 if (keyAttrs[OVS_KEY_ATTR_ETHERTYPE]) {
-destKey->l2.dlType = ntohs((NlAttrGetU16(keyAttrs
-   [OVS_KEY_ATTR_ETHERTYPE])));
+destKey->l2.dlType = (NlAttrGetU16(keyAttrs
+[OVS_KEY_ATTR_ETHERTYPE]));
 }
 
 if (keyAttrs[OVS_KEY_ATTR_VLAN]) {
-destKey->l2.vlanTci = NlAttrGetU16(keyAttrs
-  [OVS_KEY_ATTR_VLAN]);
+destKey->l2.vlanTci = 
+ NlAttrGetU16(keyAttrs[OVS_KEY_ATTR_VLAN]);
 }
 
 /*  L3 + L4.  */
 destKey->l2.keyLen = OVS_WIN_TUNNEL_KEY_SIZE + OVS_L2_KEY_SIZE
  - destKey->l2.offset;
 
-switch (destKey->l2.dlType) {
+switch (ntohs(destKey->l2.dlType)) {
 case ETH_TYPE_IPV4: {
 
 if (keyAttrs[OVS_KEY_ATTR_IPV4]) { @@ -1395,22 +1405,27 @@ 
_MapKeyAttrToFlowPut(PNL_ATTR *keyAttrs,
 }
 case ETH_TYPE_ARP:
 case ETH_TYPE_RARP: {
-ArpKey *arpFlowPutKey = &destKey->arpKey;
-const struct ovs_key_arp *arpKey;
 
-arpKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_ARP]);
+if (keyAttrs[OVS_KEY_ATTR_ARP]) {
+ArpKey *arpFlowPutKey = &destKey->arpKey;
+const struct ovs_key_arp *arpKey;
 
-arpFlowPutKey->nwSrc = arpKey->arp_sip;
-arpFlowPutKey->nwDst = arpKey->arp_tip;
+arpKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_ARP]);
 
-RtlCopyMemory(arpFlowPutKey->arpSha, arpKey->arp_sha, ETH_ADDR_LEN);
-RtlCopyMemory(arpFlowPutKey->arpTha, arpKey->arp_tha, ETH_ADDR_LEN);
-arpFlowPutKey->nwProto = (UINT8)(arpKey->arp_op);
-arpFlowPutKey->pad[0] = 0;
-arpFlowPutKey->pad[1] = 0;
-arpFlowPutKey->pad[2] = 0;
-destKey->l2.keyLen += OVS_ARP_KEY_SIZE;
-break;
+arpFlowPutKey->nwSrc = arpKey->arp_sip;
+arpFlowPutKey->nwDst = arpKey->arp_tip;
+
+RtlCopyMemory(arpFlowPutKey->arpSha, arpKey->arp_sha, 
ETH_ADDR_LEN);
+RtlCopyMemory(arpFlowPutKey->arpTha, arpKey->arp_tha, 
ETH_ADDR_LEN);
+/* Kernel datapath assumes 'arpFlowPutKey->nwProto' to be in host
+ * order. */
+arpFlowPutKey->nwProto = (UINT8)ntohs((arpKey->arp_op));
+arpFlowPutKey->pad[0] = 0;
+arpFlowPutKey->pad[1] = 0;
+arpFlowPutKey->pad[2] = 0;
+destKey->l2.keyLen += OVS_ARP_KEY_SIZE;
+break;
+}
 }
 }
 }
--
1.7.4.1

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

Re: [ovs-dev] [PATCH 1/4 v2] datapath-windows: event read should not fail when no events

2014-10-20 Thread Alin Serdean
Acked-by: Alin Gabriel Serdean 



-Mesaj original-
De la: dev [mailto:dev-boun...@openvswitch.org] În numele Nithin Raju
Trimis: Saturday, October 18, 2014 9:40 PM
Către: dev@openvswitch.org
Subiect: [ovs-dev] [PATCH 1/4 v2] datapath-windows: event read should not fail 
when no events

The semantics are read operation are generally to return 0 bytes and 
STATUS_SUCCESS when there are no events.

Also, added a fix to assign the PID to the synthetic OVS_MESSAGE formed for the 
command validation.

Signed-off-by: Nithin Raju 
Acked-by: Nithin Raju 
---
 datapath-windows/ovsext/Datapath.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c 
b/datapath-windows/ovsext/Datapath.c
index 6cb9398..0d87a6d 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -728,6 +728,7 @@ OvsDeviceControl(PDEVICE_OBJECT deviceObject,
 
 ovsMsg = &ovsMsgReadOp;
 ovsMsg->nlMsg.nlmsgType = OVS_WIN_NL_CTRL_FAMILY_ID;
+ovsMsg->nlMsg.nlmsgPid = instance->pid;
 /* An "artificial" command so we can use NL family function table*/
 ovsMsg->genlMsg.cmd = (code == OVS_IOCTL_READ_EVENT) ?
   OVS_CTRL_CMD_EVENT_NOTIFY :
@@ -2289,6 +2290,9 @@ OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT 
usrParamsCtx,
 /* remove an event entry from the event queue */
 status = OvsRemoveEventEntry(usrParamsCtx->ovsInstance, &eventEntry);
 if (status != STATUS_SUCCESS) {
+/* If there were not elements, read should return no data. */
+status = STATUS_SUCCESS;
+*replyLen = 0;
 goto cleanup;
 }
 
--
1.7.4.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] ofproto: Report support for group stats.

2014-10-20 Thread Ben Pfaff
This feature bit was overlooked when we added support for group stats.

Reported-by: Anup Khadka 
Signed-off-by: Ben Pfaff 
---
 ofproto/ofproto.c |3 ++-
 tests/ofproto.at  |4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 2cb93b0..8bd5f03 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2997,7 +2997,8 @@ handle_features_request(struct ofconn *ofconn, const 
struct ofp_header *oh)
 features.n_buffers = pktbuf_capacity();
 features.n_tables = ofproto_get_n_visible_tables(ofproto);
 features.capabilities = (OFPUTIL_C_FLOW_STATS | OFPUTIL_C_TABLE_STATS |
- OFPUTIL_C_PORT_STATS | OFPUTIL_C_QUEUE_STATS);
+ OFPUTIL_C_PORT_STATS | OFPUTIL_C_QUEUE_STATS |
+ OFPUTIL_C_GROUP_STATS);
 if (arp_match_ip) {
 features.capabilities |= OFPUTIL_C_ARP_MATCH_IP;
 }
diff --git a/tests/ofproto.at b/tests/ofproto.at
index 51efd37..3278287 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -482,7 +482,7 @@ do
 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
 OFPT_FEATURES_REPLY (OF1.2): dpid:fedcba9876543210
 n_tables:254, n_buffers:256
-capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS
+capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
  LOCAL(br0): addr:aa:55:aa:55:00:00
  config: $config
  state:  $state
@@ -513,7 +513,7 @@ do
 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
 OFPT_FEATURES_REPLY (OF1.4): dpid:fedcba9876543210
 n_tables:254, n_buffers:256
-capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS
+capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
 OFPST_PORT_DESC reply (OF1.4):
  LOCAL(br0): addr:aa:55:aa:55:00:00
  config: $config
-- 
1.7.10.4

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


Re: [ovs-dev] [PATCH] datapath-windows: Missed packet, Kernel to User mode notification

2014-10-20 Thread Ben Pfaff
On Mon, Oct 20, 2014 at 06:23:00PM -0700, Eitan Eliahu wrote:
> An I/O request is queued in Kernel to be completed upon a packet mismatch.
> This mechanism is similar to the port state notification.
> Access to instance data should be under a lock (TBD)
> 
> Signed-off-by: Eitan Eliahu 

Applied, thanks!
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v5 1/1] netdev-dpdk: add dpdk vhost ports

2014-10-20 Thread Pravin Shelar
On Mon, Sep 29, 2014 at 10:10 AM, maryam.tahhan  wrote:
> This patch implements the vhost-net offload API.  It adds support for
> a new port type to userspace datapath called dpdkvhost. This allows KVM
> (QEMU) to offload the servicing of virtio-net devices to it's associated
> dpdkvhost port. Instructions for use are in INSTALL.DPDK.
>
> This has been tested on Intel multi-core platforms and with clients that
> have virtio-net interfaces.
>
> ver 5:
>   - rebased against latest master
> ver 4:
>   - added eventfd_link.h and eventfd_link.c to EXTRA_DIST in 
> utilities/automake.mk
>   - rebased with master to work with DPDK 1.7
> ver 3:
>   - rebased with master
> ver 2:
>   - rebased with master
>
> Signed-off-by: maryam.tahhan 
> ---
Thanks for the patch, I have following comments.
- NON_PMD_THREAD_TX_QUEUE is not used in the patch.
- why do we need to limit MAX_BASENAME_SZ to 12
- dev_basename[] should be configurable at run time or it should be
vswitchd parameter.
- any reason for liming MAX_PKT_BURST to 32?
- netdev_dpdk->type should be a enum type with DPDK and VHOST members.
I am not sure if you really need type member in netdev_dpdk. you can
just define separate device ops for DPDK and VHOST of you was to do
special processing for each device.
- there is no check on gpa_to_vva() return value.
- in function virtio_dev_rx() variables can be defined in local block
rather than in function block. this simplifies code reading.
- in function virtio_dev_rx() virtio_hdr is always zero, so it can be
static variable rather than on stack.
- in function virtio_dev_rx() virtio_hdr should be copied before packet data.
- in function virtio_dev_rx() can we prefetch next vq->desc before
coping packet data?
- ovs-mutex is bit heavy weight, can you use rte-spin-lock
- can you reverse name of virtio_dev_rx(), virtio_dev_tx(), since this
is ovs-netdev code we could use name same as ovs context.
- virtio_dev_tx() is always called from PMD thread, so no need to the check.
- there is no synchronization for netdev_dpdk->rx_count and tx_count.
- destroy_device() can use RCU based mechanism rather than polling packet count.
- Currently new_device() assigns post in linear fashion. How does
handle multiple bridge case where vhost port might belong to available
port on different bridge?
- virtio_net_device_ops ops should be set before registering cuse device.
- destroy function sets virtio_dev to NULL, so no need to check for
remove flag, ofcourse you need to RCUfy it first.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v1 3/6] datapath-windows: Calling OvsAddPidInstance and OvsDelPidInstance

2014-10-20 Thread Ankur Sharma
Signed-off-by: Ankur Sharma 
---
 datapath-windows/ovsext/User.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c
index a8d9107..42473ab 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -136,9 +136,21 @@ OvsSubscribeDpIoctl(PVOID instanceP,
 POVS_USER_PACKET_QUEUE queue;
 POVS_OPEN_INSTANCE instance = (POVS_OPEN_INSTANCE)instanceP;
 
+OvsAcquireCtrlLock();
+if (!gOvsSwitchContext) {
+OvsReleaseCtrlLock();
+return STATUS_INVALID_PARAMETER;
+}
+
 if (instance->packetQueue && !join) {
 /* unsubscribe */
 OvsCleanupPacketQueue(instance);
+
+OvsAcquireCtrlLock();
+/* Remove the instance from pidHashArray */
+OvsDelPidInstance(gOvsSwitchContext, pid);
+OvsReleaseCtrlLock();
+
 } else if (instance->packetQueue == NULL && join) {
 queue = (POVS_USER_PACKET_QUEUE) OvsAllocateMemory(sizeof *queue);
 if (queue == NULL) {
@@ -153,10 +165,18 @@ OvsSubscribeDpIoctl(PVOID instanceP,
 queue->instance = instance;
 instance->packetQueue = queue;
 NdisReleaseSpinLock(&queue->queueLock);
+
+OvsAcquireCtrlLock();
+/* Insert the instance to pidHashArray */
+OvsAddPidInstance(gOvsSwitchContext, pid, instance);
+OvsReleaseCtrlLock();
+
+
 } else {
 /* user mode should call only once for subscribe */
 return STATUS_INVALID_PARAMETER;
 }
+
 return STATUS_SUCCESS;
 }
 
-- 
1.9.1

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


[ovs-dev] [PATCH v1 2/6] datapath-windows: pid-instance hash table APIs.

2014-10-20 Thread Ankur Sharma
In this patch we have added APIs for insert, delete and
search APIs.

Signed-off-by: Ankur Sharma 
---
 datapath-windows/ovsext/User.c | 40 
 datapath-windows/ovsext/User.h | 10 ++
 2 files changed, 50 insertions(+)

diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c
index a4c736b..a8d9107 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -32,6 +32,7 @@
 #include "NetProto.h"
 #include "Flow.h"
 #include "TunnelIntf.h"
+#include "Jhash.h"
 
 #ifdef OVS_DBG_MOD
 #undef OVS_DBG_MOD
@@ -597,6 +598,45 @@ OvsGetQueue(UINT32 pid)
 return NULL;
 }
 
+POVS_OPEN_INSTANCE
+OvsGetPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid)
+{
+POVS_OPEN_INSTANCE instance;
+PLIST_ENTRY head, link;
+UINT32 hash = OvsJhashBytes((const VOID *)&pid, sizeof(pid),
+OVS_HASH_BASIS);
+head = &(switchContext->pidHashArray[hash & OVS_PID_MASK]);
+LIST_FORALL(head, link) {
+instance = CONTAINING_RECORD(link, OVS_OPEN_INSTANCE, pidLink);
+if (instance->pid == pid) {
+return instance;
+}
+}
+return NULL;
+}
+
+VOID
+OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid,
+  POVS_OPEN_INSTANCE instance)
+{
+PLIST_ENTRY head;
+UINT32 hash = OvsJhashBytes((const VOID *)&pid, sizeof(pid),
+OVS_HASH_BASIS);
+head = &(switchContext->pidHashArray[hash & OVS_PID_MASK]);
+InsertHeadList(&gOvsSwitchContext->pidHashArray[hash & OVS_PID_MASK],
+   &(instance->pidLink));
+}
+
+VOID
+OvsDelPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid)
+{
+POVS_OPEN_INSTANCE instance = OvsGetPidInstance(switchContext, pid);
+
+if (instance) {
+RemoveEntryList(&(instance->pidLink));
+}
+}
+
 VOID
 OvsQueuePackets(UINT32 queueId,
 PLIST_ENTRY packetList,
diff --git a/datapath-windows/ovsext/User.h b/datapath-windows/ovsext/User.h
index 0c18e2f..47fb10b 100644
--- a/datapath-windows/ovsext/User.h
+++ b/datapath-windows/ovsext/User.h
@@ -108,4 +108,14 @@ NTSTATUS OvsWaitDpIoctl(PIRP irp, PFILE_OBJECT fileObject);
 NTSTATUS OvsNlExecuteCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
 UINT32 *replyLen);
 
+POVS_OPEN_INSTANCE
+OvsGetPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid);
+
+VOID
+OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid,
+  POVS_OPEN_INSTANCE instance);
+
+VOID
+OvsDelPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid);
+
 #endif /* __USER_H_ */
-- 
1.9.1

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


[ovs-dev] [PATCH v1 1/6] datapath-windows: pid-instance hash table data structure.

2014-10-20 Thread Ankur Sharma
This patch introduces data structure for holding instances hashed by
pid.

Signed-off-by: Ankur Sharma 
---
 datapath-windows/ovsext/Datapath.h |  2 ++
 datapath-windows/ovsext/Event.c|  1 +
 datapath-windows/ovsext/Switch.c   | 15 ++-
 datapath-windows/ovsext/Switch.h   |  3 +++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/datapath-windows/ovsext/Datapath.h 
b/datapath-windows/ovsext/Datapath.h
index abbcc1a..221515d 100644
--- a/datapath-windows/ovsext/Datapath.h
+++ b/datapath-windows/ovsext/Datapath.h
@@ -87,6 +87,8 @@ typedef struct _OVS_OPEN_INSTANCE {
  * markers can store the row and the column
  * indices. */
 } dumpState;/* data to support dump commands. */
+LIST_ENTRY pidLink; /* Links the instance to
+ * pidHashArray */
 } OVS_OPEN_INSTANCE, *POVS_OPEN_INSTANCE;
 
 NDIS_STATUS OvsCreateDeviceObject(NDIS_HANDLE ovsExtDriverHandle);
diff --git a/datapath-windows/ovsext/Event.c b/datapath-windows/ovsext/Event.c
index 656f719..96f4e16 100644
--- a/datapath-windows/ovsext/Event.c
+++ b/datapath-windows/ovsext/Event.c
@@ -258,6 +258,7 @@ OvsSubscribeEventIoctl(PFILE_OBJECT fileObject,
 ovsNumEventQueue++;
 instance->eventQueue = queue;
 queue->instance = instance;
+InitializeListHead(&(instance->pidLink));
 } else {
 queue = (POVS_EVENT_QUEUE)instance->eventQueue;
 RemoveEntryList(&queue->queueLink);
diff --git a/datapath-windows/ovsext/Switch.c b/datapath-windows/ovsext/Switch.c
index ac4a847..5593d43 100644
--- a/datapath-windows/ovsext/Switch.c
+++ b/datapath-windows/ovsext/Switch.c
@@ -360,6 +360,8 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 OvsAllocateMemory(sizeof (LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
 switchContext->portIdHashArray= (PLIST_ENTRY)
 OvsAllocateMemory(sizeof (LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
+switchContext->pidHashArray = (PLIST_ENTRY)
+OvsAllocateMemory(sizeof(LIST_ENTRY) * OVS_MAX_PID_ARRAY_SIZE);
 status = OvsAllocateFlowTable(&switchContext->datapath, switchContext);
 
 if (status == NDIS_STATUS_SUCCESS) {
@@ -369,7 +371,8 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 switchContext->dispatchLock == NULL ||
 switchContext->portNoHashArray == NULL ||
 switchContext->ovsPortNameHashArray == NULL ||
-switchContext->portIdHashArray== NULL) {
+switchContext->portIdHashArray== NULL ||
+switchContext->pidHashArray == NULL) {
 if (switchContext->dispatchLock) {
 NdisFreeRWLock(switchContext->dispatchLock);
 }
@@ -382,6 +385,11 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 if (switchContext->portIdHashArray) {
 OvsFreeMemory(switchContext->portIdHashArray);
 }
+
+if (switchContext->pidHashArray) {
+OvsFreeMemory(switchContext->pidHashArray);
+}
+
 OvsDeleteFlowTable(&switchContext->datapath);
 OvsCleanupBufferPool(switchContext);
 
@@ -399,6 +407,10 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 InitializeListHead(&switchContext->portNoHashArray[i]);
 }
 
+for (i = 0; i < OVS_MAX_PID_ARRAY_SIZE; i++) {
+InitializeListHead(&switchContext->pidHashArray[i]);
+}
+
 switchContext->isActivated = FALSE;
 switchContext->isActivateFailed = FALSE;
 switchContext->dpNo = OVS_DP_NUMBER;
@@ -420,6 +432,7 @@ OvsCleanupSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 OvsFreeMemory(switchContext->ovsPortNameHashArray);
 OvsFreeMemory(switchContext->portIdHashArray);
 OvsFreeMemory(switchContext->portNoHashArray);
+OvsFreeMemory(switchContext->pidHashArray);
 OvsDeleteFlowTable(&switchContext->datapath);
 OvsCleanupBufferPool(switchContext);
 OVS_LOG_TRACE("Exit: Delete switchContext: %p", switchContext);
diff --git a/datapath-windows/ovsext/Switch.h b/datapath-windows/ovsext/Switch.h
index ac708b7..7fdca5f 100644
--- a/datapath-windows/ovsext/Switch.h
+++ b/datapath-windows/ovsext/Switch.h
@@ -24,8 +24,10 @@
 #include "NetProto.h"
 #include "BufferMgmt.h"
 #define OVS_MAX_VPORT_ARRAY_SIZE 1024
+#define OVS_MAX_PID_ARRAY_SIZE   1024
 
 #define OVS_VPORT_MASK (OVS_MAX_VPORT_ARRAY_SIZE - 1)
+#define OVS_PID_MASK (OVS_MAX_PID_ARRAY_SIZE - 1)
 
 #define OVS_INTERNAL_VPORT_DEFAULT_INDEX 0
 
@@ -107,6 +109,7 @@ typedef struct _OVS_SWITCH_CONTEXT
 PLIST_ENTRY ovsPortNameHashArray;   // based on ovsName
 PLIST_ENTRY portIdHashArray;// based on portId
 PLIST_ENTRY portNoHashArray;// based on ovs port number
+PLIST_ENTRY pidHashArray;   // based on packet pids
 
 UINT32  numPhysicalNics;
 UINT32  numVports; // include validation port
-- 
1.9.1

[ovs-dev] [PATCH v1 5/6] datapath-windows: Refactor CreateQueue function to handle vport pid.

2014-10-20 Thread Ankur Sharma
Refactored CreateQueue function so that packets are enqueued to
correct corresponding queue.

Signed-off-by: Ankur Sharma 
---
 datapath-windows/ovsext/Actions.c  |  4 +-
 datapath-windows/ovsext/PacketIO.c |  2 +-
 datapath-windows/ovsext/Tunnel.c   |  2 +-
 datapath-windows/ovsext/User.c | 78 ++
 4 files changed, 49 insertions(+), 37 deletions(-)

diff --git a/datapath-windows/ovsext/Actions.c 
b/datapath-windows/ovsext/Actions.c
index 408b9be..f5ce12e 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -564,7 +564,7 @@ OvsDoFlowLookupOutput(OvsForwardingContext *ovsFwdCtx)
   ovsFwdCtx->tunnelRxNic != NULL, &ovsFwdCtx->layers,
   ovsFwdCtx->switchContext, &missedPackets, &num);
 if (num) {
-OvsQueuePackets(OVS_DEFAULT_PACKET_QUEUE, &missedPackets, num);
+OvsQueuePackets(&missedPackets, num);
 }
 if (status == NDIS_STATUS_SUCCESS) {
 /* Complete the packet since it was copied to user buffer. */
@@ -1495,7 +1495,7 @@ OvsActionsExecute(POVS_SWITCH_CONTEXT switchContext,
 LIST_ENTRY missedPackets;
 InitializeListHead(&missedPackets);
 InsertTailList(&missedPackets, &elem->link);
-OvsQueuePackets(OVS_DEFAULT_PACKET_QUEUE, &missedPackets, 1);
+OvsQueuePackets(&missedPackets, 1);
 dropReason = L"OVS-Completed since packet was copied to "
  L"userspace";
 } else {
diff --git a/datapath-windows/ovsext/PacketIO.c 
b/datapath-windows/ovsext/PacketIO.c
index 493c8cb..7eb6ed8 100644
--- a/datapath-windows/ovsext/PacketIO.c
+++ b/datapath-windows/ovsext/PacketIO.c
@@ -314,7 +314,7 @@ dropit:
 }
 
 /* Queue the missed packets. */
-OvsQueuePackets(OVS_DEFAULT_PACKET_QUEUE, &missedPackets, num);
+OvsQueuePackets(&missedPackets, num);
 OvsFinalizeCompletionList(&completionList);
 }
 
diff --git a/datapath-windows/ovsext/Tunnel.c b/datapath-windows/ovsext/Tunnel.c
index eb45454..b55a223 100644
--- a/datapath-windows/ovsext/Tunnel.c
+++ b/datapath-windows/ovsext/Tunnel.c
@@ -320,7 +320,7 @@ OvsInjectPacketThroughActions(PNET_BUFFER_LIST pNbl,
 if (elem) {
 /* Complete the packet since it was copied to user buffer. */
 InsertTailList(&missedPackets, &elem->link);
-OvsQueuePackets(OVS_DEFAULT_PACKET_QUEUE, &missedPackets, 1);
+OvsQueuePackets(&missedPackets, 1);
 } else {
 status = STATUS_INSUFFICIENT_RESOURCES;
 }
diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c
index 95b8652..42b251f 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -668,8 +668,7 @@ OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 
pid,
 UINT32 hash = OvsJhashBytes((const VOID *)&pid, sizeof(pid),
 OVS_HASH_BASIS);
 head = &(switchContext->pidHashArray[hash & OVS_PID_MASK]);
-InsertHeadList(&gOvsSwitchContext->pidHashArray[hash & OVS_PID_MASK],
-   &(instance->pidLink));
+InsertHeadList(head, &(instance->pidLink));
 }
 
 /*
@@ -689,55 +688,67 @@ OvsDelPidInstance(POVS_SWITCH_CONTEXT switchContext, 
UINT32 pid)
 }
 
 VOID
-OvsQueuePackets(UINT32 queueId,
-PLIST_ENTRY packetList,
+OvsQueuePackets(PLIST_ENTRY packetList,
 UINT32 numElems)
 {
-POVS_USER_PACKET_QUEUE queue = OvsGetQueue(queueId);
+POVS_USER_PACKET_QUEUE upcallQueue = NULL;
 POVS_PACKET_QUEUE_ELEM elem;
 PIRP irp = NULL;
 PLIST_ENTRY  link;
 UINT32 num = 0;
+LIST_ENTRY dropPackets;
 
-OVS_LOG_LOUD("Enter: queueId %u, numELems: %u",
-  queueId, numElems);
-if (queue == NULL) {
-goto cleanup;
-}
+OVS_LOG_LOUD("Enter: numELems: %u", numElems);
 
-NdisAcquireSpinLock(&queue->queueLock);
-if (queue->instance == NULL) {
-NdisReleaseSpinLock(&queue->queueLock);
-goto cleanup;
-} else {
-OvsAppendList(&queue->packetList, packetList);
-queue->numPackets += numElems;
-}
-if (queue->pendingIrp) {
-PDRIVER_CANCEL cancelRoutine;
-irp = queue->pendingIrp;
-queue->pendingIrp = NULL;
-cancelRoutine = IoSetCancelRoutine(irp, NULL);
-if (cancelRoutine == NULL) {
-irp = NULL;
-}
-}
-NdisReleaseSpinLock(&queue->queueLock);
-if (irp) {
-OvsCompleteIrpRequest(irp, 0, STATUS_SUCCESS);
-}
+InitializeListHead(&dropPackets);
 
-cleanup:
 while (!IsListEmpty(packetList)) {
 link = RemoveHeadList(packetList);
 elem = CONTAINING_RECORD(link, OVS_PACKET_QUEUE_ELEM, link);
+
+/* XXX: There is a race condition here.
+ * What if queue is deleted after getQueue returns and 

[ovs-dev] [PATCH v1 6/6] datapath-windows: Fixes during integration testing.

2014-10-20 Thread Ankur Sharma
Signed-off-by: Ankur Sharma 
---
 datapath-windows/ovsext/User.c | 6 --
 datapath-windows/ovsext/User.h | 6 +++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c
index 42b251f..cce99a5 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -141,6 +141,7 @@ OvsSubscribeDpIoctl(PVOID instanceP,
 OvsReleaseCtrlLock();
 return STATUS_INVALID_PARAMETER;
 }
+OvsReleaseCtrlLock();
 
 if (instance->packetQueue && !join) {
 /* unsubscribe */
@@ -171,7 +172,6 @@ OvsSubscribeDpIoctl(PVOID instanceP,
 OvsAddPidInstance(gOvsSwitchContext, pid, instance);
 OvsReleaseCtrlLock();
 
-
 } else {
 /* user mode should call only once for subscribe */
 return STATUS_INVALID_PARAMETER;
@@ -1009,7 +1009,9 @@ OvsCreateQueueNlPacket(PVOID userData,
 return NULL;
 }
 
-if (!OvsGetPid(vport, nb, &pid)) {
+OvsGetPid(vport, nb, &pid);
+
+if (!pid) {
 /*
  * There is no userspace queue created yet, so there is no point for
  * creating a new packet to be queued.
diff --git a/datapath-windows/ovsext/User.h b/datapath-windows/ovsext/User.h
index 47fb10b..139b0ca 100644
--- a/datapath-windows/ovsext/User.h
+++ b/datapath-windows/ovsext/User.h
@@ -1,4 +1,4 @@
-/*
+ /*
  * Copyright (c) 2014 VMware, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,6 +49,7 @@ typedef struct _OVS_USER_PACKET_QUEUE {
 } OVS_USER_PACKET_QUEUE, *POVS_USER_PACKET_QUEUE;
 
 typedef struct _OVS_PACKET_QUEUE_ELEM {
+UINT32  upcallPid;
 LIST_ENTRY link;
 OVS_PACKET_HDR_INFO hdrInfo;
 OVS_PACKET_INFO packet;
@@ -78,8 +79,7 @@ POVS_PACKET_QUEUE_ELEM OvsCreateQueueNlPacket(PVOID userData,
   BOOLEAN isRecv,
   POVS_PACKET_HDR_INFO hdrInfo);
 
-VOID OvsQueuePackets(UINT32 queueId, PLIST_ENTRY packetList,
- UINT32 numElems);
+VOID OvsQueuePackets(PLIST_ENTRY packetList, UINT32 numElems);
 NTSTATUS OvsCreateAndAddPackets(PVOID userData,
 UINT32 userDataLen,
 UINT32 cmd,
-- 
1.9.1

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


[ovs-dev] [PATCH v1 4/6] datapath-windows: Add code for OvsGetQueue.

2014-10-20 Thread Ankur Sharma
Signed-off-by: Ankur Sharma 
---
 datapath-windows/ovsext/User.c | 45 +-
 1 file changed, 40 insertions(+), 5 deletions(-)

diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c
index 42473ab..95b8652 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -608,16 +608,35 @@ OvsGetNextPacket(POVS_OPEN_INSTANCE instance)
 return CONTAINING_RECORD(link, OVS_PACKET_QUEUE_ELEM, link);
 }
 
-
+/*
+ * ---
+ * Given a pid, returns the corresponding USER_PACKET_QUEUE.
+ * ---
+ */
 POVS_USER_PACKET_QUEUE
 OvsGetQueue(UINT32 pid)
 {
-/* XXX To be implemented. Return the queue assoiated with the pid*/
-UNREFERENCED_PARAMETER(pid);
-ASSERT(FALSE);
-return NULL;
+POVS_OPEN_INSTANCE instance;
+POVS_USER_PACKET_QUEUE ret = NULL;
+
+OvsAcquireCtrlLock();
+instance = OvsGetPidInstance(gOvsSwitchContext, pid);
+
+if (instance) {
+ret = instance->packetQueue;
+}
+
+OvsReleaseCtrlLock();
+
+return ret;
 }
 
+/*
+ * ---
+ * Given a pid, returns the corresponding instance.
+ * gOvsCtrlLock must be acquired before calling this API.
+ * ---
+ */
 POVS_OPEN_INSTANCE
 OvsGetPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid)
 {
@@ -635,6 +654,12 @@ OvsGetPidInstance(POVS_SWITCH_CONTEXT switchContext, 
UINT32 pid)
 return NULL;
 }
 
+/*
+ * ---
+ * Given a pid and an instance. This API adds instance to pidHashArray.
+ * gOvsCtrlLock must be acquired before calling this API.
+ * ---
+ */
 VOID
 OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid,
   POVS_OPEN_INSTANCE instance)
@@ -647,6 +672,12 @@ OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, 
UINT32 pid,
&(instance->pidLink));
 }
 
+/*
+ * ---
+ * Given a pid and an instance. This API removes instance from pidHashArray.
+ * gOvsCtrlLock must be acquired before calling this API.
+ * ---
+ */
 VOID
 OvsDelPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid)
 {
@@ -903,6 +934,10 @@ OvsGetPid(POVS_VPORT_ENTRY vport, PNET_BUFFER nb, UINT32 
*pid)
 {
 UNREFERENCED_PARAMETER(nb);
 
+if (!vport) {
+return STATUS_INVALID_PARAMETER;
+}
+
 /* XXX select a pid from an array of pids using a flow based hash */
 *pid = vport->upcallPid;
 return STATUS_SUCCESS;
-- 
1.9.1

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


[ovs-dev] '/etc/init.d/openvswitch force-reload-kmod' on RHEL7 fails,

2014-10-20 Thread Alex Wang
Hey Flavio,

We found when set selinux 'enforcing' on RHEL7/CentOS7,
The init.d script command 'force-reload-kmod' cannot work properly:
Shown below:

[root@ovs_team_rhel7]# /etc/init.d/openvswitch force-reload-kmod

Detected internal interfaces:  [  OK  ]
Saving flows [  OK  ]
Killing ovsdb-server (11131) [  OK  ]
Starting ovsdb-server [  OK  ]
Configuring Open vSwitch system IDs [  OK  ]
Killing ovs-vswitchd (11146) [  OK  ]
*Saving interface configuration /usr/share/openvswitch/scripts/ovs-save: ip
not found in /*
*sbin:/usr/sbin:/bin:/usr/bin*
*[FAILED]*
*Failed to save configuration, not replacing kernel module ... (warning).*
Starting ovs-vswitchd [  OK  ]
Enabling remote OVSDB managers [  OK  ]


The reason seems to be that domain openvswitch_t does not have right
to access /usr/sbin/ => that's why ovs-save reports 'ip not found'

We are using the latest selinux-policy:
http://rpmfind.net//linux/RPM/centos/updates/7.0.1406/x86_64/Packages/selinux-policy-3.12.1-153.el7_0.11.noarch.html

We are using kernel: 3.10.0-123.8.1.el7.x86_64

I checked the selinux-policy-doc, it should support openvswitch running
shell long
ago...

* Fri Apr 05 2013 Miroslav Grepl  3.12.1-26
  - Try to label on controlC devices up to 30 correctly
..

  - Allow openvswitch to execute shell


So, could you help us check and maybe try if you could reproduce it
yourself?

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


Re: [ovs-dev] [PATCH v1 1/6] datapath-windows: pid-instance hash table data structure.

2014-10-20 Thread Eitan Eliahu
LG
Is there any reason to initialize the pidLink in the Event queue? (We have a 
single Event queue per datapath, the Pid is mainly for packet miss queues)
Thanks,
Eitan

-Original Message-
From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Ankur Sharma
Sent: Monday, October 20, 2014 5:35 PM
To: dev@openvswitch.org
Subject: [ovs-dev] [PATCH v1 1/6] datapath-windows: pid-instance hash table 
data structure.

This patch introduces data structure for holding instances hashed by pid.

Signed-off-by: Ankur Sharma 
---
 datapath-windows/ovsext/Datapath.h |  2 ++
 datapath-windows/ovsext/Event.c|  1 +
 datapath-windows/ovsext/Switch.c   | 15 ++-
 datapath-windows/ovsext/Switch.h   |  3 +++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/datapath-windows/ovsext/Datapath.h 
b/datapath-windows/ovsext/Datapath.h
index abbcc1a..221515d 100644
--- a/datapath-windows/ovsext/Datapath.h
+++ b/datapath-windows/ovsext/Datapath.h
@@ -87,6 +87,8 @@ typedef struct _OVS_OPEN_INSTANCE {
  * markers can store the row and the column
  * indices. */
 } dumpState;/* data to support dump commands. */
+LIST_ENTRY pidLink; /* Links the instance to
+ * pidHashArray */
 } OVS_OPEN_INSTANCE, *POVS_OPEN_INSTANCE;
 
 NDIS_STATUS OvsCreateDeviceObject(NDIS_HANDLE ovsExtDriverHandle); diff --git 
a/datapath-windows/ovsext/Event.c b/datapath-windows/ovsext/Event.c index 
656f719..96f4e16 100644
--- a/datapath-windows/ovsext/Event.c
+++ b/datapath-windows/ovsext/Event.c
@@ -258,6 +258,7 @@ OvsSubscribeEventIoctl(PFILE_OBJECT fileObject,
 ovsNumEventQueue++;
 instance->eventQueue = queue;
 queue->instance = instance;
+InitializeListHead(&(instance->pidLink));
 } else {
 queue = (POVS_EVENT_QUEUE)instance->eventQueue;
 RemoveEntryList(&queue->queueLink);
diff --git a/datapath-windows/ovsext/Switch.c b/datapath-windows/ovsext/Switch.c
index ac4a847..5593d43 100644
--- a/datapath-windows/ovsext/Switch.c
+++ b/datapath-windows/ovsext/Switch.c
@@ -360,6 +360,8 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 OvsAllocateMemory(sizeof (LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
 switchContext->portIdHashArray= (PLIST_ENTRY)
 OvsAllocateMemory(sizeof (LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
+switchContext->pidHashArray = (PLIST_ENTRY)
+OvsAllocateMemory(sizeof(LIST_ENTRY) * OVS_MAX_PID_ARRAY_SIZE);
 status = OvsAllocateFlowTable(&switchContext->datapath, switchContext);
 
 if (status == NDIS_STATUS_SUCCESS) { @@ -369,7 +371,8 @@ 
OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 switchContext->dispatchLock == NULL ||
 switchContext->portNoHashArray == NULL ||
 switchContext->ovsPortNameHashArray == NULL ||
-switchContext->portIdHashArray== NULL) {
+switchContext->portIdHashArray== NULL ||
+switchContext->pidHashArray == NULL) {
 if (switchContext->dispatchLock) {
 NdisFreeRWLock(switchContext->dispatchLock);
 }
@@ -382,6 +385,11 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 if (switchContext->portIdHashArray) {
 OvsFreeMemory(switchContext->portIdHashArray);
 }
+
+if (switchContext->pidHashArray) {
+OvsFreeMemory(switchContext->pidHashArray);
+}
+
 OvsDeleteFlowTable(&switchContext->datapath);
 OvsCleanupBufferPool(switchContext);
 
@@ -399,6 +407,10 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 InitializeListHead(&switchContext->portNoHashArray[i]);
 }
 
+for (i = 0; i < OVS_MAX_PID_ARRAY_SIZE; i++) {
+InitializeListHead(&switchContext->pidHashArray[i]);
+}
+
 switchContext->isActivated = FALSE;
 switchContext->isActivateFailed = FALSE;
 switchContext->dpNo = OVS_DP_NUMBER; @@ -420,6 +432,7 @@ 
OvsCleanupSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 OvsFreeMemory(switchContext->ovsPortNameHashArray);
 OvsFreeMemory(switchContext->portIdHashArray);
 OvsFreeMemory(switchContext->portNoHashArray);
+OvsFreeMemory(switchContext->pidHashArray);
 OvsDeleteFlowTable(&switchContext->datapath);
 OvsCleanupBufferPool(switchContext);
 OVS_LOG_TRACE("Exit: Delete switchContext: %p", switchContext); diff --git 
a/datapath-windows/ovsext/Switch.h b/datapath-windows/ovsext/Switch.h
index ac708b7..7fdca5f 100644
--- a/datapath-windows/ovsext/Switch.h
+++ b/datapath-windows/ovsext/Switch.h
@@ -24,8 +24,10 @@
 #include "NetProto.h"
 #include "BufferMgmt.h"
 #define OVS_MAX_VPORT_ARRAY_SIZE 1024
+#define OVS_MAX_PID_ARRAY_SIZE   1024
 
 #define OVS_VPORT_MASK (OVS_MAX_VPORT_ARRAY_SIZE - 1)
+#define OVS_PID_MASK (OVS_MAX_PID_ARRAY_SIZE - 1)
 
 #define OVS_INTERNAL_VPORT_DEFAULT_INDEX 0
 
@@ -107,6 +109,7 @@ typedef struct _OVS_SWITCH_CONTEXT

Re: [ovs-dev] [PATCH v1 2/6] datapath-windows: pid-instance hash table APIs.

2014-10-20 Thread Eitan Eliahu
LG
Just add comment that these functions should be executed when the pidHash 
(table or table entry) lock is held.

-Original Message-
From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Ankur Sharma
Sent: Monday, October 20, 2014 5:35 PM
To: dev@openvswitch.org
Subject: [ovs-dev] [PATCH v1 2/6] datapath-windows: pid-instance hash table 
APIs.

In this patch we have added APIs for insert, delete and search APIs.

Signed-off-by: Ankur Sharma 
---
 datapath-windows/ovsext/User.c | 40 
 datapath-windows/ovsext/User.h | 10 ++
 2 files changed, 50 insertions(+)

diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c 
index a4c736b..a8d9107 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -32,6 +32,7 @@
 #include "NetProto.h"
 #include "Flow.h"
 #include "TunnelIntf.h"
+#include "Jhash.h"
 
 #ifdef OVS_DBG_MOD
 #undef OVS_DBG_MOD
@@ -597,6 +598,45 @@ OvsGetQueue(UINT32 pid)
 return NULL;
 }
 
+POVS_OPEN_INSTANCE
+OvsGetPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid) {
+POVS_OPEN_INSTANCE instance;
+PLIST_ENTRY head, link;
+UINT32 hash = OvsJhashBytes((const VOID *)&pid, sizeof(pid),
+OVS_HASH_BASIS);
+head = &(switchContext->pidHashArray[hash & OVS_PID_MASK]);
+LIST_FORALL(head, link) {
+instance = CONTAINING_RECORD(link, OVS_OPEN_INSTANCE, pidLink);
+if (instance->pid == pid) {
+return instance;
+}
+}
+return NULL;
+}
+
+VOID
+OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid,
+  POVS_OPEN_INSTANCE instance) {
+PLIST_ENTRY head;
+UINT32 hash = OvsJhashBytes((const VOID *)&pid, sizeof(pid),
+OVS_HASH_BASIS);
+head = &(switchContext->pidHashArray[hash & OVS_PID_MASK]);
+InsertHeadList(&gOvsSwitchContext->pidHashArray[hash & OVS_PID_MASK],
+   &(instance->pidLink)); }
+
+VOID
+OvsDelPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid) {
+POVS_OPEN_INSTANCE instance = OvsGetPidInstance(switchContext, 
+pid);
+
+if (instance) {
+RemoveEntryList(&(instance->pidLink));
+}
+}
+
 VOID
 OvsQueuePackets(UINT32 queueId,
 PLIST_ENTRY packetList, diff --git 
a/datapath-windows/ovsext/User.h b/datapath-windows/ovsext/User.h index 
0c18e2f..47fb10b 100644
--- a/datapath-windows/ovsext/User.h
+++ b/datapath-windows/ovsext/User.h
@@ -108,4 +108,14 @@ NTSTATUS OvsWaitDpIoctl(PIRP irp, PFILE_OBJECT 
fileObject);  NTSTATUS OvsNlExecuteCmdHandler(POVS_USER_PARAMS_CONTEXT 
usrParamsCtx,
 UINT32 *replyLen);
 
+POVS_OPEN_INSTANCE
+OvsGetPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid);
+
+VOID
+OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid,
+  POVS_OPEN_INSTANCE instance);
+
+VOID
+OvsDelPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid);
+
 #endif /* __USER_H_ */
--
1.9.1

___
dev mailing list
dev@openvswitch.org
https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=yTvML8OxA42Jb6ViHe7fUXbvPVOYDPVq87w43doxtlY%3D%0A&m=DpYNIV0H8d7fbwYPi8Nm4hpYShmCdVok4d53VhMOClE%3D%0A&s=95e79a4b05ea761331b8ad49580fb1cc4c082a726f32f74077b1559277359d8c
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev