Re: [ovs-dev] [PATCH v5] datapath-windows: Add support for UDP and ICMP to Conntrack Module

2016-06-13 Thread Alin Serdean
Hi Sai,
Thanks for incorporating the comments so far. It looks good but we need to 
treat corner cases like no valid resource allocations and NULL checks for 
parameter.

A few small nits inlined.

Thanks,
Alin.
<---cut>
>  ctx->key.src.port = flowKey->ipKey.l4.tpSrc;
>  ctx->key.dst.port = flowKey->ipKey.l4.tpDst;
> +if (flowKey->ipKey.nwProto == IPPROTO_ICMP) {
> +ICMPHdr icmpStorage;
> +const ICMPHdr *icmp;
> +icmp = OvsGetIcmp(curNbl, l4Offset, );
> +ASSERT(icmp);
> +ctx->key.src.port = ctx->key.dst.port =
> + icmp->fields.echo.id;
> +
> +/* Related bit is set when ICMP has an error */
> +/* XXX parse out the appropriate src and dst from inner pkt */
> +switch (icmp->type) {
> +   case ICMP4_DEST_UNREACH:
> +   case ICMP4_TIME_EXCEEDED:
> +   case ICMP4_PARAM_PROB:
> +   case ICMP4_SOURCE_QUENCH:
> +   case ICMP4_REDIRECT: {
> +   ctx->related = TRUE;
> +   }
[Alin Gabriel Serdean: ] break;
> +   default:
> +   ctx->related = FALSE;
[Alin Gabriel Serdean: ] break; Without breaks ctx->related will always be 
false;
> +}
> +}

<---cut>
>  //Delete and update the Conntrack
>  OvsCtEntryDelete(ctx->entry);
>  ctx->entry = NULL;
> -entry = OvsCtEntryCreate(tcp, curNbl, ctx, key,
> - commit, currentTime);
> +entry = OvsCtEntryCreate(curNbl, key->ipKey.nwProto, l4Offset,
> + ctx, key, commit, currentTime);
[Alin Gabriel Serdean: ] entry can be null, if for example the tcp packet was 
invalid. We need to treat that case because the following code will run after.
/* Copy mark and label from entry into flowKey. If actions specify
   different mark and label, update the flowKey. */
OvsCtUpdateFlowKey(key, state, zone, entry->mark, >labels);

>  break;
>  }
>  }
> @@ -401,15 +493,12 @@ OvsCtExecute_(PNET_BUFFER_LIST curNbl,
>  NDIS_STATUS status = NDIS_STATUS_SUCCESS;
>  POVS_CT_ENTRY entry = NULL;
>  OvsConntrackKeyLookupCtx ctx = { 0 };
> -TCPHdr tcpStorage;
> -UINT64 currentTime;
>  LOCK_STATE_EX lockState;
> -const TCPHdr *tcp;
> -tcp = OvsGetTcp(curNbl, layers->l4Offset, );
> +UINT64 currentTime;
>  NdisGetCurrentSystemTime((LARGE_INTEGER *) );
> 
>  /* Retrieve the Conntrack Key related fields from packet */
> -OvsCtSetupLookupCtx(key, zone, );
> +OvsCtSetupLookupCtx(key, zone, , curNbl, layers->l4Offset);
> 
>  NdisAcquireRWLockWrite(ovsConntrackLockObj, , 0);
> 
> @@ -418,11 +507,12 @@ OvsCtExecute_(PNET_BUFFER_LIST curNbl,
> 
>  if (!entry) {
>  /* If no matching entry was found, create one and add New state */
> -entry = OvsCtEntryCreate(tcp, curNbl, ,
> +entry = OvsCtEntryCreate(curNbl, key->ipKey.nwProto,
> + layers->l4Offset, ,
>   key, commit, currentTime);
>  } else {
>  /* Process the entry and update CT flags */
> -entry = OvsProcessConntrackEntry(curNbl, tcp, , key,
> +entry = OvsProcessConntrackEntry(curNbl, layers->l4Offset,
> + , key,
>   zone, commit, currentTime);
>  }
> 
> diff --git a/datapath-windows/ovsext/Conntrack.h b/datapath-
> windows/ovsext/Conntrack.h
> index a754544..883ac57 100644
> --- a/datapath-windows/ovsext/Conntrack.h
> +++ b/datapath-windows/ovsext/Conntrack.h
> @@ -80,8 +80,11 @@ typedef struct OvsConntrackKeyLookupCtx {
> 
>  #define CT_HASH_TABLE_SIZE ((UINT32)1 << 10)  #define
> CT_HASH_TABLE_MASK (CT_HASH_TABLE_SIZE - 1)
> -#define CT_ENTRY_TIMEOUT (2 * 6)   // 2m
> -#define CT_CLEANUP_INTERVAL (2 * 6) // 2m
> +#define CT_INTERVAL_SEC 1000LL //1s
> +#define CT_ENTRY_TIMEOUT (2 * 60 * CT_INTERVAL_SEC)   // 2m
> +#define CT_CLEANUP_INTERVAL (2 * 60 * CT_INTERVAL_SEC) // 2m
> +
> +
>  /* Given POINTER, the address of the given MEMBER in a STRUCT object,
> returns
> the STRUCT object. */
>  #define CONTAINER_OF(POINTER, STRUCT, MEMBER)   \
> @@ -99,9 +102,13 @@ BOOLEAN OvsConntrackValidateTcpPacket(const
> TCPHdr *tcp);  OVS_CT_ENTRY * OvsConntrackCreateTcpEntry(const TCPHdr
> *tcp,
>PNET_BUFFER_LIST nbl,
>UINT64 now);
> +OVS_CT_ENTRY * OvsConntrackCreateOtherEntry(UINT64 now);
>  enum CT_UPDATE_RES OvsConntrackUpdateTcpEntry(OVS_CT_ENTRY*
> conn_,
>const TCPHdr *tcp,
>PNET_BUFFER_LIST nbl,
>BOOLEAN reply,
>  

Re: [ovs-dev] [PATCH monitor_cond V7 00/10] Conditional monitor implementation

2016-06-13 Thread Liran Schour
Hui Kang/Watson/IBM wrote on 13/06/2016 07:58:41 PM:

> "dev"  wrote on 06/13/2016 07:19:25 AM:
> 
> > From: Liran Schour 
> > To: b...@ovn.org
> > Cc: d...@openvswitch.com
> > Date: 06/13/2016 08:29 AM
> > Subject: [ovs-dev] [PATCH monitor_cond V7 00/10] Conditional monitor
> > implementation
> > Sent by: "dev" 
> > 
> > This patch series implements conditional monitoring by introducing an 
OVSDB
> > RFC extension with 2 new JSON-RPC methods: "monitor_cond" and
> > "monitor_cond_change". Specification of this extension is defined in 
the
> > ovsdb-server (1) man page.
> > Monitor2 is now merged into monitor_cond. A monitor_cond session 
> > with an empty 
> > condition, will behave exactly like monitor2 and will get update2 
> > notifications
> > on all rows.
> > 
> > This patch series is also available on: https://github.com/
> liranschour/ovs.git
> > branch monitor_cond_ovn.
> 
> Hi, Liran,
> I am interested in cloning this patch from github. However, in your 
> git repo, I
> see several branches name with monitor_cond_ovn, i.e., monitor_cond_ovn,
> monitor_cond_ovn_v7_ovn, monitor_cond_ovn_dev
> 
> Which one shall I use? Thanks.
> 

Like I wrote above, the branch is: monitor_cond_ovn.

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


Re: [ovs-dev] [PATCH] datapath-windows: use ip proto for tunnel port lookup

2016-06-13 Thread Alin Serdean
Please disregard this review I it was intended for the V2 
(https://patchwork.ozlabs.org/patch/629912/)

Thanks,
Alin.

> -Mesaj original-
> De la: dev [mailto:dev-boun...@openvswitch.org] În numele Alin Serdean
> Trimis: Tuesday, June 14, 2016 7:01 AM
> Către: Nithin Raju ; dev@openvswitch.org
> Subiect: Re: [ovs-dev] [PATCH] datapath-windows: use ip proto for tunnel
> port lookup
> 
> Hi Nithin,
> 
> Thanks for the patch. Beside a few small nits regarding whitespace and extra
> comments, please see considerations to GRE tunnels in inlined comments.
> 
> Alin.
> > -if (tunnelVport) {
> > +break;
> > +case OVS_VPORT_TYPE_VXLAN:
> >  ovsActionStats.rxVxlan++;
> > +break;
> > +#if 0
> > +case OVS_VPORT_TYPE_GENEVE:
> > +ovsActionStats.rxGeneve++;
> > +break;
> > +#endif
> [Alin Gabriel Serdean: ] I think you can fan out the ifdef and Yin can add 
> them
> later
> > +case OVS_VPORT_TYPE_GRE:
> > +ovsActionStats.rxGre++;
> > +break;
> >  }
> > -break;
> >  }
> >  }
> >
> > diff --git a/datapath-windows/ovsext/Tunnel.c b/datapath-
> > windows/ovsext/Tunnel.c index 97d2020..c5aae1a 100644
> > --- a/datapath-windows/ovsext/Tunnel.c
> > +++ b/datapath-windows/ovsext/Tunnel.c
> > @@ -285,9 +285,9 @@
> OvsInjectPacketThroughActions(PNET_BUFFER_LIST
> > pNbl,
> >
> >  SendFlags |= NDIS_SEND_FLAGS_DISPATCH_LEVEL;
> >
> > -vport = OvsFindTunnelVportByDstPort(gOvsSwitchContext,
> > -htons(tunnelKey.dst_port),
> > -OVS_VPORT_TYPE_VXLAN);
> > +vport = OvsFindTunnelVportByDstPortAndType(gOvsSwitchContext,
> > +
> > + htons(tunnelKey.dst_port),
> > +
> > + OVS_VPORT_TYPE_VXLAN);
> >
> >  if (vport == NULL){
> >  status = STATUS_UNSUCCESSFUL; diff --git a/datapath-
> > windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c index
> > 222b2c1..f5eeaa5 100644
> > --- a/datapath-windows/ovsext/Vport.c
> > +++ b/datapath-windows/ovsext/Vport.c
> > @@ -691,9 +691,9 @@ OvsFindVportByPortNo(POVS_SWITCH_CONTEXT
> > switchContext,
> >
> >
> >  POVS_VPORT_ENTRY
> > -OvsFindTunnelVportByDstPort(POVS_SWITCH_CONTEXT switchContext,
> > -UINT16 dstPort,
> > -OVS_VPORT_TYPE ovsPortType)
> > +OvsFindTunnelVportByDstPortAndType(POVS_SWITCH_CONTEXT
> > switchContext,
> > +   UINT16 dstPort,
> > +   OVS_VPORT_TYPE ovsPortType)
> >  {
> >  POVS_VPORT_ENTRY vport;
> >  PLIST_ENTRY head, link;
> > @@ -711,6 +711,41 @@
> > OvsFindTunnelVportByDstPort(POVS_SWITCH_CONTEXT switchContext,  }
> >
> >  POVS_VPORT_ENTRY
> > +OvsFindTunnelVportByDstPortAndNWProto(POVS_SWITCH_CONTEXT
> > switchContext,
> > +  UINT16 dstPort,
> > +  UINT8 nwProto) {
> > +POVS_VPORT_ENTRY vport;
> > +PLIST_ENTRY head, link;
> > +UINT32 hash = OvsJhashBytes((const VOID *), sizeof(dstPort),
> > +OVS_HASH_BASIS);
> > +head = &(switchContext->tunnelVportsArray[hash &
> > OVS_VPORT_MASK]);
> > +LIST_FORALL(head, link) {
> > +vport = CONTAINING_RECORD(link, OVS_VPORT_ENTRY,
> > tunnelVportLink);
> > +if (GetPortFromPriv(vport) == dstPort) {
> > +switch (nwProto) {
> [Alin Gabriel Serdean: ] This will break in case we have a GRE tunnel set up.
> They rely only on the IP protocol; their destination port will be always set 
> to
> zero. We can have packets which have l4 port zero and a gre tunnel which will
> result in a misinterpreted patcket. Please leave the function
> OvsFindTunnelVportByPortType the way it was and create a new one.
> > +case IPPROTO_UDP:
> > +if (/* nwProto != OVS_VPORT_TYPE_GENEVE || */
> [Alin Gabriel Serdean: ] I think you can fan out the comment and Yin can add
> them later
> > +vport->ovsType != OVS_VPORT_TYPE_VXLAN) {
> > +continue;
> > +}
> > +break;
> > +case IPPROTO_TCP:
> > +if (vport->ovsType != OVS_VPORT_TYPE_STT) {
> > +continue;
> > +}
> > +break;
> > +case IPPROTO_GRE:
> > +default:
> > +break;
> > +}
> > +return vport;
> > +}
> > +}
> > +return NULL;
> > +}
> > +
> > +POVS_VPORT_ENTRY
> >  OvsFindTunnelVportByPortType(POVS_SWITCH_CONTEXT switchContext,
> >   OVS_VPORT_TYPE ovsPortType)  { @@
> > -,15 +2257,20 @@
> OvsNewVportCmdHandler(POVS_USER_PARAMS_CONTEXT
> > usrParamsCtx,
> >
> >  if (OvsIsTunnelVportType(portType)) {
> >  

Re: [ovs-dev] [PATCH v2] datapath-windows: use ip proto for tunnel port lookup

2016-06-13 Thread Alin Serdean
Hi Nithin,

Thanks for the patch. Beside a few small nits regarding whitespace and extra 
comments, please see considerations to GRE tunnels in inlined comments.

Alin.
> -if (tunnelVport) {
> +break;
> +case OVS_VPORT_TYPE_VXLAN:
>  ovsActionStats.rxVxlan++;
> +break;
> +#if 0
> +case OVS_VPORT_TYPE_GENEVE:
> +ovsActionStats.rxGeneve++;
> +break;
> +#endif
[Alin Gabriel Serdean: ] I think you can fan out the ifdef and Yin can add them 
later
> +case OVS_VPORT_TYPE_GRE:
> +ovsActionStats.rxGre++;
> +break;
>  }
> -break;
>  }
>  }
> 
> diff --git a/datapath-windows/ovsext/Tunnel.c b/datapath- 
> windows/ovsext/Tunnel.c index 97d2020..c5aae1a 100644
> --- a/datapath-windows/ovsext/Tunnel.c
> +++ b/datapath-windows/ovsext/Tunnel.c
> @@ -285,9 +285,9 @@ OvsInjectPacketThroughActions(PNET_BUFFER_LIST
> pNbl,
> 
>  SendFlags |= NDIS_SEND_FLAGS_DISPATCH_LEVEL;
> 
> -vport = OvsFindTunnelVportByDstPort(gOvsSwitchContext,
> -htons(tunnelKey.dst_port),
> -OVS_VPORT_TYPE_VXLAN);
> +vport = OvsFindTunnelVportByDstPortAndType(gOvsSwitchContext,
> +   
> + htons(tunnelKey.dst_port),
> +
> + OVS_VPORT_TYPE_VXLAN);
> 
>  if (vport == NULL){
>  status = STATUS_UNSUCCESSFUL; diff --git a/datapath- 
> windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c index
> 222b2c1..f5eeaa5 100644
> --- a/datapath-windows/ovsext/Vport.c
> +++ b/datapath-windows/ovsext/Vport.c
> @@ -691,9 +691,9 @@ OvsFindVportByPortNo(POVS_SWITCH_CONTEXT
> switchContext,
> 
> 
>  POVS_VPORT_ENTRY
> -OvsFindTunnelVportByDstPort(POVS_SWITCH_CONTEXT switchContext,
> -UINT16 dstPort,
> -OVS_VPORT_TYPE ovsPortType)
> +OvsFindTunnelVportByDstPortAndType(POVS_SWITCH_CONTEXT
> switchContext,
> +   UINT16 dstPort,
> +   OVS_VPORT_TYPE ovsPortType)
>  {
>  POVS_VPORT_ENTRY vport;
>  PLIST_ENTRY head, link;
> @@ -711,6 +711,41 @@
> OvsFindTunnelVportByDstPort(POVS_SWITCH_CONTEXT switchContext,  }
> 
>  POVS_VPORT_ENTRY
> +OvsFindTunnelVportByDstPortAndNWProto(POVS_SWITCH_CONTEXT
> switchContext,
> +  UINT16 dstPort,
> +  UINT8 nwProto) {
> +POVS_VPORT_ENTRY vport;
> +PLIST_ENTRY head, link;
> +UINT32 hash = OvsJhashBytes((const VOID *), sizeof(dstPort),
> +OVS_HASH_BASIS);
> +head = &(switchContext->tunnelVportsArray[hash &
> OVS_VPORT_MASK]);
> +LIST_FORALL(head, link) {
> +vport = CONTAINING_RECORD(link, OVS_VPORT_ENTRY,
> tunnelVportLink);
> +if (GetPortFromPriv(vport) == dstPort) {
> +switch (nwProto) {
[Alin Gabriel Serdean: ] This will break in case we have a GRE tunnel set up. 
They rely only on the IP protocol; their destination port will be always set to 
zero. We can have packets which have l4 port zero and a gre tunnel which will 
result in a misinterpreted patcket. Please leave the function 
OvsFindTunnelVportByPortType the way it was and create a new one.
> +case IPPROTO_UDP:
> +if (/* nwProto != OVS_VPORT_TYPE_GENEVE || */
[Alin Gabriel Serdean: ] I think you can fan out the comment and Yin can add 
them later
> +vport->ovsType != OVS_VPORT_TYPE_VXLAN) {
> +continue;
> +}
> +break;
> +case IPPROTO_TCP:
> +if (vport->ovsType != OVS_VPORT_TYPE_STT) {
> +continue;
> +}
> +break;
> +case IPPROTO_GRE:
> +default:
> +break;
> +}
> +return vport;
> +}
> +}
> +return NULL;
> +}
> +
> +POVS_VPORT_ENTRY
>  OvsFindTunnelVportByPortType(POVS_SWITCH_CONTEXT switchContext,
>   OVS_VPORT_TYPE ovsPortType)  { @@ 
> -,15 +2257,20 @@ OvsNewVportCmdHandler(POVS_USER_PARAMS_CONTEXT 
> usrParamsCtx,
> 
>  if (OvsIsTunnelVportType(portType)) {
>  UINT16 transportPortDest = 0;
> +UINT8 nwProto;
> +POVS_VPORT_ENTRY dupVport;
> 
>  switch (portType) {
>  case OVS_VPORT_TYPE_GRE:
> +nwProto = IPPROTO_GRE;
>  break;
>  case OVS_VPORT_TYPE_VXLAN:
>  transportPortDest = VXLAN_UDP_PORT;
> +nwProto = IPPROTO_UDP;
>  break;
>  case OVS_VPORT_TYPE_STT:
>  transportPortDest = STT_TCP_PORT;
> +nwProto = IPPROTO_TCP;
>  break;
>

[ovs-dev] [RFC PATCH 02/14] Add NSH fields for Openvswitch flow key

2016-06-13 Thread Johnson Li
Openvswitch could use the fields of Network Serivce Header(NSH)
as key to steer traffic to the Virtual Network Functions(VNF).

Signed-off-by: Johnson Li 

diff --git a/datapath/flow.c b/datapath/flow.c
index c97c9c9..fd09cec 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -489,6 +489,9 @@ static int key_extract(struct sk_buff *skb, struct 
sw_flow_key *key)
skb_reset_mac_len(skb);
__skb_push(skb, skb->data - skb_mac_header(skb));
 
+   /* Network Service Header */
+   memset(>nsh, 0, sizeof(key->nsh));
+
/* Network layer. */
if (key->eth.type == htons(ETH_P_IP)) {
struct iphdr *nh;
diff --git a/datapath/flow.h b/datapath/flow.h
index c0b628a..2f53bfe 100644
--- a/datapath/flow.h
+++ b/datapath/flow.h
@@ -54,10 +54,25 @@ struct ovs_tunnel_info {
(offsetof(struct sw_flow_key, recirc_id) +  \
FIELD_SIZEOF(struct sw_flow_key, recirc_id))
 
+/* Network Service Header, MD Type I only for the moment.
+ */
+struct ovs_nsh_key {
+   u8  flags;
+   u8  md_type;/* NSH metadata type */
+   u8  next_proto; /* NSH next protocol */
+   u8  nsi;/* NSH index */
+   u32 nsp;/* NSH path id */
+   u32 nshc1;  /* NSH context C1-C4 */
+   u32 nshc2;
+   u32 nshc3;
+   u32 nshc4;
+} __packed __aligned(4); /* Minimize padding. */
+
 struct sw_flow_key {
u8 tun_opts[255];
u8 tun_opts_len;
struct ip_tunnel_key tun_key;  /* Encapsulating tunnel key. */
+   struct ovs_nsh_key nsh; /* network service header */
struct {
u32 priority;   /* Packet QoS priority. */
u32 skb_mark;   /* SKB mark. */
-- 
1.8.4.2

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


Re: [ovs-dev] [PATCH v2] netdev-dpdk: Remove vhost send retries when no packets have been sent.

2016-06-13 Thread Ilya Maximets
Looks good to me.
Acked-by: Ilya Maximets 


On 11.06.2016 02:08, Daniele Di Proietto wrote:
> Thanks for the patch, it looks good to me.
> 
> If everybody agrees (Ilya?) I can push this to master.
> 
> Thanks,
> 
> Daniele
> 
> 2016-06-10 9:49 GMT-07:00 Kevin Traynor  >:
> 
> If the guest is connected but not servicing the virt queue, this leads
> to vhost send retries until timeout. This is fine in isolation but if
> there are other high rate queues also being serviced by the same PMD
> it can lead to a performance hit on those queues. Change to only retry
> when at least some packets have been successfully sent on the previous
> attempt.
> 
> Also, limit retries to avoid a similar delays if packets are being sent
> at a very low rate due to few available descriptors.
> 
> Reported-by: Bhanuprakash Bodireddy  >
> Signed-off-by: Kevin Traynor  >
> Acked-by: Bhanuprakash Bodireddy  >
> ---
> 
>  RFC->v2
>  - Change to PATCH after ML discussion.
>  - Rebase.
>  - Add retry limit when packets are being sent.
>  - Add Ack from Bhanu.
> 
>  lib/netdev-dpdk.c |   34 ++
>  1 files changed, 6 insertions(+), 28 deletions(-)
> 
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index 19d355f..582569c 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -141,10 +141,7 @@ static char *cuse_dev_name = NULL;/* Character 
> device cuse_dev_name. */
>  #endif
>  static char *vhost_sock_dir = NULL;   /* Location of vhost-user sockets 
> */
> 
> -/*
> - * Maximum amount of time in micro seconds to try and enqueue to vhost.
> - */
> -#define VHOST_ENQ_RETRY_USECS 100
> +#define VHOST_ENQ_RETRY_NUM 8
> 
>  static const struct rte_eth_conf port_conf = {
>  .rxmode = {
> @@ -1377,7 +1374,7 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int 
> qid,
>  struct rte_mbuf **cur_pkts = (struct rte_mbuf **) pkts;
>  unsigned int total_pkts = cnt;
>  unsigned int qos_pkts = cnt;
> -uint64_t start = 0;
> +int retries = 0;
> 
>  qid = dev->tx_q[qid % dev->real_n_txq].map;
> 
> @@ -1404,32 +1401,13 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, 
> int qid,
>  if (OVS_LIKELY(tx_pkts)) {
>  /* Packets have been sent.*/
>  cnt -= tx_pkts;
> -/* Prepare for possible next iteration.*/
> +/* Prepare for possible retry.*/
>  cur_pkts = _pkts[tx_pkts];
>  } else {
> -uint64_t timeout = VHOST_ENQ_RETRY_USECS * 
> rte_get_timer_hz() / 1E6;
> -unsigned int expired = 0;
> -
> -if (!start) {
> -start = rte_get_timer_cycles();
> -}
> -
> -/*
> - * Unable to enqueue packets to vhost interface.
> - * Check available entries before retrying.
> - */
> -while (!rte_vring_available_entries(virtio_dev, vhost_qid)) {
> -if (OVS_UNLIKELY((rte_get_timer_cycles() - start) > 
> timeout)) {
> -expired = 1;
> -break;
> -}
> -}
> -if (expired) {
> -/* break out of main loop. */
> -break;
> -}
> +/* No packets sent - do not retry.*/
> +break;
>  }
> -} while (cnt);
> +} while (cnt && (retries++ < VHOST_ENQ_RETRY_NUM));
> 
>  rte_spinlock_unlock(>tx_q[qid].tx_lock);
> 
> --
> 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] How To Start Make $950 daily Online?

2016-06-13 Thread Johnathon Oneil

Hey,
You are successfully selected for Auto Trader System..
In Case, If you don’t know what "Auto  trader" is..

It’s an online trading software.. Allowing the users to 
Make up to $10,000/Day.. (NO Experience Required)

Please Get Your Free Access Now:
http://printsandijital.com/Fc0nSg

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


[ovs-dev] [PATCH V4] Function tracer to trace all function calls

2016-06-13 Thread nghosh
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.

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 

---
 configure.ac  |  10 +++
 include/openvswitch/vlog.h|   1 +
 lib/vlog.c|  22 +++
 ovn/controller/automake.mk|   9 +++
 ovn/controller/ovn-controller.c   |  10 +++
 ovn/northd/automake.mk|   9 +++
 ovn/northd/ovn-northd.c   |  10 +++
 third-party/function_tracer.c | 126 ++
 third-party/generate_ft_report.py |  80 
 utilities/automake.mk |   1 +
 vswitchd/automake.mk  |   8 +++
 vswitchd/ovs-vswitchd.c   |   9 +++
 12 files changed, 295 insertions(+)
 create mode 100644 third-party/function_tracer.c
 create mode 100644 third-party/generate_ft_report.py

diff --git a/configure.ac b/configure.ac
index 05d80d5..4abb2ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,16 @@ AC_PROG_MKDIR_P
 AC_PROG_FGREP
 AC_PROG_EGREP
 
+AC_ARG_ENABLE(ft,
+[  --enable-ft Turn on function-tracing],
+[case "${enableval}" in
+  yes) ft=true ;;
+  no)  ft=false ;;
+  *) AC_MSG_ERROR(bad value ${enableval} for --enable-ft) ;;
+esac],[ft=false])
+AM_CONDITIONAL(ENABLE_FT, test x$ft = xtrue)
+
+
 AC_ARG_VAR([PERL], [path to Perl interpreter])
 AC_PATH_PROG([PERL], perl, no)
 if test "$PERL" = no; then
diff --git a/include/openvswitch/vlog.h b/include/openvswitch/vlog.h
index de64cbd..2df8796 100644
--- a/include/openvswitch/vlog.h
+++ b/include/openvswitch/vlog.h
@@ -57,6 +57,7 @@ enum vlog_level {
 VLL_N_LEVELS
 };
 
+void __attribute__ ((no_instrument_function)) vlog_directory(char *, int);
 const char *vlog_get_level_name(enum vlog_level);
 enum vlog_level vlog_get_level_val(const char *name);
 
diff --git a/lib/vlog.c b/lib/vlog.c
index 30b5bc2..468d444 100644
--- a/lib/vlog.c
+++ b/lib/vlog.c
@@ -1138,6 +1138,28 @@ vlog_valist(const struct vlog_module *module, enum 
vlog_level level,
 }
 }
 
+void __attribute__ ((no_instrument_function))
+vlog_directory(char *dir,int len)
+{
+int dir_len;
+if (log_file_name == NULL) {
+dir_len = strlen(ovs_logdir());
+if (dir_len > len) {
+*dir = '\0';
+}
+snprintf(dir, dir_len, "%s", ovs_logdir());
+} else {
+char *fname = strrchr(log_file_name,'/');
+if (fname) {
+   dir_len = strlen(log_file_name) - strlen(fname)+1;
+   if (dir_len > len) {
+   *dir = '\0';
+   } else {
+   snprintf(dir, dir_len, "%s", log_file_name);
+   }
+}
+}
+}
 void
 vlog(const struct vlog_module *module, enum vlog_level level,
  const char *message, ...)
diff --git a/ovn/controller/automake.mk b/ovn/controller/automake.mk
index cf57bbd..61efcf4 100644
--- a/ovn/controller/automake.mk
+++ b/ovn/controller/automake.mk
@@ -1,3 +1,9 @@
+if ENABLE_FT
+CFLAGS += -g -finstrument-functions  \
+ `pkg-config --cflags glib-2.0` \
+ `pkg-config --libs glib-2.0` -ldl -export-dynamic -lrt
+endif
+
 bin_PROGRAMS += ovn/controller/ovn-controller
 ovn_controller_ovn_controller_SOURCES = \
ovn/controller/binding.c \
@@ -20,6 +26,9 @@ ovn_controller_ovn_controller_SOURCES = \
ovn/controller/ovn-controller.h \
ovn/controller/physical.c \
ovn/controller/physical.h
+if ENABLE_FT
+ovn_controller_ovn_controller_SOURCES += third-party/function_tracer.c
+endif
 ovn_controller_ovn_controller_LDADD = ovn/lib/libovn.la lib/libopenvswitch.la
 man_MANS += ovn/controller/ovn-controller.8
 EXTRA_DIST += ovn/controller/ovn-controller.8.xml
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index 356a94b..10479e8 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -62,10 +62,19 @@ static unixctl_cb_func ct_zone_list;
 #define DEFAULT_BRIDGE_NAME "br-int"
 
 static void 

Re: [ovs-dev] [PATCH] datapath-windows: use ip proto for tunnel port lookup

2016-06-13 Thread Alin Serdean
Hi Nithin,

Thanks for the patch. Beside a few small nits regarding whitespace and extra 
comments, please see considerations to GRE tunnels in inlined comments.

Alin.
> -if (tunnelVport) {
> +break;
> +case OVS_VPORT_TYPE_VXLAN:
>  ovsActionStats.rxVxlan++;
> +break;
> +#if 0
> +case OVS_VPORT_TYPE_GENEVE:
> +ovsActionStats.rxGeneve++;
> +break;
> +#endif
[Alin Gabriel Serdean: ] I think you can fan out the ifdef and Yin can add them 
later
> +case OVS_VPORT_TYPE_GRE:
> +ovsActionStats.rxGre++;
> +break;
>  }
> -break;
>  }
>  }
> 
> diff --git a/datapath-windows/ovsext/Tunnel.c b/datapath-
> windows/ovsext/Tunnel.c
> index 97d2020..c5aae1a 100644
> --- a/datapath-windows/ovsext/Tunnel.c
> +++ b/datapath-windows/ovsext/Tunnel.c
> @@ -285,9 +285,9 @@ OvsInjectPacketThroughActions(PNET_BUFFER_LIST
> pNbl,
> 
>  SendFlags |= NDIS_SEND_FLAGS_DISPATCH_LEVEL;
> 
> -vport = OvsFindTunnelVportByDstPort(gOvsSwitchContext,
> -htons(tunnelKey.dst_port),
> -OVS_VPORT_TYPE_VXLAN);
> +vport = OvsFindTunnelVportByDstPortAndType(gOvsSwitchContext,
> +   htons(tunnelKey.dst_port),
> +
> + OVS_VPORT_TYPE_VXLAN);
> 
>  if (vport == NULL){
>  status = STATUS_UNSUCCESSFUL; diff --git a/datapath-
> windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c index
> 222b2c1..f5eeaa5 100644
> --- a/datapath-windows/ovsext/Vport.c
> +++ b/datapath-windows/ovsext/Vport.c
> @@ -691,9 +691,9 @@ OvsFindVportByPortNo(POVS_SWITCH_CONTEXT
> switchContext,
> 
> 
>  POVS_VPORT_ENTRY
> -OvsFindTunnelVportByDstPort(POVS_SWITCH_CONTEXT switchContext,
> -UINT16 dstPort,
> -OVS_VPORT_TYPE ovsPortType)
> +OvsFindTunnelVportByDstPortAndType(POVS_SWITCH_CONTEXT
> switchContext,
> +   UINT16 dstPort,
> +   OVS_VPORT_TYPE ovsPortType)
>  {
>  POVS_VPORT_ENTRY vport;
>  PLIST_ENTRY head, link;
> @@ -711,6 +711,41 @@
> OvsFindTunnelVportByDstPort(POVS_SWITCH_CONTEXT switchContext,  }
> 
>  POVS_VPORT_ENTRY
> +OvsFindTunnelVportByDstPortAndNWProto(POVS_SWITCH_CONTEXT
> switchContext,
> +  UINT16 dstPort,
> +  UINT8 nwProto) {
> +POVS_VPORT_ENTRY vport;
> +PLIST_ENTRY head, link;
> +UINT32 hash = OvsJhashBytes((const VOID *), sizeof(dstPort),
> +OVS_HASH_BASIS);
> +head = &(switchContext->tunnelVportsArray[hash &
> OVS_VPORT_MASK]);
> +LIST_FORALL(head, link) {
> +vport = CONTAINING_RECORD(link, OVS_VPORT_ENTRY,
> tunnelVportLink);
> +if (GetPortFromPriv(vport) == dstPort) {
> +switch (nwProto) {
[Alin Gabriel Serdean: ] This will break in case we have a GRE tunnel set up. 
They rely only on the IP protocol; their destination port will be always set to 
zero. We can have packets which have l4 port zero and a gre tunnel which will 
result in a misinterpreted patcket. Please leave the function 
OvsFindTunnelVportByPortType the way it was and create a new one.
> +case IPPROTO_UDP:
> +if (/* nwProto != OVS_VPORT_TYPE_GENEVE || */
[Alin Gabriel Serdean: ] I think you can fan out the comment and Yin can add 
them later
> +vport->ovsType != OVS_VPORT_TYPE_VXLAN) {
> +continue;
> +}
> +break;
> +case IPPROTO_TCP:
> +if (vport->ovsType != OVS_VPORT_TYPE_STT) {
> +continue;
> +}
> +break;
> +case IPPROTO_GRE:
> +default:
> +break;
> +}
> +return vport;
> +}
> +}
> +return NULL;
> +}
> +
> +POVS_VPORT_ENTRY
>  OvsFindTunnelVportByPortType(POVS_SWITCH_CONTEXT switchContext,
>   OVS_VPORT_TYPE ovsPortType)  { @@ -,15 
> +2257,20 @@
> OvsNewVportCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
> 
>  if (OvsIsTunnelVportType(portType)) {
>  UINT16 transportPortDest = 0;
> +UINT8 nwProto;
> +POVS_VPORT_ENTRY dupVport;
> 
>  switch (portType) {
>  case OVS_VPORT_TYPE_GRE:
> +nwProto = IPPROTO_GRE;
>  break;
>  case OVS_VPORT_TYPE_VXLAN:
>  transportPortDest = VXLAN_UDP_PORT;
> +nwProto = IPPROTO_UDP;
>  break;
>  case OVS_VPORT_TYPE_STT:
>  transportPortDest = STT_TCP_PORT;
> +nwProto = IPPROTO_TCP;
>  break;
>  

[ovs-dev] [PATCH v2] ipfix: Bug fix for not sending template packets on 32-bit OS

2016-06-13 Thread Benli Ye
'last_template_set_time' in truct dpif_ipfix_exporter is declared
as time_t and time_t is long int type. If we initialize
'last_template_set_time' as TIME_MIN, whose value is -2147483648
on 32-bit OS and -2^63 on 64-bit OS. There will be a problem on
32-bit OS when comparing 'last_template_set_time' with a unisgned int
type variable, because type casting will happen and negative value
could be a large positive number. Fix this problem by simply initialize
'last_template_set_time' as 0.

Signed-off-by: Benli Ye 
---
 ofproto/ofproto-dpif-ipfix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index 79ba234..b1b2237 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -495,7 +495,7 @@ dpif_ipfix_exporter_init(struct dpif_ipfix_exporter 
*exporter)
 {
 exporter->collectors = NULL;
 exporter->seq_number = 1;
-exporter->last_template_set_time = TIME_MIN;
+exporter->last_template_set_time = 0;
 hmap_init(>cache_flow_key_map);
 ovs_list_init(>cache_flow_start_timestamp_list);
 exporter->cache_active_timeout = 0;
@@ -511,7 +511,7 @@ dpif_ipfix_exporter_clear(struct dpif_ipfix_exporter 
*exporter)
 collectors_destroy(exporter->collectors);
 exporter->collectors = NULL;
 exporter->seq_number = 1;
-exporter->last_template_set_time = TIME_MIN;
+exporter->last_template_set_time = 0;
 exporter->cache_active_timeout = 0;
 exporter->cache_max_flows = 0;
 }
-- 
1.9.1

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


Re: [ovs-dev] [PATCH v4] Add configurable OpenFlow port name.

2016-06-13 Thread Xiao Liang
On Mon, Jun 6, 2016 at 9:35 AM, Ben Pfaff  wrote:
> On Sun, Jun 05, 2016 at 12:57:02AM +0800, Xiao Liang wrote:
>> On Sat, Jun 4, 2016 at 1:15 AM, Ben Pfaff  wrote:
>> > On Tue, May 24, 2016 at 03:07:23PM +0800, Xiao Liang wrote:
>> >> Add new column "ofname" in Interface table to configure port name reported
>> >> to controllers with OpenFlow protocol, thus decouple OpenFlow port name 
>> >> from
>> >> device name.
>
> ...
>
>> > I'd like ovs-ofctl to report an error if a user attempts to refer to a
>> > port by name but there is more than one port with the name.  That could
>> > be in a separate patch.
>>
>> And what do you think of also adding an option (say, "--all") to
>> select all ports with the name?
>
> Do you think that users would find that option to be useful in practice?
> If you do, and it can be implemented cleanly in ovs-ofctl, then I think
> it would be OK to add an --all option.
>

Maybe useful if someone intentionally sets duplicate names and wants
to configure them by group.

And about the implementation... it would be great if you can give some
suggestions.

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


Re: [ovs-dev] [PATCH v2 2/2] netdev-dpdk: Support user-defined socket attribs

2016-06-13 Thread Ansis Atteka
On 13 June 2016 at 14:36, Aaron Conole  wrote:

> Daniele Di Proietto  writes:
>
> > On 10/06/2016 10:51, "Aaron Conole"  wrote:
> >
> >>Aaron Conole  writes:
> >>
> >>> Christian Ehrhardt  writes:
> >>>
>  On Tue, May 24, 2016 at 4:10 PM, Aaron Conole 
> wrote:
> 
> > Daniele Di Proietto  writes:
> >
> > > Hi Aaron,
> > >
> > > I'm still a little bit nervous about calling chown on a (partially)
> > > user controlled file name.
> >
> > I agree, that always seems scary.
> >
> > > Before moving forward I wanted to discuss a couple of other
> options:
> > >
> > > * Ansis (in CC) suggested using -runas parameter in qemu.  This way
> > > qemu can open the socket as root and drop privileges before
> starting
> > > guest execution.
> >
> > I'm not sure how to do this with libvirt, or via the OpenStack
> Neutron
> > plugin.  I also don't know if it would be an acceptable workaround
> for
> > users.  Additionally, I recall there being something of a "don't even
> > know if this works" around it.  Maybe Christian or Ansis (both in CC)
> > can expound on it.
> >
> 
>  Hi,
>  IIRC we kind of agree that long term a proper MAC will be much better
> but
>  most involved people needed something to get it working like "now".
>  Since they are complementary (other than the fix removing a bit of the
>  urgency for more MAC) it was kind of the least bad option.
> 
>  You have to be aware that I brought up the discussion on d...@dpdk.org
> - see
>  [1] and [2]:
>  But this will take time and eventually still be the applications task
> to
>  "do something" - no matter if via API or via the chmod's right now.
>  So Aaron is trying to get something that works now until the long term
>  things are in place, which I appreciate.
> 
>  FYI - I was even more in a hurry as it was clear that OVS-2.5 won't
> get
>  this in time I run with [3] for now.
>  I never intended to suggest that, but with the discussion in place,
> one
>  could ask if you (Aaron) want to pick up that instead.
>  That would keep OVS free for now until DPDK made up the API (see [2])
> for
>  socket ownership control and this then could be implemented in OVS?
> 
>  (I hope) In some months/years we will all be happy to drop this bunch
> of
>  interim solutions, never the less we need it for now.
> 
>  [1]: http://dpdk.org/dev/patchwork/patch/1/
>  [2]: http://dpdk.org/ml/archives/dev/2015-December/030326.html
>  [3]:
> 
> https://git.launchpad.net/~ubuntu-server/dpdk/commit/?h=ubuntu-xenial-to-dpdk2.2=f3c7aa1b2ddea8e092ad4a89e41a0e19d01ed4e7
> 
>  [...]
> 
> 
> > I think originally we quickly discussed 4 possible solutions (and
> > hopefully I captured them correctly):
> >
> > 1. OVS downgrades to the ovs user, and kvm runs under the ovs
> >group.  I don't actually like this solution because kvm could then
> >pollute the ovs database.
> >
> > 2. OVS runs as some user and sets the user/group ownership of the
> socket
> >via chown/chmod where permissions come from the database (the
> >original context had ovs running as root - but as I described
> above
> >it doesn't need to be root provided ovs+DPDK can start without
> root).
> >
> > 3. OVS runs as some user, kvm starts as root, opens the socket and
> >downgrades.  IIRC, this doesn't actually work, or it may have
> >implications on other projects.  I don't remember exactly what was
> >not as great about this solution, TBH.
> >
> > 4. OVS and KVM run as whatever users; MAC is used to enforce the
> >layering between them.
> >
> > I think solution 2 and solution 4 don't actually interfere with each
> > other, and can be used to a complementary effect (if implemented
> > properly) so that the MAC layer enforces access, but even without
> MAC,
> > the DAC layer can provide appropriate whitelisting behavior.
> >
> 
>  I also remember several complex changes needed for the #1 and #3 that
>  always would end up with huge effort and a high risk not being
> accepted.
>  Probably that is what you refer to with "implications on other
> projects".
> 
>  Also keep in mind the position of dpdk out of the last few discussions
>  which I'd like to summarize as "dpdk got this path from an app, so
> this app
>  OWNS that path".
> >>>
> >>> I'd like to continue on, but I am not sure what the concerns are right
> >>> now.  Is it possible to enumerate them point by point so that I can
> >>> understand them?  I think there are two outstanding concerns right now:
> >>>
> >>> 1. the proposed 

Re: [ovs-dev] [PATCH v2] datapath-windows: Sample action support.

2016-06-13 Thread Alin Serdean
Acked-by: Alin Gabriel Serdean 


> -Mesaj original-
> De la: dev [mailto:dev-boun...@openvswitch.org] În numele Sorin Vinturis
> Trimis: Wednesday, June 1, 2016 6:50 PM
> Către: dev@openvswitch.org
> Subiect: [ovs-dev] [PATCH v2] datapath-windows: Sample action support.
> 
> This patch adds support for sampling to the OVS extension.
> 
> The following flow was used for generating sample actions:
>   ovs-ofctl add-flow tcp:127.0.0.1: "actions=sample(
> probability=12345,collector_set_id=23456,obs_domain_id=34567,
> obs_point_id=45678)"
> 
> Signed-off-by: Sorin Vinturis 
> ---
> v2: Moved random functions to Util.h and removed Random.h.
> ---
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 00/10] datapath: NAT backports

2016-06-13 Thread Jesse Gross
On Thu, Jun 9, 2016 at 3:45 PM, Jarno Rajahalme  wrote:
> This series adds the conntrack NAT integration upstreamed in Linux 4.6
> to the OVS tree kernel module.  Main code is the same as upstream,
> backports are provided for Linux kernels 3.10 - 4.3.  Code compiles on
> the latest release of each Linux version on this range.  Linux 4.4 and
> 4.5 remain untested as OVS tree kernel module does not yet support
> them.

Can you check 4.4-4.6 to see if any additional backports are needed?
(There might not be any if it already works on older kernels.) It has
been reported that things seem to generally work up to 4.6 just by
removing the configure check so it shouldn't be hard to test. We're
trying to get support for 4.6 in so if we skip the backports for this
then it will just add more to the backlog of things that will need to
be immediately addressed.

> I have retained the original Acks for patches that are simple
> "cherry-picks" from upstream patches.  In some cases I have squashed
> in later bug fixes so that the end result is identical to the current
> net-next upstream.

Can you include the upstream git hash in the commit message of each
patch? This makes it significantly easier to review. Here's an example
of the format that we've generally used for backports:
http://openvswitch.org/pipermail/dev/2016-June/072572.html

The closer we can keep each patch to its upstream equivalent, the
easier it is to maintain things.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2] datapath-windows: Sample action support.

2016-06-13 Thread Nithin Raju
Acked-by: Nithin Raju 

-Original Message-
From: dev  on behalf of Sorin Vinturis

Date: Wednesday, June 1, 2016 at 8:50 AM
To: "dev@openvswitch.org" 
Subject: [ovs-dev] [PATCH v2] datapath-windows: Sample action support.

>This patch adds support for sampling to the OVS extension.
>
>The following flow was used for generating sample actions:
>  ovs-ofctl add-flow tcp:127.0.0.1: "actions=sample(
>probability=12345,collector_set_id=23456,obs_domain_id=34567,
>obs_point_id=45678)"
>
>Signed-off-by: Sorin Vinturis 
>---
>v2: Moved random functions to Util.h and removed Random.h.
>---
> datapath-windows/ovsext/Actions.c | 181
>+++---
> datapath-windows/ovsext/Util.h|  27 ++
> 2 files changed, 175 insertions(+), 33 deletions(-)
>
>diff --git a/datapath-windows/ovsext/Actions.c
>b/datapath-windows/ovsext/Actions.c
>index 4edf7d0..1e894eb 100644
>--- a/datapath-windows/ovsext/Actions.c
>+++ b/datapath-windows/ovsext/Actions.c
>@@ -1596,6 +1596,131 @@ OvsExecuteHash(OvsFlowKey *key,
> hash = 1;
> 
> key->dpHash = hash;
>+}
>+
>+/*
>+ * 
>--
>+ * OvsOutputUserspaceAction --
>+ *  This function sends the packet to userspace according to nested
>+ *  %OVS_USERSPACE_ATTR_* attributes.
>+ * 
>--
>+ */
>+static __inline NDIS_STATUS
>+OvsOutputUserspaceAction(OvsForwardingContext *ovsFwdCtx,
>+ OvsFlowKey *key,
>+ const PNL_ATTR attr)
>+{
>+NTSTATUS status = NDIS_STATUS_SUCCESS;
>+PNL_ATTR userdataAttr;
>+PNL_ATTR queueAttr;
>+POVS_PACKET_QUEUE_ELEM elem;
>+POVS_PACKET_HDR_INFO layers = >layers;
>+BOOLEAN isRecv = FALSE;
>+
>+POVS_VPORT_ENTRY vport =
>OvsFindVportByPortNo(ovsFwdCtx->switchContext,
>+  ovsFwdCtx->srcVportNo);
>+
>+if (vport) {
>+if (vport->isExternal ||
>+OvsIsTunnelVportType(vport->ovsType)) {
>+isRecv = TRUE;
>+}
>+}
>+
>+queueAttr = NlAttrFindNested(attr, OVS_USERSPACE_ATTR_PID);
>+userdataAttr = NlAttrFindNested(attr, OVS_USERSPACE_ATTR_USERDATA);
>+
>+elem = OvsCreateQueueNlPacket(NlAttrData(userdataAttr),
>+  NlAttrGetSize(userdataAttr),
>+  OVS_PACKET_CMD_ACTION,
>+  vport, key, ovsFwdCtx->curNbl,
>+ 
>NET_BUFFER_LIST_FIRST_NB(ovsFwdCtx->curNbl),
>+  isRecv,
>+  layers);
>+if (elem) {
>+LIST_ENTRY missedPackets;
>+InitializeListHead();
>+InsertTailList(, >link);
>+OvsQueuePackets(, 1);
>+} else {
>+status = NDIS_STATUS_FAILURE;
>+}
>+
>+return status;
>+}
>+
>+/*
>+ * 
>--
>+ * OvsExecuteSampleAction --
>+ *  Executes actions based on probability, as specified in the nested
>+ *  %OVS_SAMPLE_ATTR_* attributes.
>+ * 
>--
>+ */
>+static __inline NDIS_STATUS
>+OvsExecuteSampleAction(OvsForwardingContext *ovsFwdCtx,
>+   OvsFlowKey *key,
>+   const PNL_ATTR attr)
>+{
>+PNET_BUFFER_LIST newNbl = NULL;
>+PNL_ATTR actionsList = NULL;
>+PNL_ATTR a = NULL;
>+INT rem = 0;
>+
>+SRand();
>+NL_ATTR_FOR_EACH_UNSAFE(a, rem, NlAttrData(attr),
>NlAttrGetSize(attr)) {
>+switch (NlAttrType(a)) {
>+case OVS_SAMPLE_ATTR_PROBABILITY:
>+{
>+UINT32 probability = NlAttrGetU32(a);
>+
>+if (!probability || Rand() > probability) {
>+return 0;
>+}
>+break;
>+}
>+case OVS_SAMPLE_ATTR_ACTIONS:
>+actionsList = a;
>+break;
>+}
>+}
>+
>+if (actionsList) {
>+rem = NlAttrGetSize(actionsList);
>+a = (PNL_ATTR)NlAttrData(actionsList);
>+}
>+
>+if (!rem) {
>+/* Actions list is empty, do nothing */
>+return STATUS_SUCCESS;
>+}
>+
>+/*
>+ * The only known usage of sample action is having a single
>user-space
>+ * action. Treat this usage as a special case.
>+ */
>+if (NlAttrType(a) == OVS_ACTION_ATTR_USERSPACE &&
>+NlAttrIsLast(a, rem)) {
>+return OvsOutputUserspaceAction(ovsFwdCtx, key, a);
>+}
>+
>+newNbl = OvsPartialCopyNBL(ovsFwdCtx->switchContext,
>ovsFwdCtx->curNbl,
>+   0, 0, TRUE /*copy NBL info*/);
>+if (newNbl == NULL) {
>+/*
>+ * Skip the sample action when out of memory, but 

Re: [ovs-dev] [PATCH v3] datapath-windows: Add GRE checksum

2016-06-13 Thread Nithin Raju
>>
>>-Mesaj original-
>> De la: Nithin Raju [mailto:nit...@vmware.com]
>> Trimis: Wednesday, June 8, 2016 10:10 PM
>> Către: Alin Serdean ;
>> dev@openvswitch.org
>> Subiect: Re: [ovs-dev] [PATCH v3] datapath-windows: Add GRE checksum
>> 
>> 
>> >+/* Get a contignuous buffer for the maxmimum length of a GRE
>> >+ header
>> >*/
>> >+bufferStart = NdisGetDataBuffer(curNb, OVS_MAX_GRE_LGTH, NULL, 1,
>> >+ 0);
>> 
>> Sorry we have to go back and forth on this. Like I mentioned in the
>>previous
>> email, the idea is to get a contiguous chunk of memory so we can walk
>>all the
>> header until the GRE header. It is a good idea to use
>> NdisGetDataBuffer() instead of copying the NBL. But, we won¹t avoid the
>> copied NBL anyway since decap has to happen on the copied NBL.
>[Alin Gabriel Serdean: ] Agreed. I only wanted a check to make sure the
>whole ETH, IP, GRE was contiguous.
>> 
>> In any case, NdisGetDataBuffer() has some pitfalls:
>> "If the requested data in the buffer is contiguous, this return value
>>is a
>> pointer to a location that NDIS provides. If the data is not
>>contiguous, NDIS
>> uses the Storage parameter as follows:
>> 
>> * If the Storage parameter is non-NULL, NDIS copies the data to the
>>buffer at
>> Storage. This return value is the pointer passed to the Storage
>>parameter.
>> * If the Storage parameter is NULL, this return value is NULL.²
>> 
>> So, if the first MDL does not fit the headers until the GRE headers, we
>>need
>> to pass explicit memory to NdisGetDataBuffer() in argument #3 in order
>>for
>> NDIS to copy it over to a contiguous chunk of memory.
>[Alin Gabriel Serdean: ] We have to take into consideration that NDIS 6.3
>supports NVGRE and in NDIS 6.4 GRE
>(https://urldefense.proofpoint.com/v2/url?u=https-3A__support.microsoft.co
>m_en-2Dus_kb_3022776=CwIFAA=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uE
>s=pNHQcdr7B40b4h6Yb7FIedI1dnBsxdDuTLBYD3JqV80=Xih_0c1MPDafKSkW1nO5-mIu
>tm1WK_ZmMcu7likx3jM=OR7CpNr_D_lG7SqFfSsi2qb63XGh1WaXVKtbLqjfT8s=  ).

[Nithin]: I am not sure how NDIS supporting GRE and NVGRE would affect
help with putting the ETH + IP + GRE header in a contiguous buffer. The
MDLs are typically formed by the mini port driver, and NDIS will either
run a parser on top of it or use an offload if the NIC supports it.

>Packets can be split in multiple Mdl's, if the miniport supports it, as
>early as at the beginning of the upper-layer-protocol
>(https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_e
>n-2Dus_library_windows_hardware_ff571065-28v-3Dvs.85-29.aspx=CwIFAA=Sq
>cl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs=pNHQcdr7B40b4h6Yb7FIedI1dnBsxd
>DuTLBYD3JqV80=Xih_0c1MPDafKSkW1nO5-mIutm1WK_ZmMcu7likx3jM=sZElhQvcdQPd
>zDWCX8jmxd33zxPVzkGsudCT0Z8pdr4= ) and if the split header is not
>greater than the maximum header size which is configurable. In the case
>of VXLAN / STT we can be in the case above, because of the UDP/TCP like
>packet

[Nithin]: Yes, in fact even for NICs that support header-split (mostly
Intel), the payload of the packet WILL NOT be in the first MDL. In case of
GRE, the split would happen at the IP header itself. So, GRE header would
not be in the contigous buffer.

>, but for GRE things differ since there are cards which support
>offloading:
>https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en
>-2Dus_library_windows_hardware_dn605832-28v-3Dvs.85-29.aspx=CwIFAA=Sqc
>l0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs=pNHQcdr7B40b4h6Yb7FIedI1dnBsxdD
>uTLBYD3JqV80=Xih_0c1MPDafKSkW1nO5-mIutm1WK_ZmMcu7likx3jM=A4LA4vS20hf4l
>keq-wjCc6N9kbBMqswRnC-SSulTF6s=
>"The protocol driver will guarantee that all the prepended encapsulation
>headers (ETH, IP, GRE) will be physically contiguous and will be in the
>first MDL of the packet."


>I do not think we will be in a situation in which a GRE header will not
>be continuous.
>If you consider we should still have a fragmented header problem, I will
>allocate a buffer and execute another NdisGetDataBuffer call if the first
>one failed.

[Nithin]: The documention you point to is to the send direction. In case
of receive, where does it say that the protocol/filter driver can expect
the miniport driver to pack the ETH + IP + GRE header in one contiguous
buffer?

In any case, if you are particular that the code is correct, I am ok with
the patch. I was trying to give suggestions to make the code solid.

Acked-by: Nithin Raju 

-- Nithin

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


Re: [ovs-dev] [PATCH 4/5] datapath-windows: Add support for Conntrack IPCTNL_MSG_CT_DELETE cmd in Datapath.c

2016-06-13 Thread Sairam Venugopal
I missed out () in:

if (!IS_NFNL_CMD(usrParamsCtx->ovsMsg->nlMsg.nlmsgType) &&
(usrParamsCtx->ovsMsg->genlMsg.cmd ==
OVS_CTRL_CMD_EVENT_NOTIFY ||
usrParamsCtx->ovsMsg->genlMsg.cmd ==
OVS_CTRL_CMD_READ_NOTIFY))


I have addressed this in an updated version. I will send the one out after
addressing other review comments across the patch series.

Thanks,
Sairam

On 6/13/16, 3:37 PM, "Sairam Venugopal"  wrote:

>Create new NETLINK_CMD and NETLINK_FAMILY to assist in flushing conntrack
>entries. Modify
>Datapath.c to now support netfilter-netlink messages apart from the
>existing netfilter-generic messages. Also hookup the command handler to
>execute the OvsCtFlush in Conntrack.c
>
>Signed-off-by: Sairam Venugopal 
>---
> datapath-windows/include/OvsDpInterfaceExt.h | 17 ++
> datapath-windows/ovsext/Datapath.c   | 80
>
> 2 files changed, 88 insertions(+), 9 deletions(-)
>
>diff --git a/datapath-windows/include/OvsDpInterfaceExt.h
>b/datapath-windows/include/OvsDpInterfaceExt.h
>index e235376..1044de7 100644
>--- a/datapath-windows/include/OvsDpInterfaceExt.h
>+++ b/datapath-windows/include/OvsDpInterfaceExt.h
>@@ -17,6 +17,9 @@
> #ifndef __OVS_DP_INTERFACE_EXT_H_
> #define __OVS_DP_INTERFACE_EXT_H_ 1
> 
>+#include "include/windows/linux/netfilter/nfnetlink.h"
>+#include "include/windows/linux/netfilter/nfnetlink_conntrack.h"
>+
> /* Windows kernel datapath extensions to the standard datapath
>interface. */
> 
> /* Version number of the datapath interface extensions. */
>@@ -65,6 +68,7 @@
> #define OVS_WIN_NL_VPORT_FAMILY_ID   (NLMSG_MIN_TYPE + 4)
> #define OVS_WIN_NL_FLOW_FAMILY_ID(NLMSG_MIN_TYPE + 5)
> #define OVS_WIN_NL_NETDEV_FAMILY_ID  (NLMSG_MIN_TYPE + 6)
>+#define OVS_WIN_NL_CT_FAMILY_ID  (NLMSG_MIN_TYPE + 7)
> 
> #define OVS_WIN_NL_INVALID_MCGRP_ID  0
> #define OVS_WIN_NL_MCGRP_START_ID100
>@@ -156,4 +160,17 @@ enum ovs_win_netdev_attr {
> typedef struct ovs_dp_stats OVS_DP_STATS;
> typedef enum ovs_vport_type OVS_VPORT_TYPE;
> 
>+/* Conntrack Netlink */
>+#define NFNL_TYPE_CT_GET (NFNL_SUBSYS_CTNETLINK << 8 | IPCTNL_MSG_CT_GET)
>+#define NFNL_TYPE_CT_DEL (NFNL_SUBSYS_CTNETLINK << 8 |
>IPCTNL_MSG_CT_DELETE)
>+#define NFNL_SUBSYSTEM_TYPE(nlmsgType) (nlmsgType >> 8)
>+#define NFNL_CT_CMD(nlmsgType) (nlmsgType & 0xff)
>+#define IS_NFNL_CMD(nlmsgType) ((nlmsgType == NFNL_TYPE_CT_GET) ||
>(nlmsgType == NFNL_TYPE_CT_DEL))
>+#define OVS_NL_CT_ATTR_MAX (IPCTNL_MSG_MAX - 1)
>+
>+#define OVS_CT_FAMILY  "ovs_ct"
>+#define OVS_CT_MCGROUP "ovs_ct"
>+#define OVS_CT_VERSION 1
>+
>+
> #endif /* __OVS_DP_INTERFACE_EXT_H_ */
>diff --git a/datapath-windows/ovsext/Datapath.c
>b/datapath-windows/ovsext/Datapath.c
>index b2c7020..802f0b1 100644
>--- a/datapath-windows/ovsext/Datapath.c
>+++ b/datapath-windows/ovsext/Datapath.c
>@@ -103,7 +103,8 @@ NetlinkCmdHandlerOvsGetNetdevCmdHandler,
>  OvsDeleteVportCmdHandler,
>  OvsPendPacketCmdHandler,
>  OvsSubscribePacketCmdHandler,
>- OvsReadPacketCmdHandler;
>+ OvsReadPacketCmdHandler,
>+ OvsCtDeleteCmdHandler;
> 
> static NTSTATUS HandleGetDpTransaction(POVS_USER_PARAMS_CONTEXT
>usrParamsCtx,
>UINT32 *replyLen);
>@@ -282,6 +283,24 @@ NETLINK_FAMILY nlFLowFamilyOps = {
> .opsCount = ARRAY_SIZE(nlFlowFamilyCmdOps)
> };
> 
>+/* Netlink Ct family. */
>+NETLINK_CMD nlCtFamilyCmdOps[] = {
>+{ .cmd  = IPCTNL_MSG_CT_DELETE,
>+  .handler  = OvsCtDeleteCmdHandler,
>+  .supportedDevOp   = OVS_TRANSACTION_DEV_OP,
>+  .validateDpIndex  = TRUE
>+}
>+};
>+
>+NETLINK_FAMILY nlCtFamilyOps = {
>+.name = OVS_CT_FAMILY, /* Keep this for consistency*/
>+.id   = OVS_WIN_NL_CT_FAMILY_ID, /* Keep this for consistency*/
>+.version  = OVS_CT_VERSION, /* Keep this for consistency*/
>+.maxAttr  = OVS_NL_CT_ATTR_MAX,
>+.cmds = nlCtFamilyCmdOps,
>+.opsCount = ARRAY_SIZE(nlCtFamilyCmdOps)
>+};
>+
> /* Netlink netdev family. */
> NETLINK_CMD nlNetdevFamilyCmdOps[] = {
> { .cmd = OVS_WIN_NETDEV_CMD_GET,
>@@ -885,6 +904,9 @@ OvsDeviceControl(PDEVICE_OBJECT deviceObject,
> 
> ASSERT(ovsMsg);
> switch (ovsMsg->nlMsg.nlmsgType) {
>+case NFNL_TYPE_CT_DEL:
>+nlFamilyOps = 
>+break;
> case OVS_WIN_NL_CTRL_FAMILY_ID:
> nlFamilyOps = 
> break;
>@@ -961,6 +983,30 @@ ValidateNetlinkCmd(UINT32 devOp,
> goto done;
> }
> 
>+/*
>+Verify if the Netlink message is part of Netfilter Netlink
>+This is currently used by Conntrack
>+*/
>+if (IS_NFNL_CMD(ovsMsg->nlMsg.nlmsgType)) {
>+
>+/* Validate Netfilter Netlink version is 0 */
>+if (ovsMsg->nfGenMsg.version != NFNETLINK_V0) {
>+

[ovs-dev] [PATCH 4/5] datapath-windows: Add support for Conntrack IPCTNL_MSG_CT_DELETE cmd in Datapath.c

2016-06-13 Thread Sairam Venugopal
Create new NETLINK_CMD and NETLINK_FAMILY to assist in flushing conntrack 
entries. Modify
Datapath.c to now support netfilter-netlink messages apart from the
existing netfilter-generic messages. Also hookup the command handler to
execute the OvsCtFlush in Conntrack.c

Signed-off-by: Sairam Venugopal 
---
 datapath-windows/include/OvsDpInterfaceExt.h | 17 ++
 datapath-windows/ovsext/Datapath.c   | 80 
 2 files changed, 88 insertions(+), 9 deletions(-)

diff --git a/datapath-windows/include/OvsDpInterfaceExt.h 
b/datapath-windows/include/OvsDpInterfaceExt.h
index e235376..1044de7 100644
--- a/datapath-windows/include/OvsDpInterfaceExt.h
+++ b/datapath-windows/include/OvsDpInterfaceExt.h
@@ -17,6 +17,9 @@
 #ifndef __OVS_DP_INTERFACE_EXT_H_
 #define __OVS_DP_INTERFACE_EXT_H_ 1
 
+#include "include/windows/linux/netfilter/nfnetlink.h"
+#include "include/windows/linux/netfilter/nfnetlink_conntrack.h"
+
 /* Windows kernel datapath extensions to the standard datapath interface. */
 
 /* Version number of the datapath interface extensions. */
@@ -65,6 +68,7 @@
 #define OVS_WIN_NL_VPORT_FAMILY_ID   (NLMSG_MIN_TYPE + 4)
 #define OVS_WIN_NL_FLOW_FAMILY_ID(NLMSG_MIN_TYPE + 5)
 #define OVS_WIN_NL_NETDEV_FAMILY_ID  (NLMSG_MIN_TYPE + 6)
+#define OVS_WIN_NL_CT_FAMILY_ID  (NLMSG_MIN_TYPE + 7)
 
 #define OVS_WIN_NL_INVALID_MCGRP_ID  0
 #define OVS_WIN_NL_MCGRP_START_ID100
@@ -156,4 +160,17 @@ enum ovs_win_netdev_attr {
 typedef struct ovs_dp_stats OVS_DP_STATS;
 typedef enum ovs_vport_type OVS_VPORT_TYPE;
 
+/* Conntrack Netlink */
+#define NFNL_TYPE_CT_GET (NFNL_SUBSYS_CTNETLINK << 8 | IPCTNL_MSG_CT_GET)
+#define NFNL_TYPE_CT_DEL (NFNL_SUBSYS_CTNETLINK << 8 | IPCTNL_MSG_CT_DELETE)
+#define NFNL_SUBSYSTEM_TYPE(nlmsgType) (nlmsgType >> 8)
+#define NFNL_CT_CMD(nlmsgType) (nlmsgType & 0xff)
+#define IS_NFNL_CMD(nlmsgType) ((nlmsgType == NFNL_TYPE_CT_GET) || (nlmsgType 
== NFNL_TYPE_CT_DEL))
+#define OVS_NL_CT_ATTR_MAX (IPCTNL_MSG_MAX - 1)
+
+#define OVS_CT_FAMILY  "ovs_ct"
+#define OVS_CT_MCGROUP "ovs_ct"
+#define OVS_CT_VERSION 1
+
+
 #endif /* __OVS_DP_INTERFACE_EXT_H_ */
diff --git a/datapath-windows/ovsext/Datapath.c 
b/datapath-windows/ovsext/Datapath.c
index b2c7020..802f0b1 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -103,7 +103,8 @@ NetlinkCmdHandlerOvsGetNetdevCmdHandler,
  OvsDeleteVportCmdHandler,
  OvsPendPacketCmdHandler,
  OvsSubscribePacketCmdHandler,
- OvsReadPacketCmdHandler;
+ OvsReadPacketCmdHandler,
+ OvsCtDeleteCmdHandler;
 
 static NTSTATUS HandleGetDpTransaction(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
UINT32 *replyLen);
@@ -282,6 +283,24 @@ NETLINK_FAMILY nlFLowFamilyOps = {
 .opsCount = ARRAY_SIZE(nlFlowFamilyCmdOps)
 };
 
+/* Netlink Ct family. */
+NETLINK_CMD nlCtFamilyCmdOps[] = {
+{ .cmd  = IPCTNL_MSG_CT_DELETE,
+  .handler  = OvsCtDeleteCmdHandler,
+  .supportedDevOp   = OVS_TRANSACTION_DEV_OP,
+  .validateDpIndex  = TRUE
+}
+};
+
+NETLINK_FAMILY nlCtFamilyOps = {
+.name = OVS_CT_FAMILY, /* Keep this for consistency*/
+.id   = OVS_WIN_NL_CT_FAMILY_ID, /* Keep this for consistency*/
+.version  = OVS_CT_VERSION, /* Keep this for consistency*/
+.maxAttr  = OVS_NL_CT_ATTR_MAX,
+.cmds = nlCtFamilyCmdOps,
+.opsCount = ARRAY_SIZE(nlCtFamilyCmdOps)
+};
+
 /* Netlink netdev family. */
 NETLINK_CMD nlNetdevFamilyCmdOps[] = {
 { .cmd = OVS_WIN_NETDEV_CMD_GET,
@@ -885,6 +904,9 @@ OvsDeviceControl(PDEVICE_OBJECT deviceObject,
 
 ASSERT(ovsMsg);
 switch (ovsMsg->nlMsg.nlmsgType) {
+case NFNL_TYPE_CT_DEL:
+nlFamilyOps = 
+break;
 case OVS_WIN_NL_CTRL_FAMILY_ID:
 nlFamilyOps = 
 break;
@@ -961,6 +983,30 @@ ValidateNetlinkCmd(UINT32 devOp,
 goto done;
 }
 
+/*
+Verify if the Netlink message is part of Netfilter Netlink
+This is currently used by Conntrack
+*/
+if (IS_NFNL_CMD(ovsMsg->nlMsg.nlmsgType)) {
+
+/* Validate Netfilter Netlink version is 0 */
+if (ovsMsg->nfGenMsg.version != NFNETLINK_V0) {
+status = STATUS_INVALID_PARAMETER;
+goto done;
+}
+
+/* Validate Netfilter Netlink Subsystem */
+if (NFNL_SUBSYSTEM_TYPE(ovsMsg->nlMsg.nlmsgType)
+!= NFNL_SUBSYS_CTNETLINK) {
+status = STATUS_INVALID_PARAMETER;
+goto done;
+}
+
+/* Exit the function because there aren't any other validations */
+status = STATUS_SUCCESS;
+goto done;
+}
+
 for (i = 0; i < nlFamilyOps->opsCount; i++) {
 if (nlFamilyOps->cmds[i].cmd == ovsMsg->genlMsg.cmd) {
 

[ovs-dev] [PATCH 1/5] Windows: Add netfilter-conntrack header files to Include folder

2016-06-13 Thread Sairam Venugopal
Include netfilter-conntrack header files in user-space. This will be used
by Windows userspace for adding debugging support in Conntrack. Some of these 
files
are intentionally left blank and will be updated once relevant support is
added in Windows datapath.

Signed-off-by: Sairam Venugopal 
---
 include/windows/automake.mk|   6 +
 .../windows/linux/netfilter/nf_conntrack_common.h  | 113 ++
 include/windows/linux/netfilter/nf_conntrack_ftp.h |   0
 .../windows/linux/netfilter/nf_conntrack_sctp.h|   0
 include/windows/linux/netfilter/nf_conntrack_tcp.h |  49 
 include/windows/linux/netfilter/nfnetlink.h|  63 ++
 .../windows/linux/netfilter/nfnetlink_conntrack.h  | 249 +
 7 files changed, 480 insertions(+)
 create mode 100644 include/windows/linux/netfilter/nf_conntrack_common.h
 create mode 100644 include/windows/linux/netfilter/nf_conntrack_ftp.h
 create mode 100644 include/windows/linux/netfilter/nf_conntrack_sctp.h
 create mode 100644 include/windows/linux/netfilter/nf_conntrack_tcp.h
 create mode 100644 include/windows/linux/netfilter/nfnetlink.h
 create mode 100644 include/windows/linux/netfilter/nfnetlink_conntrack.h

diff --git a/include/windows/automake.mk b/include/windows/automake.mk
index 58b52f1..382627b 100644
--- a/include/windows/automake.mk
+++ b/include/windows/automake.mk
@@ -9,6 +9,12 @@ noinst_HEADERS += \
include/windows/arpa/inet.h \
include/windows/dirent.h \
include/windows/getopt.h \
+   include/windows/linux/netfilter/nf_conntrack_common.h \
+   include/windows/linux/netfilter/nf_conntrack_ftp.h \
+   include/windows/linux/netfilter/nf_conntrack_sctp.h \
+   include/windows/linux/netfilter/nf_conntrack_tcp.h \
+   include/windows/linux/netfilter/nfnetlink.h \
+   include/windows/linux/netfilter/nfnetlink_conntrack.h \
include/windows/linux/pkt_sched.h \
include/windows/linux/types.h \
include/windows/net/if.h \
diff --git a/include/windows/linux/netfilter/nf_conntrack_common.h 
b/include/windows/linux/netfilter/nf_conntrack_common.h
new file mode 100644
index 000..9904003
--- /dev/null
+++ b/include/windows/linux/netfilter/nf_conntrack_common.h
@@ -0,0 +1,113 @@
+#ifndef _NF_CONNTRACK_COMMON_H
+#define _NF_CONNTRACK_COMMON_H
+/* Connection state tracking for netfilter.  This is separated from,
+   but required by, the NAT layer; it can also be used by an iptables
+   extension. */
+enum ip_conntrack_info {
+/* Part of an established connection (either direction). */
+IP_CT_ESTABLISHED,
+
+/* Like NEW, but related to an existing connection, or ICMP error
+   (in either direction). */
+IP_CT_RELATED,
+
+/* Started a new connection to track (only
+   IP_CT_DIR_ORIGINAL); may be a retransmission. */
+IP_CT_NEW,
+
+/* >= this indicates reply direction */
+IP_CT_IS_REPLY,
+
+IP_CT_ESTABLISHED_REPLY = IP_CT_ESTABLISHED + IP_CT_IS_REPLY,
+IP_CT_RELATED_REPLY = IP_CT_RELATED + IP_CT_IS_REPLY,
+IP_CT_NEW_REPLY = IP_CT_NEW + IP_CT_IS_REPLY,
+/* Number of distinct IP_CT types (no NEW in reply dirn). */
+IP_CT_NUMBER = IP_CT_IS_REPLY * 2 - 1
+};
+
+/* Bitset representing status of connection. */
+enum ip_conntrack_status {
+/* It's an expected connection: bit 0 set.  This bit never changed */
+IPS_EXPECTED_BIT = 0,
+IPS_EXPECTED = (1 << IPS_EXPECTED_BIT),
+
+/* We've seen packets both ways: bit 1 set.  Can be set, not unset. */
+IPS_SEEN_REPLY_BIT = 1,
+IPS_SEEN_REPLY = (1 << IPS_SEEN_REPLY_BIT),
+
+/* Conntrack should never be early-expired. */
+IPS_ASSURED_BIT = 2,
+IPS_ASSURED = (1 << IPS_ASSURED_BIT),
+
+/* Connection is confirmed: originating packet has left box */
+IPS_CONFIRMED_BIT = 3,
+IPS_CONFIRMED = (1 << IPS_CONFIRMED_BIT),
+
+/* Connection needs src nat in orig dir.  This bit never changed. */
+IPS_SRC_NAT_BIT = 4,
+IPS_SRC_NAT = (1 << IPS_SRC_NAT_BIT),
+
+/* Connection needs dst nat in orig dir.  This bit never changed. */
+IPS_DST_NAT_BIT = 5,
+IPS_DST_NAT = (1 << IPS_DST_NAT_BIT),
+
+/* Both together. */
+IPS_NAT_MASK = (IPS_DST_NAT | IPS_SRC_NAT),
+
+/* Connection needs TCP sequence adjusted. */
+IPS_SEQ_ADJUST_BIT = 6,
+IPS_SEQ_ADJUST = (1 << IPS_SEQ_ADJUST_BIT),
+
+/* NAT initialization bits. */
+IPS_SRC_NAT_DONE_BIT = 7,
+IPS_SRC_NAT_DONE = (1 << IPS_SRC_NAT_DONE_BIT),
+
+IPS_DST_NAT_DONE_BIT = 8,
+IPS_DST_NAT_DONE = (1 << IPS_DST_NAT_DONE_BIT),
+
+/* Both together */
+IPS_NAT_DONE_MASK = (IPS_DST_NAT_DONE | IPS_SRC_NAT_DONE),
+
+/* Connection is dying (removed from lists), can not be unset. */
+IPS_DYING_BIT = 9,
+IPS_DYING = (1 << IPS_DYING_BIT),
+
+/* Connection has fixed timeout. */
+IPS_FIXED_TIMEOUT_BIT = 10,
+IPS_FIXED_TIMEOUT = (1 << IPS_FIXED_TIMEOUT_BIT),
+
+/* Conntrack is a template */
+  

[ovs-dev] [PATCH 2/5] datapath-windows: Add support for Netfilter netlink message

2016-06-13 Thread Sairam Venugopal
Introduce NF_GEN_MSG_HDR similar to GENL_MSG_HDR that will be used for
communicating via netfilter-netlink channel. This will be used by
userspace to retrieve and modify Conntrack data in Windows.

Signed-off-by: Sairam Venugopal 
---
 datapath-windows/ovsext/Netlink/Netlink.c  | 11 +++
 datapath-windows/ovsext/Netlink/Netlink.h  |  8 ++--
 datapath-windows/ovsext/Netlink/NetlinkProto.h |  9 +
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/datapath-windows/ovsext/Netlink/Netlink.c 
b/datapath-windows/ovsext/Netlink/Netlink.c
index 1eec320..a25a22a 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -672,6 +672,17 @@ NlMsgAttrsLen(const PNL_MSG_HDR nlh)
 return NlHdrPayloadLen(nlh) - GENL_HDRLEN - OVS_HDRLEN;
 }
 
+/*
+ * ---
+ * Returns size of to nfnlmsg attributes.
+ * ---
+ */
+UINT32
+NfNlMsgAttrsLen(const PNL_MSG_HDR nlh)
+{
+return NlHdrPayloadLen(nlh) - NF_GEN_MSG_HDRLEN - OVS_HDRLEN;
+}
+
 /* Netlink message parse. */
 
 /*
diff --git a/datapath-windows/ovsext/Netlink/Netlink.h 
b/datapath-windows/ovsext/Netlink/Netlink.h
index b1b3bed..cce7ec3 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.h
+++ b/datapath-windows/ovsext/Netlink/Netlink.h
@@ -27,7 +27,10 @@
  */
 typedef struct _OVS_MESSAGE {
 NL_MSG_HDR nlMsg;
-GENL_MSG_HDR genlMsg;
+union {
+GENL_MSG_HDR genlMsg;
+NF_GEN_MSG_HDR nfGenMsg;
+};
 OVS_HDR ovsHdr;
 /* Variable length nl_attrs follow. */
 } OVS_MESSAGE, *POVS_MESSAGE;
@@ -107,6 +110,7 @@ PCHAR NlHdrPayload(const PNL_MSG_HDR nlh);
 UINT32 NlHdrPayloadLen(const PNL_MSG_HDR nlh);
 PNL_ATTR NlMsgAttrs(const PNL_MSG_HDR nlh);
 UINT32 NlMsgAttrsLen(const PNL_MSG_HDR nlh);
+UINT32 NfNlMsgAttrsLen(const PNL_MSG_HDR nlh);
 
 /* Netlink message parse */
 PNL_MSG_HDR NlMsgNext(const PNL_MSG_HDR nlh);
@@ -135,7 +139,7 @@ const PNL_ATTR NlAttrFindNested(const PNL_ATTR nla,
 UINT16 type);
 BOOLEAN NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
 UINT32 totalAttrLen, const NL_POLICY policy[],
-const UINT32 numPolicy, PNL_ATTR attrs[], 
+const UINT32 numPolicy, PNL_ATTR attrs[],
 UINT32 numAttrs);
 BOOLEAN NlAttrParseNested(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
   UINT32 totalAttrLen, const NL_POLICY policy[],
diff --git a/datapath-windows/ovsext/Netlink/NetlinkProto.h 
b/datapath-windows/ovsext/Netlink/NetlinkProto.h
index f2e9aee..beb14d5 100644
--- a/datapath-windows/ovsext/Netlink/NetlinkProto.h
+++ b/datapath-windows/ovsext/Netlink/NetlinkProto.h
@@ -98,6 +98,14 @@ typedef struct _GENL_MSG_HDR {
 } GENL_MSG_HDR, *PGENL_MSG_HDR;
 BUILD_ASSERT_DECL(sizeof(GENL_MSG_HDR) == 4);
 
+/* Netfilter Generic Message */
+typedef struct _NF_GEN_MSG_HDR {
+UINT8 nfgenFamily;   /* AF_xxx */
+UINT8 version;   /* nfnetlink version */
+UINT16 resId;/* resource id */
+} NF_GEN_MSG_HDR, *PNF_GEN_MSG_HDR;
+BUILD_ASSERT_DECL(sizeof(NF_GEN_MSG_HDR) == 4);
+
 /* Netlink attributes */
 typedef struct _NL_ATTR {
 UINT16 nlaLen;
@@ -113,6 +121,7 @@ BUILD_ASSERT_DECL(sizeof(NL_ATTR) == 4);
 
 #define NLMSG_HDRLEN ((INT) NLMSG_ALIGN(sizeof(NL_MSG_HDR)))
 #define GENL_HDRLEN NLMSG_ALIGN(sizeof(GENL_MSG_HDR))
+#define NF_GEN_MSG_HDRLEN NLMSG_ALIGN(sizeof(NF_GEN_MSG_HDR))
 #define OVS_HDRLEN NLMSG_ALIGN(sizeof(OVS_HDR))
 #define NLA_HDRLEN ((INT) NLA_ALIGN(sizeof(NL_ATTR)))
 
-- 
2.5.0.windows.1

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


[ovs-dev] [PATCH 3/5] datapath-windows: Add support for flushing conntrack entries

2016-06-13 Thread Sairam Venugopal
Flush out all conntrack entries or those that match a given zone. Since
the conntrack module is internal to OVS in Windows, this functionality
needs to be added in.

Signed-off-by: Sairam Venugopal 
---
 datapath-windows/ovsext/Conntrack.c | 75 +
 1 file changed, 75 insertions(+)

diff --git a/datapath-windows/ovsext/Conntrack.c 
b/datapath-windows/ovsext/Conntrack.c
index 7316442..81c70d6 100644
--- a/datapath-windows/ovsext/Conntrack.c
+++ b/datapath-windows/ovsext/Conntrack.c
@@ -619,3 +619,78 @@ ovsConntrackEntryCleaner(PVOID data)
 
 PsTerminateSystemThread(STATUS_SUCCESS);
 }
+
+/*
+ *
+ * OvsCtFlush
+ * Flushes out all Conntrack Entries that match the given zone
+ *
+ */
+static __inline NDIS_STATUS
+OvsCtFlush(UINT16 zone)
+{
+PLIST_ENTRY link, next;
+POVS_CT_ENTRY entry;
+
+LOCK_STATE_EX lockState;
+NdisAcquireRWLockWrite(ovsConntrackLockObj, , 0);
+
+for (int i = 0; i < CT_HASH_TABLE_SIZE; i++) {
+LIST_FORALL_SAFE([i], link, next) {
+entry = CONTAINING_RECORD(link, OVS_CT_ENTRY, link);
+if (!zone || zone == entry->key.zone)
+OvsCtEntryDelete(entry);
+}
+}
+
+NdisReleaseRWLock(ovsConntrackLockObj, );
+return NDIS_STATUS_SUCCESS;
+}
+
+NTSTATUS
+OvsCtDeleteCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
+  UINT32 *replyLen)
+{
+POVS_MESSAGE msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer;
+PNL_MSG_HDR nlMsgHdr = &(msgIn->nlMsg);
+PNL_ATTR ctAttrs[__CTA_MAX];
+UINT32 attrOffset = NLMSG_HDRLEN + NF_GEN_MSG_HDRLEN + OVS_HDRLEN;
+NL_ERROR nlError = NL_ERROR_SUCCESS;
+NTSTATUS status;
+UINT16 zone = 0;
+
+static const NL_POLICY ctZonePolicy[] = {
+[CTA_ZONE] = { .type = NL_A_BE16, .optional = TRUE },
+};
+
+if ((NlAttrParse(nlMsgHdr, attrOffset, NfNlMsgAttrsLen(nlMsgHdr),
+ctZonePolicy, ARRAY_SIZE(ctZonePolicy),
+ctAttrs, ARRAY_SIZE(ctAttrs)))
+!= TRUE) {
+OVS_LOG_ERROR("Zone attr parsing failed for msg: %p", nlMsgHdr);
+status = STATUS_INVALID_PARAMETER;
+goto done;
+}
+
+if (ctAttrs[CTA_ZONE]) {
+zone = NlAttrGetU16(ctAttrs[CTA_ZONE]);
+}
+
+status = OvsCtFlush(zone);
+
+done:
+if (status) {
+nlError = NlMapStatusToNlErr(status);
+}
+if (nlError != NL_ERROR_SUCCESS) {
+POVS_MESSAGE_ERROR msgError = (POVS_MESSAGE_ERROR)
+   usrParamsCtx->outputBuffer;
+
+ASSERT(msgError);
+NlBuildErrorMsg(msgIn, msgError, nlError, replyLen);
+ASSERT(*replyLen != 0);
+status = STATUS_SUCCESS;
+}
+
+return status;
+}
-- 
2.5.0.windows.1

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


[ovs-dev] [PATCH 5/5] Windows: Add conntrack-flush support in userspace

2016-06-13 Thread Sairam Venugopal
Modify dpif-netlink.c and netlink-conntrack.c to send down flush command
to Windows datapath. Include netlink-conntrack.c and netlink-conntrack.h
in automake.mk for Windows binaries.

Windows currently supports only NETLINK_GENERIC port. In order to support
the NETLINK_NETFILTER messages, the port id is being overwritten to
NETLINK_GENERIC on Windows and datapath has been updated to support the
new message format.

Signed-off-by: Sairam Venugopal 
---
 lib/automake.mk |  2 ++
 lib/dpif-netlink.c  | 15 +++
 lib/netlink-conntrack.c | 33 +
 3 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/lib/automake.mk b/lib/automake.mk
index eabc0e7..4d4ee01 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -372,6 +372,8 @@ lib_libopenvswitch_la_SOURCES += \
lib/dpif-netlink.c \
lib/dpif-netlink.h \
lib/netdev-windows.c \
+   lib/netlink-conntrack.c \
+   lib/netlink-conntrack.h \
lib/netlink-notifier.c \
lib/netlink-notifier.h \
lib/netlink-protocol.h \
diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 9bff3a8..e2bea23 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -2274,7 +2274,6 @@ dpif_netlink_get_datapath_version(void)
 return version_str;
 }
 
-#ifdef __linux__
 struct dpif_netlink_ct_dump_state {
 struct ct_dpif_dump_state up;
 struct nl_ct_dump_state *nl_ct_dump;
@@ -2335,7 +2334,6 @@ dpif_netlink_ct_flush(struct dpif *dpif OVS_UNUSED, const 
uint16_t *zone)
 return nl_ct_flush();
 }
 }
-#endif
 
 const struct dpif_class dpif_netlink_class = {
 "system",
@@ -2377,17 +2375,10 @@ const struct dpif_class dpif_netlink_class = {
 NULL,   /* enable_upcall */
 NULL,   /* disable_upcall */
 dpif_netlink_get_datapath_version, /* get_datapath_version */
-#ifdef __linux__
 dpif_netlink_ct_dump_start,
 dpif_netlink_ct_dump_next,
 dpif_netlink_ct_dump_done,
-dpif_netlink_ct_flush,
-#else
-NULL,   /* ct_dump_start */
-NULL,   /* ct_dump_next */
-NULL,   /* ct_dump_done */
-NULL,   /* ct_flush */
-#endif
+dpif_netlink_ct_flush
 };
 
 static int
@@ -2442,7 +2433,7 @@ dpif_netlink_is_internal_device(const char *name)
 
 return reply.type == OVS_VPORT_TYPE_INTERNAL;
 }
-
+
 /* Parses the contents of 'buf', which contains a "struct ovs_header" followed
  * by Netlink attributes, into 'vport'.  Returns 0 if successful, otherwise a
  * positive errno value.
@@ -2946,7 +2937,7 @@ dpif_netlink_flow_get_stats(const struct 
dpif_netlink_flow *flow,
 stats->used = flow->used ? get_32aligned_u64(flow->used) : 0;
 stats->tcp_flags = flow->tcp_flags ? *flow->tcp_flags : 0;
 }
-
+
 /* Logs information about a packet that was recently lost in 'ch' (in
  * 'dpif_'). */
 static void
diff --git a/lib/netlink-conntrack.c b/lib/netlink-conntrack.c
index 47a3c62..bc31391 100644
--- a/lib/netlink-conntrack.c
+++ b/lib/netlink-conntrack.c
@@ -75,6 +75,10 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 
5);
 #define IPS_UNTRACKED_BIT 12
 #define IPS_UNTRACKED (1 << IPS_UNTRACKED_BIT)
 
+#ifdef _WIN32
+#define NETLINK_NETFILTER   NETLINK_GENERIC //Override for Windowss
+#endif
+
 static const struct nl_policy nfnlgrp_conntrack_policy[] = {
 [CTA_TUPLE_ORIG] = { .type = NL_A_NESTED, .optional = false },
 [CTA_TUPLE_REPLY] = { .type = NL_A_NESTED, .optional = false },
@@ -118,7 +122,7 @@ struct nl_ct_dump_state {
 bool filter_zone;
 uint16_t zone;
 };
-
+
 /* Conntrack netlink dumping. */
 
 /* Initialize a conntrack netlink dump. */
@@ -200,7 +204,7 @@ nl_ct_dump_done(struct nl_ct_dump_state *state)
 free(state);
 return error;
 }
-
+
 /* Format conntrack event 'entry' of 'type' to 'ds'. */
 void
 nl_ct_format_event_entry(const struct ct_dpif_entry *entry,
@@ -235,6 +239,26 @@ nl_ct_flush(void)
 return err;
 }
 
+#ifdef _WIN32
+int
+nl_ct_flush_zone(uint16_t flush_zone)
+{
+/* Windows can flush a specific zone */
+struct ofpbuf buf;
+int err;
+
+ofpbuf_init(, NL_DUMP_BUFSIZE);
+
+nl_msg_put_nfgenmsg(, 0, AF_UNSPEC, NFNL_SUBSYS_CTNETLINK,
+IPCTNL_MSG_CT_DELETE, NLM_F_REQUEST);
+nl_msg_put_be16(, CTA_ZONE, flush_zone);
+
+err = nl_transact(NETLINK_NETFILTER, , NULL);
+ofpbuf_uninit();
+
+return err;
+}
+#else
 int
 nl_ct_flush_zone(uint16_t flush_zone)
 {
@@ -299,7 +323,8 @@ nl_ct_flush_zone(uint16_t flush_zone)
  * have a master connection anymore */
 return 0;
 }
-
+#endif
+
 /* Conntrack netlink parsing. */
 
 static bool
@@ -788,7 +813,7 @@ nl_ct_parse_entry(struct ofpbuf *buf, struct ct_dpif_entry 
*entry,
 
 return true;
 }
-
+
 /* NetFilter utility functions. */
 
 /* Puts a nlmsghdr and nfgenmsg at the beginning of 'msg', which must be
-- 

[ovs-dev] [PATCH 0/5] Windows: Add support for conntrack-flush command

2016-06-13 Thread Sairam Venugopal
Conntrack module is part of OVS datapath on Windows and lacks support netlink 
support. The following patches adds support in Windows datapath for accepting 
netfilter-netlink messages from userspace and executing the command. The 
current version adds support for flushing conntrack entries by parsing the new 
message format.

Netfilter's conntrack related header files have been added to Windows to limit 
the userspace changes. Some of them have been intentionally left empty since 
Windows datapath does not support them.

Sairam Venugopal (5):
  Windows: Add netfilter-conntrack header files to Include folder
  datapath-windows: Add support for Netfilter netlink message
  datapath-windows: Add support for flushing conntrack entries
  datapath-windows: Add support for Conntrack IPCTNL_MSG_CT_DELETE cmd
in Datapath.c
  Windows: Add conntrack-flush support in userspace

 datapath-windows/include/OvsDpInterfaceExt.h   |  17 ++
 datapath-windows/ovsext/Conntrack.c|  75 +++
 datapath-windows/ovsext/Datapath.c |  80 ++-
 datapath-windows/ovsext/Netlink/Netlink.c  |  11 +
 datapath-windows/ovsext/Netlink/Netlink.h  |   8 +-
 datapath-windows/ovsext/Netlink/NetlinkProto.h |   9 +
 include/windows/automake.mk|   6 +
 .../windows/linux/netfilter/nf_conntrack_common.h  | 113 ++
 include/windows/linux/netfilter/nf_conntrack_ftp.h |   0
 .../windows/linux/netfilter/nf_conntrack_sctp.h|   0
 include/windows/linux/netfilter/nf_conntrack_tcp.h |  49 
 include/windows/linux/netfilter/nfnetlink.h|  63 ++
 .../windows/linux/netfilter/nfnetlink_conntrack.h  | 249 +
 lib/automake.mk|   2 +
 lib/dpif-netlink.c |  15 +-
 lib/netlink-conntrack.c|  33 ++-
 16 files changed, 703 insertions(+), 27 deletions(-)
 create mode 100644 include/windows/linux/netfilter/nf_conntrack_common.h
 create mode 100644 include/windows/linux/netfilter/nf_conntrack_ftp.h
 create mode 100644 include/windows/linux/netfilter/nf_conntrack_sctp.h
 create mode 100644 include/windows/linux/netfilter/nf_conntrack_tcp.h
 create mode 100644 include/windows/linux/netfilter/nfnetlink.h
 create mode 100644 include/windows/linux/netfilter/nfnetlink_conntrack.h

-- 
2.5.0.windows.1

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


Re: [ovs-dev] [PATCH 1/3] ofproto-dpif-upcall: Translate input port as part of upcall translation.

2016-06-13 Thread Daniele Di Proietto
2016-06-13 13:47 GMT-07:00 Jesse Gross :

> On Mon, Jun 13, 2016 at 1:16 PM, Daniele Di Proietto
>  wrote:
> >
> > 2016-06-09 17:46 GMT-07:00 Jesse Gross :
> >>
> >> When we generate wildcards for upcalled flows, the flows and therefore
> >> the wildcards, are in OpenFlow format. These are mostly the same but
> >> one exception is the input port. We work around this problem by simply
> >> performing an exact match on the input port when generating netlink
> >> formatted keys. (This does not lose any information in practice because
> >> action translation also always exact matches on input port.)
> >>
> >> While this works fine for kernel based flows, it misses the userspace
> >> datapath, which directly consumes the OFP format mask for the input
> >> port. The effect of this is that the in_port mask is sometimes only
> >> the lower 16 bits of the field. (This is because OFP format is a 16-bit
> >> value stored in a 32-bit field. The full width of the field is
> initialized
> >> with an exact match mask but certain operations result in cleaving this
> >> down to 16 bits.) In practice this does not cause a problem because
> >> datapath
> >> port numbers are almost always in the lower 16 bits of the range
> anyways.
> >>
> >> This moves the masking of the datapath format field to translation so
> that
> >> all datapaths see the same result. This also makes more sense
> conceptually
> >> as the input port in the flow is also in ODP format at this stage.
> >>
> >> Signed-off-by: Jesse Gross 
> >> ---
> >>  ofproto/ofproto-dpif-upcall.c | 11 ++-
> >>  1 file changed, 10 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/ofproto/ofproto-dpif-upcall.c
> b/ofproto/ofproto-dpif-upcall.c
> >> index a18fc5a..9400ef9 100644
> >> --- a/ofproto/ofproto-dpif-upcall.c
> >> +++ b/ofproto/ofproto-dpif-upcall.c
> >> @@ -1083,7 +1083,16 @@ upcall_xlate(struct udpif *udpif, struct upcall
> >> *upcall,
> >>
> >>  upcall->dump_seq = seq_read(udpif->dump_seq);
> >>  upcall->reval_seq = seq_read(udpif->reval_seq);
> >> +
> >>  xlate_actions(, >xout);
> >> +if (wc) {
> >> +/* Convert the input port wildcard from OFP to ODP format.
> >> There's no
> >> + * real way to do this for arbitrary bitmasks since the
> numbering
> >> spaces
> >> + * aren't the same. However, flow translation always exact
> >> matches the
> >> + * whole thing, so we can do the same here. */
> >> +WC_MASK_FIELD(wc, in_port.odp_port);
> >> +}
> >> +
> >
> >
> > I guess the above could be done in xlate_wc_finish().
>
> I did consider that but the problem is that some callers still want
> the port to be in OpenFlow format, such as ofproto_trace(). Even
> though this is just masking the whole field, I consider the operation
> here to be "converting" it to ODP format and so more appropriate for
> the upcall code.
>
> The other area where we have this type of split between ODP/OpenFlow
> format is with tunnel metadata. That has a flag to indicate which
> format it is in which is nice. As part of some larger work I'm
> considering making that flag apply to both input port and tunnel
> metadata, which might have some benefits for both pieces. If I end up
> doing that then I'll move this into the xlate code so that it is
> transparent.
>
>
Makes sense, thanks



> > Acked-by: Daniele Di Proietto 
>
> Thanks, I'll this series to master and the first patch to branch-2.5
> in a minute.
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2] ofp-util: Fix parsing of parenthesized values within key-value pairs.

2016-06-13 Thread Ben Pfaff
Reported-by: james hopper 
Reported-at: http://openvswitch.org/pipermail/discuss/2016-June/021662.html
Signed-off-by: Ben Pfaff 
---
v1->v2: Fold in Andy Zhou's coding style suggestions.

 AUTHORS   |   1 +
 lib/ofp-util.c| 111 ++
 tests/ofp-util.at |  43 +++
 tests/ofproto.at  |   4 ++
 utilities/ovs-ofctl.c |  21 ++
 5 files changed, 136 insertions(+), 44 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 9fda4c1..e2ac267 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -452,6 +452,7 @@ Ziyou Wang  ziy...@vmware.com
 Zoltán Balogh   zoltan.bal...@ericsson.com
 ankur dwivedi   ankurengg2...@gmail.com
 chen zhang  3zhangchen9...@gmail.com
+james hopperjameshop...@email.com
 kk yap  yap...@stanford.edu
 likunyunkunyu...@hotmail.com
 meishengxin meisheng...@huawei.com
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 21a2574..6519e62 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -7355,6 +7355,38 @@ ofputil_normalize_match_quiet(struct match *match)
 ofputil_normalize_match__(match, false);
 }
 
+static size_t
+parse_value(const char *s, const char *delimiters)
+{
+size_t n = 0;
+
+/* Iterate until we reach a delimiter.
+ *
+ * strchr(s, '\0') returns s+strlen(s), so this test handles the null
+ * terminator at the end of 's'.  */
+while (!strchr(delimiters, s[n])) {
+if (s[n] == '(') {
+int level = 0;
+do {
+switch (s[n]) {
+case '\0':
+return n;
+case '(':
+level++;
+break;
+case ')':
+level--;
+break;
+}
+n++;
+} while (level > 0);
+} else {
+n++;
+}
+}
+return n;
+}
+
 /* Parses a key or a key-value pair from '*stringp'.
  *
  * On success: Stores the key into '*keyp'.  Stores the value, if present, into
@@ -7368,58 +7400,49 @@ ofputil_normalize_match_quiet(struct match *match)
 bool
 ofputil_parse_key_value(char **stringp, char **keyp, char **valuep)
 {
-char *pos, *key, *value;
-size_t key_len;
-
-pos = *stringp;
-pos += strspn(pos, ", \t\r\n");
-if (*pos == '\0') {
+/* Skip white space and delimiters.  If that brings us to the end of the
+ * input string, we are done and there are no more key-value pairs. */
+*stringp += strspn(*stringp, ", \t\r\n");
+if (**stringp == '\0') {
 *keyp = *valuep = NULL;
 return false;
 }
 
-key = pos;
-key_len = strcspn(pos, ":=(, \t\r\n");
-if (key[key_len] == ':' || key[key_len] == '=') {
-/* The value can be separated by a colon. */
-size_t value_len;
-
-value = key + key_len + 1;
-value_len = strcspn(value, ", \t\r\n");
-pos = value + value_len + (value[value_len] != '\0');
-value[value_len] = '\0';
-} else if (key[key_len] == '(') {
-/* The value can be surrounded by balanced parentheses.  The outermost
- * set of parentheses is removed. */
-int level = 1;
-size_t value_len;
-
-value = key + key_len + 1;
-for (value_len = 0; level > 0; value_len++) {
-switch (value[value_len]) {
-case '\0':
-level = 0;
-break;
-
-case '(':
-level++;
-break;
+/* Extract the key and the delimiter that ends the key-value pair or begins
+ * the value.  Advance the input position past the key and delimiter. */
+char *key = *stringp;
+size_t key_len = strcspn(key, ":=(, \t\r\n");
+char key_delim = key[key_len];
+key[key_len] = '\0';
+*stringp += key_len + (key_delim != '\0');
 
-case ')':
-level--;
-break;
-}
-}
-value[value_len - 1] = '\0';
-pos = value + value_len;
+/* Figure out what delimiter ends the value:
+ *
+ * - If key_delim is ":" or "=", the value extends until white space
+ *   or a comma.
+ *
+ * - If key_delim is "(", the value extends until ")".
+ *
+ * If there is no value, we are done. */
+const char *value_delims;
+if (key_delim == ':' || key_delim == '=') {
+value_delims = ", \t\r\n";
+} else if (key_delim == '(') {
+value_delims = ")";
 } else {
-/* There might be no value at all. */
-value = key + key_len;  /* Will become the empty string below. */
-pos = key + key_len + (key[key_len] != '\0');
+*keyp = key;
+*valuep = key + key_len; /* Empty string. */
+return true;
 }
-key[key_len] = '\0';
 
-*stringp = pos;
+/* Extract the value.  

Re: [ovs-dev] [PATCH] ofp-util: Fix parsing of parenthesized values within key-value pairs.

2016-06-13 Thread Ben Pfaff
On Mon, Jun 13, 2016 at 12:47:02PM -0700, Andy Zhou wrote:
> On Sun, Jun 12, 2016 at 5:43 PM, Ben Pfaff  wrote:
> 
> > Reported-by: james hopper 
> > Reported-at:
> > http://openvswitch.org/pipermail/discuss/2016-June/021662.html
> > Signed-off-by: Ben Pfaff 
> > ---
> >  AUTHORS   |   1 +
> >  lib/ofp-util.c| 109
> > ++
> >  tests/ofp-util.at |  43 
> >  tests/ofproto.at  |   4 ++
> >  utilities/ovs-ofctl.c |  21 ++
> >  5 files changed, 134 insertions(+), 44 deletions(-)
> >
> > diff --git a/AUTHORS b/AUTHORS
> > index 9fda4c1..e2ac267 100644
> > --- a/AUTHORS
> > +++ b/AUTHORS
> > @@ -452,6 +452,7 @@ Ziyou Wang  ziy...@vmware.com
> >  Zoltán Balogh   zoltan.bal...@ericsson.com
> >  ankur dwivedi   ankurengg2...@gmail.com
> >  chen zhang  3zhangchen9...@gmail.com
> > +james hopperjameshop...@email.com
> >  kk yap  yap...@stanford.edu
> >  likunyunkunyu...@hotmail.com
> >  meishengxin meisheng...@huawei.com
> > diff --git a/lib/ofp-util.c b/lib/ofp-util.c
> > index 2c6fb1f..2c93dd4 100644
> > --- a/lib/ofp-util.c
> > +++ b/lib/ofp-util.c
> > @@ -7355,6 +7355,36 @@ ofputil_normalize_match_quiet(struct match *match)
> >  ofputil_normalize_match__(match, false);
> >  }
> >
> > +static size_t
> > +parse_value(const char *s, const char *delimiters)
> > +{
> > +size_t n = 0;
> > +for (;;) {
> >
> Would it be easier to read with a while loop?  Of course, there is nothing
> wrong
> using the for loop logically.
> 
> e.g.
> size_t n = 0;
>  While (!strchr(delimiters, s[n]) {
> if (s[n] == '(')
> ...
> 
>  }
>  return n;

That's a nice way to do it.  Thanks, I changed it.

> 
> > +if (strchr(delimiters, s[n])) {
> > +/* strchr(s, '\0') returns s+strlen(s), so this case handles
> > the
> > + * null terminator at the end of 's'.  */
> > +return n;
> > +} else if (s[n] == '(') {
> > +int level = 0;
> > +do {
> > +switch (s[n]) {
> > +case '\0':
> > +return n;
> > +case '(':
> > +level++;
> > +break;
> > +case ')':
> > +level--;
> > +break;
> >
> Is it possible for n to advance beyond end of string, in case of imbalanced
> ")" ?

It should not be possible because of the "case '\0':".

> I have not played with the test cases, so this is not a full review.

Thanks, I'll send v2.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v6] ipfix: add support for exporting ipfix statistics

2016-06-13 Thread Ben Pfaff
On Mon, Jun 13, 2016 at 11:57:13AM +0800, Benli Ye wrote:
> It is meaningful for user to check the stats of IPFIX.
> Using IPFIX stats, user can know how much flows the system
> can support. It is also can be used for performance check
> of IPFIX.

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


Re: [ovs-dev] [PATCH] ovs-vsctl: Support identifying Flow_Sample_Collector_Set records by id.

2016-06-13 Thread Ben Pfaff
On Fri, Jun 10, 2016 at 09:00:21PM -0700, Andy Zhou wrote:
> On Fri, Jun 10, 2016 at 3:19 PM, Ben Pfaff  wrote:
> 
> > This allows commands like
> > ovs-vsctl list Flow_Sample_Collector_Set 123
> > if there's a record with id 123.  It's not perfect, since there can be
> > more than one record with the same id, but it's helpful.
> >
> 
> > Signed-off-by: Ben Pfaff 
> >
> 
> Tested, it works.
>  Acked-by: Andy Zhou 

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


Re: [ovs-dev] [PATCH] Change acinclude to support 4.6 kernels

2016-06-13 Thread pravin shelar
On Sun, Jun 12, 2016 at 4:49 AM, Ryan Moats  wrote:
> Jesse Gross  wrote on 06/09/2016 02:49:38 PM:
>
>> From: Jesse Gross 
>> To: Ryan Moats/Omaha/IBM@IBMUS
>> Cc: ovs dev 
>> Date: 06/09/2016 02:50 PM
>> Subject: Re: [ovs-dev] [PATCH] Change acinclude to support 4.6 kernels
>>
>> On Thu, Jun 9, 2016 at 7:31 AM, Ryan Moats  wrote:
>> > From: RYAN D. MOATS 
>> >
>> > We've been compiling and testing against the 4.6.0 kernel
>> > tree and 2.5.90 looks pretty good.  So, let's start the
>> > update pieces.
>> >
>> > Signed-off-by: RYAN D. MOATS 
>>
>> There are a bunch of patches from 4.4-4.6 that aren't yet in the
>> backport version of the OVS kernel datapath. I'd like to consistently
>> take in all of these so that we don't miss anything rather than just
>> doing it piecemeal. Pravin previously sent out a patchset to do this
>> but it needs some revision.
>
> That's a fair comment - I'll throw the patch in the deferred
> category for now.
>
> Pravin - how goes revising the patchset that Jesse refers to above?
> I'm willing to provide an extra set of hands if need be...
>

I plan to posting second version of the patches this week. After that
we can coordinate work to get OVS support to latest stable kernel
release.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] Group with select type

2016-06-13 Thread Ben Pfaff
You'd have to add such a field, as I said.

On Mon, Jun 13, 2016 at 04:50:54PM -0400, Junguk Cho wrote:
> Hi.
> 
> Thank you for reply.
> 
> I looked for a document. However, I cannot find how to set ICMP seq number
> and then selecting on the least-significant bit.
> 
> Would you please give an example or forward me to an reference.
> 
> Thanks.
> Junguk
> 
> 2016-06-13 12:43 GMT-04:00 Ben Pfaff :
> 
> > On Mon, Jun 13, 2016 at 11:54:11AM -0400, Junguk Cho wrote:
> > > I would like to test group with select type for round-robin way.
> > >
> > > I basically followed this page (
> > > http://openvswitch.org/pipermail/discuss/2014-August/014785.html).
> > > For example, there are one client and three servers.
> > > If I ping from one client to three servers with Virtual IP address, it
> > > always goes to the same place.  I think ovs generates the same hash
> > values
> > > since ping does not have different header fields for hash.
> > > Is it right?
> > >
> > > So, I think I should use some "fields" option to make different paths
> > like
> > > nw_proto or dst_port.
> > >
> > > Is there a way of doing round-robin for ping-like traffic?
> >
> > You could do this by adding an OVS field for ICMP sequence number and
> > then selecting on the least-significant bit.
> >
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2 2/2] netdev-dpdk: Support user-defined socket attribs

2016-06-13 Thread Aaron Conole
Daniele Di Proietto  writes:

> On 10/06/2016 10:51, "Aaron Conole"  wrote:
>
>>Aaron Conole  writes:
>>
>>> Christian Ehrhardt  writes:
>>>
 On Tue, May 24, 2016 at 4:10 PM, Aaron Conole  wrote:

> Daniele Di Proietto  writes:
>
> > Hi Aaron,
> >
> > I'm still a little bit nervous about calling chown on a (partially)
> > user controlled file name.
>
> I agree, that always seems scary.
>
> > Before moving forward I wanted to discuss a couple of other options:
> >
> > * Ansis (in CC) suggested using -runas parameter in qemu.  This way
> > qemu can open the socket as root and drop privileges before starting
> > guest execution.
>
> I'm not sure how to do this with libvirt, or via the OpenStack Neutron
> plugin.  I also don't know if it would be an acceptable workaround for
> users.  Additionally, I recall there being something of a "don't even
> know if this works" around it.  Maybe Christian or Ansis (both in CC)
> can expound on it.
>

 Hi,
 IIRC we kind of agree that long term a proper MAC will be much better but
 most involved people needed something to get it working like "now".
 Since they are complementary (other than the fix removing a bit of the
 urgency for more MAC) it was kind of the least bad option.

 You have to be aware that I brought up the discussion on d...@dpdk.org - 
 see
 [1] and [2]:
 But this will take time and eventually still be the applications task to
 "do something" - no matter if via API or via the chmod's right now.
 So Aaron is trying to get something that works now until the long term
 things are in place, which I appreciate.

 FYI - I was even more in a hurry as it was clear that OVS-2.5 won't get
 this in time I run with [3] for now.
 I never intended to suggest that, but with the discussion in place, one
 could ask if you (Aaron) want to pick up that instead.
 That would keep OVS free for now until DPDK made up the API (see [2]) for
 socket ownership control and this then could be implemented in OVS?

 (I hope) In some months/years we will all be happy to drop this bunch of
 interim solutions, never the less we need it for now.

 [1]: http://dpdk.org/dev/patchwork/patch/1/
 [2]: http://dpdk.org/ml/archives/dev/2015-December/030326.html
 [3]:
 https://git.launchpad.net/~ubuntu-server/dpdk/commit/?h=ubuntu-xenial-to-dpdk2.2=f3c7aa1b2ddea8e092ad4a89e41a0e19d01ed4e7

 [...]


> I think originally we quickly discussed 4 possible solutions (and
> hopefully I captured them correctly):
>
> 1. OVS downgrades to the ovs user, and kvm runs under the ovs
>group.  I don't actually like this solution because kvm could then
>pollute the ovs database.
>
> 2. OVS runs as some user and sets the user/group ownership of the socket
>via chown/chmod where permissions come from the database (the
>original context had ovs running as root - but as I described above
>it doesn't need to be root provided ovs+DPDK can start without root).
>
> 3. OVS runs as some user, kvm starts as root, opens the socket and
>downgrades.  IIRC, this doesn't actually work, or it may have
>implications on other projects.  I don't remember exactly what was
>not as great about this solution, TBH.
>
> 4. OVS and KVM run as whatever users; MAC is used to enforce the
>layering between them.
>
> I think solution 2 and solution 4 don't actually interfere with each
> other, and can be used to a complementary effect (if implemented
> properly) so that the MAC layer enforces access, but even without MAC,
> the DAC layer can provide appropriate whitelisting behavior.
>

 I also remember several complex changes needed for the #1 and #3 that
 always would end up with huge effort and a high risk not being accepted.
 Probably that is what you refer to with "implications on other projects".

 Also keep in mind the position of dpdk out of the last few discussions
 which I'd like to summarize as "dpdk got this path from an app, so this app
 OWNS that path".
>>>
>>> I'd like to continue on, but I am not sure what the concerns are right
>>> now.  Is it possible to enumerate them point by point so that I can
>>> understand them?  I think there are two outstanding concerns right now:
>>>
>>> 1. the proposed approach is not good enough (vis-a-vis DAC vs. MAC)
>>>
>>> 2. the proposed approach would be better implemented in the utility
>>>that wants access to the sockets (vis-a-vis the libvirt discussion)
>>>
>>> Am I understanding the concerns correctly?
>>
>>Ping?
>
> I found another theoretical problem with 

Re: [ovs-dev] [PATCH] netlink-notifier: Support multiple groups.

2016-06-13 Thread Jarno Rajahalme
Thanks for the review Pravin! I fixed this before merging just a minute ago.

  Jarno

> On Jun 7, 2016, at 4:54 PM, pravin shelar  wrote:
> 
> On Thu, May 26, 2016 at 4:29 PM, Jarno Rajahalme  > wrote:
>> A netlink notifier ('nln') already supports multiple notifiers.  This
>> patch allows each of these notifiers to subscribe to a different
>> multicast group.  Sharing a single socket for multiple event types
>> (each on their own multicast group) provides serialization of events
>> when reordering of different event types could be problematic.  For
>> example, if a 'create' event and 'delete' event are on different
>> netlink multicast group, we may want to process those events in the
>> order in which kernel issued them, rather than in the order we happen
>> to check for them.
>> 
>> Moving the multicast group argument from nln_create() to
>> nln_notifier_create() allows each notifier to specify a different
>> multicast group.  The parse callback needs to identify the group the
>> message belonged to by returning the corresponding group number, or 0
>> when an parse error occurs.
>> 
>> Signed-off-by: Jarno Rajahalme 
> I am getting following warning.
> 
> tests/test-netlink-conntrack.c: In function ‘event_parse’:
> 
> tests/test-netlink-conntrack.c:50:1: error: control reaches end of
> non-void function [-Werror=return-type]
> 
> }
> 
> other than this and comments from Cascardo, the patch looks good to me.

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


Re: [ovs-dev] [PATCH] netlink-notifier: Support multiple groups.

2016-06-13 Thread Jarno Rajahalme
Thanks for the review!

Applied to master with changes indicated, with one response below,

  Jarno

> On Jun 2, 2016, at 7:19 AM, Thadeu Lima de Souza Cascardo 
>  wrote:
> 
> On Thu, May 26, 2016 at 04:29:28PM -0700, Jarno Rajahalme wrote:
>> A netlink notifier ('nln') already supports multiple notifiers.  This
>> patch allows each of these notifiers to subscribe to a different
>> multicast group.  Sharing a single socket for multiple event types
>> (each on their own multicast group) provides serialization of events
>> when reordering of different event types could be problematic.  For
>> example, if a 'create' event and 'delete' event are on different
>> netlink multicast group, we may want to process those events in the
>> order in which kernel issued them, rather than in the order we happen
>> to check for them.
>> 
>> Moving the multicast group argument from nln_create() to
>> nln_notifier_create() allows each notifier to specify a different
>> multicast group.  The parse callback needs to identify the group the
>> message belonged to by returning the corresponding group number, or 0
>> when an parse error occurs.
>> 
>> Signed-off-by: Jarno Rajahalme 
> 
> Hi, Jarno.
> 
> Just two nitpicks below. Besides that,
> 
> Acked-by: Thadeu Lima de Souza Cascardo  >
> 
>> ---
>> lib/netlink-notifier.c | 47 
>> ++
>> lib/netlink-notifier.h | 13 ++--
>> lib/route-table.c  | 40 +++
>> lib/rtnetlink.c| 10 -
>> tests/test-netlink-conntrack.c | 32 +---
>> 5 files changed, 78 insertions(+), 64 deletions(-)
>> 
>> diff --git a/lib/netlink-notifier.c b/lib/netlink-notifier.c
>> index c2b4f7b..0e4ed9a 100644
>> --- a/lib/netlink-notifier.c
>> +++ b/lib/netlink-notifier.c
>> 

(snip)

>> @@ -126,11 +121,21 @@ nln_notifier_create(struct nln *nln, nln_notify_func 
>> *cb, void *aux)
>> nln_run(nln);
>> }
>> 
>> +error = nl_sock_join_mcgroup(nln->notify_sock, multicast_group);
>> +if (error) {
>> +VLOG_WARN("could not join netlink multicast group: %s",
>> +  ovs_strerror(error));
>> +return NULL;
>> +}
>> +
>> notifier = xmalloc(sizeof *notifier);
>> -ovs_list_push_back(>all_notifiers, >node);
>> +notifier->multicast_group = multicast_group;
>> notifier->cb = cb;
>> notifier->aux = aux;
>> notifier->nln = nln;
>> +
>> +ovs_list_push_back(>all_notifiers, >node);
>> +
>> return notifier;
>> }
>> 
>> @@ -142,6 +147,8 @@ nln_notifier_destroy(struct nln_notifier *notifier)
>> if (notifier) {
>> struct nln *nln = notifier->nln;
>> 
>> +nl_sock_leave_mcgroup(nln->notify_sock, notifier->multicast_group);
>> +
> 
> I was afraid this could be a problem, but we hardly destroy any notifier, we
> just call if_notifier_destroy when exiting the bridge. It just means that if 
> we
> ever have notifiers with a shorter lifetime, this either means we have a 
> single
> notifier per group, or we need some refcounting. I think you should keep this
> change, as it seems the best decision right now.
> 

I changed this to leave the group only if no other notifier is interested in 
the same group, like this:

diff --git a/lib/netlink-notifier.c b/lib/netlink-notifier.c
index 0e4ed9a..f6d1e4d 100644
--- a/lib/netlink-notifier.c
+++ b/lib/netlink-notifier.c
@@ -146,10 +146,21 @@ nln_notifier_destroy(struct nln_notifier *notifier)
 {
 if (notifier) {
 struct nln *nln = notifier->nln;
-
-nl_sock_leave_mcgroup(nln->notify_sock, notifier->multicast_group);
+struct nln_notifier *iter;
+int count = 0;
 
 ovs_list_remove(>node);
+
+/* Leave the group if no other notifier is interested in it. */
+LIST_FOR_EACH (iter, node, >all_notifiers) {
+if (iter->multicast_group == notifier->multicast_group) {
+count++;
+}
+}
+if (count == 0) {
+nl_sock_leave_mcgroup(nln->notify_sock, notifier->multicast_group);
+}
+
 if (ovs_list_is_empty(>all_notifiers)) {
 nl_sock_destroy(nln->notify_sock);
 nln->notify_sock = NULL;


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


Re: [ovs-dev] [PATCH v4 04/17] conntrack: New userspace connection tracker.

2016-06-13 Thread Joe Stringer
On 10 June 2016 at 15:47, Daniele Di Proietto  wrote:
> This commit adds the conntrack module.
>
> It is a connection tracker that resides entirely in userspace.  Its
> primary user will be the dpif-netdev datapath.
>
> The module main goal is to provide conntrack_execute(), which offers a
> convenient interface to implement the datapath ct() action.
>
> The conntrack module uses two submodules to deal with the l4 protocol
> details (conntrack-other for UDP and ICMP, conntrack-tcp for TCP).
>
> The conntrack-tcp submodule implementation is adapted from FreeBSD's pf
> subsystem, therefore it's BSD licensed.  It has been slightly altered to
> match the OVS coding style and to allow the pickup of already
> established connections.
>
> Signed-off-by: Daniele Di Proietto 
> Acked-by: Antonio Fischetti 

I've got a bunch of pretty trivial comments below, but it seems
otherwise fine to me. Thanks!

Acked-by: Joe Stringer 

> ---
>  COPYING |   1 +
>  debian/copyright.in |   4 +
>  include/openvswitch/types.h |   4 +
>  lib/automake.mk |   5 +
>  lib/conntrack-other.c   |  85 +
>  lib/conntrack-private.h |  88 +
>  lib/conntrack-tcp.c | 462 +++
>  lib/conntrack.c | 890 
> 
>  lib/conntrack.h | 150 
>  lib/util.h  |   9 +
>  10 files changed, 1698 insertions(+)
>  create mode 100644 lib/conntrack-other.c
>  create mode 100644 lib/conntrack-private.h
>  create mode 100644 lib/conntrack-tcp.c
>  create mode 100644 lib/conntrack.c
>  create mode 100644 lib/conntrack.h
>
> diff --git a/COPYING b/COPYING
> index 308e3ea..afb98b9 100644
> --- a/COPYING
> +++ b/COPYING
> @@ -25,6 +25,7 @@ License, version 2.
>  The following files are licensed under the 2-clause BSD license.
>  include/windows/getopt.h
>  lib/getopt_long.c
> +lib/conntrack-tcp.c
>
>  The following files are licensed under the 3-clause BSD-license
>  include/windows/netinet/icmp6.h
> diff --git a/debian/copyright.in b/debian/copyright.in
> index 57d007a..a15f4dd 100644
> --- a/debian/copyright.in
> +++ b/debian/copyright.in
> @@ -21,6 +21,9 @@ Upstream Copyright Holders:
> Copyright (c) 2014 Michael Chapman
> Copyright (c) 2014 WindRiver, Inc.
> Copyright (c) 2014 Avaya, Inc.
> +   Copyright (c) 2001 Daniel Hartmeier
> +   Copyright (c) 2002 - 2008 Henning Brauer
> +   Copyright (c) 2012 Gleb Smirnoff 
>
>  License:
>
> @@ -90,6 +93,7 @@ License:
> lib/getopt_long.c
> include/windows/getopt.h
> datapath-windows/ovsext/Conntrack-tcp.c
> +   lib/conntrack-tcp.c
>
>  * The following files are licensed under the 3-clause BSD-license
>
> diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h
> index bc94145..35bde0a 100644
> --- a/include/openvswitch/types.h
> +++ b/include/openvswitch/types.h
> @@ -107,6 +107,10 @@ static const ovs_u128 OVS_U128_MAX = { { UINT32_MAX, 
> UINT32_MAX,
>   UINT32_MAX, UINT32_MAX } };
>  static const ovs_be128 OVS_BE128_MAX OVS_UNUSED = { { OVS_BE32_MAX, 
> OVS_BE32_MAX,
> OVS_BE32_MAX, OVS_BE32_MAX } };
> +static const ovs_u128 OVS_U128_MIN OVS_UNUSED = { {0, 0, 0, 0} };
> +static const ovs_u128 OVS_BE128_MIN OVS_UNUSED = { {0, 0, 0, 0} };
> +
> +#define OVS_U128_ZERO OVS_U128_MIN
>
>  /* A 64-bit value, in network byte order, that is only aligned on a 32-bit
>   * boundary. */
> diff --git a/lib/automake.mk b/lib/automake.mk
> index eabc0e7..4ba1a2c 100644
> --- a/lib/automake.mk
> +++ b/lib/automake.mk
> @@ -49,6 +49,11 @@ lib_libopenvswitch_la_SOURCES = \
> lib/compiler.h \
> lib/connectivity.c \
> lib/connectivity.h \
> +   lib/conntrack-private.h \
> +   lib/conntrack-tcp.c \
> +   lib/conntrack-other.c \
> +   lib/conntrack.c \
> +   lib/conntrack.h \
> lib/coverage.c \
> lib/coverage.h \
> lib/crc32c.c \
> diff --git a/lib/conntrack-other.c b/lib/conntrack-other.c
> new file mode 100644
> index 000..295cb2c
> --- /dev/null
> +++ b/lib/conntrack-other.c
> @@ -0,0 +1,85 @@
> +/*
> + * 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 

Re: [ovs-dev] Group with select type

2016-06-13 Thread Junguk Cho
Hi.

Thank you for reply.

I looked for a document. However, I cannot find how to set ICMP seq number
and then selecting on the least-significant bit.

Would you please give an example or forward me to an reference.

Thanks.
Junguk

2016-06-13 12:43 GMT-04:00 Ben Pfaff :

> On Mon, Jun 13, 2016 at 11:54:11AM -0400, Junguk Cho wrote:
> > I would like to test group with select type for round-robin way.
> >
> > I basically followed this page (
> > http://openvswitch.org/pipermail/discuss/2014-August/014785.html).
> > For example, there are one client and three servers.
> > If I ping from one client to three servers with Virtual IP address, it
> > always goes to the same place.  I think ovs generates the same hash
> values
> > since ping does not have different header fields for hash.
> > Is it right?
> >
> > So, I think I should use some "fields" option to make different paths
> like
> > nw_proto or dst_port.
> >
> > Is there a way of doing round-robin for ping-like traffic?
>
> You could do this by adding an OVS field for ICMP sequence number and
> then selecting on the least-significant bit.
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 1/3] ofproto-dpif-upcall: Translate input port as part of upcall translation.

2016-06-13 Thread Jesse Gross
On Mon, Jun 13, 2016 at 1:16 PM, Daniele Di Proietto
 wrote:
>
> 2016-06-09 17:46 GMT-07:00 Jesse Gross :
>>
>> When we generate wildcards for upcalled flows, the flows and therefore
>> the wildcards, are in OpenFlow format. These are mostly the same but
>> one exception is the input port. We work around this problem by simply
>> performing an exact match on the input port when generating netlink
>> formatted keys. (This does not lose any information in practice because
>> action translation also always exact matches on input port.)
>>
>> While this works fine for kernel based flows, it misses the userspace
>> datapath, which directly consumes the OFP format mask for the input
>> port. The effect of this is that the in_port mask is sometimes only
>> the lower 16 bits of the field. (This is because OFP format is a 16-bit
>> value stored in a 32-bit field. The full width of the field is initialized
>> with an exact match mask but certain operations result in cleaving this
>> down to 16 bits.) In practice this does not cause a problem because
>> datapath
>> port numbers are almost always in the lower 16 bits of the range anyways.
>>
>> This moves the masking of the datapath format field to translation so that
>> all datapaths see the same result. This also makes more sense conceptually
>> as the input port in the flow is also in ODP format at this stage.
>>
>> Signed-off-by: Jesse Gross 
>> ---
>>  ofproto/ofproto-dpif-upcall.c | 11 ++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
>> index a18fc5a..9400ef9 100644
>> --- a/ofproto/ofproto-dpif-upcall.c
>> +++ b/ofproto/ofproto-dpif-upcall.c
>> @@ -1083,7 +1083,16 @@ upcall_xlate(struct udpif *udpif, struct upcall
>> *upcall,
>>
>>  upcall->dump_seq = seq_read(udpif->dump_seq);
>>  upcall->reval_seq = seq_read(udpif->reval_seq);
>> +
>>  xlate_actions(, >xout);
>> +if (wc) {
>> +/* Convert the input port wildcard from OFP to ODP format.
>> There's no
>> + * real way to do this for arbitrary bitmasks since the numbering
>> spaces
>> + * aren't the same. However, flow translation always exact
>> matches the
>> + * whole thing, so we can do the same here. */
>> +WC_MASK_FIELD(wc, in_port.odp_port);
>> +}
>> +
>
>
> I guess the above could be done in xlate_wc_finish().

I did consider that but the problem is that some callers still want
the port to be in OpenFlow format, such as ofproto_trace(). Even
though this is just masking the whole field, I consider the operation
here to be "converting" it to ODP format and so more appropriate for
the upcall code.

The other area where we have this type of split between ODP/OpenFlow
format is with tunnel metadata. That has a flag to indicate which
format it is in which is nice. As part of some larger work I'm
considering making that flag apply to both input port and tunnel
metadata, which might have some benefits for both pieces. If I end up
doing that then I'll move this into the xlate code so that it is
transparent.

> Acked-by: Daniele Di Proietto 

Thanks, I'll this series to master and the first patch to branch-2.5
in a minute.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v6] datapath-windows: Add Geneve support

2016-06-13 Thread Yin Lin
Signed-off-by: Yin Lin 
---
 datapath-windows/automake.mk   |   2 +
 datapath-windows/ovsext/Actions.c  |  74 ++-
 datapath-windows/ovsext/Debug.h|   1 +
 datapath-windows/ovsext/DpInternal.h   |  29 ++-
 datapath-windows/ovsext/Flow.c | 173 ++--
 datapath-windows/ovsext/Flow.h |   7 +
 datapath-windows/ovsext/Geneve.c   | 361 +
 datapath-windows/ovsext/Geneve.h   | 122 +++
 datapath-windows/ovsext/Gre.c  |   7 +-
 datapath-windows/ovsext/Stt.c  |   2 +-
 datapath-windows/ovsext/Util.h |   1 +
 datapath-windows/ovsext/Vport.c|  19 +-
 datapath-windows/ovsext/ovsext.vcxproj |   2 +
 13 files changed, 715 insertions(+), 85 deletions(-)
 create mode 100644 datapath-windows/ovsext/Geneve.c
 create mode 100644 datapath-windows/ovsext/Geneve.h

diff --git a/datapath-windows/automake.mk b/datapath-windows/automake.mk
index c9af806..53fb5c5 100644
--- a/datapath-windows/automake.mk
+++ b/datapath-windows/automake.mk
@@ -68,6 +68,8 @@ EXTRA_DIST += \
datapath-windows/ovsext/Vport.h \
datapath-windows/ovsext/Vxlan.c \
datapath-windows/ovsext/Vxlan.h \
+   datapath-windows/ovsext/Geneve.c \
+   datapath-windows/ovsext/Geneve.h \
datapath-windows/ovsext/ovsext.inf \
datapath-windows/ovsext/ovsext.rc \
datapath-windows/ovsext/ovsext.vcxproj \
diff --git a/datapath-windows/ovsext/Actions.c 
b/datapath-windows/ovsext/Actions.c
index 53be718..644dcfd 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -48,6 +48,8 @@ typedef struct _OVS_ACTION_STATS {
 UINT64 txVxlan;
 UINT64 rxStt;
 UINT64 txStt;
+UINT64 rxGeneve;
+UINT64 txGeneve;
 UINT64 flowMiss;
 UINT64 flowUserspace;
 UINT64 txTcp;
@@ -229,11 +231,9 @@ OvsDetectTunnelRxPkt(OvsForwardingContext *ovsFwdCtx,
 case OVS_VPORT_TYPE_VXLAN:
 ovsActionStats.rxVxlan++;
 break;
-#if 0
 case OVS_VPORT_TYPE_GENEVE:
 ovsActionStats.rxGeneve++;
 break;
-#endif
 case OVS_VPORT_TYPE_GRE:
 ovsActionStats.rxGre++;
 break;
@@ -330,6 +330,9 @@ OvsDetectTunnelPkt(OvsForwardingContext *ovsFwdCtx,
 case OVS_VPORT_TYPE_STT:
 ovsActionStats.txStt++;
 break;
+case OVS_VPORT_TYPE_GENEVE:
+   ovsActionStats.txGeneve++;
+   break;
 }
 ovsFwdCtx->tunnelTxNic = dstVport;
 }
@@ -686,6 +689,11 @@ OvsTunnelPortTx(OvsForwardingContext *ovsFwdCtx)
  >tunKey, ovsFwdCtx->switchContext,
  >layers, );
 break;
+case OVS_VPORT_TYPE_GENEVE:
+status = OvsEncapGeneve(ovsFwdCtx->tunnelTxNic, ovsFwdCtx->curNbl,
+>tunKey, ovsFwdCtx->switchContext,
+>layers, );
+break;
 default:
 ASSERT(! "Tx: Unhandled tunnel type");
 }
@@ -764,6 +772,10 @@ OvsTunnelPortRx(OvsForwardingContext *ovsFwdCtx)
 dropReason = L"OVS-STT segment is cached";
 }
 break;
+case OVS_VPORT_TYPE_GENEVE:
+status = OvsDecapGeneve(ovsFwdCtx->switchContext, ovsFwdCtx->curNbl,
+>tunKey, );
+break;
 default:
 OVS_LOG_ERROR("Rx: Unhandled tunnel type: %d\n",
   tunnelRxVport->ovsType);
@@ -1230,57 +1242,6 @@ OvsActionMplsPush(OvsForwardingContext *ovsFwdCtx,
 }
 
 /*
- * --
- * OvsTunnelAttrToIPv4TunnelKey --
- *  Convert tunnel attribute to OvsIPv4TunnelKey.
- * --
- */
-static __inline NDIS_STATUS
-OvsTunnelAttrToIPv4TunnelKey(PNL_ATTR attr,
- OvsIPv4TunnelKey *tunKey)
-{
-   PNL_ATTR a;
-   INT rem;
-
-   tunKey->attr[0] = 0;
-   tunKey->attr[1] = 0;
-   tunKey->attr[2] = 0;
-   ASSERT(NlAttrType(attr) == OVS_KEY_ATTR_TUNNEL);
-
-   NL_ATTR_FOR_EACH_UNSAFE (a, rem, NlAttrData(attr),
-NlAttrGetSize(attr)) {
-  switch (NlAttrType(a)) {
-  case OVS_TUNNEL_KEY_ATTR_ID:
- tunKey->tunnelId = NlAttrGetBe64(a);
- tunKey->flags |= OVS_TNL_F_KEY;
- break;
-  case OVS_TUNNEL_KEY_ATTR_IPV4_SRC:
- tunKey->src = NlAttrGetBe32(a);
- break;
-  case OVS_TUNNEL_KEY_ATTR_IPV4_DST:
- tunKey->dst = NlAttrGetBe32(a);
- break;
-  case OVS_TUNNEL_KEY_ATTR_TOS:
- tunKey->tos = NlAttrGetU8(a);
- break;
-  case OVS_TUNNEL_KEY_ATTR_TTL:
- tunKey->ttl = NlAttrGetU8(a);
- break;
-  case OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT:
- tunKey->flags |= OVS_TNL_F_DONT_FRAGMENT;
- 

[ovs-dev] [PATCH v6] datapath-windows: Add Geneve support

2016-06-13 Thread Yin Lin
Signed-off-by: Yin Lin 
---
 datapath-windows/automake.mk   |   2 +
 datapath-windows/ovsext/Actions.c  |  74 ++-
 datapath-windows/ovsext/Debug.h|   1 +
 datapath-windows/ovsext/DpInternal.h   |  29 ++-
 datapath-windows/ovsext/Flow.c | 173 ++--
 datapath-windows/ovsext/Flow.h |   7 +
 datapath-windows/ovsext/Geneve.c   | 361 +
 datapath-windows/ovsext/Geneve.h   | 122 +++
 datapath-windows/ovsext/Gre.c  |   7 +-
 datapath-windows/ovsext/Stt.c  |   2 +-
 datapath-windows/ovsext/Util.h |   1 +
 datapath-windows/ovsext/Vport.c|  19 +-
 datapath-windows/ovsext/ovsext.vcxproj |   2 +
 13 files changed, 715 insertions(+), 85 deletions(-)
 create mode 100644 datapath-windows/ovsext/Geneve.c
 create mode 100644 datapath-windows/ovsext/Geneve.h

diff --git a/datapath-windows/automake.mk b/datapath-windows/automake.mk
index c9af806..53fb5c5 100644
--- a/datapath-windows/automake.mk
+++ b/datapath-windows/automake.mk
@@ -68,6 +68,8 @@ EXTRA_DIST += \
datapath-windows/ovsext/Vport.h \
datapath-windows/ovsext/Vxlan.c \
datapath-windows/ovsext/Vxlan.h \
+   datapath-windows/ovsext/Geneve.c \
+   datapath-windows/ovsext/Geneve.h \
datapath-windows/ovsext/ovsext.inf \
datapath-windows/ovsext/ovsext.rc \
datapath-windows/ovsext/ovsext.vcxproj \
diff --git a/datapath-windows/ovsext/Actions.c 
b/datapath-windows/ovsext/Actions.c
index 53be718..644dcfd 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -48,6 +48,8 @@ typedef struct _OVS_ACTION_STATS {
 UINT64 txVxlan;
 UINT64 rxStt;
 UINT64 txStt;
+UINT64 rxGeneve;
+UINT64 txGeneve;
 UINT64 flowMiss;
 UINT64 flowUserspace;
 UINT64 txTcp;
@@ -229,11 +231,9 @@ OvsDetectTunnelRxPkt(OvsForwardingContext *ovsFwdCtx,
 case OVS_VPORT_TYPE_VXLAN:
 ovsActionStats.rxVxlan++;
 break;
-#if 0
 case OVS_VPORT_TYPE_GENEVE:
 ovsActionStats.rxGeneve++;
 break;
-#endif
 case OVS_VPORT_TYPE_GRE:
 ovsActionStats.rxGre++;
 break;
@@ -330,6 +330,9 @@ OvsDetectTunnelPkt(OvsForwardingContext *ovsFwdCtx,
 case OVS_VPORT_TYPE_STT:
 ovsActionStats.txStt++;
 break;
+case OVS_VPORT_TYPE_GENEVE:
+   ovsActionStats.txGeneve++;
+   break;
 }
 ovsFwdCtx->tunnelTxNic = dstVport;
 }
@@ -686,6 +689,11 @@ OvsTunnelPortTx(OvsForwardingContext *ovsFwdCtx)
  >tunKey, ovsFwdCtx->switchContext,
  >layers, );
 break;
+case OVS_VPORT_TYPE_GENEVE:
+status = OvsEncapGeneve(ovsFwdCtx->tunnelTxNic, ovsFwdCtx->curNbl,
+>tunKey, ovsFwdCtx->switchContext,
+>layers, );
+break;
 default:
 ASSERT(! "Tx: Unhandled tunnel type");
 }
@@ -764,6 +772,10 @@ OvsTunnelPortRx(OvsForwardingContext *ovsFwdCtx)
 dropReason = L"OVS-STT segment is cached";
 }
 break;
+case OVS_VPORT_TYPE_GENEVE:
+status = OvsDecapGeneve(ovsFwdCtx->switchContext, ovsFwdCtx->curNbl,
+>tunKey, );
+break;
 default:
 OVS_LOG_ERROR("Rx: Unhandled tunnel type: %d\n",
   tunnelRxVport->ovsType);
@@ -1230,57 +1242,6 @@ OvsActionMplsPush(OvsForwardingContext *ovsFwdCtx,
 }
 
 /*
- * --
- * OvsTunnelAttrToIPv4TunnelKey --
- *  Convert tunnel attribute to OvsIPv4TunnelKey.
- * --
- */
-static __inline NDIS_STATUS
-OvsTunnelAttrToIPv4TunnelKey(PNL_ATTR attr,
- OvsIPv4TunnelKey *tunKey)
-{
-   PNL_ATTR a;
-   INT rem;
-
-   tunKey->attr[0] = 0;
-   tunKey->attr[1] = 0;
-   tunKey->attr[2] = 0;
-   ASSERT(NlAttrType(attr) == OVS_KEY_ATTR_TUNNEL);
-
-   NL_ATTR_FOR_EACH_UNSAFE (a, rem, NlAttrData(attr),
-NlAttrGetSize(attr)) {
-  switch (NlAttrType(a)) {
-  case OVS_TUNNEL_KEY_ATTR_ID:
- tunKey->tunnelId = NlAttrGetBe64(a);
- tunKey->flags |= OVS_TNL_F_KEY;
- break;
-  case OVS_TUNNEL_KEY_ATTR_IPV4_SRC:
- tunKey->src = NlAttrGetBe32(a);
- break;
-  case OVS_TUNNEL_KEY_ATTR_IPV4_DST:
- tunKey->dst = NlAttrGetBe32(a);
- break;
-  case OVS_TUNNEL_KEY_ATTR_TOS:
- tunKey->tos = NlAttrGetU8(a);
- break;
-  case OVS_TUNNEL_KEY_ATTR_TTL:
- tunKey->ttl = NlAttrGetU8(a);
- break;
-  case OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT:
- tunKey->flags |= OVS_TNL_F_DONT_FRAGMENT;
- 

Re: [ovs-dev] cannot find v4 of DNAT changes in mailing list

2016-06-13 Thread Guru Shetty
Hello Flavio,
 It does exist in the archives:
http://openvswitch.org/pipermail/dev/2016-June/072565.html

Probably ended up in your spam folder?

Thanks,
Guru

On 13 June 2016 at 13:12, Flaviof  wrote:

> Hi Guru,
>
> For some odd reason the v4 of your changes in patchwork [v4]
> does not seem to be visible via the mailing list. Is that because you
> submitted it via GitHub?!?
>
> Thanks,
>
> -- flaviof
>
> [v4]: https://patchwork.ozlabs.org/patch/633069/
>
>
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 1/3] ofproto-dpif-upcall: Translate input port as part of upcall translation.

2016-06-13 Thread Daniele Di Proietto
2016-06-09 17:46 GMT-07:00 Jesse Gross :

> When we generate wildcards for upcalled flows, the flows and therefore
> the wildcards, are in OpenFlow format. These are mostly the same but
> one exception is the input port. We work around this problem by simply
> performing an exact match on the input port when generating netlink
> formatted keys. (This does not lose any information in practice because
> action translation also always exact matches on input port.)
>
> While this works fine for kernel based flows, it misses the userspace
> datapath, which directly consumes the OFP format mask for the input
> port. The effect of this is that the in_port mask is sometimes only
> the lower 16 bits of the field. (This is because OFP format is a 16-bit
> value stored in a 32-bit field. The full width of the field is initialized
> with an exact match mask but certain operations result in cleaving this
> down to 16 bits.) In practice this does not cause a problem because
> datapath
> port numbers are almost always in the lower 16 bits of the range anyways.
>
> This moves the masking of the datapath format field to translation so that
> all datapaths see the same result. This also makes more sense conceptually
> as the input port in the flow is also in ODP format at this stage.
>
> Signed-off-by: Jesse Gross 
> ---
>  ofproto/ofproto-dpif-upcall.c | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
> index a18fc5a..9400ef9 100644
> --- a/ofproto/ofproto-dpif-upcall.c
> +++ b/ofproto/ofproto-dpif-upcall.c
> @@ -1083,7 +1083,16 @@ upcall_xlate(struct udpif *udpif, struct upcall
> *upcall,
>
>  upcall->dump_seq = seq_read(udpif->dump_seq);
>  upcall->reval_seq = seq_read(udpif->reval_seq);
> +
>  xlate_actions(, >xout);
> +if (wc) {
> +/* Convert the input port wildcard from OFP to ODP format.
> There's no
> + * real way to do this for arbitrary bitmasks since the numbering
> spaces
> + * aren't the same. However, flow translation always exact
> matches the
> + * whole thing, so we can do the same here. */
> +WC_MASK_FIELD(wc, in_port.odp_port);
> +}
> +
>

I guess the above could be done in xlate_wc_finish().

Either way this looks good to me.

Acked-by: Daniele Di Proietto 

Thanks


>  upcall->xout_initialized = true;
>
>  if (!upcall->xout.slow) {
> @@ -1489,7 +1498,7 @@ ukey_create_from_upcall(struct upcall *upcall,
> struct flow_wildcards *wc)
>  atomic_read_relaxed(_megaflows, );
>  ofpbuf_use_stack(, , sizeof maskstub);
>  if (megaflow) {
> -odp_parms.odp_in_port = ODPP_NONE;
> +odp_parms.odp_in_port = wc->masks.in_port.odp_port;
>  odp_parms.key_buf = 
>
>  odp_flow_key_from_mask(_parms, );
> --
> 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] [PATCH 2/3] odp-util: Remove odp_in_port from struct odp_flow_key_parms.

2016-06-13 Thread Daniele Di Proietto
Acked-by: Daniele Di Proietto 

Thanks

2016-06-09 17:46 GMT-07:00 Jesse Gross :

> When calling odp_flow_key_from_flow (or _mask), the in_port included
> as part of the flow is ignored and must be explicitly passed as a
> separate parameter. This is because the assumption was that the flow's
> version would often be in OFP format, rather than ODP.
>
> However, at this point all flows that are ready for serialization in
> netlink format already have their in_port properly set to ODP format.
> As a result, every caller needs to explicitly initialize the extra
> paramter to the value that is in the flow. This switches to just use
> the value in the flow to simply things and avoid the possibility of
> forgetting to initialize the extra parameter.
>
> Signed-off-by: Jesse Gross 
> ---
>  lib/dpif-netdev.c | 3 ---
>  lib/odp-util.c| 6 +++---
>  lib/odp-util.h| 6 --
>  lib/tnl-ports.c   | 2 --
>  ofproto/ofproto-dpif-upcall.c | 3 ---
>  tests/test-odp.c  | 1 -
>  6 files changed, 3 insertions(+), 18 deletions(-)
>
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index fcfd22e..f42d2da 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -1942,14 +1942,12 @@ dp_netdev_flow_to_dpif_flow(const struct
> dp_netdev_flow *netdev_flow,
>  /* Key */
>  offset = key_buf->size;
>  flow->key = ofpbuf_tail(key_buf);
> -odp_parms.odp_in_port = netdev_flow->flow.in_port.odp_port;
>  odp_flow_key_from_flow(_parms, key_buf);
>  flow->key_len = key_buf->size - offset;
>
>  /* Mask */
>  offset = mask_buf->size;
>  flow->mask = ofpbuf_tail(mask_buf);
> -odp_parms.odp_in_port = wc.masks.in_port.odp_port;
>  odp_parms.key_buf = key_buf;
>  odp_flow_key_from_mask(_parms, mask_buf);
>  flow->mask_len = mask_buf->size - offset;
> @@ -3518,7 +3516,6 @@ dp_netdev_upcall(struct dp_netdev_pmd_thread *pmd,
> struct dp_packet *packet_,
>  struct odp_flow_key_parms odp_parms = {
>  .flow = flow,
>  .mask = >masks,
> -.odp_in_port = flow->in_port.odp_port,
>  .support = dp_netdev_support,
>  };
>
> diff --git a/lib/odp-util.c b/lib/odp-util.c
> index d9ace90..289b969 100644
> --- a/lib/odp-util.c
> +++ b/lib/odp-util.c
> @@ -4274,10 +4274,10 @@ odp_flow_key_from_flow__(const struct
> odp_flow_key_parms *parms,
>  nl_msg_put_u32(buf, OVS_KEY_ATTR_DP_HASH, data->dp_hash);
>  }
>
> -/* Add an ingress port attribute if this is a mask or 'odp_in_port'
> +/* Add an ingress port attribute if this is a mask or
> 'in_port.odp_port'
>   * is not the magical value "ODPP_NONE". */
> -if (export_mask || parms->odp_in_port != ODPP_NONE) {
> -nl_msg_put_odp_port(buf, OVS_KEY_ATTR_IN_PORT,
> parms->odp_in_port);
> +if (export_mask || flow->in_port.odp_port != ODPP_NONE) {
> +nl_msg_put_odp_port(buf, OVS_KEY_ATTR_IN_PORT,
> data->in_port.odp_port);
>  }
>
>  eth_key = nl_msg_put_unspec_uninit(buf, OVS_KEY_ATTR_ETHERNET,
> diff --git a/lib/odp-util.h b/lib/odp-util.h
> index 51cf5c3..2c3cc8c 100644
> --- a/lib/odp-util.h
> +++ b/lib/odp-util.h
> @@ -194,12 +194,6 @@ struct odp_flow_key_parms {
>  const struct flow *flow;
>  const struct flow *mask;
>
> -   /* 'flow->in_port' is ignored (since it is likely to be an OpenFlow
> port
> -* number rather than a datapath port number).  Instead, if
> 'odp_in_port'
> -* is anything other than ODPP_NONE, it is included in 'buf' as the
> input
> -* port. */
> -odp_port_t odp_in_port;
> -
>  /* Indicates support for various fields. If the datapath supports a
> field,
>   * then it will always be serialised. */
>  struct odp_support support;
> diff --git a/lib/tnl-ports.c b/lib/tnl-ports.c
> index e8d43f0..e945eae 100644
> --- a/lib/tnl-ports.c
> +++ b/lib/tnl-ports.c
> @@ -316,7 +316,6 @@ tnl_port_show_v(struct ds *ds)
>  miniflow_expand(p->cr.match.flow, );
>
>  /* Key. */
> -odp_parms.odp_in_port = flow.in_port.odp_port;
>  odp_parms.support.recirc = true;
>  ofpbuf_use_stack(, , sizeof keybuf);
>  odp_flow_key_from_flow(_parms, );
> @@ -324,7 +323,6 @@ tnl_port_show_v(struct ds *ds)
>  key_len = buf.size;
>
>  /* mask*/
> -odp_parms.odp_in_port = wc.masks.in_port.odp_port;
>  odp_parms.support.recirc = false;
>  ofpbuf_use_stack(, , sizeof maskbuf);
>  odp_flow_key_from_mask(_parms, );
> diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
> index 9400ef9..b947da9 100644
> --- a/ofproto/ofproto-dpif-upcall.c
> +++ b/ofproto/ofproto-dpif-upcall.c
> @@ -1491,16 +1491,13 @@ ukey_create_from_upcall(struct upcall *upcall,
> struct flow_wildcards *wc)
>  /* dpif-netdev doesn't provide a 

Re: [ovs-dev] [PATCH 3/3] dpif-netdev: Print installed flows in dpif format.

2016-06-13 Thread Daniele Di Proietto
Looks good to me, thanks.

Acked-by: Daniele Di Proietto 

2016-06-09 17:46 GMT-07:00 Jesse Gross :

> When debug logging is enabled, dpif-netdev can print each flow as it is
> installed, which it currently does using OpenFlow match formatting.
> Compared
> to ODP formatting, there generally isn't too much difference since the
> fields are largely the same but it is inconsistent with other logging in
> dpif-netdev as well as the analogous functions that deal with the kernel.
>
> However, in some cases there is a difference between the two formats, such
> as in the cases of input port or tunnel metadata. For input port, datapath
> format helped detect that the generated masks were incorrect. As for
> tunnels,
> at the moment, it's possible to convert between the two formats on demand
> as
> we have a global metadata table. In the future, though this won't be
> possible
> as the metadata table becomes per-bridge which the datapath won't have
> access
> to.
>
> Signed-off-by: Jesse Gross 
> ---
>  lib/dpif-netdev.c |  22 +++--
>  tests/dpif-netdev.at  |  14 +++---
>  tests/ofproto-dpif.at | 130
> +-
>  tests/pmd.at  |   2 +-
>  4 files changed, 90 insertions(+), 78 deletions(-)
>
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index f42d2da..8d39d9e 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -2120,22 +2120,34 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread
> *pmd,
>  dp_netdev_flow_hash(>ufid));
>
>  if (OVS_UNLIKELY(VLOG_IS_DBG_ENABLED())) {
> -struct match match;
>  struct ds ds = DS_EMPTY_INITIALIZER;
> +struct ofpbuf key_buf, mask_buf;
> +struct odp_flow_key_parms odp_parms = {
> +.flow = >flow,
> +.mask = >wc.masks,
> +.support = dp_netdev_support,
> +};
> +
> +ofpbuf_init(_buf, 0);
> +ofpbuf_init(_buf, 0);
>
> -match.tun_md.valid = false;
> -match.flow = flow->flow;
> -miniflow_expand(>cr.mask->mf, );
> +odp_flow_key_from_flow(_parms, _buf);
> +odp_parms.key_buf = _buf;
> +odp_flow_key_from_mask(_parms, _buf);
>
>  ds_put_cstr(, "flow_add: ");
>  odp_format_ufid(ufid, );
>  ds_put_cstr(, " ");
> -match_format(, , OFP_DEFAULT_PRIORITY);
> +odp_flow_format(key_buf.data, key_buf.size,
> +mask_buf.data, mask_buf.size,
> +NULL, , false);
>  ds_put_cstr(, ", actions:");
>  format_odp_actions(, actions, actions_len);
>
>  VLOG_DBG_RL(_rl, "%s", ds_cstr());
>
> +ofpbuf_uninit(_buf);
> +ofpbuf_uninit(_buf);
>  ds_destroy();
>  }
>
> diff --git a/tests/dpif-netdev.at b/tests/dpif-netdev.at
> index ab83634..6af0f64 100644
> --- a/tests/dpif-netdev.at
> +++ b/tests/dpif-netdev.at
> @@ -67,10 +67,10 @@ m4_define([DPIF_NETDEV_DUMMY_IFACE],
> sleep 1  # wait for forwarders process packets
>
> AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0],
> [dnl
> -recirc_id=0,ip,in_port=1,vlan_tci=0x/0x1fff,dl_src=50:54:00:00:00:0b,dl_dst=50:54:00:00:00:0c,nw_frag=no,
> actions: 
> -recirc_id=0,ip,in_port=2,vlan_tci=0x/0x1fff,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_frag=no,
> actions: 
> -recirc_id=0,ip,in_port=7,vlan_tci=0x/0x1fff,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_frag=no,
> actions: 
> -recirc_id=0,ip,in_port=8,vlan_tci=0x/0x1fff,dl_src=50:54:00:00:00:0b,dl_dst=50:54:00:00:00:0c,nw_frag=no,
> actions: 
> +recirc_id(0),in_port(1),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(frag=no),
> actions: 
> +recirc_id(0),in_port(2),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no),
> actions: 
> +recirc_id(0),in_port(7),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no),
> actions: 
> +recirc_id(0),in_port(8),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(frag=no),
> actions: 
>  ])
>
> OVS_VSWITCHD_STOP
> @@ -95,7 +95,7 @@ m4_define([DPIF_NETDEV_MISS_FLOW_INSTALL],
>
>  
> skb_priority(0),skb_mark(0),recirc_id(0),dp_hash(0),in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
>  ])
> AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0],
> [dnl
> -recirc_id=0,ip,in_port=1,vlan_tci=0x/0x1fff,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_frag=no,
> actions: 
> +recirc_id(0),in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no),
> actions: 
>  ])
>
> # Now, the same again without megaflows.
> @@ -108,8 +108,8 @@
> recirc_id=0,ip,in_port=1,vlan_tci=0x/0x1fff,dl_src=50:54:00:00:00:09,dl_dst=
>
>  
> 

[ovs-dev] cannot find v4 of DNAT changes in mailing list

2016-06-13 Thread Flaviof
Hi Guru,

For some odd reason the v4 of your changes in patchwork [v4]
does not seem to be visible via the mailing list. Is that because you
submitted it via GitHub?!?

Thanks,

-- flaviof

[v4]: https://patchwork.ozlabs.org/patch/633069/
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] ofp-util: Fix parsing of parenthesized values within key-value pairs.

2016-06-13 Thread Andy Zhou
On Sun, Jun 12, 2016 at 5:43 PM, Ben Pfaff  wrote:

> Reported-by: james hopper 
> Reported-at:
> http://openvswitch.org/pipermail/discuss/2016-June/021662.html
> Signed-off-by: Ben Pfaff 
> ---
>  AUTHORS   |   1 +
>  lib/ofp-util.c| 109
> ++
>  tests/ofp-util.at |  43 
>  tests/ofproto.at  |   4 ++
>  utilities/ovs-ofctl.c |  21 ++
>  5 files changed, 134 insertions(+), 44 deletions(-)
>
> diff --git a/AUTHORS b/AUTHORS
> index 9fda4c1..e2ac267 100644
> --- a/AUTHORS
> +++ b/AUTHORS
> @@ -452,6 +452,7 @@ Ziyou Wang  ziy...@vmware.com
>  Zoltán Balogh   zoltan.bal...@ericsson.com
>  ankur dwivedi   ankurengg2...@gmail.com
>  chen zhang  3zhangchen9...@gmail.com
> +james hopperjameshop...@email.com
>  kk yap  yap...@stanford.edu
>  likunyunkunyu...@hotmail.com
>  meishengxin meisheng...@huawei.com
> diff --git a/lib/ofp-util.c b/lib/ofp-util.c
> index 2c6fb1f..2c93dd4 100644
> --- a/lib/ofp-util.c
> +++ b/lib/ofp-util.c
> @@ -7355,6 +7355,36 @@ ofputil_normalize_match_quiet(struct match *match)
>  ofputil_normalize_match__(match, false);
>  }
>
> +static size_t
> +parse_value(const char *s, const char *delimiters)
> +{
> +size_t n = 0;
> +for (;;) {
>
Would it be easier to read with a while loop?  Of course, there is nothing
wrong
using the for loop logically.

e.g.
size_t n = 0;
 While (!strchr(delimiters, s[n]) {
if (s[n] == '(')
...

 }
 return n;


> +if (strchr(delimiters, s[n])) {
> +/* strchr(s, '\0') returns s+strlen(s), so this case handles
> the
> + * null terminator at the end of 's'.  */
> +return n;
> +} else if (s[n] == '(') {
> +int level = 0;
> +do {
> +switch (s[n]) {
> +case '\0':
> +return n;
> +case '(':
> +level++;
> +break;
> +case ')':
> +level--;
> +break;
>
Is it possible for n to advance beyond end of string, in case of imbalanced
")" ?
I have not played with the test cases, so this is not a full review.

> +}
> +n++;
> +} while (level > 0);
> +} else {
> +n++;
> +}
> +}
> +}
> +
>  /* Parses a key or a key-value pair from '*stringp'.
>   *
>   * On success: Stores the key into '*keyp'.  Stores the value, if
> present, into
> @@ -7368,58 +7398,49 @@ ofputil_normalize_match_quiet(struct match *match)
>  bool
>  ofputil_parse_key_value(char **stringp, char **keyp, char **valuep)
>  {
> -char *pos, *key, *value;
> -size_t key_len;
> -
> -pos = *stringp;
> -pos += strspn(pos, ", \t\r\n");
> -if (*pos == '\0') {
> +/* Skip white space and delimiters.  If that brings us to the end of
> the
> + * input string, we are done and there are no more key-value pairs. */
> +*stringp += strspn(*stringp, ", \t\r\n");
> +if (**stringp == '\0') {
>  *keyp = *valuep = NULL;
>  return false;
>  }
>
> -key = pos;
> -key_len = strcspn(pos, ":=(, \t\r\n");
> -if (key[key_len] == ':' || key[key_len] == '=') {
> -/* The value can be separated by a colon. */
> -size_t value_len;
> -
> -value = key + key_len + 1;
> -value_len = strcspn(value, ", \t\r\n");
> -pos = value + value_len + (value[value_len] != '\0');
> -value[value_len] = '\0';
> -} else if (key[key_len] == '(') {
> -/* The value can be surrounded by balanced parentheses.  The
> outermost
> - * set of parentheses is removed. */
> -int level = 1;
> -size_t value_len;
> -
> -value = key + key_len + 1;
> -for (value_len = 0; level > 0; value_len++) {
> -switch (value[value_len]) {
> -case '\0':
> -level = 0;
> -break;
> -
> -case '(':
> -level++;
> -break;
> +/* Extract the key and the delimiter that ends the key-value pair or
> begins
> + * the value.  Advance the input position past the key and delimiter.
> */
> +char *key = *stringp;
> +size_t key_len = strcspn(key, ":=(, \t\r\n");
> +char key_delim = key[key_len];
> +key[key_len] = '\0';
> +*stringp += key_len + (key_delim != '\0');
>
> -case ')':
> -level--;
> -break;
> -}
> -}
> -value[value_len - 1] = '\0';
> -pos = value + value_len;
> +/* Figure out what delimiter ends the value:
> + *
> + * - If key_delim is ":" or "=", the value extends until white
> space
> + *   or a comma.
> + *
> + *   

[ovs-dev] Quote

2016-06-13 Thread Sehrab
Good Day,

I was directed by one of your customer to buy from you.

Please I want to know if you can ship to Spain before i order


Regards,
Sehreb
Logistics,
KASHISH EXPORTS S.A.S
Tel: +32 88459891-3

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


Re: [ovs-dev] [PATCH v1] ipfix: Bug fix for not sending template packets on 32-bit OS

2016-06-13 Thread Ben Pfaff
On Sat, Jun 11, 2016 at 09:55:39AM +0800, Benli Ye wrote:
> 'last_template_set_time' in truct dpif_ipfix_exporter is declared
> as time_t and time_t is long int type. If we initialize
> 'last_template_set_time' as TIME_MIN, whose value is -2147483648
> on 32-bit OS and -2^63 on 64-bit OS. There will be a problem on
> 32-bit OS when comparing 'last_template_set_time' with a unisgned int
> type variable, because type casting will happen and negative value
> could be a large positive number. Fix this problem by simply initialize
> 'last_template_set_time' as 0.

I'm not really happy with the way that the ipfix module manages time,
but this seems like the best "quick fix" for older branches especially.

Can you provide a Signed-off-by?
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v3] ipfix: support tunnel information for Flow IPFIX

2016-06-13 Thread Ben Pfaff
Hi Daniel.

As I understand it, the goal is to translate these OpenFlow actions:
sample(sampling_port=1), sample(sampling_port=2), 1, 2
into these datapath actions:
set(tunnel(...)), sample(...), 1,
set(tunnel(...)), sample(...), 7471
(For readability, I'm adding line breaks and omitting most arguments.)

The way I'm suggesting to do this is that the translation of OpenFlow
"sample" action should first emit set(tunnel(...), then the sample
action itself.  This can be done in a completely separate way from
the action output.  For example, the following OpenFlow action:
sample(sampling_port=1)
would translate into these datapath actions;
set(tunnel(...)), sample(...)
This behavior is going to be less surprising to controller writers.
After all, why should sampling a packet require output?

Now, you may be asking whether this will cause duplicate
set(tunnel(...)) actions.  I do not think so, in the common case,
because ordinarily I'd expect that an output would immediately follow
the sampling.  In that case, the "commit" will not output a duplicate
set(tunnel(...)).  So, for example, this:
sample(sampling_port=1), 1
would translate into:
set(tunnel(...)), sample(...), 1

The example you give, where the first sample action is separated from
the output to its port by a different sample action for a different
port, would output two set(tunnel(...)) actions for each port.  However,
if that's a real problem in practice, then the controller can emit
OpenFlow actions in a different order:
sample(sampling_port=1), 1, sample(sampling_port=2), 2
which may be easier for the controller anyhow.

On Sat, Jun 11, 2016 at 01:31:05AM +, Daniel Ye wrote:
> Hi Ben,
> 
> Yes, my first idea is to do adjust_sample_acion()  action in 
> commit_odp_tunnel_action(), but it can hardly
> handle the problem that if there are two or more user world sample action and 
> each has a sampling_port, like the
> last case in my new added testing. We add a flow in the user world like 
> below, port 1 and 2 are both tunnel port:
> "in_port=3, 
> actions=sample(probability=65535,collector_set_id=1,sampling_port=1),sample(probability=65535,collector_set_id=1,sampling_port=2),output:1,2”
> And we want to get the datapath action in the following format:
> Datapath actions: 
> set(tunnel(tun_id=0x5,src=2.2.2.2,dst=1.1.1.1,tos=0x1,ttl=64,flags(df|key))),sample(sample=100.0%,actions(userspace(pid=0,flow_sample(probability=65535,collector_set_id=1,obs_domain_id=0,obs_point_id=0,output_port=1),tunnel_out_port=1))),1,set(tunnel(tun_id=0x6,src=2.2.2.3,dst=1.1.1.2,tos=0x1,ttl=64,flags(df|key))),sample(sample=100.0%,actions(userspace(pid=0,flow_sample(probability=65535,collector_set_id=1,obs_domain_id=0,obs_point_id=0,output_port=7471),tunnel_out_port=7471))),7471
> 
> If we don’t know the output port, I have’t found a way to decide which sample 
> action should be adjusted. So I do the adjust when the output port is known.
> 
> Bests,
> Daniel
>  
> > On Jun 11, 2016, at 6:30 AM, Ben Pfaff  wrote:
> > 
> > <0>
> 

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


Re: [ovs-dev] [PATCH] ovn-architecture.7.xml: Fix ovn-controller behavior in VIF life cycle

2016-06-13 Thread Ben Pfaff
On Mon, Jun 13, 2016 at 12:43:26PM -0400, Hui Kang wrote:
> Signed-off-by: Hui Kang 

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


Re: [ovs-dev] [PATCH monitor_cond V7 00/10] Conditional monitor implementation

2016-06-13 Thread Hui Kang


"dev"  wrote on 06/13/2016 07:19:25 AM:

> From: Liran Schour 
> To: b...@ovn.org
> Cc: d...@openvswitch.com
> Date: 06/13/2016 08:29 AM
> Subject: [ovs-dev] [PATCH monitor_cond V7 00/10] Conditional monitor
> implementation
> Sent by: "dev" 
>
> This patch series implements conditional monitoring by introducing an
OVSDB
> RFC extension with 2 new JSON-RPC methods: "monitor_cond" and
> "monitor_cond_change". Specification of this extension is defined in the
> ovsdb-server (1) man page.
> Monitor2 is now merged into monitor_cond. A monitor_cond session
> with an empty
> condition, will behave exactly like monitor2 and will get update2
> notifications
> on all rows.
>
> This patch series is also available on:
https://github.com/liranschour/ovs.git
> branch monitor_cond_ovn.

Hi, Liran,
I am interested in cloning this patch from github. However, in your git
repo, I
see several branches name with monitor_cond_ovn, i.e., monitor_cond_ovn,
monitor_cond_ovn_v7_ovn, monitor_cond_ovn_dev

Which one shall I use? Thanks.

- Hui

>
> OVN:
> Last patch in this series is a RFC for OVN usage of conditional
monitoring.
>
> Performance evaluation:
> OVN is the main candidate for conditional monitoring usage. It is clear
that
> conditional monitoring reduces computation on the ovn-controller (client)
side
> due to the reduced size of flow tables and update messages. However,
> performance evaluation shows also a reduction in computation on the SB
> ovsdb-server side proportional to the degree that each logical network is
> spread over physical hosts in the DC.
>
> Evaluation on simulated environment of 50 hosts and 1000 logical ports
shows
> the following results (cycles #):
>
> LN spread over # hosts|master| patch| change
> -
> 1 | 58855158082  | 38175941755  | 35.1%
> 3 | 54816462604  | 40255584120  | 26.5%
> 6 | 52972265506  | 39481653891  | 25.4%
>12 | 57036827284  | 42008285519  | 26.3%
>18 | 61900476558  | 45903107035  | 25.8%
>24 | 64281399690  | 55617752599  | 13.4%
>30 | 66905128558  | 61835913623  |  7.5%
>42 | 76763742331  | 70522724721  |  8.1%
>50 | 85372146321  | 80130285454  |  6.1%
>
> Changes V6 --> V7:
> --
> * Change ovsdb-idl API to include only add and remove clause from
condition.
> * IDL maintain and track conditions. Send monitor_cond_change on
condition
>   change.
> * Due to IDL API change, OVN does not maintain and track condition.
> * Report column duplication on ovsdv_monitor_add_column().
> * Split added documentation according to patches.
> * Add to testing for monitor_cond_change method in ovsdb-client via
unixctl
>   command.
> * An update, if any, as a result of a condition change, will be sent to
the
>   client before the reply to the "monitor_cond_update" request.
> * Minor fixes due to review.
>
> Liran Schour (10):
>   ovsdb: create column index mapping between ovsdb row to monitor row
>   ovsdb: add conditions utilities to support monitor_cond
>   ovsdb: allow unmonitored columns in condition evaluation
>   ovsdb: generate update notifications for monitor_cond session
>   ovsdb: enable jsonrpc-server to service "monitor_cond_change" request
>   ovsdb-client: support monitor-cond method
>   lib: add to ovsdb-idl monitor_id
>   python: move Python idl to work with monitor_cond
>   lib: add monitor_cond_change API to C IDL lib
>   RFC OVN: Quick implementation of conditional monitoring
>
>  NEWS|   3 +-
>  lib/automake.mk |   2 +
>  lib/ovsdb-condition.c   |  47 
>  lib/ovsdb-condition.h   |  45 +++
>  lib/ovsdb-idl-provider.h|   2 +
>  lib/ovsdb-idl.c | 239 ++--
>  lib/ovsdb-idl.h |  30 ++
>  ovn/controller/binding.c| 108 +++-
>  ovn/controller/binding.h|   4 +-
>  ovn/controller/lport.c  | 123 -
>  ovn/controller/lport.h  |  10 +-
>  ovn/controller/ovn-controller.c |  23 +-
>  ovsdb/condition.c   | 188 -
>  ovsdb/condition.h   |  57 ++--
>  ovsdb/jsonrpc-server.c  | 233 +---
>  ovsdb/jsonrpc-server.h  |   2 +-
>  ovsdb/monitor.c | 592 +
> +--
>  ovsdb/monitor.h |  46 +++-
>  ovsdb/ovsdb-client.1.in |  37 ++-
>  ovsdb/ovsdb-client.c|  98 +--
>  ovsdb/ovsdb-idlc.in | 364 +++-
>  ovsdb/ovsdb-server.1.in | 221 +--
>  ovsdb/ovsdb-server.c|  20 +-
>  ovsdb/query.c   |   6 +-
>  python/ovs/db/data.py   |  16 +-
>  python/ovs/db/idl.py| 

[ovs-dev] [PATCH] ovn-architecture.7.xml: Fix ovn-controller behavior in VIF life cycle

2016-06-13 Thread Hui Kang
Signed-off-by: Hui Kang 
---
 ovn/ovn-architecture.7.xml | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ovn/ovn-architecture.7.xml b/ovn/ovn-architecture.7.xml
index f8a348b..72786bc 100644
--- a/ovn/ovn-architecture.7.xml
+++ b/ovn/ovn-architecture.7.xml
@@ -382,12 +382,12 @@
 
   On the hypervisor where the VM is powered on, ovn-controller
   notices external-ids:iface-id in the new
-  Interface.  In response, it updates the local hypervisor's OpenFlow
-  tables so that packets to and from the VIF are properly handled.
-  Afterward, in the OVN Southbound DB, it updates the
+  Interface. In response, in the OVN Southbound DB, it updates the
   Binding table's chassis column for the
-  row that links the logical port from
-  external-ids:iface-id to the hypervisor.
+  row that links the logical port from external-ids:
+  iface-id to the hypervisor. Afterward, ovn-controller
+  updates the local hypervisor's OpenFlow tables so that packets to and 
from
+  the VIF are properly handled.
 
 
 
-- 
1.9.1

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


Re: [ovs-dev] Group with select type

2016-06-13 Thread Ben Pfaff
On Mon, Jun 13, 2016 at 11:54:11AM -0400, Junguk Cho wrote:
> I would like to test group with select type for round-robin way.
> 
> I basically followed this page (
> http://openvswitch.org/pipermail/discuss/2014-August/014785.html).
> For example, there are one client and three servers.
> If I ping from one client to three servers with Virtual IP address, it
> always goes to the same place.  I think ovs generates the same hash values
> since ping does not have different header fields for hash.
> Is it right?
> 
> So, I think I should use some "fields" option to make different paths like
> nw_proto or dst_port.
> 
> Is there a way of doing round-robin for ping-like traffic?

You could do this by adding an OVS field for ICMP sequence number and
then selecting on the least-significant bit.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Can 1,000+ members be wrong?

2016-06-13 Thread Fran

Hey,
I Noticed you didn’t got “Google Trader System”
You are really missing the opportunity of Making 6 Figure Per Month
You no longer need to work 9 to 5 After Getting it.. ( I promise)

Get it Now == http://bricapar.com/Ph8ebO


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


Re: [ovs-dev] [PATCH] vtep: add per-tunnel tunnel key support in vtep-ctl and ovs-vtep. related to commit c2cd1902

2016-06-13 Thread Darrell Ball
I was not able to apply this patch - can you fix this

Also, can you make sure the OVN vtep GW test passes (using make check) with
the patch submitted

2043: ovn.at:1029ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS
  vtep

The changes to vtep.xml are hard to follow; also I am not sure
they are required as there is already documentation for
 Per Logical_Switch+Physical_Locator pair tunnel keys.






On Tue, Jun 7, 2016 at 1:19 AM, Itamar Ofek  wrote:

>  This patch adds support for handeling a per-tunnel tunnel key in the
>  ovs-vtep and vtep-ctl to support the usage of neutron L2GW as an
> inter-cloud
>  gateway.
>
>  The Neutron spec is available here:
> https://review.openstack.org/#/c/270786/
>
> Requested-by: "Ofer Ben-Yacov" 
> Signed-off-by: "Itamar Ofek" 
> ---
>  tests/vtep-ctl.at | 132
> +--
>  vtep/ovs-vtep |  52 +---
>  vtep/vtep-ctl.c   | 138
> +++---
>  vtep/vtep.xml |  10 +++-
>  4 files changed, 200 insertions(+), 132 deletions(-)
>
> diff --git a/tests/vtep-ctl.at b/tests/vtep-ctl.at
> index f0511ad..b7803c3 100644
> --- a/tests/vtep-ctl.at
> +++ b/tests/vtep-ctl.at
> @@ -437,8 +437,8 @@ AT_CHECK([RUN_VTEP_CTL(
>  ], [0], [], [], [VTEP_CTL_CLEANUP])
>  AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
> [ucast-mac-local
> -  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
> -  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11
> +  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]]
> +  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]]
>
>  mcast-mac-local
>
> @@ -464,7 +464,7 @@ AT_CHECK([RUN_VTEP_CTL(
>  ], [0], [], [], [VTEP_CTL_CLEANUP])
>  AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
> [ucast-mac-local
> -  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11
> +  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 [[]]
>
>  mcast-mac-local
>
> @@ -484,8 +484,8 @@ AT_CHECK([RUN_VTEP_CTL(
>  ], [0], [], [], [VTEP_CTL_CLEANUP])
>  AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
> [ucast-mac-local
> -  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
> -  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11
> +  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]]
> +  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]]
>
>  mcast-mac-local
>
> @@ -495,7 +495,7 @@ AT_CHECK([RUN_VTEP_CTL(
>  ], [0], [], [], [VTEP_CTL_CLEANUP])
>  AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
> [ucast-mac-local
> -  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11
> +  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]]
>
>  mcast-mac-local
>
> @@ -515,8 +515,8 @@ AT_CHECK([RUN_VTEP_CTL(
>  ], [0], [], [], [VTEP_CTL_CLEANUP])
>  AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
> [ucast-mac-remote
> -  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
> -  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11
> +  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]]
> +  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]]
>
>  mcast-mac-remote
>
> @@ -542,7 +542,7 @@ AT_CHECK([RUN_VTEP_CTL(
>  ], [0], [], [], [VTEP_CTL_CLEANUP])
>  AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
> [ucast-mac-remote
> -  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11
> +  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 [[]]
>
>  mcast-mac-remote
>
> @@ -562,8 +562,8 @@ AT_CHECK([RUN_VTEP_CTL(
>  ], [0], [], [], [VTEP_CTL_CLEANUP])
>  AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
> [ucast-mac-remote
> -  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
> -  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11
> +  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]]
> +  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]]
>
>  mcast-mac-remote
>
> @@ -573,7 +573,7 @@ AT_CHECK([RUN_VTEP_CTL(
>  ], [0], [], [], [VTEP_CTL_CLEANUP])
>  AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
> [ucast-mac-remote
> -  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11
> +  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]]
>
>  mcast-mac-remote
>
> @@ -595,16 +595,16 @@ AT_CHECK([RUN_VTEP_CTL(
>  ], [0], [], [], [VTEP_CTL_CLEANUP])
>  AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
> [ucast-mac-local
> -  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
> -  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11
> +  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]]
> +  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]]
>
>  mcast-mac-local
>
>  ], [], [VTEP_CTL_CLEANUP])
>  AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
> [ucast-mac-remote
> -  02:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
> -  02:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11
> +  02:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]]
> +  02:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]]
>
>  mcast-mac-remote
>
> @@ -627,9 +627,9 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
> [ucast-mac-local
>
>  mcast-mac-local
> -  

[ovs-dev] Subject: [ovsdb-idl 1/1] Fix issues detected in Partial Map Update feature

2016-06-13 Thread Lutz, Arnoldo
Hi. 
We found some issues affecting Partial Map Update feature included in master 
branch.
This patch fixes a memory leak due to lack of freeing datum allocated in the 
process of
requesting a change to a map.
It also fix an error produced when NDEBUG flag is not set that causes an 
assertion when preparing
the map to be changed.


From 540230095eb5d552bb1cc559abb1bbdc668197b1 Mon Sep 17 00:00:00 2001
From: "arnoldo.lutz.guev...@hpe.com" 
Date: Thu, 9 Jun 2016 09:41:00 -0700
Subject: [ovsdb-idl 1/1] Fix issues detected in Partial Map Update feature

Fix of a memory leak not freeing datums.
Change use of ovsdb_idl_read function when preparing changes to maps.

Signed-off-by: arnoldo.lutz.guev...@hpe.com 
---
 lib/ovsdb-idl.c| 13 -
 lib/ovsdb-map-op.c |  1 +
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 2b372cb..b2b84c2 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -2225,7 +2225,16 @@ ovsdb_idl_txn_extract_mutations(struct ovsdb_idl_row 
*row,
 column = >columns[idx];
 key_type = column->type.key.type;
 value_type = column->type.value.type;
-old_datum = ovsdb_idl_read(row, column);
+
+/* Get the value to be changed */
+if (row->new && row->written && bitmap_is_set(row->written,idx)) {
+old_datum = >new[idx];
+} else if (row->old != NULL) {
+old_datum = >old[idx];
+} else {
+old_datum = CONST_CAST(struct ovsdb_datum*,
+ovsdb_datum_default(>type));
+}
 
 del_set = json_array_create_empty();
 ins_map = json_array_create_empty();
@@ -3407,6 +3416,7 @@ ovsdb_idl_txn_write_partial_map(const struct 
ovsdb_idl_row *row_,
 
 if (!is_valid_partial_update(row, column, datum)) {
 ovsdb_datum_destroy(datum, >type);
+free(datum);
 return;
 }
 
@@ -3437,6 +3447,7 @@ ovsdb_idl_txn_delete_partial_map(const struct 
ovsdb_idl_row *row_,
 struct ovsdb_type type_ = column->type;
 type_.value.type = OVSDB_TYPE_VOID;
 ovsdb_datum_destroy(datum, _);
+free(datum);
 return;
 }
 ovsdb_idl_txn_add_map_op(row, column, datum, MAP_OP_DELETE);
diff --git a/lib/ovsdb-map-op.c b/lib/ovsdb-map-op.c
index 58f43dc..23fc5f5 100644
--- a/lib/ovsdb-map-op.c
+++ b/lib/ovsdb-map-op.c
@@ -57,6 +57,7 @@ map_op_destroy_datum(struct map_op *map_op, const struct 
ovsdb_type *type)
 } else {
 ovsdb_datum_destroy(map_op->datum, type);
 }
+free(map_op->datum);
 map_op->datum = NULL;
 }
 
-- 
1.9.1
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Group with select type

2016-06-13 Thread Junguk Cho
Hi,

I would like to test group with select type for round-robin way.

I basically followed this page (
http://openvswitch.org/pipermail/discuss/2014-August/014785.html).
For example, there are one client and three servers.
If I ping from one client to three servers with Virtual IP address, it
always goes to the same place.  I think ovs generates the same hash values
since ping does not have different header fields for hash.
Is it right?

So, I think I should use some "fields" option to make different paths like
nw_proto or dst_port.

Is there a way of doing round-robin for ping-like traffic?

Thansk in advance.
Junguk
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] utilities/ovs-docker: Add support for specifying vlan tag on add-port cal

2016-06-13 Thread Guru Shetty
On 11 June 2016 at 05:28, Brian Turek  wrote:

> Signed-off-by: Brian Turek 
>

Thank you for your contribution. How did you send this patch? I couldn't
apply it on my local tree using 'git am'. Sending it via 'git send-email'
usually gets it right.

The change in the patch itself is not much, so I took a look. The thing
that concerns me a bit with this patch is that I could potentially run
commands of the form:

utilities/ovs-docker add-port br-int eth1 f5f314682193 --vlan="2 -- set
bridge br-int external_ids:hello=hi"

We could avoid it by doing something like this instead:
diff --git a/utilities/ovs-docker b/utilities/ovs-docker
index 43cea54..82c0343 100755
--- a/utilities/ovs-docker
+++ b/utilities/ovs-docker
@@ -90,6 +90,10 @@ add_port () {
 MTU=`expr X"$1" : 'X[^=]*=\(.*\)'`
 shift
 ;;
+--vlan=*)
+TAG=`expr X"$1" : 'X[^=]*=\(.*\)'`
+shift
+;;
 *)
 echo >&2 "$UTIL add-port: unknown option \"$1\""
 exit 1
@@ -134,6 +138,15 @@ add_port () {
 exit 1
 fi

+if [ -n "$TAG" ]; then
+if ovs_vsctl set port "${PORTNAME}_l" tag="$TAG"; then :; else
+echo >&2 "$UTIL: Failed to set vlan $tag"
+ovs_vsctl del-port "${PORTNAME}_l"
+ip link delete "${PORTNAME}_l"
+exit 1
+fi
+fi
+
 ip link set "${PORTNAME}_l" up





>
> diff --git a/utilities/ovs-docker b/utilities/ovs-docker
> index 43cea54..98892b6 100755
> --- a/utilities/ovs-docker
> +++ b/utilities/ovs-docker
> @@ -90,6 +90,10 @@ add_port () {
>  MTU=`expr X"$1" : 'X[^=]*=\(.*\)'`
>  shift
>  ;;
> +--vlan=*)
> +TAG="tag=$(expr X"$1" : 'X[^=]*=\(.*\)')"
> +shift
> +;;
>  *)
>  echo >&2 "$UTIL add-port: unknown option \"$1\""
>  exit 1
> @@ -126,7 +130,7 @@ add_port () {
>
>  # Add one end of veth to OVS bridge.
>  if ovs_vsctl --may-exist add-port "$BRIDGE" "${PORTNAME}_l" \
> -   -- set interface "${PORTNAME}_l" \
> +   $TAG -- set interface "${PORTNAME}_l" \
> external_ids:container_id="$CONTAINER" \
> external_ids:container_iface="$INTERFACE"; then :; else
>  echo >&2 "$UTIL: Failed to add "${PORTNAME}_l" port to bridge
> $BRIDGE"
> @@ -224,15 +228,15 @@ usage: ${UTIL} COMMAND
>  Commands:
>add-port BRIDGE INTERFACE CONTAINER [--ipaddress="ADDRESS"]
>  [--gateway=GATEWAY] [--macaddress="MACADDRESS"]
> -[--mtu=MTU]
> +[--mtu=MTU] [--vlan=VLAN]
>  Adds INTERFACE inside CONTAINER and connects it as a
> port
>  in Open vSwitch BRIDGE. Optionally, sets ADDRESS on
>  INTERFACE. ADDRESS can include a '/' to represent
> network
> -prefix length. Optionally, sets a GATEWAY, MACADDRESS
> -and MTU.  e.g.:
> +prefix length. Optionally, sets a GATEWAY, MACADDRESS,
> +MTU, and VLAN.  e.g.:
>  ${UTIL} add-port br-int eth1 c474a0e2830e
>  --ipaddress=192.168.1.2/24 --gateway=192.168.1.1
> ---macaddress="a2:c3:0d:49:7f:f8" --mtu=1450
> +--macaddress="a2:c3:0d:49:7f:f8" --mtu=1450 --vlan=10
>del-port BRIDGE INTERFACE CONTAINER
>  Deletes INTERFACE inside CONTAINER and removes its
>  connection to Open vSwitch BRIDGE. e.g.:
> ___
> 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 v1] ipfix: Bug fix for not sending template packets on 32-bit OS

2016-06-13 Thread William Tu
Acked-by: William Tu 

I think it fixes the issue, although the root cause is that we are

1) Comparing signed int (last_template_set_time) and unsigned int
(export_time_sec). From the C99, the operand with signed integer type
is converted to the type of the operand with unsigned integer type, so
last_template_set_time is cast to unsigned int.
...
&& (exporter->last_template_set_time + IPFIX_TEMPLATE_INTERVAL)
<= export_time_sec) {

And, after initial send,
2) assigning unsigned int to signed int
  exporter->last_template_set_time = export_time_sec;

I don't have a 32-bit system to test, but explicitly cast to time_t
should also solve the problem.

Regards,
William

On Fri, Jun 10, 2016 at 6:55 PM, Benli Ye  wrote:
> 'last_template_set_time' in truct dpif_ipfix_exporter is declared
> as time_t and time_t is long int type. If we initialize
> 'last_template_set_time' as TIME_MIN, whose value is -2147483648
> on 32-bit OS and -2^63 on 64-bit OS. There will be a problem on
> 32-bit OS when comparing 'last_template_set_time' with a unisgned int
> type variable, because type casting will happen and negative value
> could be a large positive number. Fix this problem by simply initialize
> 'last_template_set_time' as 0.
> ---
>  ofproto/ofproto-dpif-ipfix.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
> index 79ba234..b1b2237 100644
> --- a/ofproto/ofproto-dpif-ipfix.c
> +++ b/ofproto/ofproto-dpif-ipfix.c
> @@ -495,7 +495,7 @@ dpif_ipfix_exporter_init(struct dpif_ipfix_exporter 
> *exporter)
>  {
>  exporter->collectors = NULL;
>  exporter->seq_number = 1;
> -exporter->last_template_set_time = TIME_MIN;
> +exporter->last_template_set_time = 0;
>  hmap_init(>cache_flow_key_map);
>  ovs_list_init(>cache_flow_start_timestamp_list);
>  exporter->cache_active_timeout = 0;
> @@ -511,7 +511,7 @@ dpif_ipfix_exporter_clear(struct dpif_ipfix_exporter 
> *exporter)
>  collectors_destroy(exporter->collectors);
>  exporter->collectors = NULL;
>  exporter->seq_number = 1;
> -exporter->last_template_set_time = TIME_MIN;
> +exporter->last_template_set_time = 0;
>  exporter->cache_active_timeout = 0;
>  exporter->cache_max_flows = 0;
>  }
> --
> 1.9.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 monitor_cond V7 01/10] ovsdb: create column index mapping between ovsdb row to monitor row

2016-06-13 Thread Liran Schour
Columns indexing is different in ovsdb_row then in ovsdb_monitor_row.
We need mapping between the 2 for condition evaluation.

signed-off-by: Liran Schour 
---
 ovsdb/jsonrpc-server.c | 26 ++--
 ovsdb/monitor.c| 65 +++---
 ovsdb/monitor.h|  6 +
 3 files changed, 53 insertions(+), 44 deletions(-)

diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 4913d7e..208027a 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -1158,8 +1158,12 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor 
*dbmon,
 return ovsdb_syntax_error(columns, NULL, "%s is not a valid "
   "column name", s);
 }
-ovsdb_monitor_add_column(dbmon, table, column, select,
- allocated_columns);
+if (ovsdb_monitor_add_column(dbmon, table, column, select,
+ allocated_columns)) {
+return ovsdb_syntax_error(columns, NULL, "column %s "
+  "mentioned more than once",
+  column->name);
+}
 }
 } else {
 struct shash_node *node;
@@ -1167,8 +1171,12 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor 
*dbmon,
 SHASH_FOR_EACH (node, >columns) {
 const struct ovsdb_column *column = node->data;
 if (column->index != OVSDB_COL_UUID) {
-ovsdb_monitor_add_column(dbmon, table, column, select,
- allocated_columns);
+if (ovsdb_monitor_add_column(dbmon, table, column, select,
+ allocated_columns)) {
+return ovsdb_syntax_error(columns, NULL, "column %s "
+  "mentioned more than once",
+  column->name);
+}
 }
 }
 }
@@ -1217,7 +1225,6 @@ ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session 
*s, struct ovsdb *db,
 
 SHASH_FOR_EACH (node, json_object(monitor_requests)) {
 const struct ovsdb_table *table;
-const char *column_name;
 size_t allocated_columns;
 const struct json *mr_value;
 size_t i;
@@ -1251,15 +1258,6 @@ ovsdb_jsonrpc_monitor_create(struct 
ovsdb_jsonrpc_session *s, struct ovsdb *db,
 goto error;
 }
 }
-
-column_name = ovsdb_monitor_table_check_duplicates(m->dbmon, table);
-
-if (column_name) {
-error = ovsdb_syntax_error(mr_value, NULL, "column %s "
-   "mentioned more than once",
-column_name);
-goto error;
-}
 }
 
 dbmon = ovsdb_monitor_add(m->dbmon);
diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c
index e910e3f..1e334d2 100644
--- a/ovsdb/monitor.c
+++ b/ovsdb/monitor.c
@@ -116,6 +116,11 @@ struct ovsdb_monitor_table {
 struct ovsdb_monitor_column *columns;
 size_t n_columns;
 
+/* Columns in ovsdb_monitor_row have different indexes then in
+ * ovsdb_row. This field maps between column->index to the index in the
+ * ovsdb_monitor_row. It is used for condition evaluation. */
+unsigned int *columns_index_map;
+
 /* Contains 'ovsdb_monitor_changes' indexed by 'transaction'. */
 struct hmap changes;
 };
@@ -304,6 +309,24 @@ ovsdb_monitor_row_destroy(const struct ovsdb_monitor_table 
*mt,
 }
 }
 
+static void
+ovsdb_monitor_columns_sort(struct ovsdb_monitor *dbmon)
+{
+int i;
+struct shash_node *node;
+
+SHASH_FOR_EACH (node, >tables) {
+struct ovsdb_monitor_table *mt = node->data;
+
+qsort(mt->columns, mt->n_columns, sizeof *mt->columns,
+  compare_ovsdb_monitor_column);
+for (i = 0; i < mt->n_columns; i++) {
+/* re-set index map due to sort */
+mt->columns_index_map[mt->columns[i].column->index] = i;
+}
+}
+}
+
 void
 ovsdb_monitor_add_jsonrpc_monitor(struct ovsdb_monitor *dbmon,
   struct ovsdb_jsonrpc_monitor 
*jsonrpc_monitor)
@@ -341,14 +364,21 @@ ovsdb_monitor_add_table(struct ovsdb_monitor *m,
 const struct ovsdb_table *table)
 {
 struct ovsdb_monitor_table *mt;
+int i;
+size_t n_columns = shash_count(>schema->columns);
 
 mt = xzalloc(sizeof *mt);
 mt->table = table;
 shash_add(>tables, table->schema->name, mt);
 hmap_init(>changes);
+mt->columns_index_map =
+xmalloc(sizeof *mt->columns_index_map * n_columns);
+for (i = 0; i < n_columns; i++) {
+mt->columns_index_map[i] = -1;
+}
 }
 
-void
+const char *
 ovsdb_monitor_add_column(struct ovsdb_monitor *dbmon,
  

[ovs-dev] [PATCH monitor_cond V7 05/10] ovsdb: enable jsonrpc-server to service "monitor_cond_change" request

2016-06-13 Thread Liran Schour
ovsdb-server now accepts "monitor_cond_change" request. After conditions change
we compose update notification according to the current state of the
database without using a change list before sending reply to the 
monitor_cond_change
request.
Sees ovsdb-server (1) man page for details of monitor_cond_change.

Signed-off-by: Liran Schour 
---
 ovsdb/jsonrpc-server.c  | 147 +++-
 ovsdb/monitor.c | 254 +++-
 ovsdb/monitor.h |  32 +++---
 ovsdb/ovsdb-server.1.in |  72 ++
 4 files changed, 443 insertions(+), 62 deletions(-)

diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 8fa4a1e..536a044 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -90,6 +90,10 @@ static void ovsdb_jsonrpc_trigger_complete_done(
 static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_create(
 struct ovsdb_jsonrpc_session *, struct ovsdb *, struct json *params,
 enum ovsdb_monitor_version, const struct json *request_id);
+static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_cond_change(
+struct ovsdb_jsonrpc_session *s,
+struct json *params,
+const struct json *request_id);
 static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_cancel(
 struct ovsdb_jsonrpc_session *,
 struct json_array *params,
@@ -99,6 +103,9 @@ static void ovsdb_jsonrpc_monitor_flush_all(struct 
ovsdb_jsonrpc_session *);
 static bool ovsdb_jsonrpc_monitor_needs_flush(struct ovsdb_jsonrpc_session *);
 static struct json *ovsdb_jsonrpc_monitor_compose_update(
 struct ovsdb_jsonrpc_monitor *monitor, bool initial);
+static struct jsonrpc_msg * ovsdb_jsonrpc_create_notify(
+const struct ovsdb_jsonrpc_monitor *m,
+struct json *params);
 
 
 /* JSON-RPC database server. */
@@ -415,7 +422,7 @@ static void ovsdb_jsonrpc_session_wait(struct 
ovsdb_jsonrpc_session *);
 static void ovsdb_jsonrpc_session_get_memory_usage(
 const struct ovsdb_jsonrpc_session *, struct simap *usage);
 static void ovsdb_jsonrpc_session_got_request(struct ovsdb_jsonrpc_session *,
- struct jsonrpc_msg *);
+  struct jsonrpc_msg *);
 static void ovsdb_jsonrpc_session_got_notify(struct ovsdb_jsonrpc_session *,
  struct jsonrpc_msg *);
 
@@ -876,6 +883,9 @@ ovsdb_jsonrpc_session_got_request(struct 
ovsdb_jsonrpc_session *s,
 reply = ovsdb_jsonrpc_monitor_create(s, db, request->params,
  version, request->id);
 }
+} else if (!strcmp(request->method, "monitor_cond_change")) {
+reply = ovsdb_jsonrpc_monitor_cond_change(s, request->params,
+  request->id);
 } else if (!strcmp(request->method, "monitor_cancel")) {
 reply = ovsdb_jsonrpc_monitor_cancel(s, json_array(request->params),
  request->id);
@@ -1308,6 +1318,136 @@ error:
 return jsonrpc_create_error(json, request_id);
 }
 
+static struct ovsdb_error *
+ovsdb_jsonrpc_parse_monitor_cond_change_request(
+struct ovsdb_jsonrpc_monitor *m,
+const struct ovsdb_table *table,
+const struct json *cond_change_req)
+{
+const struct ovsdb_table_schema *ts = table->schema;
+const struct json *condition, *columns;
+struct ovsdb_parser parser;
+struct ovsdb_error *error;
+
+ovsdb_parser_init(, cond_change_req, "table %s", ts->name);
+columns = ovsdb_parser_member(, "columns", OP_ARRAY | OP_OPTIONAL);
+condition = ovsdb_parser_member(, "where", OP_ARRAY | OP_OPTIONAL);
+
+error = ovsdb_parser_finish();
+if (error) {
+return error;
+}
+
+if (columns) {
+error = ovsdb_syntax_error(cond_change_req, NULL, "changing columns "
+   "is unsupported");
+return error;
+}
+error = ovsdb_monitor_table_condition_update(m->dbmon, m->condition, table,
+ condition);
+
+return error;
+}
+
+static struct jsonrpc_msg *
+ovsdb_jsonrpc_monitor_cond_change(struct ovsdb_jsonrpc_session *s,
+  struct json *params,
+  const struct json *request_id)
+{
+struct ovsdb_error *error;
+struct ovsdb_jsonrpc_monitor *m;
+struct json *monitor_cond_change_reqs;
+struct shash_node *node;
+struct json *json;
+
+if (json_array(params)->n != 3) {
+error = ovsdb_syntax_error(params, NULL, "invalid parameters");
+goto error;
+}
+
+m = ovsdb_jsonrpc_monitor_find(s, params->u.array.elems[0]);
+if (!m) {
+error = ovsdb_syntax_error(request_id, NULL,
+

[ovs-dev] [PATCH monitor_cond V7 03/10] ovsdb: allow unmonitored columns in condition evaluation

2016-06-13 Thread Liran Schour
This commit allows to add unmonitored columns to a monitored table
due to condition update.
It will be used to evaluate conditions on unmonitored columns.
Update notification includes only monitored columns.
Due to the limited number of columns, we do not remove unused unmonitored
columns on condition update for code simplicity.

Signed-off-by: Liran Schour 
---
 ovsdb/jsonrpc-server.c | 23 +++
 ovsdb/monitor.c| 34 --
 ovsdb/monitor.h|  2 +-
 3 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 208027a..3a69a85 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -1093,8 +1093,7 @@ parse_bool(struct ovsdb_parser *parser, const char *name, 
bool default_value)
 static struct ovsdb_error * OVS_WARN_UNUSED_RESULT
 ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor *dbmon,
 const struct ovsdb_table *table,
-const struct json *monitor_request,
-size_t *allocated_columns)
+const struct json *monitor_request)
 {
 const struct ovsdb_table_schema *ts = table->schema;
 enum ovsdb_monitor_selection select;
@@ -1158,8 +1157,8 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor 
*dbmon,
 return ovsdb_syntax_error(columns, NULL, "%s is not a valid "
   "column name", s);
 }
-if (ovsdb_monitor_add_column(dbmon, table, column, select,
- allocated_columns)) {
+if (ovsdb_monitor_add_column(dbmon, table, column,
+ select, true)) {
 return ovsdb_syntax_error(columns, NULL, "column %s "
   "mentioned more than once",
   column->name);
@@ -1171,8 +1170,8 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor 
*dbmon,
 SHASH_FOR_EACH (node, >columns) {
 const struct ovsdb_column *column = node->data;
 if (column->index != OVSDB_COL_UUID) {
-if (ovsdb_monitor_add_column(dbmon, table, column, select,
- allocated_columns)) {
+if (ovsdb_monitor_add_column(dbmon, table, column,
+ select, true)) {
 return ovsdb_syntax_error(columns, NULL, "column %s "
   "mentioned more than once",
   column->name);
@@ -1225,7 +1224,6 @@ ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session 
*s, struct ovsdb *db,
 
 SHASH_FOR_EACH (node, json_object(monitor_requests)) {
 const struct ovsdb_table *table;
-size_t allocated_columns;
 const struct json *mr_value;
 size_t i;
 
@@ -1240,20 +1238,21 @@ ovsdb_jsonrpc_monitor_create(struct 
ovsdb_jsonrpc_session *s, struct ovsdb *db,
 
 /* Parse columns. */
 mr_value = node->data;
-allocated_columns = 0;
 if (mr_value->type == JSON_ARRAY) {
 const struct json_array *array = _value->u.array;
 
 for (i = 0; i < array->n; i++) {
-error = ovsdb_jsonrpc_parse_monitor_request(
-m->dbmon, table, array->elems[i], _columns);
+error = ovsdb_jsonrpc_parse_monitor_request(m->dbmon,
+table,
+array->elems[i]);
 if (error) {
 goto error;
 }
 }
 } else {
-error = ovsdb_jsonrpc_parse_monitor_request(
-m->dbmon, table, mr_value, _columns);
+error = ovsdb_jsonrpc_parse_monitor_request(m->dbmon,
+table,
+mr_value);
 if (error) {
 goto error;
 }
diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c
index 1e334d2..5228a0a 100644
--- a/ovsdb/monitor.c
+++ b/ovsdb/monitor.c
@@ -75,6 +75,7 @@ struct jsonrpc_monitor_node {
 struct ovsdb_monitor_column {
 const struct ovsdb_column *column;
 enum ovsdb_monitor_selection select;
+bool monitored;
 };
 
 /* A row that has changed in a monitored table. */
@@ -115,6 +116,8 @@ struct ovsdb_monitor_table {
 /* Columns being monitored. */
 struct ovsdb_monitor_column *columns;
 size_t n_columns;
+size_t n_monitored_columns;
+size_t allocated_columns;
 
 /* Columns in ovsdb_monitor_row have different indexes then in
  * ovsdb_row. This field maps between column->index to the index in the
@@ 

[ovs-dev] [PATCH monitor_cond V7 02/10] ovsdb: add conditions utilities to support monitor_cond

2016-06-13 Thread Liran Schour
Change ovsdb_condition to be a 3-element json array or a boolean value (see 
ovsdb-server
man page).
Conditions utilities will be used later for conditional monitoring.

Signed-off-by: Liran Schour 
---
 ovsdb/condition.c| 188 +++
 ovsdb/condition.h|  41 +--
 ovsdb/ovsdb-server.1.in  |   6 ++
 ovsdb/query.c|   6 +-
 tests/ovsdb-condition.at |  41 +++
 tests/test-ovsdb.c   |  78 +++-
 6 files changed, 338 insertions(+), 22 deletions(-)

diff --git a/ovsdb/condition.c b/ovsdb/condition.c
index 4baf1bb..d375ad2 100644
--- a/ovsdb/condition.c
+++ b/ovsdb/condition.c
@@ -52,7 +52,7 @@ ovsdb_function_to_string(enum ovsdb_function function)
 return NULL;
 }
 
-static OVS_WARN_UNUSED_RESULT struct ovsdb_error *
+static struct ovsdb_error *
 ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
const struct json *json,
struct ovsdb_symbol_table *symtab,
@@ -64,6 +64,18 @@ ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
 const char *column_name;
 struct ovsdb_type type;
 
+if (json->type == JSON_TRUE || json->type == JSON_FALSE) {
+clause->function =
+json->type == JSON_TRUE ? OVSDB_F_TRUE : OVSDB_F_FALSE;
+
+/* Column and arg fields are not being used with boolean functions.
+ * Use dummy values */
+clause->column = ovsdb_table_schema_get_column(ts, "_uuid");
+clause->index = clause->column->index;
+ovsdb_datum_init_default(>arg, >column->type);
+return NULL;
+}
+
 if (json->type != JSON_ARRAY
 || json->u.array.n != 3
 || json->u.array.elems[0]->type != JSON_STRING
@@ -79,6 +91,7 @@ ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
   "No column %s in table %s.",
   column_name, ts->name);
 }
+clause->index = clause->column->index;
 type = clause->column->type;
 
 function_name = json_string(array->elems[1]);
@@ -109,7 +122,6 @@ ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
 return error;
 }
 break;
-
 case OVSDB_F_EQ:
 case OVSDB_F_NE:
 break;
@@ -126,6 +138,9 @@ ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
 type.n_min = 0;
 }
 break;
+case OVSDB_F_TRUE:
+case OVSDB_F_FALSE:
+OVS_NOT_REACHED();
 }
 return ovsdb_datum_from_json(>arg, , array->elems[2], symtab);
 }
@@ -164,6 +179,19 @@ compare_clauses_3way(const void *a_, const void *b_)
 }
 }
 
+static int
+compare_clauses_3way_with_data(const void *a_, const void *b_)
+{
+const struct ovsdb_clause *a = a_;
+const struct ovsdb_clause *b = b_;
+int res;
+
+res = compare_clauses_3way(a, b);
+return res ? res : ovsdb_datum_compare_3way(>arg,
+>arg,
+>column->type);
+ }
+
 struct ovsdb_error *
 ovsdb_condition_from_json(const struct ovsdb_table_schema *ts,
   const struct json *json,
@@ -185,12 +213,13 @@ ovsdb_condition_from_json(const struct ovsdb_table_schema 
*ts,
 cnd->n_clauses = 0;
 return error;
 }
+bitmap_set1(cnd->functions, cnd->clauses[i].function);
 cnd->n_clauses++;
 }
 
 /* A real database would have a query optimizer here. */
 qsort(cnd->clauses, cnd->n_clauses, sizeof *cnd->clauses,
-  compare_clauses_3way);
+  compare_clauses_3way_with_data);
 
 return NULL;
 }
@@ -198,10 +227,15 @@ ovsdb_condition_from_json(const struct ovsdb_table_schema 
*ts,
 static struct json *
 ovsdb_clause_to_json(const struct ovsdb_clause *clause)
 {
-return json_array_create_3(
-json_string_create(clause->column->name),
-json_string_create(ovsdb_function_to_string(clause->function)),
-ovsdb_datum_to_json(>arg, >column->type));
+if (clause->function != OVSDB_F_TRUE &&
+clause->function != OVSDB_F_FALSE) {
+return json_array_create_3(
+json_string_create(clause->column->name),
+json_string_create(ovsdb_function_to_string(clause->function)),
+ovsdb_datum_to_json(>arg, >column->type));
+}
+
+return json_boolean_create(clause->function == OVSDB_F_TRUE);
 }
 
 struct json *
@@ -218,13 +252,20 @@ ovsdb_condition_to_json(const struct ovsdb_condition *cnd)
 }
 
 static bool
-ovsdb_clause_evaluate(const struct ovsdb_row *row,
-  const struct ovsdb_clause *c)
+ovsdb_clause_evaluate(const struct ovsdb_datum *fields,
+  const struct ovsdb_clause *c,
+  unsigned int index_map[])
 {
-const struct ovsdb_datum *field = >fields[c->column->index];
+const struct ovsdb_datum *field = [index_map ?
+   

[ovs-dev] [PATCH monitor_cond V7 07/10] lib: add to ovsdb-idl monitor_id

2016-06-13 Thread Liran Schour
IDL uses now a uuid to specify a monitoring session that is being
sent to the server on "monitor_cond" request.
This uuid will be used to issue ongoing "monitor_cond_change" requests
for this monitoring session.

Signed-off-by: Liran Schour 
---
 lib/ovsdb-idl.c | 17 +++--
 lib/ovsdb-idl.h |  1 +
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 170c171..a940c5a 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -87,6 +87,7 @@ enum ovsdb_idl_state {
 struct ovsdb_idl {
 const struct ovsdb_idl_class *class;
 struct jsonrpc_session *session;
+struct uuid uuid;
 struct shash table_by_name;
 struct ovsdb_idl_table *tables; /* Contains "struct ovsdb_idl_table *"s.*/
 unsigned int change_seqno;
@@ -275,6 +276,7 @@ ovsdb_idl_create(const char *remote, const struct 
ovsdb_idl_class *class,
 idl->schema = NULL;
 
 hmap_init(>outstanding_txns);
+uuid_generate(>uuid);
 
 return idl;
 }
@@ -399,7 +401,7 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
 && !strcmp(msg->method, "update2")
 && msg->params->type == JSON_ARRAY
 && msg->params->u.array.n == 2
-&& msg->params->u.array.elems[0]->type == JSON_NULL) {
+&& msg->params->u.array.elems[0]->type == JSON_STRING) {
 /* Database contents changed. */
 ovsdb_idl_parse_update(idl, msg->params->u.array.elems[1],
OVSDB_UPDATE2);
@@ -443,10 +445,10 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
 OVS_NOT_REACHED();
 }
 } else if (msg->type == JSONRPC_NOTIFY
-&& !strcmp(msg->method, "update")
-&& msg->params->type == JSON_ARRAY
-&& msg->params->u.array.n == 2
-&& msg->params->u.array.elems[0]->type == JSON_NULL) {
+   && !strcmp(msg->method, "update")
+   && msg->params->type == JSON_ARRAY
+   && msg->params->u.array.n == 2
+   && msg->params->u.array.elems[0]->type == JSON_STRING) {
 /* Database contents changed. */
 ovsdb_idl_parse_update(idl, msg->params->u.array.elems[1],
OVSDB_UPDATE);
@@ -989,6 +991,7 @@ ovsdb_idl_send_monitor_request__(struct ovsdb_idl *idl,
 struct shash *schema;
 struct json *monitor_requests;
 struct jsonrpc_msg *msg;
+char uuid[UUID_LEN + 1];
 size_t i;
 
 schema = parse_schema(idl->schema);
@@ -1040,10 +1043,12 @@ ovsdb_idl_send_monitor_request__(struct ovsdb_idl *idl,
 free_schema(schema);
 
 json_destroy(idl->request_id);
+
+snprintf(uuid, sizeof uuid, UUID_FMT, UUID_ARGS(>uuid));
 msg = jsonrpc_create_request(
 method,
 json_array_create_3(json_string_create(idl->class->database),
-json_null_create(), monitor_requests),
+json_string_create(uuid), monitor_requests),
 >request_id);
 jsonrpc_session_send(idl->session, msg);
 }
diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h
index 5edffc4..70449fa 100644
--- a/lib/ovsdb-idl.h
+++ b/lib/ovsdb-idl.h
@@ -61,6 +61,7 @@ void ovsdb_idl_set_lock(struct ovsdb_idl *, const char 
*lock_name);
 bool ovsdb_idl_has_lock(const struct ovsdb_idl *);
 bool ovsdb_idl_is_lock_contended(const struct ovsdb_idl *);
 
+const struct uuid  * ovsdb_idl_get_monitor_id(const struct ovsdb_idl *);
 unsigned int ovsdb_idl_get_seqno(const struct ovsdb_idl *);
 bool ovsdb_idl_has_ever_connected(const struct ovsdb_idl *);
 void ovsdb_idl_enable_reconnect(struct ovsdb_idl *);
-- 
2.1.4

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


[ovs-dev] [PATCH monitor_cond V7 08/10] python: move Python idl to work with monitor_cond

2016-06-13 Thread Liran Schour
Python idl works now with "monitor_cond" method. Add test
for backward compatibility with old "monitor" method.

Signed-off-by: Liran Schour 
---
 python/ovs/db/data.py |  16 -
 python/ovs/db/idl.py  | 172 --
 tests/ovsdb-idl.at|  97 
 3 files changed, 265 insertions(+), 20 deletions(-)

diff --git a/python/ovs/db/data.py b/python/ovs/db/data.py
index 42e78fb..747acd5 100644
--- a/python/ovs/db/data.py
+++ b/python/ovs/db/data.py
@@ -162,7 +162,7 @@ class Atom(object):
 % (self.to_string(), base.enum.to_string()))
 elif base.type in [ovs.db.types.IntegerType, ovs.db.types.RealType]:
 if ((base.min is None or self.value >= base.min) and
-(base.max is None or self.value <= base.max)):
+(base.max is None or self.value <= base.max)):
 pass
 elif base.min is not None and base.max is not None:
 raise ConstraintViolation(
@@ -171,7 +171,7 @@ class Atom(object):
 elif base.min is not None:
 raise ConstraintViolation(
 "%s is less than minimum allowed value %.15g"
-% (self.to_string(), base.min))
+% (self.to_string(), base.min))
 else:
 raise ConstraintViolation(
 "%s is greater than maximum allowed value %.15g"
@@ -415,6 +415,18 @@ class Datum(object):
 s.append(tail)
 return ''.join(s)
 
+def diff(self, datum):
+if self.type.n_max > 1 or len(self.values) == 0:
+for k, v in six.iteritems(datum.values):
+if k in self.values and v == self.values[k]:
+del self.values[k]
+else:
+self.values[k] = v
+else:
+return datum
+
+return self
+
 def as_list(self):
 if self.type.is_map():
 return [[k.value, v.value] for k, v in six.iteritems(self.values)]
diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index e69d35e..2f36456 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -33,6 +33,9 @@ ROW_CREATE = "create"
 ROW_UPDATE = "update"
 ROW_DELETE = "delete"
 
+OVSDB_UPDATE = 0
+OVSDB_UPDATE2 = 1
+
 
 class Idl(object):
 """Open vSwitch Database Interface Definition Language (OVSDB IDL).
@@ -86,6 +89,10 @@ class Idl(object):
   currently being constructed, if there is one, or None otherwise.
 """
 
+IDL_S_INITIAL = 0
+IDL_S_MONITOR_REQUESTED = 1
+IDL_S_MONITOR_COND_REQUESTED = 2
+
 def __init__(self, remote, schema):
 """Creates and returns a connection to the database named 'db_name' on
 'remote', which should be in a form acceptable to
@@ -116,6 +123,8 @@ class Idl(object):
 self._monitor_request_id = None
 self._last_seqno = None
 self.change_seqno = 0
+self.uuid = uuid.uuid1()
+self.state = self.IDL_S_INITIAL
 
 # Database locking.
 self.lock_name = None  # Name of lock we need, None if none.
@@ -134,6 +143,7 @@ class Idl(object):
 table.need_table = False
 table.rows = {}
 table.idl = self
+table.condition = []
 
 def close(self):
 """Closes the connection to the database.  The IDL will no longer
@@ -180,11 +190,15 @@ class Idl(object):
 if msg is None:
 break
 if (msg.type == ovs.jsonrpc.Message.T_NOTIFY
-and msg.method == "update"
-and len(msg.params) == 2
-and msg.params[0] is None):
+and msg.method == "update2"
+and len(msg.params) == 2):
+# Database contents changed.
+self.__parse_update(msg.params[1], OVSDB_UPDATE2)
+elif (msg.type == ovs.jsonrpc.Message.T_NOTIFY
+and msg.method == "update"
+and len(msg.params) == 2):
 # Database contents changed.
-self.__parse_update(msg.params[1])
+self.__parse_update(msg.params[1], OVSDB_UPDATE)
 elif (msg.type == ovs.jsonrpc.Message.T_REPLY
   and self._monitor_request_id is not None
   and self._monitor_request_id == msg.id):
@@ -193,10 +207,15 @@ class Idl(object):
 self.change_seqno += 1
 self._monitor_request_id = None
 self.__clear()
-self.__parse_update(msg.result)
+if self.state == self.IDL_S_MONITOR_COND_REQUESTED:
+self.__parse_update(msg.result, OVSDB_UPDATE2)
+else:
+assert self.state == self.IDL_S_MONITOR_REQUESTED
+self.__parse_update(msg.result, OVSDB_UPDATE)
+
 

[ovs-dev] [PATCH monitor_cond V7 00/10] Conditional monitor implementation

2016-06-13 Thread Liran Schour
This patch series implements conditional monitoring by introducing an OVSDB
RFC extension with 2 new JSON-RPC methods: "monitor_cond" and
"monitor_cond_change". Specification of this extension is defined in the
ovsdb-server (1) man page.
Monitor2 is now merged into monitor_cond. A monitor_cond session with an empty 
condition, will behave exactly like monitor2 and will get update2 notifications
on all rows.

This patch series is also available on: https://github.com/liranschour/ovs.git
branch monitor_cond_ovn.

OVN:
Last patch in this series is a RFC for OVN usage of conditional monitoring.

Performance evaluation:
OVN is the main candidate for conditional monitoring usage. It is clear that
conditional monitoring reduces computation on the ovn-controller (client) side
due to the reduced size of flow tables and update messages. However,
performance evaluation shows also a reduction in computation on the SB
ovsdb-server side proportional to the degree that each logical network is
spread over physical hosts in the DC.

Evaluation on simulated environment of 50 hosts and 1000 logical ports shows
the following results (cycles #):

LN spread over # hosts|master| patch| change
-
1 | 58855158082  | 38175941755  | 35.1%
3 | 54816462604  | 40255584120  | 26.5%
6 | 52972265506  | 39481653891  | 25.4%
   12 | 57036827284  | 42008285519  | 26.3%
   18 | 61900476558  | 45903107035  | 25.8%
   24 | 64281399690  | 55617752599  | 13.4%
   30 | 66905128558  | 61835913623  |  7.5%
   42 | 76763742331  | 70522724721  |  8.1%
   50 | 85372146321  | 80130285454  |  6.1%

Changes V6 --> V7:
--
* Change ovsdb-idl API to include only add and remove clause from condition.
* IDL maintain and track conditions. Send monitor_cond_change on condition
  change.
* Due to IDL API change, OVN does not maintain and track condition.
* Report column duplication on ovsdv_monitor_add_column().
* Split added documentation according to patches.
* Add to testing for monitor_cond_change method in ovsdb-client via unixctl
  command.
* An update, if any, as a result of a condition change, will be sent to the
  client before the reply to the "monitor_cond_update" request.
* Minor fixes due to review.

Liran Schour (10):
  ovsdb: create column index mapping between ovsdb row to monitor row
  ovsdb: add conditions utilities to support monitor_cond
  ovsdb: allow unmonitored columns in condition evaluation
  ovsdb: generate update notifications for monitor_cond session
  ovsdb: enable jsonrpc-server to service "monitor_cond_change" request
  ovsdb-client: support monitor-cond method
  lib: add to ovsdb-idl monitor_id
  python: move Python idl to work with monitor_cond
  lib: add monitor_cond_change API to C IDL lib
  RFC OVN: Quick implementation of conditional monitoring

 NEWS|   3 +-
 lib/automake.mk |   2 +
 lib/ovsdb-condition.c   |  47 
 lib/ovsdb-condition.h   |  45 +++
 lib/ovsdb-idl-provider.h|   2 +
 lib/ovsdb-idl.c | 239 ++--
 lib/ovsdb-idl.h |  30 ++
 ovn/controller/binding.c| 108 +++-
 ovn/controller/binding.h|   4 +-
 ovn/controller/lport.c  | 123 -
 ovn/controller/lport.h  |  10 +-
 ovn/controller/ovn-controller.c |  23 +-
 ovsdb/condition.c   | 188 -
 ovsdb/condition.h   |  57 ++--
 ovsdb/jsonrpc-server.c  | 233 +---
 ovsdb/jsonrpc-server.h  |   2 +-
 ovsdb/monitor.c | 592 ++--
 ovsdb/monitor.h |  46 +++-
 ovsdb/ovsdb-client.1.in |  37 ++-
 ovsdb/ovsdb-client.c|  98 +--
 ovsdb/ovsdb-idlc.in | 364 +++-
 ovsdb/ovsdb-server.1.in | 221 +--
 ovsdb/ovsdb-server.c|  20 +-
 ovsdb/query.c   |   6 +-
 python/ovs/db/data.py   |  16 +-
 python/ovs/db/idl.py| 190 +++--
 tests/ovn-controller.at |   3 +
 tests/ovs-vswitchd.at   |   8 +-
 tests/ovsdb-condition.at|  41 +++
 tests/ovsdb-idl.at  | 243 -
 tests/ovsdb-monitor.at  | 251 +
 tests/test-ovsdb.c  | 292 +++-
 tests/test-ovsdb.py |  34 +++
 33 files changed, 3268 insertions(+), 310 deletions(-)
 create mode 100644 lib/ovsdb-condition.c
 create mode 100644 lib/ovsdb-condition.h

-- 
2.1.4

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


[ovs-dev] [PATCH monitor_cond V7 09/10] lib: add monitor_cond_change API to C IDL lib

2016-06-13 Thread Liran Schour
Add to IDL API that allows the user to add and remove clauses on a table's 
condition
iteratively. IDL maintain tables condition and send monitor_cond_change to the 
server
upon condition change.
Add tests for conditional monitoring to IDL.

Signed-off-by: Liran Schour 
---
 lib/automake.mk  |   2 +
 lib/ovsdb-condition.c|  47 ++
 lib/ovsdb-condition.h|  45 ++
 lib/ovsdb-idl-provider.h |   2 +
 lib/ovsdb-idl.c  | 194 -
 lib/ovsdb-idl.h  |  29 
 ovsdb/condition.h|  28 +---
 ovsdb/ovsdb-idlc.in  | 364 ++-
 python/ovs/db/idl.py |  30 +++-
 tests/ovsdb-idl.at   | 136 ++
 tests/test-ovsdb.c   | 214 +++-
 tests/test-ovsdb.py  |  34 +
 12 files changed, 1087 insertions(+), 38 deletions(-)
 create mode 100644 lib/ovsdb-condition.c
 create mode 100644 lib/ovsdb-condition.h

diff --git a/lib/automake.mk b/lib/automake.mk
index eabc0e7..96bdbed 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -181,6 +181,8 @@ lib_libopenvswitch_la_SOURCES = \
lib/ovsdb-idl.h \
lib/ovsdb-map-op.c \
lib/ovsdb-map-op.h \
+   lib/ovsdb-condition.h \
+   lib/ovsdb-condition.c \
lib/ovsdb-parser.c \
lib/ovsdb-parser.h \
lib/ovsdb-types.c \
diff --git a/lib/ovsdb-condition.c b/lib/ovsdb-condition.c
new file mode 100644
index 000..e0c4e43
--- /dev/null
+++ b/lib/ovsdb-condition.c
@@ -0,0 +1,47 @@
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 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.
+ */
+
+#include 
+
+#include 
+#include "ovsdb-error.h"
+#include "ovsdb-condition.h"
+
+struct ovsdb_error *
+ovsdb_function_from_string(const char *name, enum ovsdb_function *function)
+{
+#define OVSDB_FUNCTION(ENUM, NAME)  \
+if (!strcmp(name, NAME)) {  \
+*function = ENUM;   \
+return NULL;\
+}
+OVSDB_FUNCTIONS;
+#undef OVSDB_FUNCTION
+
+return ovsdb_syntax_error(NULL, "unknown function",
+  "No function named %s.", name);
+}
+
+const char *
+ovsdb_function_to_string(enum ovsdb_function function)
+{
+switch (function) {
+#define OVSDB_FUNCTION(ENUM, NAME) case ENUM: return NAME;
+OVSDB_FUNCTIONS;
+#undef OVSDB_FUNCTION
+}
+
+return NULL;
+}
diff --git a/lib/ovsdb-condition.h b/lib/ovsdb-condition.h
new file mode 100644
index 000..65496e1
--- /dev/null
+++ b/lib/ovsdb-condition.h
@@ -0,0 +1,45 @@
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 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 OVSDB_LIB_CONDITION_H
+#define OVSDB_LIB_CONDITION_H 1
+
+/* These list is ordered first with boolean functions and then in
+ * ascending order of the fraction of tables row that they are
+ * (heuristically) expected to leave in query results. */
+#define OVSDB_FUNCTIONS \
+OVSDB_FUNCTION(OVSDB_F_FALSE, "false")\
+OVSDB_FUNCTION(OVSDB_F_TRUE, "true")  \
+OVSDB_FUNCTION(OVSDB_F_EQ, "==")  \
+OVSDB_FUNCTION(OVSDB_F_INCLUDES, "includes")  \
+OVSDB_FUNCTION(OVSDB_F_LE, "<=")  \
+OVSDB_FUNCTION(OVSDB_F_LT, "<")   \
+OVSDB_FUNCTION(OVSDB_F_GE, ">=")  \
+OVSDB_FUNCTION(OVSDB_F_GT, ">")   \
+OVSDB_FUNCTION(OVSDB_F_EXCLUDES, "excludes")  \
+OVSDB_FUNCTION(OVSDB_F_NE, "!=")
+
+enum ovsdb_function {
+#define OVSDB_FUNCTION(ENUM, NAME) ENUM,
+OVSDB_FUNCTIONS
+#undef OVSDB_FUNCTION
+OVSDB_F_LAST = OVSDB_F_NE
+};
+
+struct ovsdb_error * ovsdb_function_from_string(const char *name,
+enum ovsdb_function *function);
+const char * 

Re: [ovs-dev] [PATCH] VxLAN-gpe implementation

2016-06-13 Thread Yang, Yi
On Mon, Jun 13, 2016 at 10:59:36AM +0200, Jiri Benc wrote:
> On Sun, 12 Jun 2016 20:53:23 +0800, Yang, Yi wrote:
> > On Mon, Jun 06, 2016 at 02:22:58PM -0700, Jesse Gross wrote:
> > > However, the changes to vport-vxlan.c are modifying compatibility code
> > > that shouldn't be extended further. Instead, just use the existing
> > > VXLAN netlink interfaces that have already been created to enable
> > > these features.
> > 
> > Jesse, sorry for late reply, I will submit a kernel patch for this.
> 
> There's no kernel patch needed, everything is in the kernel already.
> What is needed is Thadeu's "create tunnel devices using rtnetlink
> interface" patchset,
> http://thread.gmane.org/gmane.network.openvswitch.devel/64795
> 
>  Jiri

Understood, per Jesse's comments, we also need to backport all the
changes in vxlan kernel module, Pravin is doing this, maybe he is
appropriate person to do this. I just hope this can be merged into ovs
as soon as possible.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH net-next] NSH(Network Service Header) implementation

2016-06-13 Thread Yang, Yi
On Mon, Jun 13, 2016 at 12:11:14PM +0200, Jiri Benc wrote:
> On Sun, 12 Jun 2016 15:53:50 +0800, Yang, Yi wrote:
> > Will use net device after those patches are merged into net-next, It
> > seems current net device implementation in net-next doesn't include it,
> 
> The current kernel should have everything that's needed for VXLAN-GPE
> support.
> 
> > do you mean this one
> > "http://article.gmane.org/gmane.network.openvswitch.devel/64799;?
> 
> This patchset is absolutely needed for ovs to support new VXLAN
> features, including VXLAN-GPE.
> 
>  Jiri

Got it, I'll rework it after Simon and Thadeu Lima de Souza Cascardo's
patches are merged.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH monitor_cond V7 04/10] ovsdb: generate update notifications for monitor_cond session

2016-06-13 Thread Liran Schour
Hold session's conditions in ovsdb_monitor_session_condition. Pass it
to ovsdb_monitor for generating "update2" notifications.
Add functions that can generate "update2" notification for a
"monitor_cond" session.
JSON cache is enabled only for session's with true condition only.
"monitor_cond" and "monitor_cond_change" are RFC 7047 extensions
described by ovsdb-server(1) manpage.

Performance evaluation:
OVN is the main candidate for conditional monitoring usage. It is clear that
conditional monitoring reduces computation on the ovn-controller (client) side
due to the reduced size of flow tables and update messages. However,
performance evaluation shows also a reduction in computation on the SB
ovsdb-server side proportional to the degree that each logical network is
spread over physical hosts in the DC.

Evaluation on simulated environment of 50 hosts and 1000 logical ports shows
the following results (cycles #):

LN spread over # hosts|master| patch| change
-
1 | 58855158082  | 38175941755  | 35.1%
3 | 54816462604  | 40255584120  | 26.5%
6 | 52972265506  | 39481653891  | 25.4%
   12 | 57036827284  | 42008285519  | 26.3%
   18 | 61900476558  | 45903107035  | 25.8%
   24 | 64281399690  | 55617752599  | 13.4%
   30 | 66905128558  | 61835913623  |  7.5%
   42 | 76763742331  | 70522724721  |  8.1%
   50 | 85372146321  | 80130285454  |  6.1%
---
 ovsdb/jsonrpc-server.c  |  39 ++-
 ovsdb/monitor.c | 285 +++-
 ovsdb/monitor.h |  30 -
 ovsdb/ovsdb-server.1.in | 143 +---
 4 files changed, 444 insertions(+), 53 deletions(-)

diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 3a69a85..8fa4a1e 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -28,6 +28,7 @@
 #include "ovsdb-error.h"
 #include "ovsdb-parser.h"
 #include "ovsdb.h"
+#include "condition.h"
 #include "poll-loop.h"
 #include "reconnect.h"
 #include "row.h"
@@ -865,7 +866,8 @@ ovsdb_jsonrpc_session_got_request(struct 
ovsdb_jsonrpc_session *s,
 reply = execute_transaction(s, db, request);
 }
 } else if (!strcmp(request->method, "monitor") ||
-   (monitor2_enable__ && !strcmp(request->method, "monitor2"))) {
+   (monitor2_enable__ && !strcmp(request->method, "monitor2")) ||
+   !strcmp(request->method, "monitor_cond")) {
 struct ovsdb *db = ovsdb_jsonrpc_lookup_db(s, request, );
 if (!reply) {
 int l = strlen(request->method) - strlen("monitor");
@@ -1064,6 +1066,7 @@ struct ovsdb_jsonrpc_monitor {
 uint64_t unflushed; /* The first transaction that has not been
flushed to the jsonrpc remote client. */
 enum ovsdb_monitor_version version;
+struct ovsdb_monitor_session_condition *condition;/* Session's condition */
 };
 
 static struct ovsdb_jsonrpc_monitor *
@@ -1091,20 +1094,27 @@ parse_bool(struct ovsdb_parser *parser, const char 
*name, bool default_value)
 }
 
 static struct ovsdb_error * OVS_WARN_UNUSED_RESULT
-ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor *dbmon,
-const struct ovsdb_table *table,
-const struct json *monitor_request)
+ovsdb_jsonrpc_parse_monitor_request(
+   struct ovsdb_monitor *dbmon,
+   const struct ovsdb_table *table,
+   struct ovsdb_monitor_session_condition *cond,
+   const struct json *monitor_request)
 {
 const struct ovsdb_table_schema *ts = table->schema;
 enum ovsdb_monitor_selection select;
-const struct json *columns, *select_json;
+const struct json *columns, *select_json, *where = NULL;
 struct ovsdb_parser parser;
 struct ovsdb_error *error;
 
 ovsdb_parser_init(, monitor_request, "table %s", ts->name);
+if (cond) {
+where = ovsdb_parser_member(, "where", OP_ARRAY | OP_OPTIONAL);
+}
 columns = ovsdb_parser_member(, "columns", OP_ARRAY | OP_OPTIONAL);
+
 select_json = ovsdb_parser_member(, "select",
   OP_OBJECT | OP_OPTIONAL);
+
 error = ovsdb_parser_finish();
 if (error) {
 return error;
@@ -1179,6 +1189,12 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor 
*dbmon,
 }
 }
 }
+if (cond) {
+error = ovsdb_monitor_table_condition_create(cond, table, where);
+if (error) {
+return error;
+}
+}
 
 return NULL;
 }
@@ -1217,6 +1233,9 @@ ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session 
*s, struct ovsdb *db,
 m->session = s;
 m->db = db;
 

[ovs-dev] [PATCH monitor_cond V7 09/10] lib: add monitor_cond_change API to C IDL lib

2016-06-13 Thread Liran Schour
Add to IDL API that allows the user to add and remove clauses on a table's 
condition
iteratively. IDL maintain tables condition and send monitor_cond_change to the 
server
upon condition change.
Add tests for conditional monitoring to IDL.

Signed-off-by: Liran Schour 
---
 lib/automake.mk  |   2 +
 lib/ovsdb-condition.c|  47 ++
 lib/ovsdb-condition.h|  45 ++
 lib/ovsdb-idl-provider.h |   2 +
 lib/ovsdb-idl.c  | 194 -
 lib/ovsdb-idl.h  |  29 
 ovsdb/condition.h|  28 +---
 ovsdb/ovsdb-idlc.in  | 364 ++-
 python/ovs/db/idl.py |  30 +++-
 tests/ovsdb-idl.at   | 136 ++
 tests/test-ovsdb.c   | 214 +++-
 tests/test-ovsdb.py  |  34 +
 12 files changed, 1087 insertions(+), 38 deletions(-)
 create mode 100644 lib/ovsdb-condition.c
 create mode 100644 lib/ovsdb-condition.h

diff --git a/lib/automake.mk b/lib/automake.mk
index eabc0e7..96bdbed 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -181,6 +181,8 @@ lib_libopenvswitch_la_SOURCES = \
lib/ovsdb-idl.h \
lib/ovsdb-map-op.c \
lib/ovsdb-map-op.h \
+   lib/ovsdb-condition.h \
+   lib/ovsdb-condition.c \
lib/ovsdb-parser.c \
lib/ovsdb-parser.h \
lib/ovsdb-types.c \
diff --git a/lib/ovsdb-condition.c b/lib/ovsdb-condition.c
new file mode 100644
index 000..e0c4e43
--- /dev/null
+++ b/lib/ovsdb-condition.c
@@ -0,0 +1,47 @@
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 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.
+ */
+
+#include 
+
+#include 
+#include "ovsdb-error.h"
+#include "ovsdb-condition.h"
+
+struct ovsdb_error *
+ovsdb_function_from_string(const char *name, enum ovsdb_function *function)
+{
+#define OVSDB_FUNCTION(ENUM, NAME)  \
+if (!strcmp(name, NAME)) {  \
+*function = ENUM;   \
+return NULL;\
+}
+OVSDB_FUNCTIONS;
+#undef OVSDB_FUNCTION
+
+return ovsdb_syntax_error(NULL, "unknown function",
+  "No function named %s.", name);
+}
+
+const char *
+ovsdb_function_to_string(enum ovsdb_function function)
+{
+switch (function) {
+#define OVSDB_FUNCTION(ENUM, NAME) case ENUM: return NAME;
+OVSDB_FUNCTIONS;
+#undef OVSDB_FUNCTION
+}
+
+return NULL;
+}
diff --git a/lib/ovsdb-condition.h b/lib/ovsdb-condition.h
new file mode 100644
index 000..65496e1
--- /dev/null
+++ b/lib/ovsdb-condition.h
@@ -0,0 +1,45 @@
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 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 OVSDB_LIB_CONDITION_H
+#define OVSDB_LIB_CONDITION_H 1
+
+/* These list is ordered first with boolean functions and then in
+ * ascending order of the fraction of tables row that they are
+ * (heuristically) expected to leave in query results. */
+#define OVSDB_FUNCTIONS \
+OVSDB_FUNCTION(OVSDB_F_FALSE, "false")\
+OVSDB_FUNCTION(OVSDB_F_TRUE, "true")  \
+OVSDB_FUNCTION(OVSDB_F_EQ, "==")  \
+OVSDB_FUNCTION(OVSDB_F_INCLUDES, "includes")  \
+OVSDB_FUNCTION(OVSDB_F_LE, "<=")  \
+OVSDB_FUNCTION(OVSDB_F_LT, "<")   \
+OVSDB_FUNCTION(OVSDB_F_GE, ">=")  \
+OVSDB_FUNCTION(OVSDB_F_GT, ">")   \
+OVSDB_FUNCTION(OVSDB_F_EXCLUDES, "excludes")  \
+OVSDB_FUNCTION(OVSDB_F_NE, "!=")
+
+enum ovsdb_function {
+#define OVSDB_FUNCTION(ENUM, NAME) ENUM,
+OVSDB_FUNCTIONS
+#undef OVSDB_FUNCTION
+OVSDB_F_LAST = OVSDB_F_NE
+};
+
+struct ovsdb_error * ovsdb_function_from_string(const char *name,
+enum ovsdb_function *function);
+const char * 

[ovs-dev] [PATCH monitor_cond V7 07/10] lib: add to ovsdb-idl monitor_id

2016-06-13 Thread Liran Schour
IDL uses now a uuid to specify a monitoring session that is being
sent to the server on "monitor_cond" request.
This uuid will be used to issue ongoing "monitor_cond_change" requests
for this monitoring session.

Signed-off-by: Liran Schour 
---
 lib/ovsdb-idl.c | 17 +++--
 lib/ovsdb-idl.h |  1 +
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 170c171..a940c5a 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -87,6 +87,7 @@ enum ovsdb_idl_state {
 struct ovsdb_idl {
 const struct ovsdb_idl_class *class;
 struct jsonrpc_session *session;
+struct uuid uuid;
 struct shash table_by_name;
 struct ovsdb_idl_table *tables; /* Contains "struct ovsdb_idl_table *"s.*/
 unsigned int change_seqno;
@@ -275,6 +276,7 @@ ovsdb_idl_create(const char *remote, const struct 
ovsdb_idl_class *class,
 idl->schema = NULL;
 
 hmap_init(>outstanding_txns);
+uuid_generate(>uuid);
 
 return idl;
 }
@@ -399,7 +401,7 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
 && !strcmp(msg->method, "update2")
 && msg->params->type == JSON_ARRAY
 && msg->params->u.array.n == 2
-&& msg->params->u.array.elems[0]->type == JSON_NULL) {
+&& msg->params->u.array.elems[0]->type == JSON_STRING) {
 /* Database contents changed. */
 ovsdb_idl_parse_update(idl, msg->params->u.array.elems[1],
OVSDB_UPDATE2);
@@ -443,10 +445,10 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
 OVS_NOT_REACHED();
 }
 } else if (msg->type == JSONRPC_NOTIFY
-&& !strcmp(msg->method, "update")
-&& msg->params->type == JSON_ARRAY
-&& msg->params->u.array.n == 2
-&& msg->params->u.array.elems[0]->type == JSON_NULL) {
+   && !strcmp(msg->method, "update")
+   && msg->params->type == JSON_ARRAY
+   && msg->params->u.array.n == 2
+   && msg->params->u.array.elems[0]->type == JSON_STRING) {
 /* Database contents changed. */
 ovsdb_idl_parse_update(idl, msg->params->u.array.elems[1],
OVSDB_UPDATE);
@@ -989,6 +991,7 @@ ovsdb_idl_send_monitor_request__(struct ovsdb_idl *idl,
 struct shash *schema;
 struct json *monitor_requests;
 struct jsonrpc_msg *msg;
+char uuid[UUID_LEN + 1];
 size_t i;
 
 schema = parse_schema(idl->schema);
@@ -1040,10 +1043,12 @@ ovsdb_idl_send_monitor_request__(struct ovsdb_idl *idl,
 free_schema(schema);
 
 json_destroy(idl->request_id);
+
+snprintf(uuid, sizeof uuid, UUID_FMT, UUID_ARGS(>uuid));
 msg = jsonrpc_create_request(
 method,
 json_array_create_3(json_string_create(idl->class->database),
-json_null_create(), monitor_requests),
+json_string_create(uuid), monitor_requests),
 >request_id);
 jsonrpc_session_send(idl->session, msg);
 }
diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h
index 5edffc4..70449fa 100644
--- a/lib/ovsdb-idl.h
+++ b/lib/ovsdb-idl.h
@@ -61,6 +61,7 @@ void ovsdb_idl_set_lock(struct ovsdb_idl *, const char 
*lock_name);
 bool ovsdb_idl_has_lock(const struct ovsdb_idl *);
 bool ovsdb_idl_is_lock_contended(const struct ovsdb_idl *);
 
+const struct uuid  * ovsdb_idl_get_monitor_id(const struct ovsdb_idl *);
 unsigned int ovsdb_idl_get_seqno(const struct ovsdb_idl *);
 bool ovsdb_idl_has_ever_connected(const struct ovsdb_idl *);
 void ovsdb_idl_enable_reconnect(struct ovsdb_idl *);
-- 
2.1.4

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


[ovs-dev] [PATCH monitor_cond V7 05/10] ovsdb: enable jsonrpc-server to service "monitor_cond_change" request

2016-06-13 Thread Liran Schour
ovsdb-server now accepts "monitor_cond_change" request. After conditions change
we compose update notification according to the current state of the
database without using a change list before sending reply to the 
monitor_cond_change
request.
Sees ovsdb-server (1) man page for details of monitor_cond_change.

Signed-off-by: Liran Schour 
---
 ovsdb/jsonrpc-server.c  | 147 +++-
 ovsdb/monitor.c | 254 +++-
 ovsdb/monitor.h |  32 +++---
 ovsdb/ovsdb-server.1.in |  72 ++
 4 files changed, 443 insertions(+), 62 deletions(-)

diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 8fa4a1e..536a044 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -90,6 +90,10 @@ static void ovsdb_jsonrpc_trigger_complete_done(
 static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_create(
 struct ovsdb_jsonrpc_session *, struct ovsdb *, struct json *params,
 enum ovsdb_monitor_version, const struct json *request_id);
+static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_cond_change(
+struct ovsdb_jsonrpc_session *s,
+struct json *params,
+const struct json *request_id);
 static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_cancel(
 struct ovsdb_jsonrpc_session *,
 struct json_array *params,
@@ -99,6 +103,9 @@ static void ovsdb_jsonrpc_monitor_flush_all(struct 
ovsdb_jsonrpc_session *);
 static bool ovsdb_jsonrpc_monitor_needs_flush(struct ovsdb_jsonrpc_session *);
 static struct json *ovsdb_jsonrpc_monitor_compose_update(
 struct ovsdb_jsonrpc_monitor *monitor, bool initial);
+static struct jsonrpc_msg * ovsdb_jsonrpc_create_notify(
+const struct ovsdb_jsonrpc_monitor *m,
+struct json *params);
 
 
 /* JSON-RPC database server. */
@@ -415,7 +422,7 @@ static void ovsdb_jsonrpc_session_wait(struct 
ovsdb_jsonrpc_session *);
 static void ovsdb_jsonrpc_session_get_memory_usage(
 const struct ovsdb_jsonrpc_session *, struct simap *usage);
 static void ovsdb_jsonrpc_session_got_request(struct ovsdb_jsonrpc_session *,
- struct jsonrpc_msg *);
+  struct jsonrpc_msg *);
 static void ovsdb_jsonrpc_session_got_notify(struct ovsdb_jsonrpc_session *,
  struct jsonrpc_msg *);
 
@@ -876,6 +883,9 @@ ovsdb_jsonrpc_session_got_request(struct 
ovsdb_jsonrpc_session *s,
 reply = ovsdb_jsonrpc_monitor_create(s, db, request->params,
  version, request->id);
 }
+} else if (!strcmp(request->method, "monitor_cond_change")) {
+reply = ovsdb_jsonrpc_monitor_cond_change(s, request->params,
+  request->id);
 } else if (!strcmp(request->method, "monitor_cancel")) {
 reply = ovsdb_jsonrpc_monitor_cancel(s, json_array(request->params),
  request->id);
@@ -1308,6 +1318,136 @@ error:
 return jsonrpc_create_error(json, request_id);
 }
 
+static struct ovsdb_error *
+ovsdb_jsonrpc_parse_monitor_cond_change_request(
+struct ovsdb_jsonrpc_monitor *m,
+const struct ovsdb_table *table,
+const struct json *cond_change_req)
+{
+const struct ovsdb_table_schema *ts = table->schema;
+const struct json *condition, *columns;
+struct ovsdb_parser parser;
+struct ovsdb_error *error;
+
+ovsdb_parser_init(, cond_change_req, "table %s", ts->name);
+columns = ovsdb_parser_member(, "columns", OP_ARRAY | OP_OPTIONAL);
+condition = ovsdb_parser_member(, "where", OP_ARRAY | OP_OPTIONAL);
+
+error = ovsdb_parser_finish();
+if (error) {
+return error;
+}
+
+if (columns) {
+error = ovsdb_syntax_error(cond_change_req, NULL, "changing columns "
+   "is unsupported");
+return error;
+}
+error = ovsdb_monitor_table_condition_update(m->dbmon, m->condition, table,
+ condition);
+
+return error;
+}
+
+static struct jsonrpc_msg *
+ovsdb_jsonrpc_monitor_cond_change(struct ovsdb_jsonrpc_session *s,
+  struct json *params,
+  const struct json *request_id)
+{
+struct ovsdb_error *error;
+struct ovsdb_jsonrpc_monitor *m;
+struct json *monitor_cond_change_reqs;
+struct shash_node *node;
+struct json *json;
+
+if (json_array(params)->n != 3) {
+error = ovsdb_syntax_error(params, NULL, "invalid parameters");
+goto error;
+}
+
+m = ovsdb_jsonrpc_monitor_find(s, params->u.array.elems[0]);
+if (!m) {
+error = ovsdb_syntax_error(request_id, NULL,
+

[ovs-dev] [PATCH monitor_cond V7 08/10] python: move Python idl to work with monitor_cond

2016-06-13 Thread Liran Schour
Python idl works now with "monitor_cond" method. Add test
for backward compatibility with old "monitor" method.

Signed-off-by: Liran Schour 
---
 python/ovs/db/data.py |  16 -
 python/ovs/db/idl.py  | 172 --
 tests/ovsdb-idl.at|  97 
 3 files changed, 265 insertions(+), 20 deletions(-)

diff --git a/python/ovs/db/data.py b/python/ovs/db/data.py
index 42e78fb..747acd5 100644
--- a/python/ovs/db/data.py
+++ b/python/ovs/db/data.py
@@ -162,7 +162,7 @@ class Atom(object):
 % (self.to_string(), base.enum.to_string()))
 elif base.type in [ovs.db.types.IntegerType, ovs.db.types.RealType]:
 if ((base.min is None or self.value >= base.min) and
-(base.max is None or self.value <= base.max)):
+(base.max is None or self.value <= base.max)):
 pass
 elif base.min is not None and base.max is not None:
 raise ConstraintViolation(
@@ -171,7 +171,7 @@ class Atom(object):
 elif base.min is not None:
 raise ConstraintViolation(
 "%s is less than minimum allowed value %.15g"
-% (self.to_string(), base.min))
+% (self.to_string(), base.min))
 else:
 raise ConstraintViolation(
 "%s is greater than maximum allowed value %.15g"
@@ -415,6 +415,18 @@ class Datum(object):
 s.append(tail)
 return ''.join(s)
 
+def diff(self, datum):
+if self.type.n_max > 1 or len(self.values) == 0:
+for k, v in six.iteritems(datum.values):
+if k in self.values and v == self.values[k]:
+del self.values[k]
+else:
+self.values[k] = v
+else:
+return datum
+
+return self
+
 def as_list(self):
 if self.type.is_map():
 return [[k.value, v.value] for k, v in six.iteritems(self.values)]
diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index e69d35e..2f36456 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -33,6 +33,9 @@ ROW_CREATE = "create"
 ROW_UPDATE = "update"
 ROW_DELETE = "delete"
 
+OVSDB_UPDATE = 0
+OVSDB_UPDATE2 = 1
+
 
 class Idl(object):
 """Open vSwitch Database Interface Definition Language (OVSDB IDL).
@@ -86,6 +89,10 @@ class Idl(object):
   currently being constructed, if there is one, or None otherwise.
 """
 
+IDL_S_INITIAL = 0
+IDL_S_MONITOR_REQUESTED = 1
+IDL_S_MONITOR_COND_REQUESTED = 2
+
 def __init__(self, remote, schema):
 """Creates and returns a connection to the database named 'db_name' on
 'remote', which should be in a form acceptable to
@@ -116,6 +123,8 @@ class Idl(object):
 self._monitor_request_id = None
 self._last_seqno = None
 self.change_seqno = 0
+self.uuid = uuid.uuid1()
+self.state = self.IDL_S_INITIAL
 
 # Database locking.
 self.lock_name = None  # Name of lock we need, None if none.
@@ -134,6 +143,7 @@ class Idl(object):
 table.need_table = False
 table.rows = {}
 table.idl = self
+table.condition = []
 
 def close(self):
 """Closes the connection to the database.  The IDL will no longer
@@ -180,11 +190,15 @@ class Idl(object):
 if msg is None:
 break
 if (msg.type == ovs.jsonrpc.Message.T_NOTIFY
-and msg.method == "update"
-and len(msg.params) == 2
-and msg.params[0] is None):
+and msg.method == "update2"
+and len(msg.params) == 2):
+# Database contents changed.
+self.__parse_update(msg.params[1], OVSDB_UPDATE2)
+elif (msg.type == ovs.jsonrpc.Message.T_NOTIFY
+and msg.method == "update"
+and len(msg.params) == 2):
 # Database contents changed.
-self.__parse_update(msg.params[1])
+self.__parse_update(msg.params[1], OVSDB_UPDATE)
 elif (msg.type == ovs.jsonrpc.Message.T_REPLY
   and self._monitor_request_id is not None
   and self._monitor_request_id == msg.id):
@@ -193,10 +207,15 @@ class Idl(object):
 self.change_seqno += 1
 self._monitor_request_id = None
 self.__clear()
-self.__parse_update(msg.result)
+if self.state == self.IDL_S_MONITOR_COND_REQUESTED:
+self.__parse_update(msg.result, OVSDB_UPDATE2)
+else:
+assert self.state == self.IDL_S_MONITOR_REQUESTED
+self.__parse_update(msg.result, OVSDB_UPDATE)
+
 

[ovs-dev] [PATCH monitor_cond V7 01/10] ovsdb: create column index mapping between ovsdb row to monitor row

2016-06-13 Thread Liran Schour
Columns indexing is different in ovsdb_row then in ovsdb_monitor_row.
We need mapping between the 2 for condition evaluation.

signed-off-by: Liran Schour 
---
 ovsdb/jsonrpc-server.c | 26 ++--
 ovsdb/monitor.c| 65 +++---
 ovsdb/monitor.h|  6 +
 3 files changed, 53 insertions(+), 44 deletions(-)

diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 4913d7e..208027a 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -1158,8 +1158,12 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor 
*dbmon,
 return ovsdb_syntax_error(columns, NULL, "%s is not a valid "
   "column name", s);
 }
-ovsdb_monitor_add_column(dbmon, table, column, select,
- allocated_columns);
+if (ovsdb_monitor_add_column(dbmon, table, column, select,
+ allocated_columns)) {
+return ovsdb_syntax_error(columns, NULL, "column %s "
+  "mentioned more than once",
+  column->name);
+}
 }
 } else {
 struct shash_node *node;
@@ -1167,8 +1171,12 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor 
*dbmon,
 SHASH_FOR_EACH (node, >columns) {
 const struct ovsdb_column *column = node->data;
 if (column->index != OVSDB_COL_UUID) {
-ovsdb_monitor_add_column(dbmon, table, column, select,
- allocated_columns);
+if (ovsdb_monitor_add_column(dbmon, table, column, select,
+ allocated_columns)) {
+return ovsdb_syntax_error(columns, NULL, "column %s "
+  "mentioned more than once",
+  column->name);
+}
 }
 }
 }
@@ -1217,7 +1225,6 @@ ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session 
*s, struct ovsdb *db,
 
 SHASH_FOR_EACH (node, json_object(monitor_requests)) {
 const struct ovsdb_table *table;
-const char *column_name;
 size_t allocated_columns;
 const struct json *mr_value;
 size_t i;
@@ -1251,15 +1258,6 @@ ovsdb_jsonrpc_monitor_create(struct 
ovsdb_jsonrpc_session *s, struct ovsdb *db,
 goto error;
 }
 }
-
-column_name = ovsdb_monitor_table_check_duplicates(m->dbmon, table);
-
-if (column_name) {
-error = ovsdb_syntax_error(mr_value, NULL, "column %s "
-   "mentioned more than once",
-column_name);
-goto error;
-}
 }
 
 dbmon = ovsdb_monitor_add(m->dbmon);
diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c
index e910e3f..1e334d2 100644
--- a/ovsdb/monitor.c
+++ b/ovsdb/monitor.c
@@ -116,6 +116,11 @@ struct ovsdb_monitor_table {
 struct ovsdb_monitor_column *columns;
 size_t n_columns;
 
+/* Columns in ovsdb_monitor_row have different indexes then in
+ * ovsdb_row. This field maps between column->index to the index in the
+ * ovsdb_monitor_row. It is used for condition evaluation. */
+unsigned int *columns_index_map;
+
 /* Contains 'ovsdb_monitor_changes' indexed by 'transaction'. */
 struct hmap changes;
 };
@@ -304,6 +309,24 @@ ovsdb_monitor_row_destroy(const struct ovsdb_monitor_table 
*mt,
 }
 }
 
+static void
+ovsdb_monitor_columns_sort(struct ovsdb_monitor *dbmon)
+{
+int i;
+struct shash_node *node;
+
+SHASH_FOR_EACH (node, >tables) {
+struct ovsdb_monitor_table *mt = node->data;
+
+qsort(mt->columns, mt->n_columns, sizeof *mt->columns,
+  compare_ovsdb_monitor_column);
+for (i = 0; i < mt->n_columns; i++) {
+/* re-set index map due to sort */
+mt->columns_index_map[mt->columns[i].column->index] = i;
+}
+}
+}
+
 void
 ovsdb_monitor_add_jsonrpc_monitor(struct ovsdb_monitor *dbmon,
   struct ovsdb_jsonrpc_monitor 
*jsonrpc_monitor)
@@ -341,14 +364,21 @@ ovsdb_monitor_add_table(struct ovsdb_monitor *m,
 const struct ovsdb_table *table)
 {
 struct ovsdb_monitor_table *mt;
+int i;
+size_t n_columns = shash_count(>schema->columns);
 
 mt = xzalloc(sizeof *mt);
 mt->table = table;
 shash_add(>tables, table->schema->name, mt);
 hmap_init(>changes);
+mt->columns_index_map =
+xmalloc(sizeof *mt->columns_index_map * n_columns);
+for (i = 0; i < n_columns; i++) {
+mt->columns_index_map[i] = -1;
+}
 }
 
-void
+const char *
 ovsdb_monitor_add_column(struct ovsdb_monitor *dbmon,
  

[ovs-dev] [PATCH monitor_cond V7 06/10] ovsdb-client: support monitor-cond method

2016-06-13 Thread Liran Schour
Add monitor_cond method to ovsdb-client. Enable testing of monitor_cond_change
via unixctl command.Add unit tests for monitor_cond and monitor_cond_change.
See ovsdb-client(1) man page for details.
Replace monitor2 with monitor_cond.

Signed-off-by: Liran Schour 
---
 NEWS|   3 +-
 lib/ovsdb-idl.c |  28 +++---
 ovsdb/jsonrpc-server.c  |  14 +--
 ovsdb/jsonrpc-server.h  |   2 +-
 ovsdb/ovsdb-client.1.in |  37 ---
 ovsdb/ovsdb-client.c|  98 +++
 ovsdb/ovsdb-server.c|  20 ++--
 tests/ovs-vswitchd.at   |   8 +-
 tests/ovsdb-idl.at  |  10 +-
 tests/ovsdb-monitor.at  | 251 
 10 files changed, 391 insertions(+), 80 deletions(-)

diff --git a/NEWS b/NEWS
index ba201cf..796ee38 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,8 @@
 Post-v2.5.0
 -
- ovsdb-server:
- * New "monitor2" and "update2" extensions to RFC 7047.
+ * New "monitor_cond" "monitor_cond_update" and "update2" extensions to
+ RFC 7047.
- OpenFlow:
  * OpenFlow 1.1+ OFPT_QUEUE_GET_CONFIG_REQUEST now supports OFPP_ANY.
  * OpenFlow 1.4+ OFPMP_QUEUE_DESC is now supported.
diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index b14bef2..170c171 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -79,8 +79,8 @@ enum ovsdb_idl_state {
 IDL_S_SCHEMA_REQUESTED,
 IDL_S_MONITOR_REQUESTED,
 IDL_S_MONITORING,
-IDL_S_MONITOR2_REQUESTED,
-IDL_S_MONITORING2,
+IDL_S_MONITOR_COND_REQUESTED,
+IDL_S_MONITORING_COND,
 IDL_S_NO_SCHEMA
 };
 
@@ -154,7 +154,7 @@ static struct vlog_rate_limit semantic_rl = 
VLOG_RATE_LIMIT_INIT(1, 5);
 static void ovsdb_idl_clear(struct ovsdb_idl *);
 static void ovsdb_idl_send_schema_request(struct ovsdb_idl *);
 static void ovsdb_idl_send_monitor_request(struct ovsdb_idl *);
-static void ovsdb_idl_send_monitor2_request(struct ovsdb_idl *);
+static void ovsdb_idl_send_monitor_cond_request(struct ovsdb_idl *);
 static void ovsdb_idl_parse_update(struct ovsdb_idl *, const struct json *,
enum ovsdb_update_version);
 static struct ovsdb_error *ovsdb_idl_parse_update__(struct ovsdb_idl *,
@@ -413,20 +413,20 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
 case IDL_S_SCHEMA_REQUESTED:
 /* Reply to our "get_schema" request. */
 idl->schema = json_clone(msg->result);
-ovsdb_idl_send_monitor2_request(idl);
-idl->state = IDL_S_MONITOR2_REQUESTED;
+ovsdb_idl_send_monitor_cond_request(idl);
+idl->state = IDL_S_MONITOR_COND_REQUESTED;
 break;
 
 case IDL_S_MONITOR_REQUESTED:
-case IDL_S_MONITOR2_REQUESTED:
-/* Reply to our "monitor" or "monitor2" request. */
+case IDL_S_MONITOR_COND_REQUESTED:
+/* Reply to our "monitor" or "monitor_cond" request. */
 idl->change_seqno++;
 ovsdb_idl_clear(idl);
 if (idl->state == IDL_S_MONITOR_REQUESTED) {
 idl->state = IDL_S_MONITORING;
 ovsdb_idl_parse_update(idl, msg->result, OVSDB_UPDATE);
-} else { /* IDL_S_MONITOR2_REQUESTED. */
-idl->state = IDL_S_MONITORING2;
+} else { /* IDL_S_MONITOR_COND_REQUESTED. */
+idl->state = IDL_S_MONITORING_COND;
 ovsdb_idl_parse_update(idl, msg->result, OVSDB_UPDATE2);
 }
 
@@ -437,7 +437,7 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
 break;
 
 case IDL_S_MONITORING:
-case IDL_S_MONITORING2:
+case IDL_S_MONITORING_COND:
 case IDL_S_NO_SCHEMA:
 default:
 OVS_NOT_REACHED();
@@ -464,7 +464,7 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
 /* Someone else stole our lock. */
 ovsdb_idl_parse_lock_notify(idl, msg->params, false);
 } else if (msg->type == JSONRPC_ERROR
-   && idl->state == IDL_S_MONITOR2_REQUESTED
+   && idl->state == IDL_S_MONITOR_COND_REQUESTED
&& idl->request_id
&& json_equal(idl->request_id, msg->id)) {
 if (msg->error && !strcmp(json_string(msg->error),
@@ -1066,9 +1066,9 @@ log_parse_update_error(struct ovsdb_error *error)
 }
 
 static void
-ovsdb_idl_send_monitor2_request(struct ovsdb_idl *idl)
+ovsdb_idl_send_monitor_cond_request(struct ovsdb_idl *idl)
 {
-ovsdb_idl_send_monitor_request__(idl, "monitor2");
+ovsdb_idl_send_monitor_request__(idl, "monitor_cond");
 }
 
 static void
@@ -3246,7 +3246,7 @@ ovsdb_idl_update_has_lock(struct ovsdb_idl *idl, bool 
new_has_lock)
 {
 if (new_has_lock && !idl->has_lock) {
 if (idl->state == IDL_S_MONITORING ||
-idl->state == IDL_S_MONITORING2) {
+idl->state == IDL_S_MONITORING_COND) {
 

[ovs-dev] [PATCH monitor_cond V7 10/10] RFC OVN: Quick implementation of conditional monitoring

2016-06-13 Thread Liran Schour
Conditional monitor of: Port_Binding, Logical_Flow, Multicast_Group
MAC_Binding tables. As a result ovn-controller will be notified only about
records belongs to a datapath that is being served by this hypervisor.

Hack: Ideally, logical datapath ID should be retrieved from Port_Binding table
and by that conditions should be composed only from logical datapath IDs.
In the meantime we first add the logical port to the conditions and on retrieval
of port binding record, we add the logical datapath to the conditions.

Signed-off-by: Liran Schour 
---
 ovn/controller/binding.c| 108 ++-
 ovn/controller/binding.h|   4 +-
 ovn/controller/lport.c  | 123 ++--
 ovn/controller/lport.h  |  10 +++-
 ovn/controller/ovn-controller.c |  23 +---
 tests/ovn-controller.at |   3 +
 6 files changed, 254 insertions(+), 17 deletions(-)

diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
index a07c327..d8af74c 100644
--- a/ovn/controller/binding.c
+++ b/ovn/controller/binding.c
@@ -21,9 +21,11 @@
 #include "lib/sset.h"
 #include "lib/util.h"
 #include "lib/vswitch-idl.h"
+#include "lib/hash.h"
 #include "openvswitch/vlog.h"
 #include "ovn/lib/ovn-sb-idl.h"
 #include "ovn-controller.h"
+#include "lport.h"
 
 VLOG_DEFINE_THIS_MODULE(binding);
 
@@ -101,10 +103,108 @@ update_qos(const struct ovsrec_interface *iface_rec,
 ovsrec_interface_set_ingress_policing_burst(iface_rec, MAX(0, burst));
 }
 
+static struct sset g_lports = SSET_INITIALIZER(_lports);
+
+static void
+update_lports(struct controller_ctx *ctx,
+  struct sset *tmp_lports,
+  const struct lport_index *lports)
+{
+const char **lports_array, **tmp_lports_array;
+struct sset_node *node;
+int i, j;
+
+lports_array = sset_sort(_lports);
+tmp_lports_array = sset_sort(tmp_lports);
+for (i = 0, j = 0; lports_array[i] && tmp_lports_array[j];) {
+int cmp = strcmp(lports_array[i], tmp_lports_array[j]);
+if (!cmp) {
+i++;
+j++;
+} else if (cmp < 0) {
+node = sset_find(_lports, lports_array[i]);
+if (node) {
+VLOG_INFO("Remove port %s from condition", lports_array[i]);
+sbrec_port_binding_remove_clause_logical_port(ctx->ovnsb_idl,
+  OVSDB_F_EQ,
+  lports_array[i]);
+sbrec_port_binding_remove_clause_parent_port(ctx->ovnsb_idl,
+ OVSDB_F_EQ,
+ lports_array[i]);
+sset_delete(_lports, node);
+}
+i++;
+} else if (cmp > 0) {
+if (!lport_lookup_by_name(lports, tmp_lports_array[j])) {
+VLOG_INFO("Add port %s", tmp_lports_array[j]);
+sbrec_port_binding_add_clause_logical_port(ctx->ovnsb_idl,
+   OVSDB_F_EQ,
+   
tmp_lports_array[j]);
+sbrec_port_binding_add_clause_parent_port(ctx->ovnsb_idl,
+  OVSDB_F_EQ,
+  tmp_lports_array[j]);
+sset_add(_lports, tmp_lports_array[j]);
+}
+j++;
+}
+}
+for (; lports_array[i]; i++) {
+node = sset_find(_lports, lports_array[i]);
+if (node) {
+VLOG_INFO("Remove port %s from condition", lports_array[i]);
+sbrec_port_binding_remove_clause_logical_port(ctx->ovnsb_idl,
+  OVSDB_F_EQ,
+  lports_array[i]);
+sbrec_port_binding_remove_clause_parent_port(ctx->ovnsb_idl,
+ OVSDB_F_EQ,
+ lports_array[i]);
+sset_delete(_lports, node);
+}
+}
+for (; tmp_lports_array[j]; j++) {
+if (!lport_lookup_by_name(lports, tmp_lports_array[j])) {
+VLOG_INFO("Add port %s", tmp_lports_array[j]);
+sbrec_port_binding_add_clause_logical_port(ctx->ovnsb_idl,
+   OVSDB_F_EQ,
+   tmp_lports_array[j]);
+sbrec_port_binding_add_clause_parent_port(ctx->ovnsb_idl,
+  OVSDB_F_EQ,
+  tmp_lports_array[j]);
+sset_add(_lports, tmp_lports_array[j]);
+}
+}
+
+free(lports_array);
+

[ovs-dev] [PATCH monitor_cond V7 02/10] ovsdb: add conditions utilities to support monitor_cond

2016-06-13 Thread Liran Schour
Change ovsdb_condition to be a 3-element json array or a boolean value (see 
ovsdb-server
man page).
Conditions utilities will be used later for conditional monitoring.

Signed-off-by: Liran Schour 
---
 ovsdb/condition.c| 188 +++
 ovsdb/condition.h|  41 +--
 ovsdb/ovsdb-server.1.in  |   6 ++
 ovsdb/query.c|   6 +-
 tests/ovsdb-condition.at |  41 +++
 tests/test-ovsdb.c   |  78 +++-
 6 files changed, 338 insertions(+), 22 deletions(-)

diff --git a/ovsdb/condition.c b/ovsdb/condition.c
index 4baf1bb..d375ad2 100644
--- a/ovsdb/condition.c
+++ b/ovsdb/condition.c
@@ -52,7 +52,7 @@ ovsdb_function_to_string(enum ovsdb_function function)
 return NULL;
 }
 
-static OVS_WARN_UNUSED_RESULT struct ovsdb_error *
+static struct ovsdb_error *
 ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
const struct json *json,
struct ovsdb_symbol_table *symtab,
@@ -64,6 +64,18 @@ ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
 const char *column_name;
 struct ovsdb_type type;
 
+if (json->type == JSON_TRUE || json->type == JSON_FALSE) {
+clause->function =
+json->type == JSON_TRUE ? OVSDB_F_TRUE : OVSDB_F_FALSE;
+
+/* Column and arg fields are not being used with boolean functions.
+ * Use dummy values */
+clause->column = ovsdb_table_schema_get_column(ts, "_uuid");
+clause->index = clause->column->index;
+ovsdb_datum_init_default(>arg, >column->type);
+return NULL;
+}
+
 if (json->type != JSON_ARRAY
 || json->u.array.n != 3
 || json->u.array.elems[0]->type != JSON_STRING
@@ -79,6 +91,7 @@ ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
   "No column %s in table %s.",
   column_name, ts->name);
 }
+clause->index = clause->column->index;
 type = clause->column->type;
 
 function_name = json_string(array->elems[1]);
@@ -109,7 +122,6 @@ ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
 return error;
 }
 break;
-
 case OVSDB_F_EQ:
 case OVSDB_F_NE:
 break;
@@ -126,6 +138,9 @@ ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
 type.n_min = 0;
 }
 break;
+case OVSDB_F_TRUE:
+case OVSDB_F_FALSE:
+OVS_NOT_REACHED();
 }
 return ovsdb_datum_from_json(>arg, , array->elems[2], symtab);
 }
@@ -164,6 +179,19 @@ compare_clauses_3way(const void *a_, const void *b_)
 }
 }
 
+static int
+compare_clauses_3way_with_data(const void *a_, const void *b_)
+{
+const struct ovsdb_clause *a = a_;
+const struct ovsdb_clause *b = b_;
+int res;
+
+res = compare_clauses_3way(a, b);
+return res ? res : ovsdb_datum_compare_3way(>arg,
+>arg,
+>column->type);
+ }
+
 struct ovsdb_error *
 ovsdb_condition_from_json(const struct ovsdb_table_schema *ts,
   const struct json *json,
@@ -185,12 +213,13 @@ ovsdb_condition_from_json(const struct ovsdb_table_schema 
*ts,
 cnd->n_clauses = 0;
 return error;
 }
+bitmap_set1(cnd->functions, cnd->clauses[i].function);
 cnd->n_clauses++;
 }
 
 /* A real database would have a query optimizer here. */
 qsort(cnd->clauses, cnd->n_clauses, sizeof *cnd->clauses,
-  compare_clauses_3way);
+  compare_clauses_3way_with_data);
 
 return NULL;
 }
@@ -198,10 +227,15 @@ ovsdb_condition_from_json(const struct ovsdb_table_schema 
*ts,
 static struct json *
 ovsdb_clause_to_json(const struct ovsdb_clause *clause)
 {
-return json_array_create_3(
-json_string_create(clause->column->name),
-json_string_create(ovsdb_function_to_string(clause->function)),
-ovsdb_datum_to_json(>arg, >column->type));
+if (clause->function != OVSDB_F_TRUE &&
+clause->function != OVSDB_F_FALSE) {
+return json_array_create_3(
+json_string_create(clause->column->name),
+json_string_create(ovsdb_function_to_string(clause->function)),
+ovsdb_datum_to_json(>arg, >column->type));
+}
+
+return json_boolean_create(clause->function == OVSDB_F_TRUE);
 }
 
 struct json *
@@ -218,13 +252,20 @@ ovsdb_condition_to_json(const struct ovsdb_condition *cnd)
 }
 
 static bool
-ovsdb_clause_evaluate(const struct ovsdb_row *row,
-  const struct ovsdb_clause *c)
+ovsdb_clause_evaluate(const struct ovsdb_datum *fields,
+  const struct ovsdb_clause *c,
+  unsigned int index_map[])
 {
-const struct ovsdb_datum *field = >fields[c->column->index];
+const struct ovsdb_datum *field = [index_map ?
+   

[ovs-dev] [PATCH monitor_cond V7 00/10] Conditional monitor implementation

2016-06-13 Thread Liran Schour
This patch series implements conditional monitoring by introducing an OVSDB
RFC extension with 2 new JSON-RPC methods: "monitor_cond" and
"monitor_cond_change". Specification of this extension is defined in the
ovsdb-server (1) man page.
Monitor2 is now merged into monitor_cond. A monitor_cond session with an empty 
condition, will behave exactly like monitor2 and will get update2 notifications
on all rows.

This patch series is also available on: https://github.com/liranschour/ovs.git
branch monitor_cond_ovn.

OVN:
Last patch in this series is a RFC for OVN usage of conditional monitoring.

Performance evaluation:
OVN is the main candidate for conditional monitoring usage. It is clear that
conditional monitoring reduces computation on the ovn-controller (client) side
due to the reduced size of flow tables and update messages. However,
performance evaluation shows also a reduction in computation on the SB
ovsdb-server side proportional to the degree that each logical network is
spread over physical hosts in the DC.

Evaluation on simulated environment of 50 hosts and 1000 logical ports shows
the following results (cycles #):

LN spread over # hosts|master| patch| change
-
1 | 58855158082  | 38175941755  | 35.1%
3 | 54816462604  | 40255584120  | 26.5%
6 | 52972265506  | 39481653891  | 25.4%
   12 | 57036827284  | 42008285519  | 26.3%
   18 | 61900476558  | 45903107035  | 25.8%
   24 | 64281399690  | 55617752599  | 13.4%
   30 | 66905128558  | 61835913623  |  7.5%
   42 | 76763742331  | 70522724721  |  8.1%
   50 | 85372146321  | 80130285454  |  6.1%

Changes V6 --> V7:
--
* Change ovsdb-idl API to include only add and remove clause from condition.
* IDL maintain and track conditions. Send monitor_cond_change on condition
  change.
* Due to IDL API change, OVN does not maintain and track condition.
* Report column duplication on ovsdv_monitor_add_column().
* Split added documentation according to patches.
* Add to testing for monitor_cond_change method in ovsdb-client via unixctl
  command.
* An update, if any, as a result of a condition change, will be sent to the
  client before the reply to the "monitor_cond_update" request.
* Minor fixes due to review.

Liran Schour (10):
  ovsdb: create column index mapping between ovsdb row to monitor row
  ovsdb: add conditions utilities to support monitor_cond
  ovsdb: allow unmonitored columns in condition evaluation
  ovsdb: generate update notifications for monitor_cond session
  ovsdb: enable jsonrpc-server to service "monitor_cond_change" request
  ovsdb-client: support monitor-cond method
  lib: add to ovsdb-idl monitor_id
  python: move Python idl to work with monitor_cond
  lib: add monitor_cond_change API to C IDL lib
  RFC OVN: Quick implementation of conditional monitoring

 NEWS|   3 +-
 lib/automake.mk |   2 +
 lib/ovsdb-condition.c   |  47 
 lib/ovsdb-condition.h   |  45 +++
 lib/ovsdb-idl-provider.h|   2 +
 lib/ovsdb-idl.c | 239 ++--
 lib/ovsdb-idl.h |  30 ++
 ovn/controller/binding.c| 108 +++-
 ovn/controller/binding.h|   4 +-
 ovn/controller/lport.c  | 123 -
 ovn/controller/lport.h  |  10 +-
 ovn/controller/ovn-controller.c |  23 +-
 ovsdb/condition.c   | 188 -
 ovsdb/condition.h   |  57 ++--
 ovsdb/jsonrpc-server.c  | 233 +---
 ovsdb/jsonrpc-server.h  |   2 +-
 ovsdb/monitor.c | 592 ++--
 ovsdb/monitor.h |  46 +++-
 ovsdb/ovsdb-client.1.in |  37 ++-
 ovsdb/ovsdb-client.c|  98 +--
 ovsdb/ovsdb-idlc.in | 364 +++-
 ovsdb/ovsdb-server.1.in | 221 +--
 ovsdb/ovsdb-server.c|  20 +-
 ovsdb/query.c   |   6 +-
 python/ovs/db/data.py   |  16 +-
 python/ovs/db/idl.py| 190 +++--
 tests/ovn-controller.at |   3 +
 tests/ovs-vswitchd.at   |   8 +-
 tests/ovsdb-condition.at|  41 +++
 tests/ovsdb-idl.at  | 243 -
 tests/ovsdb-monitor.at  | 251 +
 tests/test-ovsdb.c  | 292 +++-
 tests/test-ovsdb.py |  34 +++
 33 files changed, 3268 insertions(+), 310 deletions(-)
 create mode 100644 lib/ovsdb-condition.c
 create mode 100644 lib/ovsdb-condition.h

-- 
2.1.4

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


[ovs-dev] [PATCH monitor_cond V7 03/10] ovsdb: allow unmonitored columns in condition evaluation

2016-06-13 Thread Liran Schour
This commit allows to add unmonitored columns to a monitored table
due to condition update.
It will be used to evaluate conditions on unmonitored columns.
Update notification includes only monitored columns.
Due to the limited number of columns, we do not remove unused unmonitored
columns on condition update for code simplicity.

Signed-off-by: Liran Schour 
---
 ovsdb/jsonrpc-server.c | 23 +++
 ovsdb/monitor.c| 34 --
 ovsdb/monitor.h|  2 +-
 3 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 208027a..3a69a85 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -1093,8 +1093,7 @@ parse_bool(struct ovsdb_parser *parser, const char *name, 
bool default_value)
 static struct ovsdb_error * OVS_WARN_UNUSED_RESULT
 ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor *dbmon,
 const struct ovsdb_table *table,
-const struct json *monitor_request,
-size_t *allocated_columns)
+const struct json *monitor_request)
 {
 const struct ovsdb_table_schema *ts = table->schema;
 enum ovsdb_monitor_selection select;
@@ -1158,8 +1157,8 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor 
*dbmon,
 return ovsdb_syntax_error(columns, NULL, "%s is not a valid "
   "column name", s);
 }
-if (ovsdb_monitor_add_column(dbmon, table, column, select,
- allocated_columns)) {
+if (ovsdb_monitor_add_column(dbmon, table, column,
+ select, true)) {
 return ovsdb_syntax_error(columns, NULL, "column %s "
   "mentioned more than once",
   column->name);
@@ -1171,8 +1170,8 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor 
*dbmon,
 SHASH_FOR_EACH (node, >columns) {
 const struct ovsdb_column *column = node->data;
 if (column->index != OVSDB_COL_UUID) {
-if (ovsdb_monitor_add_column(dbmon, table, column, select,
- allocated_columns)) {
+if (ovsdb_monitor_add_column(dbmon, table, column,
+ select, true)) {
 return ovsdb_syntax_error(columns, NULL, "column %s "
   "mentioned more than once",
   column->name);
@@ -1225,7 +1224,6 @@ ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session 
*s, struct ovsdb *db,
 
 SHASH_FOR_EACH (node, json_object(monitor_requests)) {
 const struct ovsdb_table *table;
-size_t allocated_columns;
 const struct json *mr_value;
 size_t i;
 
@@ -1240,20 +1238,21 @@ ovsdb_jsonrpc_monitor_create(struct 
ovsdb_jsonrpc_session *s, struct ovsdb *db,
 
 /* Parse columns. */
 mr_value = node->data;
-allocated_columns = 0;
 if (mr_value->type == JSON_ARRAY) {
 const struct json_array *array = _value->u.array;
 
 for (i = 0; i < array->n; i++) {
-error = ovsdb_jsonrpc_parse_monitor_request(
-m->dbmon, table, array->elems[i], _columns);
+error = ovsdb_jsonrpc_parse_monitor_request(m->dbmon,
+table,
+array->elems[i]);
 if (error) {
 goto error;
 }
 }
 } else {
-error = ovsdb_jsonrpc_parse_monitor_request(
-m->dbmon, table, mr_value, _columns);
+error = ovsdb_jsonrpc_parse_monitor_request(m->dbmon,
+table,
+mr_value);
 if (error) {
 goto error;
 }
diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c
index 1e334d2..5228a0a 100644
--- a/ovsdb/monitor.c
+++ b/ovsdb/monitor.c
@@ -75,6 +75,7 @@ struct jsonrpc_monitor_node {
 struct ovsdb_monitor_column {
 const struct ovsdb_column *column;
 enum ovsdb_monitor_selection select;
+bool monitored;
 };
 
 /* A row that has changed in a monitored table. */
@@ -115,6 +116,8 @@ struct ovsdb_monitor_table {
 /* Columns being monitored. */
 struct ovsdb_monitor_column *columns;
 size_t n_columns;
+size_t n_monitored_columns;
+size_t allocated_columns;
 
 /* Columns in ovsdb_monitor_row have different indexes then in
  * ovsdb_row. This field maps between column->index to the index in the
@@ 

[ovs-dev] [PATCH monitor_cond V7 04/10] ovsdb: generate update notifications for monitor_cond session

2016-06-13 Thread Liran Schour
Hold session's conditions in ovsdb_monitor_session_condition. Pass it
to ovsdb_monitor for generating "update2" notifications.
Add functions that can generate "update2" notification for a
"monitor_cond" session.
JSON cache is enabled only for session's with true condition only.
"monitor_cond" and "monitor_cond_change" are RFC 7047 extensions
described by ovsdb-server(1) manpage.

Performance evaluation:
OVN is the main candidate for conditional monitoring usage. It is clear that
conditional monitoring reduces computation on the ovn-controller (client) side
due to the reduced size of flow tables and update messages. However,
performance evaluation shows also a reduction in computation on the SB
ovsdb-server side proportional to the degree that each logical network is
spread over physical hosts in the DC.

Evaluation on simulated environment of 50 hosts and 1000 logical ports shows
the following results (cycles #):

LN spread over # hosts|master| patch| change
-
1 | 58855158082  | 38175941755  | 35.1%
3 | 54816462604  | 40255584120  | 26.5%
6 | 52972265506  | 39481653891  | 25.4%
   12 | 57036827284  | 42008285519  | 26.3%
   18 | 61900476558  | 45903107035  | 25.8%
   24 | 64281399690  | 55617752599  | 13.4%
   30 | 66905128558  | 61835913623  |  7.5%
   42 | 76763742331  | 70522724721  |  8.1%
   50 | 85372146321  | 80130285454  |  6.1%
---
 ovsdb/jsonrpc-server.c  |  39 ++-
 ovsdb/monitor.c | 285 +++-
 ovsdb/monitor.h |  30 -
 ovsdb/ovsdb-server.1.in | 143 +---
 4 files changed, 444 insertions(+), 53 deletions(-)

diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 3a69a85..8fa4a1e 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -28,6 +28,7 @@
 #include "ovsdb-error.h"
 #include "ovsdb-parser.h"
 #include "ovsdb.h"
+#include "condition.h"
 #include "poll-loop.h"
 #include "reconnect.h"
 #include "row.h"
@@ -865,7 +866,8 @@ ovsdb_jsonrpc_session_got_request(struct 
ovsdb_jsonrpc_session *s,
 reply = execute_transaction(s, db, request);
 }
 } else if (!strcmp(request->method, "monitor") ||
-   (monitor2_enable__ && !strcmp(request->method, "monitor2"))) {
+   (monitor2_enable__ && !strcmp(request->method, "monitor2")) ||
+   !strcmp(request->method, "monitor_cond")) {
 struct ovsdb *db = ovsdb_jsonrpc_lookup_db(s, request, );
 if (!reply) {
 int l = strlen(request->method) - strlen("monitor");
@@ -1064,6 +1066,7 @@ struct ovsdb_jsonrpc_monitor {
 uint64_t unflushed; /* The first transaction that has not been
flushed to the jsonrpc remote client. */
 enum ovsdb_monitor_version version;
+struct ovsdb_monitor_session_condition *condition;/* Session's condition */
 };
 
 static struct ovsdb_jsonrpc_monitor *
@@ -1091,20 +1094,27 @@ parse_bool(struct ovsdb_parser *parser, const char 
*name, bool default_value)
 }
 
 static struct ovsdb_error * OVS_WARN_UNUSED_RESULT
-ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor *dbmon,
-const struct ovsdb_table *table,
-const struct json *monitor_request)
+ovsdb_jsonrpc_parse_monitor_request(
+   struct ovsdb_monitor *dbmon,
+   const struct ovsdb_table *table,
+   struct ovsdb_monitor_session_condition *cond,
+   const struct json *monitor_request)
 {
 const struct ovsdb_table_schema *ts = table->schema;
 enum ovsdb_monitor_selection select;
-const struct json *columns, *select_json;
+const struct json *columns, *select_json, *where = NULL;
 struct ovsdb_parser parser;
 struct ovsdb_error *error;
 
 ovsdb_parser_init(, monitor_request, "table %s", ts->name);
+if (cond) {
+where = ovsdb_parser_member(, "where", OP_ARRAY | OP_OPTIONAL);
+}
 columns = ovsdb_parser_member(, "columns", OP_ARRAY | OP_OPTIONAL);
+
 select_json = ovsdb_parser_member(, "select",
   OP_OBJECT | OP_OPTIONAL);
+
 error = ovsdb_parser_finish();
 if (error) {
 return error;
@@ -1179,6 +1189,12 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor 
*dbmon,
 }
 }
 }
+if (cond) {
+error = ovsdb_monitor_table_condition_create(cond, table, where);
+if (error) {
+return error;
+}
+}
 
 return NULL;
 }
@@ -1217,6 +1233,9 @@ ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session 
*s, struct ovsdb *db,
 m->session = s;
 m->db = db;
 

[ovs-dev] [PATCH monitor_cond V7 10/10] RFC OVN: Quick implementation of conditional monitoring

2016-06-13 Thread Liran Schour
Conditional monitor of: Port_Binding, Logical_Flow, Multicast_Group
MAC_Binding tables. As a result ovn-controller will be notified only about
records belongs to a datapath that is being served by this hypervisor.

Hack: Ideally, logical datapath ID should be retrieved from Port_Binding table
and by that conditions should be composed only from logical datapath IDs.
In the meantime we first add the logical port to the conditions and on retrieval
of port binding record, we add the logical datapath to the conditions.

Signed-off-by: Liran Schour 
---
 ovn/controller/binding.c| 108 ++-
 ovn/controller/binding.h|   4 +-
 ovn/controller/lport.c  | 123 ++--
 ovn/controller/lport.h  |  10 +++-
 ovn/controller/ovn-controller.c |  23 +---
 tests/ovn-controller.at |   3 +
 6 files changed, 254 insertions(+), 17 deletions(-)

diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
index a07c327..d8af74c 100644
--- a/ovn/controller/binding.c
+++ b/ovn/controller/binding.c
@@ -21,9 +21,11 @@
 #include "lib/sset.h"
 #include "lib/util.h"
 #include "lib/vswitch-idl.h"
+#include "lib/hash.h"
 #include "openvswitch/vlog.h"
 #include "ovn/lib/ovn-sb-idl.h"
 #include "ovn-controller.h"
+#include "lport.h"
 
 VLOG_DEFINE_THIS_MODULE(binding);
 
@@ -101,10 +103,108 @@ update_qos(const struct ovsrec_interface *iface_rec,
 ovsrec_interface_set_ingress_policing_burst(iface_rec, MAX(0, burst));
 }
 
+static struct sset g_lports = SSET_INITIALIZER(_lports);
+
+static void
+update_lports(struct controller_ctx *ctx,
+  struct sset *tmp_lports,
+  const struct lport_index *lports)
+{
+const char **lports_array, **tmp_lports_array;
+struct sset_node *node;
+int i, j;
+
+lports_array = sset_sort(_lports);
+tmp_lports_array = sset_sort(tmp_lports);
+for (i = 0, j = 0; lports_array[i] && tmp_lports_array[j];) {
+int cmp = strcmp(lports_array[i], tmp_lports_array[j]);
+if (!cmp) {
+i++;
+j++;
+} else if (cmp < 0) {
+node = sset_find(_lports, lports_array[i]);
+if (node) {
+VLOG_INFO("Remove port %s from condition", lports_array[i]);
+sbrec_port_binding_remove_clause_logical_port(ctx->ovnsb_idl,
+  OVSDB_F_EQ,
+  lports_array[i]);
+sbrec_port_binding_remove_clause_parent_port(ctx->ovnsb_idl,
+ OVSDB_F_EQ,
+ lports_array[i]);
+sset_delete(_lports, node);
+}
+i++;
+} else if (cmp > 0) {
+if (!lport_lookup_by_name(lports, tmp_lports_array[j])) {
+VLOG_INFO("Add port %s", tmp_lports_array[j]);
+sbrec_port_binding_add_clause_logical_port(ctx->ovnsb_idl,
+   OVSDB_F_EQ,
+   
tmp_lports_array[j]);
+sbrec_port_binding_add_clause_parent_port(ctx->ovnsb_idl,
+  OVSDB_F_EQ,
+  tmp_lports_array[j]);
+sset_add(_lports, tmp_lports_array[j]);
+}
+j++;
+}
+}
+for (; lports_array[i]; i++) {
+node = sset_find(_lports, lports_array[i]);
+if (node) {
+VLOG_INFO("Remove port %s from condition", lports_array[i]);
+sbrec_port_binding_remove_clause_logical_port(ctx->ovnsb_idl,
+  OVSDB_F_EQ,
+  lports_array[i]);
+sbrec_port_binding_remove_clause_parent_port(ctx->ovnsb_idl,
+ OVSDB_F_EQ,
+ lports_array[i]);
+sset_delete(_lports, node);
+}
+}
+for (; tmp_lports_array[j]; j++) {
+if (!lport_lookup_by_name(lports, tmp_lports_array[j])) {
+VLOG_INFO("Add port %s", tmp_lports_array[j]);
+sbrec_port_binding_add_clause_logical_port(ctx->ovnsb_idl,
+   OVSDB_F_EQ,
+   tmp_lports_array[j]);
+sbrec_port_binding_add_clause_parent_port(ctx->ovnsb_idl,
+  OVSDB_F_EQ,
+  tmp_lports_array[j]);
+sset_add(_lports, tmp_lports_array[j]);
+}
+}
+
+free(lports_array);
+

[ovs-dev] [PATCH monitor_cond V7 06/10] ovsdb-client: support monitor-cond method

2016-06-13 Thread Liran Schour
Add monitor_cond method to ovsdb-client. Enable testing of monitor_cond_change
via unixctl command.Add unit tests for monitor_cond and monitor_cond_change.
See ovsdb-client(1) man page for details.
Replace monitor2 with monitor_cond.

Signed-off-by: Liran Schour 
---
 NEWS|   3 +-
 lib/ovsdb-idl.c |  28 +++---
 ovsdb/jsonrpc-server.c  |  14 +--
 ovsdb/jsonrpc-server.h  |   2 +-
 ovsdb/ovsdb-client.1.in |  37 ---
 ovsdb/ovsdb-client.c|  98 +++
 ovsdb/ovsdb-server.c|  20 ++--
 tests/ovs-vswitchd.at   |   8 +-
 tests/ovsdb-idl.at  |  10 +-
 tests/ovsdb-monitor.at  | 251 
 10 files changed, 391 insertions(+), 80 deletions(-)

diff --git a/NEWS b/NEWS
index ba201cf..796ee38 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,8 @@
 Post-v2.5.0
 -
- ovsdb-server:
- * New "monitor2" and "update2" extensions to RFC 7047.
+ * New "monitor_cond" "monitor_cond_update" and "update2" extensions to
+ RFC 7047.
- OpenFlow:
  * OpenFlow 1.1+ OFPT_QUEUE_GET_CONFIG_REQUEST now supports OFPP_ANY.
  * OpenFlow 1.4+ OFPMP_QUEUE_DESC is now supported.
diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index b14bef2..170c171 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -79,8 +79,8 @@ enum ovsdb_idl_state {
 IDL_S_SCHEMA_REQUESTED,
 IDL_S_MONITOR_REQUESTED,
 IDL_S_MONITORING,
-IDL_S_MONITOR2_REQUESTED,
-IDL_S_MONITORING2,
+IDL_S_MONITOR_COND_REQUESTED,
+IDL_S_MONITORING_COND,
 IDL_S_NO_SCHEMA
 };
 
@@ -154,7 +154,7 @@ static struct vlog_rate_limit semantic_rl = 
VLOG_RATE_LIMIT_INIT(1, 5);
 static void ovsdb_idl_clear(struct ovsdb_idl *);
 static void ovsdb_idl_send_schema_request(struct ovsdb_idl *);
 static void ovsdb_idl_send_monitor_request(struct ovsdb_idl *);
-static void ovsdb_idl_send_monitor2_request(struct ovsdb_idl *);
+static void ovsdb_idl_send_monitor_cond_request(struct ovsdb_idl *);
 static void ovsdb_idl_parse_update(struct ovsdb_idl *, const struct json *,
enum ovsdb_update_version);
 static struct ovsdb_error *ovsdb_idl_parse_update__(struct ovsdb_idl *,
@@ -413,20 +413,20 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
 case IDL_S_SCHEMA_REQUESTED:
 /* Reply to our "get_schema" request. */
 idl->schema = json_clone(msg->result);
-ovsdb_idl_send_monitor2_request(idl);
-idl->state = IDL_S_MONITOR2_REQUESTED;
+ovsdb_idl_send_monitor_cond_request(idl);
+idl->state = IDL_S_MONITOR_COND_REQUESTED;
 break;
 
 case IDL_S_MONITOR_REQUESTED:
-case IDL_S_MONITOR2_REQUESTED:
-/* Reply to our "monitor" or "monitor2" request. */
+case IDL_S_MONITOR_COND_REQUESTED:
+/* Reply to our "monitor" or "monitor_cond" request. */
 idl->change_seqno++;
 ovsdb_idl_clear(idl);
 if (idl->state == IDL_S_MONITOR_REQUESTED) {
 idl->state = IDL_S_MONITORING;
 ovsdb_idl_parse_update(idl, msg->result, OVSDB_UPDATE);
-} else { /* IDL_S_MONITOR2_REQUESTED. */
-idl->state = IDL_S_MONITORING2;
+} else { /* IDL_S_MONITOR_COND_REQUESTED. */
+idl->state = IDL_S_MONITORING_COND;
 ovsdb_idl_parse_update(idl, msg->result, OVSDB_UPDATE2);
 }
 
@@ -437,7 +437,7 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
 break;
 
 case IDL_S_MONITORING:
-case IDL_S_MONITORING2:
+case IDL_S_MONITORING_COND:
 case IDL_S_NO_SCHEMA:
 default:
 OVS_NOT_REACHED();
@@ -464,7 +464,7 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
 /* Someone else stole our lock. */
 ovsdb_idl_parse_lock_notify(idl, msg->params, false);
 } else if (msg->type == JSONRPC_ERROR
-   && idl->state == IDL_S_MONITOR2_REQUESTED
+   && idl->state == IDL_S_MONITOR_COND_REQUESTED
&& idl->request_id
&& json_equal(idl->request_id, msg->id)) {
 if (msg->error && !strcmp(json_string(msg->error),
@@ -1066,9 +1066,9 @@ log_parse_update_error(struct ovsdb_error *error)
 }
 
 static void
-ovsdb_idl_send_monitor2_request(struct ovsdb_idl *idl)
+ovsdb_idl_send_monitor_cond_request(struct ovsdb_idl *idl)
 {
-ovsdb_idl_send_monitor_request__(idl, "monitor2");
+ovsdb_idl_send_monitor_request__(idl, "monitor_cond");
 }
 
 static void
@@ -3246,7 +3246,7 @@ ovsdb_idl_update_has_lock(struct ovsdb_idl *idl, bool 
new_has_lock)
 {
 if (new_has_lock && !idl->has_lock) {
 if (idl->state == IDL_S_MONITORING ||
-idl->state == IDL_S_MONITORING2) {
+idl->state == IDL_S_MONITORING_COND) {
 

Re: [ovs-dev] [PATCH net-next] NSH(Network Service Header) implementation

2016-06-13 Thread Jiri Benc
On Sun, 12 Jun 2016 15:53:50 +0800, Yang, Yi wrote:
> Will use net device after those patches are merged into net-next, It
> seems current net device implementation in net-next doesn't include it,

The current kernel should have everything that's needed for VXLAN-GPE
support.

> do you mean this one
> "http://article.gmane.org/gmane.network.openvswitch.devel/64799;?

This patchset is absolutely needed for ovs to support new VXLAN
features, including VXLAN-GPE.

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


[ovs-dev] [PATCH v2 1/1] netdev-dpdk: NUMA Aware vHost User

2016-06-13 Thread Ciara Loftus
This commit allows for vHost User memory from QEMU, DPDK and OVS, as
well as the servicing PMD, to all come from the same socket.

The socket id of a vhost-user port used to be set to that of the master
lcore. Now it is possible to update the socket id if it is detected
(during VM boot) that the vhost device memory is not on this node. If
this is the case, a new mempool is created from the new node, and the
PMD thread currently servicing the port will no longer, in favour of a
thread from the new node (if enabled in the pmd-cpu-mask).

To avail of this functionality, one must enable the
CONFIG_RTE_LIBRTE_VHOST_NUMA DPDK configuration option.

Signed-off-by: Ciara Loftus 
---

v2:
- Remove numactl dependencies from travis & fedora spec files
- Updated log message

 .travis.yml |  1 +
 INSTALL.DPDK.md |  8 ++--
 NEWS|  3 +++
 acinclude.m4|  2 +-
 lib/netdev-dpdk.c   | 37 ++---
 rhel/openvswitch-fedora.spec.in |  2 ++
 6 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index ee2cf21..6c818cb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,6 +11,7 @@ addons:
 packages:
   - bc
   - gcc-multilib
+  - libnuma-dev
   - libssl-dev
   - llvm-dev
   - libjemalloc1
diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index c2e32bf..00e75bd 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -16,7 +16,7 @@ OVS needs a system with 1GB hugepages support.
 Building and Installing:
 
 
-Required: DPDK 16.04
+Required: DPDK 16.04, libnuma
 Optional (if building with vhost-cuse): `fuse`, `fuse-devel` (`libfuse-dev`
 on Debian/Ubuntu)
 
@@ -465,7 +465,11 @@ Performance Tuning:
 
It is good practice to ensure that threads that are in the datapath are
pinned to cores in the same NUMA area. e.g. pmd threads and QEMU vCPUs
-   responsible for forwarding.
+   responsible for forwarding. If DPDK is built with
+   CONFIG_RTE_LIBRTE_VHOST_NUMA=y, vHost User ports automatically
+   detect the NUMA socket of the QEMU vCPUs and will be serviced by a PMD
+   from the same node provided a core on this node is enabled in the
+   pmd-cpu-mask.
 
 9. Rx Mergeable buffers
 
diff --git a/NEWS b/NEWS
index ba201cf..fe24449 100644
--- a/NEWS
+++ b/NEWS
@@ -33,6 +33,9 @@ Post-v2.5.0
arguments. Additional arguments can be passed via the dpdk-extra
entry.
  * Add ingress policing functionality.
+ * PMD threads servicing vHost User ports can now come from the NUMA
+   node that device memory is located on if CONFIG_RTE_LIBRTE_VHOST_NUMA
+   is enabled in DPDK.
- ovs-benchmark: This utility has been removed due to lack of use and
  bitrot.
- ovs-appctl:
diff --git a/acinclude.m4 b/acinclude.m4
index 0a14856..3978980 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -219,7 +219,7 @@ AC_DEFUN([OVS_CHECK_DPDK], [
 DPDKLIB_FOUND=false
 save_LIBS=$LIBS
 for extras in "" "-ldl"; do
-LIBS="$DPDK_LIB $extras $save_LIBS $DPDK_EXTRA_LIB"
+LIBS="$DPDK_LIB $extras $save_LIBS $DPDK_EXTRA_LIB -lnuma"
 AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include 
  #include ],
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 19d355f..fc683e9 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "dirs.h"
 #include "dp-packet.h"
@@ -385,6 +386,9 @@ struct netdev_dpdk {
 int requested_n_txq;
 int requested_n_rxq;
 
+/* Socket ID detected when vHost device is brought up */
+int requested_socket_id;
+
 /* Ingress Policer */
 OVSRCU_TYPE(struct ingress_policer *) ingress_policer;
 uint32_t policer_rate;
@@ -761,6 +765,7 @@ netdev_dpdk_init(struct netdev *netdev, unsigned int 
port_no,
 }
 
 dev->socket_id = sid < 0 ? SOCKET0 : sid;
+dev->requested_socket_id = dev->socket_id;
 dev->port_id = port_no;
 dev->type = type;
 dev->flags = 0;
@@ -2344,6 +2349,8 @@ new_device(struct virtio_net *virtio_dev)
 {
 struct netdev_dpdk *dev;
 bool exists = false;
+int newnode = 0;
+long err = 0;
 
 ovs_mutex_lock(_mutex);
 /* Add device to the vhost port with the same name as that passed down. */
@@ -2357,6 +2364,19 @@ new_device(struct virtio_net *virtio_dev)
 }
 ovsrcu_set(>virtio_dev, virtio_dev);
 exists = true;
+
+/* Get NUMA information */
+err = get_mempolicy(, NULL, 0, virtio_dev,
+MPOL_F_NODE | MPOL_F_ADDR);
+if (err) {
+VLOG_INFO("Error getting NUMA info for vHost Device '%s'",
+virtio_dev->ifname);
+newnode = dev->socket_id;
+} else if (newnode != dev->socket_id) {
+

[ovs-dev] Delivery reports about your e-mail

2016-06-13 Thread MAILER-DAEMON
The original message was received at Mon, 13 Jun 2016 15:17:24 +0530
from 222.69.112.179

- The following addresses had permanent fatal errors -


- Transcript of the session follows -
... while talking to 15.122.254.121:
>>> DATA
<<< 400

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


[ovs-dev] cooperation with an international company

2016-06-13 Thread dev
Hello!

We are looking for employees working remotely.

My name is Jannie, am the personnel manager of a large International company.
Most of the work you can do from home, that is, at a distance.

Salary is $2500-$5000.

If you are interested in this offer, please visit 
Our Site

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


Re: [ovs-dev] [PATCH] VxLAN-gpe implementation

2016-06-13 Thread Jiri Benc
On Sun, 12 Jun 2016 20:53:23 +0800, Yang, Yi wrote:
> On Mon, Jun 06, 2016 at 02:22:58PM -0700, Jesse Gross wrote:
> > However, the changes to vport-vxlan.c are modifying compatibility code
> > that shouldn't be extended further. Instead, just use the existing
> > VXLAN netlink interfaces that have already been created to enable
> > these features.
> 
> Jesse, sorry for late reply, I will submit a kernel patch for this.

There's no kernel patch needed, everything is in the kernel already.
What is needed is Thadeu's "create tunnel devices using rtnetlink
interface" patchset,
http://thread.gmane.org/gmane.network.openvswitch.devel/64795

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


[ovs-dev] [PATCH v3 3/3] DSCP marking on packets egressing VIF interface

2016-06-13 Thread bschanmu
ovn-northd sets 'ip.dscp' to the DSCP value

Signed-off-by: Babu Shanmugam 
---
 ovn/controller/lflow.c  | 2 +-
 ovn/northd/ovn-northd.c | 4 
 ovn/ovn-nb.xml  | 5 +
 ovn/ovn-sb.xml  | 5 +
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
index efc427d..fae610d 100644
--- a/ovn/controller/lflow.c
+++ b/ovn/controller/lflow.c
@@ -97,7 +97,7 @@ lflow_init(void)
 expr_symtab_add_predicate(, "ip6", "eth.type == 0x86dd");
 expr_symtab_add_predicate(, "ip", "ip4 || ip6");
 expr_symtab_add_field(, "ip.proto", MFF_IP_PROTO, "ip", true);
-expr_symtab_add_field(, "ip.dscp", MFF_IP_DSCP, "ip", false);
+expr_symtab_add_field(, "ip.dscp", MFF_IP_DSCP_SHIFTED, "ip", 
false);
 expr_symtab_add_field(, "ip.ecn", MFF_IP_ECN, "ip", false);
 expr_symtab_add_field(, "ip.ttl", MFF_IP_TTL, "ip", false);
 
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 793abc4..c180cb3 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -1652,6 +1652,10 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap 
*ports,
 "eth.src", op->nbs->port_security, op->nbs->n_port_security,
 );
 const char *queue_id = smap_get(>sb->options, "qdisc_queue_id");
+const char *dscp = smap_get(>sb->options, "qos_dscp");
+if (dscp) {
+ds_put_format(, "ip.dscp = %s;", dscp);
+}
 if (queue_id) {
 ds_put_format(, "set_queue(%s);", queue_id);
 }
diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
index 9171c26..7915fc7 100644
--- a/ovn/ovn-nb.xml
+++ b/ovn/ovn-nb.xml
@@ -204,6 +204,11 @@
   If set, indicates the maximum burst size for data sent from this
   interface, in bits.
 
+
+
+  If set, indicates the DSCP code to be marked on the packets egressing
+  the VIF interface. Value should be in the range of 0 to 64.
+
   
 
 
diff --git a/ovn/ovn-sb.xml b/ovn/ovn-sb.xml
index df97680..e7edfa8 100644
--- a/ovn/ovn-sb.xml
+++ b/ovn/ovn-sb.xml
@@ -1450,6 +1450,11 @@ tcp.flags = RST;
 interface, in bits.
   
 
+  
+If set, indicates the DSCP code to be marked on the packets egressing
+the VIF interface. Value should be in the range of 0 to 64.
+  
+
   
 Indicates the queue number on the physical device. This is same as the
 queue_id used in OpenFlow in struct ofp_action_enqueue. Value should
-- 
2.5.0

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


[ovs-dev] [PATCH v3 2/3] Check and allocate free qdisc queue id for ports with qos parameters

2016-06-13 Thread bschanmu
ovn-northd processes the list of Port_Bindings and hashes the list of
queues per chassis. When it finds a port with qos_parameters and without
a queue_id, it allocates a free queue for the chassis that this port belongs.
The queue_id information is stored in the options field of Port_binding table.
Adds an action set_queue to the ingress table 0 of the logical flows
which will be translated to openflow set_queue by ovn-controller

ovn-controller opens the netdev corresponding to the tunnel interface's
status:tunnel_egress_iface value and configures a HTB qdisc on it. Then for
each SB port_binding that has queue_id set, it allocates a queue with the
qos_parameters of that port. It also frees up unused queues.

This patch replaces the older approach of policing

Signed-off-by: Babu Shanmugam 
---
 ovn/controller/binding.c | 187 +++
 ovn/lib/actions.c|  29 
 ovn/lib/actions.h|   3 +
 ovn/northd/ovn-northd.c  | 132 +++--
 ovn/ovn-nb.xml   |   8 +-
 ovn/ovn-sb.xml   |  31 +++-
 6 files changed, 360 insertions(+), 30 deletions(-)

diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
index a07c327..a1a14c4 100644
--- a/ovn/controller/binding.c
+++ b/ovn/controller/binding.c
@@ -20,6 +20,7 @@
 #include "lib/hmap.h"
 #include "lib/sset.h"
 #include "lib/util.h"
+#include "lib/netdev.h"
 #include "lib/vswitch-idl.h"
 #include "openvswitch/vlog.h"
 #include "ovn/lib/ovn-sb-idl.h"
@@ -27,6 +28,21 @@
 
 VLOG_DEFINE_THIS_MODULE(binding);
 
+#define OVN_QOS_TYPE "linux-htb"
+
+struct qos_queue {
+uint32_t queue_id;
+uint32_t max_rate;
+uint32_t burst;
+struct hmap_node node;
+};
+
+struct tunnel_iface_entry {
+const struct ovsrec_interface *iface_rec;
+const struct ovsrec_port *port_rec;
+struct ovs_list node;
+};
+
 void
 binding_register_ovs_idl(struct ovsdb_idl *ovs_idl)
 {
@@ -40,17 +56,20 @@ binding_register_ovs_idl(struct ovsdb_idl *ovs_idl)
 ovsdb_idl_add_table(ovs_idl, _table_port);
 ovsdb_idl_add_column(ovs_idl, _port_col_name);
 ovsdb_idl_add_column(ovs_idl, _port_col_interfaces);
+ovsdb_idl_add_column(ovs_idl, _port_col_qos);
 
 ovsdb_idl_add_table(ovs_idl, _table_interface);
 ovsdb_idl_add_column(ovs_idl, _interface_col_name);
 ovsdb_idl_add_column(ovs_idl, _interface_col_external_ids);
-ovsdb_idl_add_column(ovs_idl, _interface_col_ingress_policing_rate);
-ovsdb_idl_add_column(ovs_idl,
- _interface_col_ingress_policing_burst);
+ovsdb_idl_add_column(ovs_idl, _interface_col_status);
+
+ovsdb_idl_add_table(ovs_idl, _table_qos);
+ovsdb_idl_add_column(ovs_idl, _qos_col_type);
 }
 
 static void
-get_local_iface_ids(const struct ovsrec_bridge *br_int, struct shash *lports)
+get_local_iface_ids(const struct ovsrec_bridge *br_int, struct shash *lports,
+struct ovs_list *tunnel_ifaces)
 {
 int i;
 
@@ -68,10 +87,17 @@ get_local_iface_ids(const struct ovsrec_bridge *br_int, 
struct shash *lports)
 
 iface_rec = port_rec->interfaces[j];
 iface_id = smap_get(_rec->external_ids, "iface-id");
-if (!iface_id) {
-continue;
+if (iface_id) {
+shash_add(lports, iface_id, iface_rec);
+}
+
+/* Check if this is a tunnel interface. */
+if (smap_get(_rec->options, "remote_ip")) {
+struct tunnel_iface_entry *entry = xzalloc(sizeof *entry);
+entry->iface_rec = iface_rec;
+entry->port_rec = port_rec;
+ovs_list_push_back(tunnel_ifaces, >node);
 }
-shash_add(lports, iface_id, iface_rec);
 }
 }
 }
@@ -91,14 +117,127 @@ add_local_datapath(struct hmap *local_datapaths,
 }
 
 static void
-update_qos(const struct ovsrec_interface *iface_rec,
-   const struct sbrec_port_binding *pb)
+get_qos_params(const struct sbrec_port_binding *pb,
+   struct hmap *queue_map)
+{
+uint32_t max_rate = smap_get_int(>options, "qos_max_rate", 0);
+uint32_t burst = smap_get_int(>options, "qos_burst", 0);
+uint32_t queue_id = smap_get_int(>options, "qdisc_queue_id", 0);
+
+if ((!max_rate && !burst) || !queue_id) {
+/* Qos is not configured for this port. */
+return;
+}
+
+struct qos_queue *node = xzalloc(sizeof *node);
+node->max_rate = max_rate;
+node->burst = burst;
+node->queue_id = queue_id;
+hmap_insert(queue_map, >node, hash_int(queue_id, 0));
+}
+
+static const struct ovsrec_qos *
+get_noop_qos(struct controller_ctx *ctx)
 {
-int rate = smap_get_int(>options, "policing_rate", 0);
-int burst = smap_get_int(>options, "policing_burst", 0);
+const struct ovsrec_qos *qos;
+
+OVSREC_QOS_FOR_EACH(qos, ctx->ovs_idl) {
+if (!strcmp(qos->type, "linux-noop")) {
+return qos;
+

[ovs-dev] [PATCH v3 1/3] New qos type linux-noop

2016-06-13 Thread bschanmu
Linux ``No operation'' qos type is used to inform the vswitch that the
traffic control for the port is managed externally. Any configuration values
set for this type will have no effect.

This patch provides a solution suggested in this mail -
http://openvswitch.org/pipermail/discuss/2015-May/017687.html

Signed-off-by: Babu Shanmugam 
---
 lib/netdev-linux.c   | 49 -
 vswitchd/vswitch.xml |  8 
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 82813ba..8a5661d 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -418,6 +418,7 @@ static const struct tc_ops tc_ops_codel;
 static const struct tc_ops tc_ops_fqcodel;
 static const struct tc_ops tc_ops_sfq;
 static const struct tc_ops tc_ops_default;
+static const struct tc_ops tc_ops_noop;
 static const struct tc_ops tc_ops_other;
 
 static const struct tc_ops *const tcs[] = {
@@ -426,6 +427,7 @@ static const struct tc_ops *const tcs[] = {
 _ops_codel,  /* Controlled delay */
 _ops_fqcodel,/* Fair queue controlled delay */
 _ops_sfq,/* Stochastic fair queueing */
+_ops_noop,   /* Non operating qos type. */
 _ops_default,/* Default qdisc (see tc-pfifo_fast(8)). */
 _ops_other,  /* Some other qdisc. */
 NULL
@@ -2101,7 +2103,6 @@ netdev_linux_get_qos_types(const struct netdev *netdev 
OVS_UNUSED,
struct sset *types)
 {
 const struct tc_ops *const *opsp;
-
 for (opsp = tcs; *opsp != NULL; opsp++) {
 const struct tc_ops *ops = *opsp;
 if (ops->tc_install && ops->ovs_name[0] != '\0') {
@@ -2206,6 +2207,10 @@ netdev_linux_set_qos(struct netdev *netdev_,
 return EOPNOTSUPP;
 }
 
+if (new_ops == _ops_noop) {
+return new_ops->tc_install(netdev_, details);
+}
+
 ovs_mutex_lock(>mutex);
 error = tc_query_qdisc(netdev_);
 if (error) {
@@ -4489,6 +4494,48 @@ static const struct tc_ops tc_ops_hfsc = {
 hfsc_class_dump_stats   /* class_dump_stats */
 };
 
+/* "linux-noop" traffic control class. */
+
+static void
+noop_install__(struct netdev *netdev_)
+{
+struct netdev_linux *netdev = netdev_linux_cast(netdev_);
+static const struct tc tc = TC_INITIALIZER(, _ops_default);
+
+netdev->tc = CONST_CAST(struct tc *, );
+}
+
+static int
+noop_tc_install(struct netdev *netdev,
+   const struct smap *details OVS_UNUSED)
+{
+noop_install__(netdev);
+return 0;
+}
+
+static int
+noop_tc_load(struct netdev *netdev, struct ofpbuf *nlmsg OVS_UNUSED)
+{
+noop_install__(netdev);
+return 0;
+}
+
+static const struct tc_ops tc_ops_noop = {
+NULL,   /* linux_name */
+"linux-noop",   /* ovs_name */
+0,  /* n_queues */
+noop_tc_install,
+noop_tc_load,
+NULL,   /* tc_destroy */
+NULL,   /* qdisc_get */
+NULL,   /* qdisc_set */
+NULL,   /* class_get */
+NULL,   /* class_set */
+NULL,   /* class_delete */
+NULL,   /* class_get_stats */
+NULL/* class_dump_stats */
+};
+
 /* "linux-default" traffic control class.
  *
  * This class represents the default, unnamed Linux qdisc.  It corresponds to
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 5cf1ee1..b09119c 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -3387,6 +3387,14 @@
 
   
   
+linux-noop
+
+  Linux ``No operation'' qos type is used to inform the vswitch that 
the
+  traffic control for the port is managed externally. Any 
configuration values
+  set for this type will have no effect.
+
+  
+  
 egress-policer
 
   An egress policer algorithm. This implementation uses the DPDK
-- 
2.5.0

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


[ovs-dev] [PATCH v3 0/3] QOS updates with DSCP support

2016-06-13 Thread bschanmu
v2 -> v3 changes:
- Added a new qos type 'linux-noop'
- Set queues on all physical interfaces used for tunnelling
- Some minor styling fixes

Following are done through this series
1. Changed the old approach of policing the packets. It is now shaped
   with queues. Changed the Logical_Port options for NB db
2. Support for DSCP marking through options field in Logical_Port table


Babu Shanmugam (3):
  New qos type linux-noop
  Check and allocate free qdisc queue id for ports with qos parameters
  DSCP marking on packets egressing VIF interface

 lib/netdev-linux.c   |  49 -
 ovn/controller/binding.c | 187 +++
 ovn/controller/lflow.c   |   2 +-
 ovn/lib/actions.c|  29 
 ovn/lib/actions.h|   3 +
 ovn/northd/ovn-northd.c  | 136 --
 ovn/ovn-nb.xml   |  13 +++-
 ovn/ovn-sb.xml   |  36 -
 vswitchd/vswitch.xml |   8 ++
 9 files changed, 431 insertions(+), 32 deletions(-)

-- 
2.5.0

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


[ovs-dev] Message could not be delivered

2016-06-13 Thread The Post Office


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


Re: [ovs-dev] [PATCH 4/4] ovn-northd: Add logical flows to support native DHCP

2016-06-13 Thread Numan Siddique
On Thu, Jun 9, 2016 at 11:08 AM, Ben Pfaff  wrote:

> From: Numan Siddique 
>
> OVN implements a native DHCP support which caters to the common
> use case of providing an IP address to a booting instance by
> providing stateless replies to DHCP requests based on statically
> configured address mappings. To do this it allows a short list of
> DHCP options to be configured and applied at each compute host
> running ovn-controller.
>
> A new table 'Subnet' is added in OVN NB DB to store the DHCP options.
>
> For each logical port following flows are added if the CMS has defined
> DHCP options in the 'Subnet' column
>
>  - A logical flow which copies the DHCP options to the DHCP
>request packets using the 'put_dhcp_opts' action and advances the
>packet to the next stage.
>
>  - A logical flow which implements the DHCP reponder by sending
>the DHCP reply back to the inport once the 'put_dhcp_opts' action
>is applied.
>
> Signed-off-by: Numan Siddique 
> Signed-off-by: Ben Pfaff 
>
>

​I tested this patch series against the WIP networking-ovn dhcp patch [1]
and it passed all the tempest tests. I had to do the below modification in
ovn-northd.c ​

---
@@ -1385,7 +1385,7 @@ build_dhcp_action(struct ovn_port *op, ovs_be32
offer_ip,
 }
 }

-ds_put_format(pause_action, "put_dhcp_opts(reg0, offerip = "IP_FMT", ",
+ds_put_format(pause_action, "reg0[0] = put_dhcp_opts(offerip =
"IP_FMT", ",
   IP_ARGS(offer_ip));
 SMAP_FOR_EACH(node, _options) {
 ds_put_format(pause_action, "%s = %s, ", node->key, node->value);
​


Ben, in case you are busy with other things, please let me know. I can work
on fixing the test case failures.

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