Re: [ovs-dev] [ovs-discuss] fix the mod_vlan_vid actions with OpenFlow13.

2018-08-22 Thread Thomas F Herbert

On 8/21/18 10:17 PM, Lilijun (Jerry, Cloud Networking) wrote:

Hi Eric and all,

Thanks for Eric's advice very much.

But in my opinion, this issue reported from wangyunjian is something about 
feature's compatibility.

Using the rule: ovs-ofctl  -O OpenFlow13 add-flow ovsbr0 " 
table=0,priority=2,in_port=1 actions=mod_vlan_vid:3,NORMAL",
the action mod_vlan_id's  behavior is only to modify a packet's vlan id before 
we introduce the feature of QinQ.
But now it has changed to push an outer vlan unexpectedly.

The same openflow rules will act with different functions. That maybe bring 
user's packets being handled with a wrong manner and dropped unexpectedly.

So, I think we'd better fix it to keep the compatibility instead of asking 
OVS's users for rules configuration changed to another action.

The first patch from wangyunjian can worked without any compatibility broken 
although it's a bit complicated.
Do you have any better and simpler solutions or ideas?

B.R.
Lilijun

-Original Message-
From: ovs-dev-boun...@openvswitch.org [mailto:ovs-dev-boun...@openvswitch.org] 
On Behalf Of Eric Garver
Sent: Tuesday, August 21, 2018 9:45 PM
To: wangyunjian 
Cc: d...@openvswitch.org; Zhoulei (stone, Cloud Networking) 
; ovs-disc...@openvswitch.org; thomasfherb...@gmail.com
Subject: Re: [ovs-dev] [ovs-discuss] fix the mod_vlan_vid actions with 
OpenFlow13.

On Tue, Aug 21, 2018 at 02:23:33AM +, wangyunjian wrote:



-Original Message-
From: Eric Garver [mailto:e...@erig.me]
Sent: Monday, August 20, 2018 9:15 PM
To: wangyunjian 
Cc: d...@openvswitch.org; ovs-disc...@openvswitch.org; Zhoulei
(stone, Cloud Networking) ;
thomasfherb...@gmail.com
Subject: Re: [ovs-discuss] [ovs-dev] fix the mod_vlan_vid actions
with OpenFlow13.

On Mon, Aug 20, 2018 at 02:17:34AM +, wangyunjian wrote:



[..]

On Fri, Aug 17, 2018 at 12:15:30PM +, wangyunjian wrote:

The datapath flow which pushs double vlan was found using
ovs-appctl dpctl/dump-flows, but the flow was set
mod_vlan_vid

actions.

This problem is discovered from "Add support for 802.1ad
(QinQ

tunneling)".

Thanks for reporting. Can you say what version of OVS you're using?
Including any extra patches you may have applied.

The version of OVS is master branch(git log "
be5e6d6822e60b5b84ac65dcd1b249145356a809
ofp-ed-props: Fix hang for crafted OpenFlow encap/decap properties".).


My test steps:

1) ovs-vsctl add-br ovsbr0 -- set bridge ovsbr0 datapath_type=netdev
ovs-vsctl add-port ovsbr0 eth2 -- set Interface eth2
type=dpdk

options:dpdk-devargs=:03:00.0

ovs-ofctl  -O OpenFlow13 add-flow ovsbr0 "
table=0,priority=2,in_port=1

actions=mod_vlan_vid:3,NORMAL"

What happens if you add a wildcard VLAN match here?
e.g. vlan_tci=0x1000/0x1000

The packet is set vlan_vid ok with adding the wildcard VLAN match.

linux-jrWzwZ:/data/wyj/git/ovs # ovs-ofctl -O OpenFlow13 add-flow ovsbr0 
"cookie=0xb043f0d196265635,table=0,priority=2,in_port=1,vlan_tci=0x1000/0x1000 
actions=mod_vlan_vid:2,NORMAL"
linux-jrWzwZ:/data/wyj/git/ovs # tcpdump -i ovsbr0 -ne
tcpdump: verbose output suppressed, use -v or -vv for full protocol
decode listening on ovsbr0, link-type EN10MB (Ethernet), capture size
65535 bytes
10:06:53.284556 90:17:ac:b0:0a:ff > Broadcast, ethertype 802.1Q
(0x8100), length 64: vlan 2, p 0, ethertype ARP, Request who-has
3.3.3.18 tell 3.3.3.17, length 46
10:06:54.286542 90:17:ac:b0:0a:ff > Broadcast, ethertype 802.1Q
(0x8100), length 64: vlan 2, p 0, ethertype ARP, Request who-has
3.3.3.18 tell 3.3.3.17, length 46
10:06:56.283594 90:17:ac:b0:0a:ff > Broadcast, ethertype 802.1Q
(0x8100), length 64: vlan 2, p 0, ethertype ARP, Request who-has
3.3.3.18 tell 3.3.3.17, length 46

The mod_vlan_vid will implicitly insert a PUSH_VLAN action if the match/flow 
does not qualify a vlan regardless of the specified OF version. This is done on 
the ovs-ofctl side before the flow is sent over to ovs-vswitchd - long before 
any packets are involved.

You have two options:

 1) qualify the VLAN as you've done above

 2) Use set_vlan_vid action with "-O OpenFlow11" or greater. It will
_not_ attempt to push a VLAN.

This worked before 802.1ad/QinQ support only by accident because the PUSH_VLAN 
action blindly overwrote the existing VLAN.
Open Flow version 1.0 specified ambiguous actions on vlans. The action 
of mod_vlan would result in an implicit push on an untagged packet. This 
was fixed in version 1.1 and above. Please see Section B.9.3 and B.6.18. 
in OpenFlow version 1.3.
I agree with Eric that it is better to use set_vlan action and specify 
Open Flow version 1.1 or greater to avoid unexpected push vlan actions.


Hope that helps.
Eric.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev



___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [RFC PATCH v2 1/3] Add support for 802.1ad (QinQ tunneling)

2016-07-15 Thread Thomas F Herbert

On 7/15/16 9:08 AM, Xiao Liang wrote:

Thanks a lot. Please see inline.

On Fri, Jul 15, 2016 at 7:17 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

On 7/2/16 10:17 AM, Xiao Liang wrote:

Hi Tom,

Thanks for your test and comments! Please see inline.

On Sat, Jul 2, 2016 at 1:34 AM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Xiao,

Thanks. I think this is nice work and I think it advances the ball.

It needs to be rebased to latest. I got some fuzz applying the patch.
It fails make check on latest master on a few tests: 403, 405, 1091,
1117,
1119 and 2092.

A primary problem is that I forgot to modify odp_flow_from_string,
which causes flow parse not working in tests. I'm checking if there
are other bugs and try to fix them.


I tested the patch with my kernel module patch and it works. I am passing
double tagged traffic through your patch now.
I like your approach of using an array to encode the vlans in the flow.
It seems to fail appctl trace. See http://pastebin.com/fn4AKL7q I think
when
it parses the packet representation, it is confusing the dl_type with the
outer TPID.

I think the dl_type resembles eth_type in OpenFlow, which defined as
"ethernet type of the OpenFlow packet payload, after VLAN tags". In
implementation, it should be the innermost ethertype that the switch
can recognise. Suppose we support two VLAN headers, an IPv4 packet
with one or two VLAN headers will have dl_type 0x0800, and an IPv4
packet with more than two VLAN headers will have dl_type 0x8100 or
0x88a8. Seems we can't match outer TPIDs with OpenFlow.

I believe that the OF spec says the match should always be on the outer
vlan. Currently OVS matches the inner vlan only because of short cuts in the
code.

Above I meant ethertype but not VLAN TCI. Further explained in next
mail about the kernel patch.


The flow probably should be:

in_port=2,vlan_tci=0x1064,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00

in_port=1,vlan_tci=0x13e7,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00
The dl_type doesn't matter in this case.

Ben Pfaff and I had a discussion at OVSCON 2015 about getting rid of the
implied vlan detection on the CFI bit and moving to always detecting vlans
by TPID. This would allow vlan with a 0 tci. I am sure he will weigh in on
this.


I agree with you. But the the field name should be something else,
like "tpid", rather than dl_type. With dl_type being the innermost
ethertype, we could test if an packet (no matter tagged or untagged)
is IPv4 by simply matching on this field.
BTW, I see in the pastebin, you are testing with vlan_tci=0x, but
there are only flows matching vlan 100 and 999.


I have a few other comments inline below.
It may also need some cleanup here and there and there may be some white
space introduced by patch.
I didn't fully understand the double tagged tunnel type and didn't
immediately have a way to test that.

--Tom


Add new port VLAN mode "dot1q-tunnel":
- Example:
   ovs-vsctl set Port p1 vlan_mode=dot1q-tunnel tag=100

Don't you mean dot1ad tunnel, below you show cvlans?

Here I followed naming convention of the Cisco CLI "switchport mode
dot1q-tunnel". By Q-in-Q it means dot1Q-in-dot1Q, and it's simply two
802.1q headers in a 802.1ad frame (see
https://en.wikipedia.org/wiki/IEEE_802.1ad). I don't have strong
preference for the name. It can be changed if it's too confusing.


+struct vlan_hdr vlan[FLOW_MAX_VLAN_HEADERS];/* 802.1q VLAN
headers */

Proper terminology would be just VLAN headers. When both vlans are
present
that is 802.1ad not 802.1q.

As explained above. I will remove the "802.1q" because it's confusing.


I think encoding the vlans as an array is a good idea.

It is interesting that you put the vlan headers before the dl_type in the
order
they appear in the packet. I am concerned that the inner dl_type is not
in
the same 64 bit word as the vlan_tci in the case of single vlans. I have
more commentary on this below.


Please see below.


--- a/lib/flow.c
+++ b/lib/flow.c
@@ -72,8 +72,6 @@ const uint8_t flow_segment_u64s[4] = {
  /* miniflow_extract() assumes the following to be true to optimize
the
 * extraction process. */
-ASSERT_SEQUENTIAL_SAME_WORD(dl_type, vlan_tci);
-

This bothers me. There is legacy behavior that does many matches on
Ethertype+tci. I struggled with this as well in my version of the patch
which encoded both TPIDs. I am concerned that this patch to double tagged
vlans may substantially decrease performance of legacy single tagged
vlans.
In my latest patch, when I encoded a single vlan I put it in the inner
position in flow even though that was contradictory to the idea that the
flow fields should be in order that they were found in the packet. Even
though you use an array for encoding the vlans, they both are always
encoded
in the flow. We have to think about where the single vlan should be
encoded.

This is my understanding (not very sure, ple

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

2016-07-15 Thread Thomas F Herbert

On 7/15/16 9:09 AM, Xiao Liang wrote:

On Fri, Jul 15, 2016 at 8:08 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Eric and Xiao, I am cc'ing this to the ovs-dev list because other reviewers
who reviewed the kernel module may want to weigh in.

--TFH

On 7/12/16 2:17 PM, Eric Garver wrote:

This looks okay to me. This function was definitely missing a call to
parse_flow_mask_nlattrs() for the masked case. My only question is why
the original code has "if (unlikely(inner))".

Tom,
Can you speak to why this was checking for the inner tag?

Eric, please see my comments below.


On Tue, Jul 12, 2016 at 11:37:32PM +0800, Xiao Liang wrote:

Hi Eric,

Nice to hear that we could work together on this feature, and many
thanks for you effort. Hope we could get it work in the upstream soon.

By the way, for the kernel patch, I changed the last lines in
__parse_vlan_from_nlattrs:
  if (unlikely(inner)) {
  err = parse_flow_nlattrs(encap, a, en_attrs, log);
  if (err)
  return err;
  }
  return 0;
to:
  if (is_mask)
  err = parse_flow_mask_nlattrs(encap, a, en_attrs, log);
  else
  err = parse_flow_nlattrs(encap, a, en_attrs, log);

  return err;

Is it reasonable?

Yes, I think you are correct. The mask case seems to be missing from my V20
kernel module patch. Maybe when I refactored the code to use a common
function for inner and outer vlans, I dropped the mask case. However,
unlikely(inner) may be OK though because the single tagged vlan is the more
common case.

A complication is that the OF spec says that matching should be on the outer
tag only. (See section 7.2.3.8.) I don't recall but the intent of this code
may have been to check for a mask on the outer tag only. However, it makes
sense to code it in such a way that both tags are handled symmetrically.

It's true with a single OF table, but inner tag could be matched by
using multiple tables:
table=0,vlan_tci=0x1000/0x1000,actions=pop_vlan,goto_table:1
table=1,vlan_tci=0x1234/0x1fff,actions=output:1
As dp flow, I think it should always contain both VLAN headers (if present).

Yes, both vlans should be encoded in the data path.


I'm still wondering how could the second call to
__parse_vlan_from_nlattrs in parse_vlan_from_nlattrs be reached?
Did you mean "if (likely(!inner))"?

Thanks,
Xiao


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


Re: [ovs-dev] [PATCH v4 3/4] tests: Adjust VLAN+MPLS handling cases for QinQ

2016-07-15 Thread Thomas F Herbert

On 7/15/16 9:10 AM, Xiao Liang wrote:

On Fri, Jul 15, 2016 at 8:15 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

On 7/12/16 11:38 AM, Xiao Liang wrote:

When QinQ is supported, ingress VLAN are kept after push_vlan  actions,
so we should expect two VLAN headers.

Am I reading this wrong but it looks like the 0x8847 mpls type was dropped
from the test packet below?


Signed-off-by: Xiao Liang <shaw.l...@gmail.com>
mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:51,dl_dst=50:54:00:00:00:07,mpls_label=10,mpls_tc=0,mpls_ttl=64,mpls_bos=1
     50 54 00 00 00 07 40 44-44 44 54 51 81 00 20 63
-0010  88 47 00 00 a1 40 45 00-00 28 00 00 00 00 40 06
-0020  f9 7c c0 a8 00 01 c0 a8-00 02 00 00 00 00 00 00
-0030  00 00 00 00 00 00 50 00-00 00 00 00 00 00 00 00
+0010  81 00 e0 58 88 47 00 00-a1 40 45 00 00 28 00 00

What happened to 0x8847?


It's right after the vlan header:
  +0010  81 00 e0 58 88 47

Yes, I stand corrected.



+0020  00 00 40 06 f9 7c c0 a8-00 01 c0 a8 00 02 00 00
+0030  00 00 00 00 00 00 00 00-00 00 50 00 00 00 00 00
+0040  00 00 00 00
   dnl
-OFPT_PACKET_IN (OF1.2): total_len=64 in_port=1 (via action) data_len=64
(unbuffered)
+OFPT_PACKET_IN (OF1.2): total_len=68 in_port=1 (via action) data_len=68
(unbuffered)

mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:51,dl_dst=50:54:00:00:00:07,mpls_label=10,mpls_tc=0,mpls_ttl=64,mpls_bos=1
     50 54 00 00 00 07 40 44-44 44 54 51 81 00 20 63
-0010  88 47 00 00 a1 40 45 00-00 28 00 00 00 00 40 06
-0020  f9 7c c0 a8 00 01 c0 a8-00 02 00 00 00 00 00 00
-0030  00 00 00 00 00 00 50 00-00 00 00 00 00 00 00 00
+0010  81 00 e0 58 88 47 00 00-a1 40 45 00 00 28 00 00
+0020  00 00 40 06 f9 7c c0 a8-00 01 c0 a8 00 02 00 00
+0030  00 00 00 00 00 00 00 00-00 00 50 00 00 00 00 00
+0040  00 00 00 00
   dnl
-OFPT_PACKET_IN (OF1.2): total_len=64 in_port=1 (via action) data_len=64
(unbuffered)
+OFPT_PACKET_IN (OF1.2): total_len=68 in_port=1 (via action) data_len=68
(unbuffered)

mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:51,dl_dst=50:54:00:00:00:07,mpls_label=10,mpls_tc=0,mpls_ttl=64,mpls_bos=1
     50 54 00 00 00 07 40 44-44 44 54 51 81 00 20 63
-0010  88 47 00 00 a1 40 45 00-00 28 00 00 00 00 40 06
-0020  f9 7c c0 a8 00 01 c0 a8-00 02 00 00 00 00 00 00
-0030  00 00 00 00 00 00 50 00-00 00 00 00 00 00 00 00
+0010  81 00 e0 58 88 47 00 00-a1 40 45 00 00 28 00 00
+0020  00 00 40 06 f9 7c c0 a8-00 01 c0 a8 00 02 00 00
+0030  00 00 00 00 00 00 00 00-00 00 50 00 00 00 00 00
+0040  00 00 00 00
   ])
 dnl Modified MPLS controller action.
@@ -3457,8 +3460,8 @@
mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:52,dl_dst=52:54:00:00:00:07,
   ])
 dnl Modified MPLS controller action.
-dnl In this test, the input packet is vlan-tagged, which should be
stripped
-dnl before we push the MPLS and VLAN tags.
+dnl In this test, the input packet is vlan-tagged, which should be kept
as
+dnl inner vlan.
   AT_CHECK([ovs-ofctl --protocols=OpenFlow12 monitor br0 65534 -m -P
standard --detach --pidfile 2> ofctl_monitor.log])
 for i in 1 2 3; do
@@ -3468,26 +3471,29 @@ OVS_WAIT_UNTIL([test `grep OFPT_PACKET_IN
ofctl_monitor.log | wc -l` -ge 3])
   OVS_APP_EXIT_AND_WAIT(ovs-ofctl)
 AT_CHECK([ofctl_strip < ofctl_monitor.log], [0], [dnl
-OFPT_PACKET_IN (OF1.2): total_len=64 in_port=1 (via action) data_len=64
(unbuffered)
+OFPT_PACKET_IN (OF1.2): total_len=68 in_port=1 (via action) data_len=68
(unbuffered)

mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:53,dl_dst=50:54:00:00:00:07,mpls_label=10,mpls_tc=0,mpls_ttl=64,mpls_bos=1
     50 54 00 00 00 07 40 44-44 44 54 53 81 00 20 63
-0010  88 47 00 00 a1 40 45 00-00 28 00 00 00 00 40 06
-0020  f9 7c c0 a8 00 01 c0 a8-00 02 00 00 00 00 00 00
-0030  00 00 00 00 00 00 50 00-00 00 00 00 00 00 00 00
+0010  81 00 e0 58 88 47 00 00-a1 40 45 00 00 28 00 00
+0020  00 00 40 06 f9 7c c0 a8-00 01 c0 a8 00 02 00 00
+0030  00 00 00 00 00 00 00 00-00 00 50 00 00 00 00 00
+0040  00 00 00 00
   dnl
-OFPT_PACKET_IN (OF1.2): total_len=64 in_port=1 (via action) data_len=64
(unbuffered)
+OFPT_PACKET_IN (OF1.2): total_len=68 in_port=1 (via action) data_len=68
(unbuffered)

mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:53,dl_dst=50:54:00:00:00:07,mpls_label=10,mpls_tc=0,mpls_ttl=64,mpls_bos=1
     50 54 00 00 00 07 40 44-44 44 54 53 81 00 20 63
-0010  88 47 00 00 a1 40 45 00-00 28 00 00 00 00 40 06
-0020  f9 7c c0 a8 00 01 c0 a8-00 02 00 00 00 00 00 00
-0030  00 00 00 00 00 00 50 00-00 00 00 00 00 00 00 00
+0010  81 00 e0 58 88 47 00 00-a1 40 45 00 00 28 00 00
+0020  00 00 40 06 f9 7c c0 a8-00 01 c0 a8 00 02 00 00
+0030  00 00 00 00 00 00 00 00-00 00 50 00 00 00 00 00
+0040  00 00 00 00
   dnl
-OFPT_PACKET_IN (OF1.2): total_len=64 in_port=1 (via action) data_len=64
(unbuffered)
+OFPT_PACKET_IN (OF1.2): total_len=68 in_

Re: [ovs-dev] [PATCH v4 4/4] tests: Set default max_vlan_headers

2016-07-15 Thread Thomas F Herbert

On 7/15/16 9:18 AM, Xiao Liang wrote:

On Fri, Jul 15, 2016 at 8:20 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

On 7/12/16 11:38 AM, Xiao Liang wrote:

Set default max_vlan_headers of test-odp and dpif-netdev to SIZE_MAX

Signed-off-by: Xiao Liang <shaw.l...@gmail.com>
---
   lib/dpif-netdev.c | 1 +
   tests/test-odp.c  | 1 +
   2 files changed, 2 insertions(+)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 26cfaff..13c10f6 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -90,6 +90,7 @@ static struct shash dp_netdevs
OVS_GUARDED_BY(dp_netdev_mutex)
   static struct vlog_rate_limit upcall_rl = VLOG_RATE_LIMIT_INIT(600,
600);

   static struct odp_support dp_netdev_support = {
+.max_vlan_headers = SIZE_MAX,
   .max_mpls_depth = SIZE_MAX,

I realize that this is just a test but max MPLS depth is 3 but max vlan
depth is 2. Should both these be set to the same value?

I see your kernel patch is going to support 2 VLAN headers. Do you
have any special consideration why it should be the same value as
MPLS?
No, it should not be the same value as MPLS. MPLS is supported with a 
max depth of 3 in OVS but 802.1ad has a max depth of 2 by spec. In your 
patch of the actual code you handle that correctly and I commented on 
that elsewhere. My comment above is limited to this test.



   .recirc = true,
   };
diff --git a/tests/test-odp.c b/tests/test-odp.c
index 8e4db09..735f2ff 100644
--- a/tests/test-odp.c
+++ b/tests/test-odp.c
@@ -62,6 +62,7 @@ parse_keys(bool wc_keys)
   .ct_zone = true,
   .ct_mark = true,
   .ct_label = true,
+.max_vlan_headers = SIZE_MAX,
   },
   };




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


Re: [ovs-dev] [PATCH v4 4/4] tests: Set default max_vlan_headers

2016-07-15 Thread Thomas F Herbert

On 7/12/16 11:38 AM, Xiao Liang wrote:

Set default max_vlan_headers of test-odp and dpif-netdev to SIZE_MAX

Signed-off-by: Xiao Liang 
---
  lib/dpif-netdev.c | 1 +
  tests/test-odp.c  | 1 +
  2 files changed, 2 insertions(+)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 26cfaff..13c10f6 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -90,6 +90,7 @@ static struct shash dp_netdevs OVS_GUARDED_BY(dp_netdev_mutex)
  static struct vlog_rate_limit upcall_rl = VLOG_RATE_LIMIT_INIT(600, 600);

  static struct odp_support dp_netdev_support = {
+.max_vlan_headers = SIZE_MAX,
  .max_mpls_depth = SIZE_MAX,
I realize that this is just a test but max MPLS depth is 3 but max vlan 
depth is 2. Should both these be set to the same value?

  .recirc = true,
  };
diff --git a/tests/test-odp.c b/tests/test-odp.c
index 8e4db09..735f2ff 100644
--- a/tests/test-odp.c
+++ b/tests/test-odp.c
@@ -62,6 +62,7 @@ parse_keys(bool wc_keys)
  .ct_zone = true,
  .ct_mark = true,
  .ct_label = true,
+.max_vlan_headers = SIZE_MAX,
  },
  };




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


Re: [ovs-dev] [PATCH v4 3/4] tests: Adjust VLAN+MPLS handling cases for QinQ

2016-07-15 Thread Thomas F Herbert

On 7/12/16 11:38 AM, Xiao Liang wrote:

When QinQ is supported, ingress VLAN are kept after push_vlan  actions,
so we should expect two VLAN headers.
Am I reading this wrong but it looks like the 0x8847 mpls type was 
dropped from the test packet below?


Signed-off-by: Xiao Liang 
---
  tests/ofproto-dpif.at | 128 +++---
  1 file changed, 70 insertions(+), 58 deletions(-)

diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index b7a7961..f50c885 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -3386,8 +3386,8 @@ 
mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:50,dl_dst=50:54:00:00:00:07,
  ])
  
  dnl Modified MPLS controller action.

-dnl In this test, the input packet is vlan-tagged, which should be stripped
-dnl before we push the MPLS and VLAN tags.
+dnl In this test, the input packet is vlan-tagged, which should be kept as
+dnl inner vlan.
  AT_CHECK([ovs-ofctl --protocols=OpenFlow12 monitor br0 65534 -m -P standard 
--detach --pidfile 2> ofctl_monitor.log])
  
  for i in 1 2 3; do

@@ -3397,26 +3397,29 @@ OVS_WAIT_UNTIL([test `grep OFPT_PACKET_IN 
ofctl_monitor.log | wc -l` -ge 3])
  OVS_APP_EXIT_AND_WAIT(ovs-ofctl)
  
  AT_CHECK([ofctl_strip < ofctl_monitor.log], [0], [dnl

-OFPT_PACKET_IN (OF1.2): total_len=64 in_port=1 (via action) data_len=64 
(unbuffered)
+OFPT_PACKET_IN (OF1.2): total_len=68 in_port=1 (via action) data_len=68 
(unbuffered)
  
mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:51,dl_dst=50:54:00:00:00:07,mpls_label=10,mpls_tc=0,mpls_ttl=64,mpls_bos=1
    50 54 00 00 00 07 40 44-44 44 54 51 81 00 20 63
-0010  88 47 00 00 a1 40 45 00-00 28 00 00 00 00 40 06
-0020  f9 7c c0 a8 00 01 c0 a8-00 02 00 00 00 00 00 00
-0030  00 00 00 00 00 00 50 00-00 00 00 00 00 00 00 00
+0010  81 00 e0 58 88 47 00 00-a1 40 45 00 00 28 00 00

What happened to 0x8847?

+0020  00 00 40 06 f9 7c c0 a8-00 01 c0 a8 00 02 00 00
+0030  00 00 00 00 00 00 00 00-00 00 50 00 00 00 00 00
+0040  00 00 00 00
  dnl
-OFPT_PACKET_IN (OF1.2): total_len=64 in_port=1 (via action) data_len=64 
(unbuffered)
+OFPT_PACKET_IN (OF1.2): total_len=68 in_port=1 (via action) data_len=68 
(unbuffered)
  
mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:51,dl_dst=50:54:00:00:00:07,mpls_label=10,mpls_tc=0,mpls_ttl=64,mpls_bos=1
    50 54 00 00 00 07 40 44-44 44 54 51 81 00 20 63
-0010  88 47 00 00 a1 40 45 00-00 28 00 00 00 00 40 06
-0020  f9 7c c0 a8 00 01 c0 a8-00 02 00 00 00 00 00 00
-0030  00 00 00 00 00 00 50 00-00 00 00 00 00 00 00 00
+0010  81 00 e0 58 88 47 00 00-a1 40 45 00 00 28 00 00
+0020  00 00 40 06 f9 7c c0 a8-00 01 c0 a8 00 02 00 00
+0030  00 00 00 00 00 00 00 00-00 00 50 00 00 00 00 00
+0040  00 00 00 00
  dnl
-OFPT_PACKET_IN (OF1.2): total_len=64 in_port=1 (via action) data_len=64 
(unbuffered)
+OFPT_PACKET_IN (OF1.2): total_len=68 in_port=1 (via action) data_len=68 
(unbuffered)
  
mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:51,dl_dst=50:54:00:00:00:07,mpls_label=10,mpls_tc=0,mpls_ttl=64,mpls_bos=1
    50 54 00 00 00 07 40 44-44 44 54 51 81 00 20 63
-0010  88 47 00 00 a1 40 45 00-00 28 00 00 00 00 40 06
-0020  f9 7c c0 a8 00 01 c0 a8-00 02 00 00 00 00 00 00
-0030  00 00 00 00 00 00 50 00-00 00 00 00 00 00 00 00
+0010  81 00 e0 58 88 47 00 00-a1 40 45 00 00 28 00 00
+0020  00 00 40 06 f9 7c c0 a8-00 01 c0 a8 00 02 00 00
+0030  00 00 00 00 00 00 00 00-00 00 50 00 00 00 00 00
+0040  00 00 00 00
  ])
  
  dnl Modified MPLS controller action.

@@ -3457,8 +3460,8 @@ 
mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:52,dl_dst=52:54:00:00:00:07,
  ])
  
  dnl Modified MPLS controller action.

-dnl In this test, the input packet is vlan-tagged, which should be stripped
-dnl before we push the MPLS and VLAN tags.
+dnl In this test, the input packet is vlan-tagged, which should be kept as
+dnl inner vlan.
  AT_CHECK([ovs-ofctl --protocols=OpenFlow12 monitor br0 65534 -m -P standard 
--detach --pidfile 2> ofctl_monitor.log])
  
  for i in 1 2 3; do

@@ -3468,26 +3471,29 @@ OVS_WAIT_UNTIL([test `grep OFPT_PACKET_IN 
ofctl_monitor.log | wc -l` -ge 3])
  OVS_APP_EXIT_AND_WAIT(ovs-ofctl)
  
  AT_CHECK([ofctl_strip < ofctl_monitor.log], [0], [dnl

-OFPT_PACKET_IN (OF1.2): total_len=64 in_port=1 (via action) data_len=64 
(unbuffered)
+OFPT_PACKET_IN (OF1.2): total_len=68 in_port=1 (via action) data_len=68 
(unbuffered)
  
mpls,dl_vlan=99,dl_vlan_pcp=1,dl_src=40:44:44:44:54:53,dl_dst=50:54:00:00:00:07,mpls_label=10,mpls_tc=0,mpls_ttl=64,mpls_bos=1
    50 54 00 00 00 07 40 44-44 44 54 53 81 00 20 63
-0010  88 47 00 00 a1 40 45 00-00 28 00 00 00 00 40 06
-0020  f9 7c c0 a8 00 01 c0 a8-00 02 00 00 00 00 00 00
-0030  00 00 00 00 00 00 50 00-00 00 00 00 00 00 00 00
+0010  81 00 e0 58 88 47 00 00-a1 40 45 00 00 28 00 00
+0020  00 00 40 06 f9 7c c0 a8-00 01 c0 a8 00 02 00 00
+0030  00 00 00 00 

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

2016-07-15 Thread Thomas F Herbert
Eric and Xiao, I am cc'ing this to the ovs-dev list because other 
reviewers who reviewed the kernel module may want to weigh in.


--TFH

On 7/12/16 2:17 PM, Eric Garver wrote:

This looks okay to me. This function was definitely missing a call to
parse_flow_mask_nlattrs() for the masked case. My only question is why
the original code has "if (unlikely(inner))".

Tom,
Can you speak to why this was checking for the inner tag?

Eric, please see my comments below.


On Tue, Jul 12, 2016 at 11:37:32PM +0800, Xiao Liang wrote:

Hi Eric,

Nice to hear that we could work together on this feature, and many
thanks for you effort. Hope we could get it work in the upstream soon.

By the way, for the kernel patch, I changed the last lines in
__parse_vlan_from_nlattrs:
 if (unlikely(inner)) {
 err = parse_flow_nlattrs(encap, a, en_attrs, log);
 if (err)
 return err;
 }
 return 0;
to:
 if (is_mask)
 err = parse_flow_mask_nlattrs(encap, a, en_attrs, log);
 else
 err = parse_flow_nlattrs(encap, a, en_attrs, log);

 return err;

Is it reasonable?
Yes, I think you are correct. The mask case seems to be missing from my 
V20 kernel module patch. Maybe when I refactored the code to use a 
common function for inner and outer vlans, I dropped the mask case. 
However, unlikely(inner) may be OK though because the single tagged vlan 
is the more common case.


A complication is that the OF spec says that matching should be on the 
outer tag only. (See section 7.2.3.8.) I don't recall but the intent of 
this code may have been to check for a mask on the outer tag only. 
However, it makes sense to code it in such a way that both tags are 
handled symmetrically.


Thanks,
Xiao


On Mon, Jul 11, 2016 at 9:45 PM, Eric Garver  wrote:

Hi Xiao,

I hope it's okay to unicast you. I wanted to let you know that I'm
working with Thomas to get 802.1ad support accepted upstream (OVS and
kernel).

Your patchset here looks well done. I will continue testing and
providing feedback.

Regarding the kernel, I'm currently in progress of rebasing, testing,
and fixing a couple issues. When I think it's ready I will post it to
the netdev mailing list for review.

Hopefully together we can get both user space and kernel support
upstream in the very near future.

Take care.
Eric.

On Sun, Jul 03, 2016 at 08:47:05AM +0800, Xiao Liang wrote:

These patches enable tpid 0x88a8, multiple VLAN headers, and add new vlan_mode 
"dot1q-tunnel". See commit message of patch1 for details.

v2: Add VLAN handling test cases for dot1q-tunnel vlan_mode.
 Adjust VLAN+MPLS test cases for multi VLAN.
v3: Set default max_vlan_headers of netdev and test-odp (fix test failure found 
by Tom).
 Fix loop condition when parsing mask in odp-util.c.
 Clean up comments.


Xiao Liang (4):
   Add support for 802.1ad (QinQ tunneling)
   tests: Add tests for QinQ VLAN handling
   tests: Adjust VLAN+MPLS handling cases for QinQ
   tests: Set default max_vlan_headers

  include/openvswitch/flow.h|  13 +-
  include/openvswitch/ofp-actions.h |  10 +-
  include/openvswitch/packets.h |   5 +
  lib/dpctl.c   |  29 ++-
  lib/dpif-netdev.c |   8 +-
  lib/flow.c| 109 ++
  lib/flow.h|   6 +-
  lib/match.c   |  47 ++--
  lib/meta-flow.c   |  22 +-
  lib/nx-match.c|  14 +-
  lib/odp-util.c| 227 
  lib/odp-util.h|   4 +-
  lib/ofp-actions.c |  61 +++---
  lib/ofp-util.c|  56 ++---
  lib/tnl-ports.c   |   2 +-
  ofproto/bond.c|   2 +-
  ofproto/ofproto-dpif-ipfix.c  |   6 +-
  ofproto/ofproto-dpif-rid.h|   2 +-
  ofproto/ofproto-dpif-sflow.c  |   4 +-
  ofproto/ofproto-dpif-xlate.c  | 436 ++
  ofproto/ofproto-dpif-xlate.h  |   6 +-
  ofproto/ofproto-dpif.c|  74 ++-
  ofproto/ofproto.h |   8 +-
  ovn/controller/pinctrl.c  |   5 +-
  tests/ofproto-dpif.at | 238 -
  tests/test-classifier.c   |  15 +-
  tests/test-odp.c  |   1 +
  utilities/ovs-ofctl.c |  29 +--
  vswitchd/bridge.c |  27 ++-
  vswitchd/vswitch.ovsschema|  16 +-
  vswitchd/vswitch.xml  |  31 +++
  31 files changed, 1002 insertions(+), 511 deletions(-)

--
2.9.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] [RFC PATCH v2 1/3] Add support for 802.1ad (QinQ tunneling)

2016-07-15 Thread Thomas F Herbert

On 7/2/16 10:17 AM, Xiao Liang wrote:

Hi Tom,

Thanks for your test and comments! Please see inline.

On Sat, Jul 2, 2016 at 1:34 AM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Xiao,

Thanks. I think this is nice work and I think it advances the ball.

It needs to be rebased to latest. I got some fuzz applying the patch.
It fails make check on latest master on a few tests: 403, 405, 1091, 1117,
1119 and 2092.

A primary problem is that I forgot to modify odp_flow_from_string,
which causes flow parse not working in tests. I'm checking if there
are other bugs and try to fix them.


I tested the patch with my kernel module patch and it works. I am passing
double tagged traffic through your patch now.
I like your approach of using an array to encode the vlans in the flow.
It seems to fail appctl trace. See http://pastebin.com/fn4AKL7q I think when
it parses the packet representation, it is confusing the dl_type with the
outer TPID.

I think the dl_type resembles eth_type in OpenFlow, which defined as
"ethernet type of the OpenFlow packet payload, after VLAN tags". In
implementation, it should be the innermost ethertype that the switch
can recognise. Suppose we support two VLAN headers, an IPv4 packet
with one or two VLAN headers will have dl_type 0x0800, and an IPv4
packet with more than two VLAN headers will have dl_type 0x8100 or
0x88a8. Seems we can't match outer TPIDs with OpenFlow.
I believe that the OF spec says the match should always be on the outer 
vlan. Currently OVS matches the inner vlan only because of short cuts in 
the code.

The flow probably should be:
in_port=2,vlan_tci=0x1064,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00
in_port=1,vlan_tci=0x13e7,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00
The dl_type doesn't matter in this case.
Ben Pfaff and I had a discussion at OVSCON 2015 about getting rid of the 
implied vlan detection on the CFI bit and moving to always detecting 
vlans by TPID. This would allow vlan with a 0 tci. I am sure he will 
weigh in on this.



I have a few other comments inline below.
It may also need some cleanup here and there and there may be some white
space introduced by patch.
I didn't fully understand the double tagged tunnel type and didn't
immediately have a way to test that.

--Tom


Add new port VLAN mode "dot1q-tunnel":
- Example:
  ovs-vsctl set Port p1 vlan_mode=dot1q-tunnel tag=100

Don't you mean dot1ad tunnel, below you show cvlans?

Here I followed naming convention of the Cisco CLI "switchport mode
dot1q-tunnel". By Q-in-Q it means dot1Q-in-dot1Q, and it's simply two
802.1q headers in a 802.1ad frame (see
https://en.wikipedia.org/wiki/IEEE_802.1ad). I don't have strong
preference for the name. It can be changed if it's too confusing.


+struct vlan_hdr vlan[FLOW_MAX_VLAN_HEADERS];/* 802.1q VLAN
headers */

Proper terminology would be just VLAN headers. When both vlans are present
that is 802.1ad not 802.1q.

As explained above. I will remove the "802.1q" because it's confusing.


I think encoding the vlans as an array is a good idea.

It is interesting that you put the vlan headers before the dl_type in the
order
they appear in the packet. I am concerned that the inner dl_type is not in
the same 64 bit word as the vlan_tci in the case of single vlans. I have
more commentary on this below.


Please see below.


--- a/lib/flow.c
+++ b/lib/flow.c
@@ -72,8 +72,6 @@ const uint8_t flow_segment_u64s[4] = {
 /* miniflow_extract() assumes the following to be true to optimize the
* extraction process. */
-ASSERT_SEQUENTIAL_SAME_WORD(dl_type, vlan_tci);
-

This bothers me. There is legacy behavior that does many matches on
Ethertype+tci. I struggled with this as well in my version of the patch
which encoded both TPIDs. I am concerned that this patch to double tagged
vlans may substantially decrease performance of legacy single tagged vlans.
In my latest patch, when I encoded a single vlan I put it in the inner
position in flow even though that was contradictory to the idea that the
flow fields should be in order that they were found in the packet. Even
though you use an array for encoding the vlans, they both are always encoded
in the flow. We have to think about where the single vlan should be encoded.

This is my understanding (not very sure, please correct me if wrong):
The performance optimization is only relevant to miniflow_extract and
expand. This assertion is used by miniflow_extract so that it can push
dl_type and vlan_tci sequentially without any padding. There's no
problem with functionality as long as flow and miniflow structures are
in sync (see the miniflow_pad_to_64 added). There is performance
impact because more data are pushed into miniflow, but it shouldn't be
too much.
Well, we don't know about the performance impact. There could be 
significant impact to DPDK netdev. When matches fail in the EMC, they go 
to the miniflow. This could cause the layer 2 fl

Re: [ovs-dev] [RFC PATCH v2 00/13] Add Network Service Header Support

2016-07-13 Thread Thomas F Herbert



On 7/13/16 10:55 AM, Jiri Benc wrote:

On Wed, 13 Jul 2016 07:35:59 -0700, Jesse Gross wrote:

I think history tells us how this will end - similar to IPv4 options,
implementations that don't implement TLVs will become deployed and
then when there is a use for them it's no longer possible. Since I
don't want OVS to have a half implementation or contribute to this
issue, I'd like to see the whole protocol implemented before I apply
anything.

I see a big difference between this and IPv4. While in IPv4, the
options are extension to existing headers, here we're talking about a
completely different payload. It's more comparable to http vs. ftp (of
course, it's a poor comparison, but I hope it illustrates at least a
bit what I mean).

If NSH takes off (and it's a big "if" in my opinion), it's also well
possible we'll see more metadata types. The spec is pretty much open to
this. Obviously, the authors are aware of that and type 2 is optional.
As I guess will be type 3 and type 4 and whatever.

It's pretty much inevitable that applications and deployments built
around MD type 1 won't support MD type 2. And vice versa. This is
regardless whether ovs supports MD type 2 or not. They're just a
different protocol.

In my opinion, starting with MD type 1 is a good way to reduce the
initial scope. I see no problem with adding MD type 2 later.

+1


  Jiri


--
*Thomas F Herbert*
SDN Group
Office of Technology
*Red Hat*
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 1/2] doc: Refactor DPDK install documentation

2016-06-09 Thread Thomas F Herbert

On 5/9/16 2:32 AM, Bhanuprakash Bodireddy wrote:

Refactor the INSTALL.DPDK in to two documents named INSTALL.DPDK and
INSTALL.DPDK-ADVANCED. While INSTALL.DPDK document shall facilitate the
novice user in setting up the OVS DPDK and running it out of box, the
ADVANCED document is targeted at expert users looking for the optimum
performance running dpdk datapath.

This commit updates INSTALL.DPDK.md document.

Signed-off-by: Bhanuprakash Bodireddy 
---
  INSTALL.DPDK.md | 1193 +++
  1 file changed, 331 insertions(+), 862 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 93f92e4..bf646bf 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -1,1001 +1,470 @@
-Using Open vSwitch with DPDK
-
+OVS DPDK INSTALL GUIDE
+
  
-Open vSwitch can use Intel(R) DPDK lib to operate entirely in

-userspace. This file explains how to install and use Open vSwitch in
-such a mode.
+## Contents
  
-The DPDK support of Open vSwitch is considered experimental.

-It has not been thoroughly tested.
+1. [Overview](#overview)
+2. [Building and Installation](#build)
+3. [Setup OVS DPDK datapath](#ovssetup)
+4. [DPDK in the VM](#builddpdk)
+5. [OVS Testcases](#ovstc)
+6. [Limitations ](#ovslimits)
  
-This version of Open vSwitch should be built manually with `configure`

-and `make`.
+##  1. Overview
  
-OVS needs a system with 1GB hugepages support.

+Open vSwitch can use DPDK lib to operate entirely in userspace.
+This file provides information on installation and use of Open vSwitch
+using DPDK datapath.  This version of Open vSwitch should be built manually
+with `configure` and `make`.
  
-Building and Installing:

-
+The DPDK support of Open vSwitch is considered 'experimental'.
  
-Required: DPDK 16.04

-Optional (if building with vhost-cuse): `fuse`, `fuse-devel` (`libfuse-dev`
-on Debian/Ubuntu)
+### Prerequisites
  
-1. Configure build & install DPDK:

-  1. Set `$DPDK_DIR`
+* Required: DPDK 16.04
+* Hardware: [DPDK Supported NICs] when physical ports in use
  
- ```

- export DPDK_DIR=/usr/src/dpdk-16.04
- cd $DPDK_DIR
- ```
-
-  2. Then run `make install` to build and install the library.
- For default install without IVSHMEM:
-
- `make install T=x86_64-native-linuxapp-gcc DESTDIR=install`
-
- To include IVSHMEM (shared memory):
-
- `make install T=x86_64-ivshmem-linuxapp-gcc DESTDIR=install`
-
- For further details refer to http://dpdk.org/
-
-2. Configure & build the Linux kernel:
-
-   Refer to intel-dpdk-getting-started-guide.pdf for understanding
-   DPDK kernel requirement.
-
-3. Configure & build OVS:
-
-   * Non IVSHMEM:
-
- `export DPDK_BUILD=$DPDK_DIR/x86_64-native-linuxapp-gcc/`
-
-   * IVSHMEM:
-
- `export DPDK_BUILD=$DPDK_DIR/x86_64-ivshmem-linuxapp-gcc/`
-
-   ```
-   cd $(OVS_DIR)/
-   ./boot.sh
-   ./configure --with-dpdk=$DPDK_BUILD [CFLAGS="-g -O2 -Wno-cast-align"]
-   make
-   ```
-
-   Note: 'clang' users may specify the '-Wno-cast-align' flag to suppress DPDK 
cast-align warnings.
-
-To have better performance one can enable aggressive compiler optimizations and
-use the special instructions(popcnt, crc32) that may not be available on all
-machines. Instead of typing `make`, type:
-
-`make CFLAGS='-O3 -march=native'`
-
-Refer to [INSTALL.userspace.md] for general requirements of building userspace 
OVS.
-
-Using the DPDK with ovs-vswitchd:
--
-
-1. Setup system boot
-   Add the following options to the kernel bootline:
-
-   `default_hugepagesz=1GB hugepagesz=1G hugepages=1`
-
-2. Setup DPDK devices:
-
-   DPDK devices can be setup using either the VFIO (for DPDK 1.7+) or UIO
-   modules. UIO requires inserting an out of tree driver igb_uio.ko that is
-   available in DPDK. Setup for both methods are described below.
-
-   * UIO:
- 1. insert uio.ko: `modprobe uio`
- 2. insert igb_uio.ko: `insmod $DPDK_BUILD/kmod/igb_uio.ko`
- 3. Bind network device to igb_uio:
- `$DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio eth1`
-
-   * VFIO:
-
- VFIO needs to be supported in the kernel and the BIOS. More information
- can be found in the [DPDK Linux GSG].
-
- 1. Insert vfio-pci.ko: `modprobe vfio-pci`
- 2. Set correct permissions on vfio device: `sudo /usr/bin/chmod a+x 
/dev/vfio`
-and: `sudo /usr/bin/chmod 0666 /dev/vfio/*`
- 3. Bind network device to vfio-pci:
-`$DPDK_DIR/tools/dpdk_nic_bind.py --bind=vfio-pci eth1`
-
-3. Mount the hugetable filesystem
-
-   `mount -t hugetlbfs -o pagesize=1G none /dev/hugepages`
-
-   Ref to http://www.dpdk.org/doc/quick-start for verifying DPDK setup.
-
-4. Follow the instructions in [INSTALL.md] to install only the
-   userspace daemons and utilities (via 'make install').
-   1. First time only db creation (or clearing):
-
-  ```
-  mkdir -p 

Re: [ovs-dev] [PATCH 1/2] doc: Refactor DPDK install documentation

2016-05-13 Thread Thomas F Herbert

On 5/13/16 11:55 AM, Aaron Conole wrote:

Bhanuprakash Bodireddy  writes:


Refactor the INSTALL.DPDK in to two documents named INSTALL.DPDK and
INSTALL.DPDK-ADVANCED. While INSTALL.DPDK document shall facilitate the
novice user in setting up the OVS DPDK and running it out of box, the
ADVANCED document is targeted at expert users looking for the optimum
performance running dpdk datapath.

This commit updates INSTALL.DPDK.md document.

Signed-off-by: Bhanuprakash Bodireddy 
---
  INSTALL.DPDK.md | 1193 +++
  1 file changed, 331 insertions(+), 862 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 93f92e4..bf646bf 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -1,1001 +1,470 @@
-Using Open vSwitch with DPDK
-
+OVS DPDK INSTALL GUIDE
+

-Open vSwitch can use Intel(R) DPDK lib to operate entirely in
-userspace. This file explains how to install and use Open vSwitch in
-such a mode.
+## Contents

-The DPDK support of Open vSwitch is considered experimental.
-It has not been thoroughly tested.
+1. [Overview](#overview)
+2. [Building and Installation](#build)
+3. [Setup OVS DPDK datapath](#ovssetup)
+4. [DPDK in the VM](#builddpdk)
+5. [OVS Testcases](#ovstc)
+6. [Limitations ](#ovslimits)

-This version of Open vSwitch should be built manually with `configure`
-and `make`.
+##  1. Overview

-OVS needs a system with 1GB hugepages support.
+Open vSwitch can use DPDK lib to operate entirely in userspace.
+This file provides information on installation and use of Open vSwitch
+using DPDK datapath.  This version of Open vSwitch should be built manually
+with `configure` and `make`.

-Building and Installing:
-
+The DPDK support of Open vSwitch is considered 'experimental'.

-Required: DPDK 16.04
-Optional (if building with vhost-cuse): `fuse`, `fuse-devel` (`libfuse-dev`
-on Debian/Ubuntu)
+### Prerequisites

-1. Configure build & install DPDK:
-  1. Set `$DPDK_DIR`
+* Required: DPDK 16.04
+* Hardware: [DPDK Supported NICs] when physical ports in use

- ```
- export DPDK_DIR=/usr/src/dpdk-16.04
- cd $DPDK_DIR
- ```
-
-  2. Then run `make install` to build and install the library.
- For default install without IVSHMEM:
-
- `make install T=x86_64-native-linuxapp-gcc DESTDIR=install`
-
- To include IVSHMEM (shared memory):
-
- `make install T=x86_64-ivshmem-linuxapp-gcc DESTDIR=install`
-
- For further details refer to http://dpdk.org/
-
-2. Configure & build the Linux kernel:
-
-   Refer to intel-dpdk-getting-started-guide.pdf for understanding
-   DPDK kernel requirement.
-
-3. Configure & build OVS:
-
-   * Non IVSHMEM:
-
- `export DPDK_BUILD=$DPDK_DIR/x86_64-native-linuxapp-gcc/`
-
-   * IVSHMEM:
-
- `export DPDK_BUILD=$DPDK_DIR/x86_64-ivshmem-linuxapp-gcc/`
-
-   ```
-   cd $(OVS_DIR)/
-   ./boot.sh
-   ./configure --with-dpdk=$DPDK_BUILD [CFLAGS="-g -O2 -Wno-cast-align"]
-   make
-   ```
-
-   Note: 'clang' users may specify the '-Wno-cast-align' flag to suppress DPDK 
cast-align warnings.
-
-To have better performance one can enable aggressive compiler optimizations and
-use the special instructions(popcnt, crc32) that may not be available on all
-machines. Instead of typing `make`, type:
-
-`make CFLAGS='-O3 -march=native'`
-
-Refer to [INSTALL.userspace.md] for general requirements of building userspace 
OVS.
-
-Using the DPDK with ovs-vswitchd:
--
-
-1. Setup system boot
-   Add the following options to the kernel bootline:
-
-   `default_hugepagesz=1GB hugepagesz=1G hugepages=1`
-
-2. Setup DPDK devices:
-
-   DPDK devices can be setup using either the VFIO (for DPDK 1.7+) or UIO
-   modules. UIO requires inserting an out of tree driver igb_uio.ko that is
-   available in DPDK. Setup for both methods are described below.
-
-   * UIO:
- 1. insert uio.ko: `modprobe uio`
- 2. insert igb_uio.ko: `insmod $DPDK_BUILD/kmod/igb_uio.ko`
- 3. Bind network device to igb_uio:
- `$DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio eth1`
-
-   * VFIO:
-
- VFIO needs to be supported in the kernel and the BIOS. More information
- can be found in the [DPDK Linux GSG].
-
- 1. Insert vfio-pci.ko: `modprobe vfio-pci`
- 2. Set correct permissions on vfio device: `sudo /usr/bin/chmod a+x 
/dev/vfio`
-and: `sudo /usr/bin/chmod 0666 /dev/vfio/*`
- 3. Bind network device to vfio-pci:
-`$DPDK_DIR/tools/dpdk_nic_bind.py --bind=vfio-pci eth1`
-
-3. Mount the hugetable filesystem
-
-   `mount -t hugetlbfs -o pagesize=1G none /dev/hugepages`
-
-   Ref to http://www.dpdk.org/doc/quick-start for verifying DPDK setup.
-
-4. Follow the instructions in [INSTALL.md] to install only the
-   userspace daemons and utilities (via 'make install').
-   1. First time only db creation (or clearing):
-

Re: [ovs-dev] [PATCH 2/2] doc: Refactor DPDK install guide, add ADVANCED doc

2016-05-12 Thread Thomas F Herbert

On 5/9/16 2:32 AM, Bhanuprakash Bodireddy wrote:

Add INSTALL.DPDK-ADVANCED document that is forked off from original
INSTALL.DPDK guide. This document is targeted at users looking for
optimum performance on OVS using dpdk datapath.

Thanks for this effort.


Signed-off-by: Bhanuprakash Bodireddy 
---
  INSTALL.DPDK-ADVANCED.md | 809 +++
  1 file changed, 809 insertions(+)
  create mode 100644 INSTALL.DPDK-ADVANCED.md

diff --git a/INSTALL.DPDK-ADVANCED.md b/INSTALL.DPDK-ADVANCED.md
new file mode 100644
index 000..dd09d36
--- /dev/null
+++ b/INSTALL.DPDK-ADVANCED.md
@@ -0,0 +1,809 @@
+OVS DPDK ADVANCED INSTALL GUIDE
+=
+
+## Contents
+
+1. [Overview](#overview)
+2. [Building Shared Library](#build)
+3. [System configuration](#sysconf)
+4. [Performance Tuning](#perftune)
+5. [OVS Testcases](#ovstc)
+6. [Vhost Walkthrough](#vhost)
+7. [QOS](#qos)
+8. [Static Code Analysis](#staticanalyzer)
+9. [Vsperf](#vsperf)
+
+##  1. Overview
+
+The Advanced Install Guide explains how to improve OVS performance using
+DPDK datapath. This guide also provides information on tuning, system 
configuration,
+troubleshooting, static code analysis and testcases.
+
+##  2. Building Shared Library
+
+DPDK can be built as static or shared library and shall be linked by 
applications
+using DPDK datapath. The section lists steps to build shared library and 
dynamically
+link DPDK against OVS.
+
+Note: Minor performance loss is seen with OVS when using shared DPDK library as
+compared to static library.
+
+Check section 2.2, 2.3 of INSTALL.DPDK on download instructions
+for DPDK and OVS.
+
+  * Configure the DPDK library
+
+  Set `CONFIG_RTE_BUILD_SHARED_LIB=y` in `config/common_base`
+  to generate shared DPDK library
+
+
+  * Build and install DPDK
+
+For Default install (without IVSHMEM), set `export 
DPDK_TARGET=x86_64-native-linuxapp-gcc`
+For IVSHMEM case, set `export DPDK_TARGET=x86_64-ivshmem-linuxapp-gcc`
+
+```
+export DPDK_DIR=/usr/src/dpdk-16.04
+export DPDK_BUILD=$DPDK_DIR/$DPDK_TARGET
+make install T=$DPDK_TARGET DESTDIR=install
+```
+
+  * Build, Install and Setup OVS.
+
+  Export the DPDK shared library location and setup OVS as listed in
+  section 3.3 of INSTALL.DPDK.
+
+  `export LD_LIBRARY_PATH=$DPDK_DIR/x86_64-native-linuxapp-gcc/lib`
+
+##  3. System Configuration
+
+To achieve optimal OVS performance, the system can be configured and that 
includes
+BIOS tweaks, Grub cmdline additions, better understanding of NUMA nodes and
+apt selection of PCIe slots for NIC placement.
+
+### 3.1 Recommended BIOS settings
+
+  ```
+  | Settings  | values| comments
+  |---|---|---
+  | C3 power state| Disabled  | -
+  | C6 power state| Disabled  | -
+  | MLC Streamer  | Enabled   | -
+  | MLC Spacial prefetcher| Enabled   | -
+  | DCU Data prefetcher   | Enabled   | -
+  | DCA   | Enabled   | -
+  | CPU power and performance | Performance -
+  | Memory RAS and perf   |   | -
+config-> NUMA optimized   | Enabled   | -
+  ```
+
+### 3.2 PCIe Slot Selection
+
+The fastpath performance also depends on factors like the NIC placement,
+Channel speeds between PCIe slot and CPU, proximity of PCIe slot to the CPU
+cores running DPDK application. Listed below are the steps to identify
+right PCIe slot.
+
+- Retrieve host details using cmd `dmidecode -t baseboard | grep "Product 
Name"`
+- Download the technical specification for Product listed eg: S2600WT2.
+- Check the Product Architecture Overview on the Riser slot placement,
+  CPU sharing info and also PCIe channel speeds.
+
+  example: On S2600WT, CPU1 and CPU2 share Riser Slot 1 with Channel speed 
between
+  CPU1 and Riser Slot1 at 32GB/s, CPU2 and Riser Slot1 at 16GB/s. Running DPDK 
app
+  on CPU1 cores and NIC inserted in to Riser card Slots will optimize OVS 
performance
+  in this case.
+
+- Check the Riser Card #1 - Root Port mapping information, on the available 
slots
+  and individual bus speeds. In S2600WT slot 1, slot 2 has high bus speeds and 
are
+  potential slots for NIC placement.
+
+### 3.3 Setup Hugepages

Advanced Hugepage setup.

+
Basic huge page setup for 2MB huge pages is covered in INSTALL.DPDK.md. 
This section

+  1. Allocate Huge pages
+
+ For persistent allocation of huge pages, add the following options to the 
kernel bootline
+ - 2MB huge pages:
+
+   Add `hugepages=N`
+
+ - 1G huge pages:
+
+   Add `default_hugepagesz=1GB hugepagesz=1G hugepages=N`
+
+   For platforms supporting multiple huge page sizes, Add options
+
+   `default_hugepagesz= hugepagesz= hugepages=N`
+   where 'N' = Number of huge pages requested, 'size' = huge page size,
+   optional suffix [kKmMgG]
+
+For run-time allocation of huge pages
+
+ - 2MB huge 

Re: [ovs-dev] [PATCH 1/2] doc: Refactor DPDK install documentation

2016-05-12 Thread Thomas F Herbert

On 5/9/16 2:32 AM, Bhanuprakash Bodireddy wrote:

Refactor the INSTALL.DPDK in to two documents named INSTALL.DPDK and
INSTALL.DPDK-ADVANCED. While INSTALL.DPDK document shall facilitate the
novice user in setting up the OVS DPDK and running it out of box, the
ADVANCED document is targeted at expert users looking for the optimum
performance running dpdk datapath.

This commit updates INSTALL.DPDK.md document.

Signed-off-by: Bhanuprakash Bodireddy 
---
  INSTALL.DPDK.md | 1193 +++
  1 file changed, 331 insertions(+), 862 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 93f92e4..bf646bf 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -1,1001 +1,470 @@
-Using Open vSwitch with DPDK
-
+OVS DPDK INSTALL GUIDE
+

-Open vSwitch can use Intel(R) DPDK lib to operate entirely in
-userspace. This file explains how to install and use Open vSwitch in
-such a mode.
+## Contents

-The DPDK support of Open vSwitch is considered experimental.
-It has not been thoroughly tested.
+1. [Overview](#overview)
+2. [Building and Installation](#build)
+3. [Setup OVS DPDK datapath](#ovssetup)
I wonder if the following 3 sections be in the advanced guide? with a 
note here to refer to the advanced guide for configuration in the VM, 
testcases and limitations?

+4. [DPDK in the VM](#builddpdk)
+5. [OVS Testcases](#ovstc)
+6. [Limitations ](#ovslimits)

-This version of Open vSwitch should be built manually with `configure`
-and `make`.
+##  1. Overview

-OVS needs a system with 1GB hugepages support.
+Open vSwitch can use DPDK lib to operate entirely in userspace.
+This file provides information on installation and use of Open vSwitch
+using DPDK datapath.  This version of Open vSwitch should be built manually
+with `configure` and `make`.

-Building and Installing:
-
+The DPDK support of Open vSwitch is considered 'experimental'.

Isn't it time to remove this statement and not just put the word in quotes?


-Required: DPDK 16.04
-Optional (if building with vhost-cuse): `fuse`, `fuse-devel` (`libfuse-dev`
-on Debian/Ubuntu)
+### Prerequisites

-1. Configure build & install DPDK:
-  1. Set `$DPDK_DIR`
+* Required: DPDK 16.04
+* Hardware: [DPDK Supported NICs] when physical ports in use

- ```
- export DPDK_DIR=/usr/src/dpdk-16.04
- cd $DPDK_DIR
- ```
-
-  2. Then run `make install` to build and install the library.
- For default install without IVSHMEM:
-
- `make install T=x86_64-native-linuxapp-gcc DESTDIR=install`
-
- To include IVSHMEM (shared memory):
-
- `make install T=x86_64-ivshmem-linuxapp-gcc DESTDIR=install`
-
- For further details refer to http://dpdk.org/
-
-2. Configure & build the Linux kernel:
-
-   Refer to intel-dpdk-getting-started-guide.pdf for understanding
-   DPDK kernel requirement.
-
-3. Configure & build OVS:
-
-   * Non IVSHMEM:
-
- `export DPDK_BUILD=$DPDK_DIR/x86_64-native-linuxapp-gcc/`
-
-   * IVSHMEM:
-
- `export DPDK_BUILD=$DPDK_DIR/x86_64-ivshmem-linuxapp-gcc/`
-
-   ```
-   cd $(OVS_DIR)/
-   ./boot.sh
-   ./configure --with-dpdk=$DPDK_BUILD [CFLAGS="-g -O2 -Wno-cast-align"]
-   make
-   ```
-
-   Note: 'clang' users may specify the '-Wno-cast-align' flag to suppress DPDK 
cast-align warnings.
-
-To have better performance one can enable aggressive compiler optimizations and
-use the special instructions(popcnt, crc32) that may not be available on all
-machines. Instead of typing `make`, type:
-
-`make CFLAGS='-O3 -march=native'`
-
-Refer to [INSTALL.userspace.md] for general requirements of building userspace 
OVS.
-
-Using the DPDK with ovs-vswitchd:
--
-
-1. Setup system boot
-   Add the following options to the kernel bootline:
-
-   `default_hugepagesz=1GB hugepagesz=1G hugepages=1`
-
-2. Setup DPDK devices:
-
-   DPDK devices can be setup using either the VFIO (for DPDK 1.7+) or UIO
-   modules. UIO requires inserting an out of tree driver igb_uio.ko that is
-   available in DPDK. Setup for both methods are described below.
-
-   * UIO:
- 1. insert uio.ko: `modprobe uio`
- 2. insert igb_uio.ko: `insmod $DPDK_BUILD/kmod/igb_uio.ko`
- 3. Bind network device to igb_uio:
- `$DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio eth1`
-
-   * VFIO:
-
- VFIO needs to be supported in the kernel and the BIOS. More information
- can be found in the [DPDK Linux GSG].
-
- 1. Insert vfio-pci.ko: `modprobe vfio-pci`
- 2. Set correct permissions on vfio device: `sudo /usr/bin/chmod a+x 
/dev/vfio`
-and: `sudo /usr/bin/chmod 0666 /dev/vfio/*`
- 3. Bind network device to vfio-pci:
-`$DPDK_DIR/tools/dpdk_nic_bind.py --bind=vfio-pci eth1`
-
-3. Mount the hugetable filesystem
-
-   `mount -t hugetlbfs -o pagesize=1G none /dev/hugepages`
-
-   Ref to http://www.dpdk.org/doc/quick-start for verifying 

Re: [ovs-dev] [PATCH v3 0/2] doc: Refactor DPDK install guide

2016-05-12 Thread Thomas F Herbert

On 5/9/16 2:32 AM, Bhanuprakash Bodireddy wrote:

This patchset refactors the present INSTALL.DPDK.md guide.

The INSTALL guide is split in to two documents named INSTALL.DPDK and
INSTALL.DPDK-ADVANCED. The former document is simplified with emphasis
on installation, basic testcases and targets novice users. Sections on
system configuration, performance tuning, vhost walkthrough are moved
to DPDK-ADVANCED guide.

and IVSHMEM is moved too.

DPDK can be complex to install and configure to optimize OVS for best 
performance but it is relatively easy to set up for simple test cases. 
This patch is the right step to present the install information in 
separate parts. Most users won't need to refer to INSTALL.DPDK-ADVANCED.md.

+1

Reviewers can see these doc changes in rendered form in this fork:
https://github.com/bbodired/ovs/blob/master/INSTALL.DPDK.md
https://github.com/bbodired/ovs/blob/master/INSTALL.DPDK-ADVANCED.md


v1->v2:
- Rebased
- Update DPDK version to 16.04
- Add vsperf section in ADVANCED Guide

v2->v3:
- Rebased

Bhanuprakash Bodireddy (2):
   doc: Refactor DPDK install documentation
   doc: Refactor DPDK install guide, add ADVANCED doc

  INSTALL.DPDK-ADVANCED.md |  809 +++
  INSTALL.DPDK.md  | 1193 +-
  2 files changed, 1140 insertions(+), 862 deletions(-)
  create mode 100644 INSTALL.DPDK-ADVANCED.md



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


Re: [ovs-dev] [ovs-discuss] [announce] driverctl: utility for persistent alternative driver binding

2016-02-19 Thread Thomas F Herbert

On 12/14/15 6:42 AM, Gray, Mark D wrote:



-Original Message-
From: Panu Matilainen [mailto:pmati...@redhat.com]
Sent: Tuesday, December 8, 2015 12:05 PM
To: Gray, Mark D; d...@dpdk.org; us...@dpdk.org; dev@openvswitch.org;
disc...@openvswitch.org
Subject: Re: [ovs-discuss] [announce] driverctl: utility for persistent
alternative driver binding

On 12/04/2015 05:44 PM, Gray, Mark D wrote:

I welcome this initiative, one question below:


-Original Message-
From: discuss [mailto:discuss-boun...@openvswitch.org] On Behalf Of
Panu Matilainen
Sent: Friday, December 4, 2015 10:54 AM
To: d...@dpdk.org; us...@dpdk.org; dev@openvswitch.org;
disc...@openvswitch.org
Subject: [ovs-discuss] [announce] driverctl: utility for persistent
alternative driver binding

Hi all,

While this is not directly related to DPDK or OVS, it is potentially
useful for users of both, so excuse me for cross-posting.

Quoting from the project README (for the full text see
http://laiskiainen.org/git/?p=driverctl.git;a=blob_plain;f=README)

   > driverctl is a tool for manipulating and inspecting the system
   > device driver choices.
   >
   > Devices are normally assigned to their sole designated kernel driver
   > by default. However in some situations it may be desireable to
   > override that default, for example to try an older driver to
   > work around a regression in a driver or to try an experimental
   > alternative driver. Another common use-case is pass-through
   > drivers and driver stubs to allow userspace to drive the device,
   > such as in case of virtualization.
   >
   > driverctl integrates with udev to support overriding
   > driver selection for both cold- and hotplugged devices from the
   > moment of discovery, but can also change already assigned drivers,
   > assuming they are not in use by the system. The driver overrides
   > created by driverctl are persistent across system reboots
   > by default.
   >
   > Usage
   > -
   >
   > Find devices currently driven by ixgbe driver:
   >
   > # driverctl -v list-devices | grep ixgbe
   > :01:00.0 ixgbe (Ethernet 10G 4P X520/I350 rNDC)
   > :01:00.1 ixgbe (Ethernet 10G 4P X520/I350 rNDC)
   >
   > Change them to use the vfio-pci driver:
   > # driverctl set-override :01:00.0 vfio-pci
   > # driverctl set-override :01:00.1 vfio-pci
   >
   > Find devices with driver overrides:
   > # driverctl -v list-devices|grep \\*
   > :01:00.0 vfio-pci [*] (Ethernet 10G 4P X520/I350 rNDC)
   > :01:00.1 vfio-pci [*] (Ethernet 10G 4P X520/I350 rNDC)
   >
   > Remove the override from slot :01:00.1:
   > # driverctl unset-override :01:00.1

DPDK of course has its own dpdk_nic_bind(.py) tool for this purpose,
the main differences to driverctl are:
- driverctl bindings are persistent across system boots

   [Gray, Mark D] This is great!

Will this integrate with, for example in Red Hat-based systems,
/etc/sysconfig/network-scripts/ifcfg-X? In DPDK, could we then potentially

reference devices by that (arbitrary) name?

driverctl is not specific to NICs so network-scripts integration is out of 
scope.


I forgot that point. It makes sense.


That aside, maybe I'm missing something but I'm not sure what there is to
integrate with since DPDK ports are ultimately application specific.
For OVS I've sent a patch to support managing OVS DPDK ports via
network-scripts:
http://openvswitch.org/pipermail/dev/2015-December/062850.html

Thanks, I wasn’t familiar with this work but this is a good approach.

Yes, it is a good approach but it doesn't address the issue below.



. Panu -


What I am thinking would be an ideal end state for OVS would be the possibility 
to add a port using ovs-vsctl add-port referencing the device name

ovs-vsctl add-port p1p2

If dpdk was enabled, then OVS could query something(?) to determine which 
physical interface this name actually referred to and then from that figure out 
what dpdk port number it referred to.

+1



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


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


Re: [ovs-dev] [PATCH] rhel: Clarify instructions for RHEL 7.

2016-01-29 Thread Thomas F Herbert



On 1/28/16 3:46 PM, Russell Bryant wrote:

On 01/28/2016 02:55 PM, Russell Bryant wrote:

On 01/28/2016 12:56 PM, Guru Shetty wrote:


On 28 January 2016 at 08:46, Russell Bryant > wrote:

 The rpm build instructions did not clarify what spec files were to be
 used for RHEL 7 and its derivatives.  Clarify that you're actually
 supposed to use the spec files called "fedora" for RHEL 7 right now.

 Update references to Fedora versions to reflect the current release
 (23), as neither 16 or 17 are supported releases anymore.

 Signed-off-by: Russell Bryant >


I think openvswitch-kmod-fedora has been an orphan for a long time. I
think that is because the users in fedora get a more upto date kernel
module from Linux kernel itself. It probably still builds, but it will
likely not be picked up with modprobe because there is till the native
kernel module.

It seems worth keeping for testing WIP features, at least.

It doesn't build for me, though.  The error I get is that it's trying to
create a directory outside of the $RPM_BUILD_ROOT during "make
modules_install".

I'm building using:

$ rpmbuild -bb -D "kversion `uname -r`" rhel/openvswitch-kmod-fedora.spec

...

mkdir: cannot create directory
'/lib/modules/4.3.3-300.fc23.x86_64/extra': Permission denied


I was looking at how to pass $RPM_BUILD_ROOT into there properly, but I
got distracted before I got it to work.


I just posted another patch which makes it build on Fedora 23 for me, at
least.
Kmod builds and installs perfectly on Centos7 using Fedora spec without 
patch.




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


Re: [ovs-dev] [PATCH] rhel: Clarify instructions for RHEL 7.

2016-01-29 Thread Thomas F Herbert



On 1/29/16 12:43 PM, Russell Bryant wrote:

On 01/29/2016 12:04 PM, Thomas F Herbert wrote:


On 1/28/16 3:46 PM, Russell Bryant wrote:

On 01/28/2016 02:55 PM, Russell Bryant wrote:

On 01/28/2016 12:56 PM, Guru Shetty wrote:

On 28 January 2016 at 08:46, Russell Bryant <russ...@ovn.org
<mailto:russ...@ovn.org>> wrote:

  The rpm build instructions did not clarify what spec files were
to be
  used for RHEL 7 and its derivatives.  Clarify that you're actually
  supposed to use the spec files called "fedora" for RHEL 7 right
now.

  Update references to Fedora versions to reflect the current
release
  (23), as neither 16 or 17 are supported releases anymore.

  Signed-off-by: Russell Bryant <russ...@ovn.org
<mailto:russ...@ovn.org>>


I think openvswitch-kmod-fedora has been an orphan for a long time. I
think that is because the users in fedora get a more upto date kernel
module from Linux kernel itself. It probably still builds, but it will
likely not be picked up with modprobe because there is till the native
kernel module.

It seems worth keeping for testing WIP features, at least.

It doesn't build for me, though.  The error I get is that it's trying to
create a directory outside of the $RPM_BUILD_ROOT during "make
modules_install".

I'm building using:

$ rpmbuild -bb -D "kversion `uname -r`"
rhel/openvswitch-kmod-fedora.spec

...

mkdir: cannot create directory
'/lib/modules/4.3.3-300.fc23.x86_64/extra': Permission denied


I was looking at how to pass $RPM_BUILD_ROOT into there properly, but I
got distracted before I got it to work.


I just posted another patch which makes it build on Fedora 23 for me, at
least.

Kmod builds and installs perfectly on Centos7 using Fedora spec without
patch.

How did you build it?  Did you run rpmbuild directly?  If so, did you
run it as root?

Running rpmbuild as root with the current spec will install the kernel
modules into your system's /lib/modules/ directory as a part of the rpm
build.  That's what broke for me (since I wasn't root).
I don't understand. Running rpmbuild will build the rpm and that can be 
done without root. Doing a rpm -i on the resultant rpm will require root.
I think your problem is that you didn't specify a local top dir so it is 
using the default which is where it is planning to do the installation.


Here is my script, cloned from ovs-opnfv because it is currently under 
review and not merged yet.


https://github.com/tfherbert/ovs_nfv/blob/master/build/build_ovs_rpm.sh




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


Re: [ovs-dev] [PATCH 0/1] Fix Rhel spec file for kmod RPM

2016-01-28 Thread Thomas F Herbert

On 1/28/16 9:54 AM, Russell Bryant wrote:

On 01/28/2016 08:48 AM, Thomas F Herbert wrote:

In the process of building RPM's in OVS-OPNFV project, it was discovered that 
the
Rhel spec file for building the kernel module RPM was broken in such a way to 
break
depmod on kernel module installs.

This fixes the spec file be deleting the reference to openvswitch.conf.

Tested on Centos 7

The text here seems like it would be useful for the commit message.

I'm also pretty confused about the spec files and which ones are used
where.  While possibly unrelated to this patch, it would be really nice
if we could clear this up in some documentation.

We have:

 openvswitch.spec
 openvswitch-kmod-rhel6.spec
Russel, thanks for your comments. This spec file is for building the 
kernel module and it is broken. The other spec files as far as I know 
may be poorly documented but they at least work as far as I know. This 
patch addresses the limited case of fixing a broken spec file. I think 
we should fix this broken behavior first and address the larger issues 
of documentation, revisions of distros etc. with a broader patch/discussion.


Many distros don't build the out-of-tree kernel module for openvswitch 
so people probably don't use this often. However, for ovs in opnfv, we 
have some use cases where we need to build the kernel module.


INSTALL.RHEL.md talks about these two.  It also only mentions RHEL 5 and 6.

 openvswitch-fedora.spec
 openvswitch-kmod-fedora.spec

INSTALL.Fedora.md talks about these.  It mentions the kmod-rhel6 spec
for Fedora 17.  Given that Fedora 17 is long gone, this piece can
probably be removed.

 openvswitch-dkms.spec

This last one is not referred to by any documentation, so it's not clear
where you would use it.
DKMS is a prerequisite for building out-of-tree kmods. A specific spec 
file for DKMS should not be necessary as far as I know.


We don't mention RHEL/CentOS 7 anywhere.  I believe the Fedora spec is
actually used on CentOS 7.  Is that right?  In either case, can we
update the documentation to make it more clear where to go if you're
using RHEL/CentOS 7?
I hope FBL and Panu and others weigh in on the broader RPM building 
documentation changes you are recommending below. I have added them to 
the cc list.


Finally, if that's the case, is this patch still needed?  I ask since
the issue was about the RHEL 6 spec used on CentOS 7.
This patch is needed to fix the rhel kmod spec file which doesn't work. 
The rhel spec file builds the kmod for kernel "flavors." The Fedora spec 
file doesn't do that. If practice is to use the Fedora spec file for 
building the kernel module for Centos and reviewers agree that is the 
right approach, I can address that in an updated patch.





Thomas F Herbert (1):
   Fix RHEL Spec file for kmod RPM install.

  rhel/openvswitch-kmod-rhel6.spec.in | 2 --
  rhel/openvswitch-kmod.files | 3 ---
  2 files changed, 5 deletions(-)
  delete mode 100644 rhel/openvswitch-kmod.files





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


Re: [ovs-dev] [PATCH 1/1] Openvswitch: RHEL: Fix RHEL Spec file for kmod RPM install.

2016-01-28 Thread Thomas F Herbert

On 1/28/16 10:27 AM, Guru Shetty wrote:



On 28 January 2016 at 05:48, Thomas F Herbert 
<thomasfherb...@gmail.com <mailto:thomasfherb...@gmail.com>> wrote:


Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com
<mailto:thomasfherb...@gmail.com>>


The changes that this commit reverts were initially added as part of 
commit 9c12d2ec7569a12d9.

So this commit will break the original fix.
I found this building the kmod on Centos 7 and the file openvswitch.conf 
doesn't actually exist. Do Rhel 6 builds of the out-of-tree kmod still work?


---
 rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in> | 2 --
 rhel/openvswitch-kmod.files | 3 ---
 2 files changed, 5 deletions(-)
 delete mode 100644 rhel/openvswitch-kmod.files

diff --git a/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
b/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
index 5d46838..6bd58f4 100644
--- a/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
+++ b/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
@@ -19,7 +19,6 @@ Group:  System/Kernel
 License:GPLv2
 URL: http://openvswitch.org/
 Source0:%{oname}-%{version}.tar.gz
-Source1:%{oname}-kmod.files
 BuildRoot:  %(mktemp -ud
%{_tmppath}/%{name}-%{version}-%{release}-XX)
 BuildRequires:  %kernel_module_package_buildreqs

@@ -66,7 +65,6 @@ for flavor in %flavors_to_build ; do
  find $INSTALL_MOD_PATH/lib/modules -iname 'modules.*'
-exec rm {} \;
 done
 install -d %{buildroot}%{_sysconfdir}/depmod.d/
-install -m 644 %{oname}.conf %{buildroot}%{_sysconfdir}/depmod.d/

 %clean
 rm -rf $RPM_BUILD_ROOT
diff --git a/rhel/openvswitch-kmod.files b/rhel/openvswitch-kmod.files
deleted file mode 100644
index 357c2e8..000
--- a/rhel/openvswitch-kmod.files
+++ /dev/null
@@ -1,3 +0,0 @@
-%defattr(644,root,root,755)
-/lib/modules/%2-%1
-/etc/depmod.d/openvswitch.conf
--
2.5.0

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




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


Re: [ovs-dev] [PATCH 1/1] Openvswitch: RHEL: Fix RHEL Spec file for kmod RPM install.

2016-01-28 Thread Thomas F Herbert

On 1/28/16 11:07 AM, Guru Shetty wrote:
It should ideally work. If not, it is a bug. Just to make sure that 
you are doing the right thing, have you read the following piece of 
instruction in INSTALL.RHEL.md <http://INSTALL.RHEL.md> carefully?
The "missing" file is openvswitch.conf which is pointed to by the file 
openvswitch-kmod.files. However, I admit that I have not tested it on 
RHEL6. I have only tested it on Centos 7. Also, Russel Bryant has 
submitted a separate patch today update the RHEL README to state that 
the Fedora Spec file for Centos 7 builds and that may address this issue 
for now.


"""
On RHEL 6, to build the Open vSwitch kernel module, copy
   rhel/openvswitch-kmod.files into the RPM sources directory and run:

"""



On 28 January 2016 at 07:58, Thomas F Herbert 
<thomasfherb...@gmail.com <mailto:thomasfherb...@gmail.com>> wrote:


On 1/28/16 10:27 AM, Guru Shetty wrote:



On 28 January 2016 at 05:48, Thomas F Herbert
<thomasfherb...@gmail.com <mailto:thomasfherb...@gmail.com>> wrote:

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com
<mailto:thomasfherb...@gmail.com>>


The changes that this commit reverts were initially added as part
of commit 9c12d2ec7569a12d9.
So this commit will break the original fix.

I found this building the kmod on Centos 7 and the file
openvswitch.conf doesn't actually exist. Do Rhel 6 builds of the
out-of-tree kmod still work?



---
 rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in> | 2 --
 rhel/openvswitch-kmod.files | 3 ---
 2 files changed, 5 deletions(-)
 delete mode 100644 rhel/openvswitch-kmod.files

diff --git a/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
b/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
index 5d46838..6bd58f4 100644
--- a/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
+++ b/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
@@ -19,7 +19,6 @@ Group: System/Kernel
 License:GPLv2
 URL: http://openvswitch.org/
 Source0:%{oname}-%{version}.tar.gz
-Source1:%{oname}-kmod.files
 BuildRoot:  %(mktemp -ud
%{_tmppath}/%{name}-%{version}-%{release}-XX)
 BuildRequires: %kernel_module_package_buildreqs

@@ -66,7 +65,6 @@ for flavor in %flavors_to_build ; do
  find $INSTALL_MOD_PATH/lib/modules -iname
'modules.*' -exec rm {} \;
 done
 install -d %{buildroot}%{_sysconfdir}/depmod.d/
-install -m 644 %{oname}.conf
%{buildroot}%{_sysconfdir}/depmod.d/

 %clean
 rm -rf $RPM_BUILD_ROOT
diff --git a/rhel/openvswitch-kmod.files
b/rhel/openvswitch-kmod.files
deleted file mode 100644
index 357c2e8..000
--- a/rhel/openvswitch-kmod.files
+++ /dev/null
@@ -1,3 +0,0 @@
-%defattr(644,root,root,755)
-/lib/modules/%2-%1
-/etc/depmod.d/openvswitch.conf
--
2.5.0

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







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


Re: [ovs-dev] [PATCH 1/1] Openvswitch: RHEL: Fix RHEL Spec file for kmod RPM install.

2016-01-28 Thread Thomas F Herbert

On 1/28/16 11:07 AM, Guru Shetty wrote:
It should ideally work. If not, it is a bug. Just to make sure that 
you are doing the right thing, have you read the following piece of 
instruction in INSTALL.RHEL.md <http://INSTALL.RHEL.md> carefully?


"""
On RHEL 6, to build the Open vSwitch kernel module, copy
   rhel/openvswitch-kmod.files into the RPM sources directory and run:

"""



On 28 January 2016 at 07:58, Thomas F Herbert 
<thomasfherb...@gmail.com <mailto:thomasfherb...@gmail.com>> wrote:


On 1/28/16 10:27 AM, Guru Shetty wrote:



    On 28 January 2016 at 05:48, Thomas F Herbert
<thomasfherb...@gmail.com <mailto:thomasfherb...@gmail.com>> wrote:

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com
<mailto:thomasfherb...@gmail.com>>


The changes that this commit reverts were initially added as part
of commit 9c12d2ec7569a12d9.
So this commit will break the original fix.

I found this building the kmod on Centos 7 and the file
openvswitch.conf doesn't actually exist. Do Rhel 6 builds of the
out-of-tree kmod still work?

You ask a good question. That missing file causes the build to fail on 
Centos 7 which is why I submitted this patch. I have to try on RHEL or 
Centos 6. I assumed it had something to do with earlier pre-DKMS tools 
to build the depmod database with out-of-tree kernel modules.





---
 rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in> | 2 --
 rhel/openvswitch-kmod.files | 3 ---
 2 files changed, 5 deletions(-)
 delete mode 100644 rhel/openvswitch-kmod.files

diff --git a/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
b/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
index 5d46838..6bd58f4 100644
--- a/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
+++ b/rhel/openvswitch-kmod-rhel6.spec.in
<http://openvswitch-kmod-rhel6.spec.in>
@@ -19,7 +19,6 @@ Group: System/Kernel
 License:GPLv2
 URL: http://openvswitch.org/
 Source0:%{oname}-%{version}.tar.gz
-Source1:%{oname}-kmod.files
 BuildRoot:  %(mktemp -ud
%{_tmppath}/%{name}-%{version}-%{release}-XX)
 BuildRequires: %kernel_module_package_buildreqs

@@ -66,7 +65,6 @@ for flavor in %flavors_to_build ; do
  find $INSTALL_MOD_PATH/lib/modules -iname
'modules.*' -exec rm {} \;
 done
 install -d %{buildroot}%{_sysconfdir}/depmod.d/
-install -m 644 %{oname}.conf
%{buildroot}%{_sysconfdir}/depmod.d/

 %clean
 rm -rf $RPM_BUILD_ROOT
diff --git a/rhel/openvswitch-kmod.files
b/rhel/openvswitch-kmod.files
deleted file mode 100644
index 357c2e8..000
--- a/rhel/openvswitch-kmod.files
+++ /dev/null
@@ -1,3 +0,0 @@
-%defattr(644,root,root,755)
-/lib/modules/%2-%1
-/etc/depmod.d/openvswitch.conf
--
2.5.0

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







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


[ovs-dev] [PATCH 0/1] Fix Rhel spec file for kmod RPM

2016-01-28 Thread Thomas F Herbert
In the process of building RPM's in OVS-OPNFV project, it was discovered that 
the
Rhel spec file for building the kernel module RPM was broken in such a way to 
break
depmod on kernel module installs.

This fixes the spec file be deleting the reference to openvswitch.conf.

Tested on Centos 7

Thomas F Herbert (1):
  Fix RHEL Spec file for kmod RPM install.

 rhel/openvswitch-kmod-rhel6.spec.in | 2 --
 rhel/openvswitch-kmod.files | 3 ---
 2 files changed, 5 deletions(-)
 delete mode 100644 rhel/openvswitch-kmod.files

-- 
2.5.0

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


[ovs-dev] [PATCH 1/1] Openvswitch: RHEL: Fix RHEL Spec file for kmod RPM install.

2016-01-28 Thread Thomas F Herbert
Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 rhel/openvswitch-kmod-rhel6.spec.in | 2 --
 rhel/openvswitch-kmod.files | 3 ---
 2 files changed, 5 deletions(-)
 delete mode 100644 rhel/openvswitch-kmod.files

diff --git a/rhel/openvswitch-kmod-rhel6.spec.in 
b/rhel/openvswitch-kmod-rhel6.spec.in
index 5d46838..6bd58f4 100644
--- a/rhel/openvswitch-kmod-rhel6.spec.in
+++ b/rhel/openvswitch-kmod-rhel6.spec.in
@@ -19,7 +19,6 @@ Group:  System/Kernel
 License:GPLv2
 URL:http://openvswitch.org/
 Source0:%{oname}-%{version}.tar.gz
-Source1:%{oname}-kmod.files
 BuildRoot:  %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XX)
 BuildRequires:  %kernel_module_package_buildreqs
 
@@ -66,7 +65,6 @@ for flavor in %flavors_to_build ; do
  find $INSTALL_MOD_PATH/lib/modules -iname 'modules.*' -exec rm {} \;
 done
 install -d %{buildroot}%{_sysconfdir}/depmod.d/
-install -m 644 %{oname}.conf %{buildroot}%{_sysconfdir}/depmod.d/
 
 %clean
 rm -rf $RPM_BUILD_ROOT
diff --git a/rhel/openvswitch-kmod.files b/rhel/openvswitch-kmod.files
deleted file mode 100644
index 357c2e8..000
--- a/rhel/openvswitch-kmod.files
+++ /dev/null
@@ -1,3 +0,0 @@
-%defattr(644,root,root,755)
-/lib/modules/%2-%1
-/etc/depmod.d/openvswitch.conf
-- 
2.5.0

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


Re: [ovs-dev] [ovs-discuss] [announce] driverctl: utility for persistent alternative driver binding

2015-12-19 Thread Thomas F Herbert

On 12/14/15 6:42 AM, Gray, Mark D wrote:



-Original Message-
From: Panu Matilainen [mailto:pmati...@redhat.com]
Sent: Tuesday, December 8, 2015 12:05 PM
To: Gray, Mark D; d...@dpdk.org; us...@dpdk.org; dev@openvswitch.org;
disc...@openvswitch.org
Subject: Re: [ovs-discuss] [announce] driverctl: utility for persistent
alternative driver binding

On 12/04/2015 05:44 PM, Gray, Mark D wrote:

I welcome this initiative, one question below:


-Original Message-
From: discuss [mailto:discuss-boun...@openvswitch.org] On Behalf Of
Panu Matilainen
Sent: Friday, December 4, 2015 10:54 AM
To: d...@dpdk.org; us...@dpdk.org; dev@openvswitch.org;
disc...@openvswitch.org
Subject: [ovs-discuss] [announce] driverctl: utility for persistent
alternative driver binding

Hi all,

While this is not directly related to DPDK or OVS, it is potentially
useful for users of both, so excuse me for cross-posting.

Quoting from the project README (for the full text see
http://laiskiainen.org/git/?p=driverctl.git;a=blob_plain;f=README)

   > driverctl is a tool for manipulating and inspecting the system
   > device driver choices.
   >
   > Devices are normally assigned to their sole designated kernel driver
   > by default. However in some situations it may be desireable to
   > override that default, for example to try an older driver to
   > work around a regression in a driver or to try an experimental
   > alternative driver. Another common use-case is pass-through
   > drivers and driver stubs to allow userspace to drive the device,
   > such as in case of virtualization.
   >
   > driverctl integrates with udev to support overriding
   > driver selection for both cold- and hotplugged devices from the
   > moment of discovery, but can also change already assigned drivers,
   > assuming they are not in use by the system. The driver overrides
   > created by driverctl are persistent across system reboots
   > by default.
   >
   > Usage
   > -
   >
   > Find devices currently driven by ixgbe driver:
   >
   > # driverctl -v list-devices | grep ixgbe
   > :01:00.0 ixgbe (Ethernet 10G 4P X520/I350 rNDC)
   > :01:00.1 ixgbe (Ethernet 10G 4P X520/I350 rNDC)
   >
   > Change them to use the vfio-pci driver:
   > # driverctl set-override :01:00.0 vfio-pci
   > # driverctl set-override :01:00.1 vfio-pci
   >
   > Find devices with driver overrides:
   > # driverctl -v list-devices|grep \\*
   > :01:00.0 vfio-pci [*] (Ethernet 10G 4P X520/I350 rNDC)
   > :01:00.1 vfio-pci [*] (Ethernet 10G 4P X520/I350 rNDC)
   >
   > Remove the override from slot :01:00.1:
   > # driverctl unset-override :01:00.1

DPDK of course has its own dpdk_nic_bind(.py) tool for this purpose,
the main differences to driverctl are:
- driverctl bindings are persistent across system boots

   [Gray, Mark D] This is great!

Will this integrate with, for example in Red Hat-based systems,
/etc/sysconfig/network-scripts/ifcfg-X? In DPDK, could we then potentially

reference devices by that (arbitrary) name?

driverctl is not specific to NICs so network-scripts integration is out of 
scope.


I forgot that point. It makes sense.


That aside, maybe I'm missing something but I'm not sure what there is to
integrate with since DPDK ports are ultimately application specific.
For OVS I've sent a patch to support managing OVS DPDK ports via
network-scripts:
http://openvswitch.org/pipermail/dev/2015-December/062850.html

I think this is a good idea.

Thanks, I wasn’t familiar with this work but this is a good approach.


. Panu -


What I am thinking would be an ideal end state for OVS would be the possibility 
to add a port using ovs-vsctl add-port referencing the device name

ovs-vsctl add-port p1p2
I agree. The semantics should be the same for either DPDK or Linux 
kernel data planes.


If dpdk was enabled, then OVS could query something(?) to determine which 
physical interface this name actually referred to and then from that figure out 
what dpdk port number it referred to.
Also, with the approach above, this should apply to virtual interfaces. 
It should work the same way for virtual interfaces as well.



___
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] OVS+DPDK rpm

2015-11-30 Thread Thomas F Herbert

On 11/25/15 11:54 AM, Flavio Leitner wrote:

Hi,

In order to build the Fedora RPM with DPDK some changes to the
spec file are required.  However, I was told that not all users
want to build with DPDK or even have the DPDK libs installed. It
seems a fair request if you are working with OVS only.

Therefore we have two options.
1) add the option '--with dpdk' to the current spec file, so
that users that doesn't want DPDK just follow the usual steps
and that's it.  DPDK users only need to pass those two arguments
to have the OVS+DPDK RPM files.
I think this option is best. This is the most straight forward way to 
build OVS+DPDK.


2) Create another copy of .spec (openvswitch-dpdk.spec?) with DPDK
support enabled.

Another question is static versus shared linking.

Shared linking is best. That way the dpdk library is there if you need it.


My opinion is that we should go with (1), shared linked, but I don't
know if it covers all use-cases.

Thoughts?
Thanks,
fbl
  



___
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 V14 1/4] Flow and action changes for 802.1AD

2015-11-25 Thread Thomas F Herbert



On 11/25/15 12:54 AM, Ben Pfaff wrote:

On Mon, Nov 09, 2015 at 08:30:19PM -0800, Thomas F Herbert wrote:


On 11/9/15 12:58 PM, Ben Pfaff wrote:

On Fri, Oct 02, 2015 at 05:31:58PM -0400, Thomas F Herbert wrote:

From: "Thomas F. Herbert" <thomasfherb...@gmail.com>

ToDo: The flow structure needs to be updated to hold both the inner and outer
tpid since these are encoded by the kernel module.

I think I'd like to see the version with both TPIDs encoded.  That's the
way I've always envisioned this working.

 From an architectural view, it sounds indeed quite sensible. Also, it would
get rid of the vlan depth calculation in the above code which is working but
ugly. The $10 question is: are you implying that we should change the ABI by
adding new OVS_KEY_ATTRIBs for the two TPIDs? This would raise backward
compatibility and ABI issues.

I think that we covered this in-person at ovscon last week, but just in
case...  I don't think that this requires a kernel ABI change, because
the kernel ABI has always included the TPID.  I'm only suggesting that
"struct flow" consistently include the TPID; struct flow always goes
through some kind of translation whenever it passes out of OVS
userspace, so that shouldn't in itself break anything.
Yes, thanks for the comment. I will update patch to encode and decode 
both tpid's.



Also, once we have the TPIDs in place in struct flow, I am not sure
whether it is worthwhile to keep adding the VLAN_CFI bit to the TCI
value to indicate that a header is present.

I assume you are suggesting that we determining a VLAN is present by
checking eth_type_vlan(). With this we could allow any value for the VLAN
including a 1 in the DEI bit. Maybe this should be a separate patch to
eliminate the redundancy in openvswitch once the above change was made.
There was a separate comment by Pravin discussing eliminating the DEI. 
Now that we are encoding tpid's explicitly we could check tpid ethertype 
to determine if a vlan is present but probably that should wait for 
another patch.

Maybe an example would help.  Suppose we define:
 struct flow_vlan {
 ovs_be32 tpid;
 ovs_be32 tci;
 };

Yes, I did this in the kernel patch.


and then in struct flow replace vlan_tci by "struct flow_vlan
vlans[2];".  (I'm not saying this is the way to go but it's a
possibility.)

Then, we know that there's at least one VLAN in 'flow' if
'flow->vlans[0].tpid != 0' and that there are two VLANs in 'flow' if
'flow->vlans[1].tpid != 0' (presumably they'd be left-justified so you
wouldn't get just the latter).
Yes, this will make for cleaner code to calculate depth of encapsulation 
vlan.   I think that since vlans are never nested more then 2 deep, I 
could encode it the same way I do in the kernel flow key with two 
structs instead of an array of structs.


--
Thomas F Herbert Red Hat
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 5/7] Ethernet-nsh: decap and encap in DPDK-netdev dataplane.

2015-11-07 Thread Thomas F Herbert

On 9/30/15 5:47 AM, mengke wrote:

This patch adds a new type port ("eth_nsh" type) for Ethernet NSH, add related
decapsulation and encapsulation implementation at data plane level in user
space and modify the related codes at control plane level in user space.

When vport of Ethernet-NSH-Netdev receives an original packet, it will
encapsulate the packet with NSH and Ethernet header. The required information
for encapsulation is stored in vport configuration and rules when
related field are set 'flow'.

When Ethernet NSH packet are received, the tunnel port will be lookuped by the
Ethernet type(0X894F), if the Ethernet NSH port are found, the decapsulation
will be implemented. The tunnel pop actions will be implemented and the related
fields will be parsed.
I have concerns about implementing special features outside of DPDK that 
are unique to support DPDK implementation of NSH. I think we want to 
move toward having OVS with DPDK behave semantically identically  to OVS 
with the Linux kernel data plane. I realize that some things don't lend 
themselves to acceleration easily given DPDK architecture.


If I am implying separate LWT implementation for Geneve and VXLAN in the 
accelerated data plane, we need to look at that.


Signed-off-by: Ricky Li 
Signed-off-by: Mengke Liu 
---
  datapath/linux/compat/include/linux/openvswitch.h |   2 +
  lib/dpif-netlink.c|   3 +
  lib/dpif.c|   3 +-
  lib/flow.c|   3 +-
  lib/match.c   |   1 +
  lib/netdev-vport.c|  99 -
  lib/odp-util.c| 503 +-
  lib/packets.c |  24 +-
  lib/packets.h |  15 +-
  lib/tnl-ports.c   |  32 ++
  lib/tnl-ports.h   |   2 +
  ofproto/ofproto-dpif-ipfix.c  |   4 +
  ofproto/ofproto-dpif-xlate.c  |  55 ++-
  ofproto/tunnel.c  |  54 ++-
  ofproto/tunnel.h  |   8 +-
  tests/tunnel.at   |  60 +++
  16 files changed, 620 insertions(+), 248 deletions(-)

diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
b/datapath/linux/compat/include/linux/openvswitch.h
index 3d588bb..045a1f4 100644
--- a/datapath/linux/compat/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
@@ -358,6 +358,8 @@ enum ovs_tunnel_key_attr {
OVS_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */
OVS_TUNNEL_KEY_ATTR_IPV4_SRC,   /* be32 src IP address. */
OVS_TUNNEL_KEY_ATTR_IPV4_DST,   /* be32 dst IP address. */
+   OVS_TUNNEL_KEY_ATTR_ETH_SRC,/* Ethernet src . */
+   OVS_TUNNEL_KEY_ATTR_ETH_DST,/* Ethernet src . */
OVS_TUNNEL_KEY_ATTR_TOS,/* u8 Tunnel IP ToS. */
OVS_TUNNEL_KEY_ATTR_TTL,/* u8 Tunnel IP TTL. */
OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT,  /* No argument, set DF. */
diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index ffeb124..cd9a9b5 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -762,6 +762,9 @@ get_vport_type(const struct dpif_netlink_vport *vport)
  case OVS_VPORT_TYPE_VXLAN:
  return "vxlan";
  
+case OVS_VPORT_TYPE_NSH:

+return "eth_nsh";
+
  case OVS_VPORT_TYPE_LISP:
  return "lisp";
  
diff --git a/lib/dpif.c b/lib/dpif.c

index bb2d519..5bbdb96 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1108,7 +1108,8 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet 
**packets, int cnt,
  uint64_t stub[256 / 8];
  struct pkt_metadata *md = >md;
  
-if (md->tunnel.ip_dst) {

+if (md->tunnel.ip_dst ||
+   md->tunnel.nsh_flags & NSH_TNL_F_ETHERNET_PARSED) {
  /* The Linux kernel datapath throws away the tunnel information
   * that we supply as metadata.  We have to use a "set" action to
   * supply it. */
diff --git a/lib/flow.c b/lib/flow.c
index 2cbfb6d..7572f01 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -449,7 +449,8 @@ miniflow_extract(struct dp_packet *packet, struct miniflow 
*dst)
  uint8_t nw_frag, nw_tos, nw_ttl, nw_proto;
  
  /* Metadata. */

-if (md->tunnel.ip_dst) {
+if (md->tunnel.ip_dst ||
+   md->tunnel.nsh_flags & NSH_TNL_F_ETHERNET_PARSED) {
  miniflow_push_words(mf, tunnel, >tunnel,
  offsetof(struct flow_tnl, metadata) /
  sizeof(uint64_t));
diff --git a/lib/match.c b/lib/match.c
index 7f7bd4d..d2337c5 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -965,6 +965,7 @@ format_flow_tunnel(struct ds 

[ovs-dev] [PATCH net-dev V20 1/3] openvswitch: 802.1ad uapi changes.

2015-11-05 Thread Thomas F Herbert
openvswitch: Add support for 8021.AD

Change the description of the VLAN tpid field.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/uapi/linux/openvswitch.h | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 28ccedd..2e7339d 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -587,13 +587,13 @@ struct ovs_action_push_mpls {
  * @vlan_tci: Tag control identifier (TCI) to push.  The CFI bit must be set
  * (but it will not be set in the 802.1Q header that is pushed).
  *
- * The @vlan_tpid value is typically %ETH_P_8021Q.  The only acceptable TPID
- * values are those that the kernel module also parses as 802.1Q headers, to
- * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN
- * from having surprising results.
+ * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
+ * The only acceptable TPID values are those that the kernel module also parses
+ * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
+ * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
  */
 struct ovs_action_push_vlan {
-   __be16 vlan_tpid;   /* 802.1Q TPID. */
+   __be16 vlan_tpid;   /* 802.1Q or 802.1ad TPID. */
__be16 vlan_tci;/* 802.1Q TCI (VLAN ID and priority). */
 };
 
@@ -661,9 +661,10 @@ enum ovs_ct_attr {
  * is copied from the value to the packet header field, rest of the bits are
  * left unchanged.  The non-masked value bits must be passed in as zeroes.
  * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
- * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the
- * packet.
- * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet.
+ * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
+ * onto the packet.
+ * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
+ * from the packet.
  * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
  * the nested %OVS_SAMPLE_ATTR_* attributes.
  * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
-- 
2.4.3

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


[ovs-dev] [PATCH net-next V20 0/3] openvswitch: Add support for 802.1ad

2015-11-05 Thread Thomas F Herbert
V20: Added attribute parsing of inner vlan to consolidated vlan parsing fn.
Added vport vlan mtu size changes to vport from vport-netdev.c in V18. All
changes are in Pacch 3 of the series. Patches 1 and 2 have already been
acked to V18 submission.

V19: Rebased to latest net-next 4.3.0-rc6+
commit 6d08f617872cc048173d59f1ce4660b030bab5a6
plus a few reviewer's suggested changes.

Note: changes to netdev-vport.c are not included. dev_queue_xmit() is
now called directly as the send vport ops function and length
adjustments for vlans don't apply. I have concerns whether this is
correct but haven't review all the vport code. Reviewer's comments
are welcome.

V18: Patches 1 and 2 in this series have been acked from V17.

Patch 3 in the series includes some significant changes.
The patch includes fixes the decoding of the flow for the
outer tpid. Also, netlink parsing code has been consolidated to generalize
inner and outer vlans and non-mask and masked cases as much as possible.

V17,V16: Implement reviewer's comments.

V15: Implement reviewer comments.

V14: Add outer tpid to flow_key

V13: Fix incorrect encoding and decoding of netlink to/from key
attributes.

V12: Fix some problems and issues pointed out by reviewers. When parsing
netlink attributes Ether types other then 0x88a8 as outer tpid.

V11: Add inner tpid to flow key. Fix separate inner encap attribute
when parsing netlink attributes. Merge 2 patches to consolidate
qinq changes.

V10: Implement reviewer comments: Consolidate vlan parsing functions.
Splits netlink parsing and flow conversion into a separate patch. Uses
double encap attribute encapsulation for 802.1ad.  Netlink attributes
now look like this:

eth_type(0x88a8),vlan(vid=100),encap(eth_type(0x8100), vlan(vid=200),
 encap(eth_type(0x0800), ...))

The double encap atributes in this version of the patch is incompatible with
old versions of the user level 802.1ad patch. A new user level patch which
is also being submitted simultaneously to openvswitch dev mailing list.

V9:  Includes changes suggested by reviewers

V8:  Includes changes suggested by reviewers

V7:  Includes changes suggested by reviewers

V6:  Rebased to net-next

V5:  Use encapsulated attributes


For discussion, history  and previous versions of the kernel module
patch and the user code patch see the OVS dev mailing list,
openvswitch.org/pipermail/dev/..

Thomas F Herbert (3):
  openvswitch: 802.1ad uapi changes.
  Check for vlan ethernet types for 8021.q or 802.1ad
  802.1AD: Flow handling, actions, vlan parsing and netlink attributes

 include/linux/if_vlan.h  |  16 +++
 include/uapi/linux/openvswitch.h |  17 +--
 net/openvswitch/actions.c|   6 +-
 net/openvswitch/flow.c   |  76 ++---
 net/openvswitch/flow.h   |   8 +-
 net/openvswitch/flow_netlink.c   | 233 +--
 net/openvswitch/vport.c  |   4 +-
 7 files changed, 270 insertions(+), 90 deletions(-)

-- 
2.4.3

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


[ovs-dev] [PATCH net-next V20 2/3] Check for vlan ethernet types for 8021.q or 802.1ad

2015-11-05 Thread Thomas F Herbert
This is to simplify using double tagged vlans. This function allows all
valid vlan ethertypes to be checked in a single function call.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/linux/if_vlan.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 67ce5bd..d2494b5 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -627,6 +627,22 @@ static inline netdev_features_t vlan_features_check(const 
struct sk_buff *skb,
 
return features;
 }
+/**
+ * eth_type_vlan - check for valid vlan ether type.
+ * @ethertype: ether type to check
+ *
+ * Returns true if the ether type is a vlan ether type.
+ */
+static inline bool eth_type_vlan(__be16 ethertype)
+{
+   switch (ethertype) {
+   case htons(ETH_P_8021Q):
+   case htons(ETH_P_8021AD):
+   return true;
+   default:
+   return false;
+   }
+}
 
 /**
  * compare_vlan_header - Compare two vlan headers
-- 
2.4.3

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


[ovs-dev] [PATCH net-next V20 3/3] openvswitch: 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-11-05 Thread Thomas F Herbert
Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.
vport has vlan mtu adjustment added for double tagged vlans.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 net/openvswitch/actions.c  |   6 +-
 net/openvswitch/flow.c |  76 ++
 net/openvswitch/flow.h |   8 +-
 net/openvswitch/flow_netlink.c | 233 ++---
 net/openvswitch/vport.c|   4 +-
 5 files changed, 245 insertions(+), 82 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 221fa8b..2b4d001 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -236,7 +236,8 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key 
*key)
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = 0;
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
return err;
 }
 
@@ -246,7 +247,8 @@ static int push_vlan(struct sk_buff *skb, struct 
sw_flow_key *key,
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = vlan->vlan_tci;
+   key->eth.vlan.tci = vlan->vlan_tci;
+   key->eth.vlan.tpid = vlan->vlan_tpid;
return skb_vlan_push(skb, vlan->vlan_tpid,
 ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
 }
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 0ea128e..e8d6bba 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -302,24 +302,68 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  sizeof(struct icmp6hdr));
 }
 
-static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+/* Parse vlan tag from vlan header.
+ * Returns ERROR on memory error.
+ * Returns 0 if it encounters a non-vlan or incomplete packet.
+ * Returns 1 after successfully parsing vlan tag.
+ */
+
+static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *vlan)
 {
-   struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
-   __be16 tci;
-   };
-   struct qtag_prefix *qp;
+   struct vlan_head *qp = (struct vlan_head *)skb->data;
+
+   if (likely(!eth_type_vlan(qp->tpid)))
+   return 0;
 
-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   if (unlikely(skb->len < sizeof(struct vlan_head) + sizeof(__be16)))
return 0;
 
-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct vlan_head) +
+sizeof(__be16
return -ENOMEM;
 
-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   vlan->tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   vlan->tpid = qp->tpid;
+
+   __skb_pull(skb, sizeof(struct vlan_head));
+   return 1;
+}
+
+static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+{
+   int res;
+
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
+   key->eth.cvlan.tci = 0;
+   key->eth.cvlan.tpid = 0;
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where ingress processing has already stripped
+* the outer vlan tag.
+*/
+   res = parse_vlan_tag(skb, >eth.cvlan);
+   if (res < 0)
+   return res;
+   /* For inner tag, return 0 because neither
+* non-existent nor partial inner tag is an error.
+*/
+   return 0;
+   }
+   res = parse_vlan_tag(skb, >eth.vlan);
+   if (res <= 0)
+   /* This is an outer tag in the non-accelerated VLAN
+* case. Return error unless it is a complete vlan tag.
+*/
+   return res;
+
+   /* Parse inner vlan tag if present for non-accelerated case. */
+   res = parse_vlan_tag(skb, >eth.cvlan);
+   if (res <= 0)
+   return res;
 
return 0;
 }
@@ -480,12 +524,8 @@ static int key_extract(struct sk_buff *skb, struct 
sw_flow_key *key)
 * update skb->csum here.
 */
 
-   key->eth.tci = 0;
-   if (skb_vlan_tag_present(skb))
-   key->

[ovs-dev] [PATCH net-next V19 3/3] openvswitch: 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-30 Thread Thomas F Herbert
Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 net/openvswitch/actions.c  |   6 +-
 net/openvswitch/flow.c |  76 +
 net/openvswitch/flow.h |   8 +-
 net/openvswitch/flow_netlink.c | 235 +++--
 4 files changed, 251 insertions(+), 74 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 221fa8b..2b4d001 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -236,7 +236,8 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key 
*key)
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = 0;
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
return err;
 }
 
@@ -246,7 +247,8 @@ static int push_vlan(struct sk_buff *skb, struct 
sw_flow_key *key,
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = vlan->vlan_tci;
+   key->eth.vlan.tci = vlan->vlan_tci;
+   key->eth.vlan.tpid = vlan->vlan_tpid;
return skb_vlan_push(skb, vlan->vlan_tpid,
 ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
 }
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 0ea128e..e8d6bba 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -302,24 +302,68 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  sizeof(struct icmp6hdr));
 }
 
-static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+/* Parse vlan tag from vlan header.
+ * Returns ERROR on memory error.
+ * Returns 0 if it encounters a non-vlan or incomplete packet.
+ * Returns 1 after successfully parsing vlan tag.
+ */
+
+static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *vlan)
 {
-   struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
-   __be16 tci;
-   };
-   struct qtag_prefix *qp;
+   struct vlan_head *qp = (struct vlan_head *)skb->data;
+
+   if (likely(!eth_type_vlan(qp->tpid)))
+   return 0;
 
-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   if (unlikely(skb->len < sizeof(struct vlan_head) + sizeof(__be16)))
return 0;
 
-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct vlan_head) +
+sizeof(__be16
return -ENOMEM;
 
-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   vlan->tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   vlan->tpid = qp->tpid;
+
+   __skb_pull(skb, sizeof(struct vlan_head));
+   return 1;
+}
+
+static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+{
+   int res;
+
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
+   key->eth.cvlan.tci = 0;
+   key->eth.cvlan.tpid = 0;
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where ingress processing has already stripped
+* the outer vlan tag.
+*/
+   res = parse_vlan_tag(skb, >eth.cvlan);
+   if (res < 0)
+   return res;
+   /* For inner tag, return 0 because neither
+* non-existent nor partial inner tag is an error.
+*/
+   return 0;
+   }
+   res = parse_vlan_tag(skb, >eth.vlan);
+   if (res <= 0)
+   /* This is an outer tag in the non-accelerated VLAN
+* case. Return error unless it is a complete vlan tag.
+*/
+   return res;
+
+   /* Parse inner vlan tag if present for non-accelerated case. */
+   res = parse_vlan_tag(skb, >eth.cvlan);
+   if (res <= 0)
+   return res;
 
return 0;
 }
@@ -480,12 +524,8 @@ static int key_extract(struct sk_buff *skb, struct 
sw_flow_key *key)
 * update skb->csum here.
 */
 
-   key->eth.tci = 0;
-   if (skb_vlan_tag_present(skb))
-   key->eth.tci = htons(skb->vlan_tci);
-   else if (eth->h_proto == htons(ETH_P_8021Q))
-   if (unlikely(parse_vlan(sk

[ovs-dev] [PATCH net-next V19 1/3] openvswitch: 802.1ad uapi changes.

2015-10-30 Thread Thomas F Herbert
openvswitch: Add support for 8021.AD

Change the description of the VLAN tpid field.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/uapi/linux/openvswitch.h | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 28ccedd..2e7339d 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -587,13 +587,13 @@ struct ovs_action_push_mpls {
  * @vlan_tci: Tag control identifier (TCI) to push.  The CFI bit must be set
  * (but it will not be set in the 802.1Q header that is pushed).
  *
- * The @vlan_tpid value is typically %ETH_P_8021Q.  The only acceptable TPID
- * values are those that the kernel module also parses as 802.1Q headers, to
- * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN
- * from having surprising results.
+ * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
+ * The only acceptable TPID values are those that the kernel module also parses
+ * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
+ * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
  */
 struct ovs_action_push_vlan {
-   __be16 vlan_tpid;   /* 802.1Q TPID. */
+   __be16 vlan_tpid;   /* 802.1Q or 802.1ad TPID. */
__be16 vlan_tci;/* 802.1Q TCI (VLAN ID and priority). */
 };
 
@@ -661,9 +661,10 @@ enum ovs_ct_attr {
  * is copied from the value to the packet header field, rest of the bits are
  * left unchanged.  The non-masked value bits must be passed in as zeroes.
  * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
- * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the
- * packet.
- * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet.
+ * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
+ * onto the packet.
+ * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
+ * from the packet.
  * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
  * the nested %OVS_SAMPLE_ATTR_* attributes.
  * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
-- 
2.4.3

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


[ovs-dev] [PATCH net-next V19 0/3] openvswitch: Add support for 802.1ad

2015-10-30 Thread Thomas F Herbert
V19: Rebased to latest net-next 4.3.0-rc6+
commit 6d08f617872cc048173d59f1ce4660b030bab5a6
plus a few reviewer's suggested changes.

Note: changes to netdev-vport.c are not included. dev_queue_xmit() is
now called directly as the send vport ops function and length
adjustments for vlans don't apply. I have concerns whether this is
correct but haven't review all the vport code. Reviewer's comments
are welcome.

V18: Patches 1 and 2 in this series have been acked from V17.

Patch 3 in the series includes some significant changes.
The patch includes fixes the decoding of the flow for the
outer tpid. Also, netlink parsing code has been consolidated to generalize
inner and outer vlans and non-mask and masked cases as much as possible.

V17,V16: Implement reviewer's comments.

V15: Implement reviewer comments.

V14: Add outer tpid to flow_key

V13: Fix incorrect encoding and decoding of netlink to/from key
attributes.

V12: Fix some problems and issues pointed out by reviewers. When parsing
netlink attributes Ether types other then 0x88a8 as outer tpid.

V11: Add inner tpid to flow key. Fix separate inner encap attribute
when parsing netlink attributes. Merge 2 patches to consolidate
qinq changes.

V10: Implement reviewer comments: Consolidate vlan parsing functions.
Splits netlink parsing and flow conversion into a separate patch. Uses
double encap attribute encapsulation for 802.1ad.  Netlink attributes
now look like this:

eth_type(0x88a8),vlan(vid=100),encap(eth_type(0x8100), vlan(vid=200),
 encap(eth_type(0x0800), ...))

The double encap atributes in this version of the patch is incompatible with
old versions of the user level 802.1ad patch. A new user level patch which
is also being submitted simultaneously to openvswitch dev mailing list.

V9:  Includes changes suggested by reviewers

V8:  Includes changes suggested by reviewers

V7:  Includes changes suggested by reviewers

V6:  Rebased to net-next

V5:  Use encapsulated attributes


For discussion, history  and previous versions of the kernel module
patch and the user code patch see the OVS dev mailing list,
openvswitch.org/pipermail/dev/..

Thomas F Herbert (3):
  openvswitch: 802.1ad uapi changes.
  Check for vlan ethernet types for 8021.q or 802.1ad
  802.1AD: Flow handling, actions, vlan parsing and netlink attributes

 include/linux/if_vlan.h  |  16 +++
 include/uapi/linux/openvswitch.h |  17 +--
 net/openvswitch/actions.c|   6 +-
 net/openvswitch/flow.c   |  76 ++---
 net/openvswitch/flow.h   |   8 +-
 net/openvswitch/flow_netlink.c   | 235 ++-
 6 files changed, 276 insertions(+), 82 deletions(-)

-- 
2.4.3

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


[ovs-dev] [PATCH net-next V19 2/3] Check for vlan ethernet types for 8021.q or 802.1ad

2015-10-30 Thread Thomas F Herbert
This is to simplify using double tagged vlans. This function allows all
valid vlan ethertypes to be checked in a single function call.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/linux/if_vlan.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 67ce5bd..d2494b5 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -627,6 +627,22 @@ static inline netdev_features_t vlan_features_check(const 
struct sk_buff *skb,
 
return features;
 }
+/**
+ * eth_type_vlan - check for valid vlan ether type.
+ * @ethertype: ether type to check
+ *
+ * Returns true if the ether type is a vlan ether type.
+ */
+static inline bool eth_type_vlan(__be16 ethertype)
+{
+   switch (ethertype) {
+   case htons(ETH_P_8021Q):
+   case htons(ETH_P_8021AD):
+   return true;
+   default:
+   return false;
+   }
+}
 
 /**
  * compare_vlan_header - Compare two vlan headers
-- 
2.4.3

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


Re: [ovs-dev] [PATCH net-next V18 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-29 Thread Thomas F Herbert

Pravin, please look at comment inline below:

On 10/27/15 1:22 PM, Pravin Shelar wrote:

On Tue, Oct 27, 2015 at 9:45 AM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

On 10/26/15 10:10 PM, Pravin Shelar wrote:
Thanks for the review.

On Sun, Oct 25, 2015 at 5:11 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.
Outer
TPID is also encoded in the flow key.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>

This patch does not apply on current master due to conflicts related
net-branch merge.

OK, I will rebase.
Pravin, I implemented all reviewer comments and completing rebasing to 
latest net-next upstream. The patch works well and flows install 
properly. However, there may be one remaining issue. The vport-dev 
transmit function now calls dev_queue_transmit() directly because it is 
registered as the vport send op. The affect of this is that the vlan mtu 
adjustment code in ovs_netdev_send() that was patched for mtu adjustment 
for single and double tagged vlans is gone.Could you please verify that 
the size adjustment is no longer needed.



---
   net/openvswitch/actions.c  |   6 +-
   net/openvswitch/flow.c |  76 
   net/openvswitch/flow.h |   8 +-
   net/openvswitch/flow_netlink.c | 199
+
   net/openvswitch/vport-netdev.c |   4 +-
   5 files changed, 252 insertions(+), 41 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..ed19e2b 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -302,24 +302,68 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
sizeof(struct icmp6hdr));
   }

-static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+/* Parse vlan tag from vlan header.
+ * Returns ERROR on memory error.
+ * Returns 0 if it encounters a non-vlan or incomplete packet.
+ * Returns 1 after successfully parsing vlan tag.
+ */
+
+static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *vlan)
   {
-   struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
-   __be16 tci;
-   };
-   struct qtag_prefix *qp;
+   struct vlan_head *qp = (struct vlan_head *)skb->data;
+
+   if (likely(!eth_type_vlan(qp->tpid)))
+   return 0;

-   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
sizeof(__be16)))
+   if (unlikely(skb->len < sizeof(struct vlan_head) +
sizeof(__be16)))
  return 0;

Why do we need extra sizeof(__be16) bytes here?

I don't have an answer to your question. I didn't write this code and have
wondered about why the extra two bytes were reserved. I don't know why it
should be necessarily for inner or outer vlans or the HW accelerated case or
for the non-accelerated case. If no reviewer can state a case for it, I will
remove it with the next version of this patch.


Looks like it is optimization for parsing ethertype, So lets keep it.


  } else if (!tci) {
  /* Corner case for truncated 802.1Q header. */
  if (nla_len(encap)) {
@@ -1169,7 +1312,7 @@ int ovs_nla_get_match(struct net *net, struct
sw_flow_match *match,
  goto free_newmask;

  /* Always match on tci. */
-   SW_FLOW_KEY_PUT(match, eth.tci, htons(0x), true);
+   SW_FLOW_KEY_PUT(match, eth.vlan.tci, htons(0x),
true);

Also need to exact match on inner tci.

This code sets a match on tci even if no vlan is present. Is this is for the
case where there is no explicit mask specified in the netlink encoded flow?
If that is correct, then it does need to be done for the inner vlan too.

Yes, By default it needs to be matched. userspace can overwrite it
with different wildcard.


--
Thomas F Herbert Red Hat
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH net-next V17 2/3] Check for vlan ethernet types for 8021.q or 802.1ad

2015-10-27 Thread Thomas F Herbert

On 10/26/15 8:14 AM, Albino B Neto wrote:

2015-10-25 22:11 GMT-02:00 Thomas F Herbert <thomasfherb...@gmail.com>:

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
  include/linux/if_vlan.h | 16 
  1 file changed, 16 insertions(+)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 67ce5bd..d2494b5 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -627,6 +627,22 @@ static inline netdev_features_t vlan_features_check(const 
struct sk_buff *skb,

 return features;
  }
+/**
+ * eth_type_vlan - check for valid vlan ether type.
+ * @ethertype: ether type to check
+ *
+ * Returns true if the ether type is a vlan ether type.
+ */
+static inline bool eth_type_vlan(__be16 ethertype)
+{
+   switch (ethertype) {
+   case htons(ETH_P_8021Q):
+   case htons(ETH_P_8021AD):
+   return true;
+   default:
+   return false;
+   }
+}

  /**
   * compare_vlan_header - Compare two vlan headers

Description ?
This patch simplifies the code for openvswitch and potential other vlan 
code and drivers. There are at least two valid ether types for vlans and 
this code simplifies the openvswitch kernel module by simplifying code 
that checks for the presence of vlans. Do you want me to annotate the 
commit with additional description?


Albino


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


Re: [ovs-dev] [PATCH net-next V18 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-27 Thread Thomas F Herbert

On 10/26/15 10:10 PM, Pravin Shelar wrote:
Thanks for the review.

On Sun, Oct 25, 2015 at 5:11 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes. Outer
TPID is also encoded in the flow key.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>

This patch does not apply on current master due to conflicts related
net-branch merge.

OK, I will rebase.



---
  net/openvswitch/actions.c  |   6 +-
  net/openvswitch/flow.c |  76 
  net/openvswitch/flow.h |   8 +-
  net/openvswitch/flow_netlink.c | 199 +
  net/openvswitch/vport-netdev.c |   4 +-
  5 files changed, 252 insertions(+), 41 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..ed19e2b 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -302,24 +302,68 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
   sizeof(struct icmp6hdr));
  }

-static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+/* Parse vlan tag from vlan header.
+ * Returns ERROR on memory error.
+ * Returns 0 if it encounters a non-vlan or incomplete packet.
+ * Returns 1 after successfully parsing vlan tag.
+ */
+
+static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *vlan)
  {
-   struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
-   __be16 tci;
-   };
-   struct qtag_prefix *qp;
+   struct vlan_head *qp = (struct vlan_head *)skb->data;
+
+   if (likely(!eth_type_vlan(qp->tpid)))
+   return 0;

-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   if (unlikely(skb->len < sizeof(struct vlan_head) + sizeof(__be16)))
 return 0;

Why do we need extra sizeof(__be16) bytes here?
I don't have an answer to your question. I didn't write this code and 
have wondered about why the extra two bytes were reserved. I don't know 
why it should be necessarily for inner or outer vlans or the HW 
accelerated case or for the non-accelerated case. If no reviewer can 
state a case for it, I will remove it with the next version of this patch.



-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct vlan_head) +
+sizeof(__be16
 return -ENOMEM;

-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   vlan->tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   vlan->tpid = qp->tpid;
+
+   __skb_pull(skb, sizeof(struct vlan_head));
+   return 1;
+}
+

...


diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index c92d6a2..7e90f8c 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c

...


+
+static int parse_vlan_from_nlattrs(const struct nlattr **nla,
+  struct sw_flow_match *match,
+  u64 *key_attrs, bool *ie_valid,
+  const struct nlattr **a, bool is_mask,
+  bool log)
+{
+   int err;
+   const struct nlattr *encap;
+   u64 v_attrs = 0;
+
+   if (!is_mask) {
+   err = __parse_vlan_from_nlattrs(nla, match, key_attrs,
+   false, a, is_mask, log);
+   if (err)
+   return err;
+
+   /* Another encap attribute here indicates
+* the presence of a double tagged vlan.
+*/
+   encap = a[OVS_KEY_ATTR_ENCAP];
+
+   err = parse_flow_nlattrs(encap, a, _attrs, log);
+   if (err)
+   return err;
+
+   if ((v_attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) &&
+   eth_type_vlan(nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]))) {
+   if (!((v_attrs & (1 << OVS_KEY_ATTR_VLAN)) &&
+ (v_attrs & (1 << OVS_KEY_ATTR_ENCAP {
+   OVS_NLERR(log, "Invalid Inner VLAN frame");
+   return -EINVAL;
+   }
+   *ie_valid = true;
+   err = __parse_vlan_from_nlattrs(, match, _attrs,
+   true, a, is_mask, log);
+   if (err)
+   

[ovs-dev] [PATCH net-next V17 1/3] openvswitch: 802.1ad uapi changes.

2015-10-25 Thread Thomas F Herbert
openvswitch: Add support for 8021.AD

Change the description of the VLAN tpid field.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/uapi/linux/openvswitch.h | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 32e07d8..b0c959c 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -585,13 +585,13 @@ struct ovs_action_push_mpls {
  * @vlan_tci: Tag control identifier (TCI) to push.  The CFI bit must be set
  * (but it will not be set in the 802.1Q header that is pushed).
  *
- * The @vlan_tpid value is typically %ETH_P_8021Q.  The only acceptable TPID
- * values are those that the kernel module also parses as 802.1Q headers, to
- * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN
- * from having surprising results.
+ * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
+ * The only acceptable TPID values are those that the kernel module also parses
+ * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
+ * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
  */
 struct ovs_action_push_vlan {
-   __be16 vlan_tpid;   /* 802.1Q TPID. */
+   __be16 vlan_tpid;   /* 802.1Q or 802.1ad TPID. */
__be16 vlan_tci;/* 802.1Q TCI (VLAN ID and priority). */
 };
 
@@ -664,9 +664,10 @@ enum ovs_ct_attr {
  * is copied from the value to the packet header field, rest of the bits are
  * left unchanged.  The non-masked value bits must be passed in as zeroes.
  * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
- * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the
- * packet.
- * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet.
+ * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
+ * onto the packet.
+ * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
+ * from the packet.
  * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
  * the nested %OVS_SAMPLE_ATTR_* attributes.
  * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
-- 
2.4.3

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


[ovs-dev] [PATCH net-next V18 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-25 Thread Thomas F Herbert
Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes. Outer
TPID is also encoded in the flow key.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 net/openvswitch/actions.c  |   6 +-
 net/openvswitch/flow.c |  76 
 net/openvswitch/flow.h |   8 +-
 net/openvswitch/flow_netlink.c | 199 +
 net/openvswitch/vport-netdev.c |   4 +-
 5 files changed, 252 insertions(+), 41 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..09cc1c9 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -236,7 +236,8 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key 
*key)
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = 0;
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
return err;
 }
 
@@ -246,7 +247,8 @@ static int push_vlan(struct sk_buff *skb, struct 
sw_flow_key *key,
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = vlan->vlan_tci;
+   key->eth.vlan.tci = vlan->vlan_tci;
+   key->eth.vlan.tpid = vlan->vlan_tpid;
return skb_vlan_push(skb, vlan->vlan_tpid,
 ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
 }
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..ed19e2b 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -302,24 +302,68 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  sizeof(struct icmp6hdr));
 }
 
-static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+/* Parse vlan tag from vlan header.
+ * Returns ERROR on memory error.
+ * Returns 0 if it encounters a non-vlan or incomplete packet.
+ * Returns 1 after successfully parsing vlan tag.
+ */
+
+static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *vlan)
 {
-   struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
-   __be16 tci;
-   };
-   struct qtag_prefix *qp;
+   struct vlan_head *qp = (struct vlan_head *)skb->data;
+
+   if (likely(!eth_type_vlan(qp->tpid)))
+   return 0;
 
-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   if (unlikely(skb->len < sizeof(struct vlan_head) + sizeof(__be16)))
return 0;
 
-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct vlan_head) +
+sizeof(__be16
return -ENOMEM;
 
-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   vlan->tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   vlan->tpid = qp->tpid;
+
+   __skb_pull(skb, sizeof(struct vlan_head));
+   return 1;
+}
+
+static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+{
+   int res;
+
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
+   key->eth.cvlan.tci = 0;
+   key->eth.cvlan.tpid = 0;
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where ingress processing has already stripped
+* the outer vlan tag.
+*/
+   res = parse_vlan_tag(skb, >eth.cvlan);
+   if (res < 0)
+   return res;
+   /* For inner tag, return 0 because neither
+* non-existent nor partial inner tag is an error.
+*/
+   return 0;
+   }
+   res = parse_vlan_tag(skb, >eth.vlan);
+   if (res <= 0)
+   /* This is an outer tag in the non-accelerated VLAN
+* case. Return error unless it is a complete vlan tag.
+*/
+   return res;
+
+   /* Parse inner vlan tag if present for non-accelerated case. */
+   res = parse_vlan_tag(skb, >eth.cvlan);
+   if (res <= 0)
+   return res;
 
return 0;
 }
@@ -480,12 +524,8 @@ static int key_extract(struct sk_buff *skb, struct 
sw_flow_key *key)
 * update skb->csum here.
 */
 
-   key->eth.tci = 0;
-   if (skb_vlan_tag_present(skb))
-   key->eth.tci = htons(skb->vlan_tci);
-  

[ovs-dev] [PATCH net-next V18 0/3] openvswitch: Add support for 802.1ad

2015-10-25 Thread Thomas F Herbert
V18: Patches 1 and 2 in this series have been acked from V17.

Patch 3 in the series includes some significant changes.
The patch includes fixes the decoding of the flow for the
outer tpid. Also, netlink parsing code has been consolidated to generalize
inner and outer vlans and non-mask and masked cases as much as possible.

V17,V16: Implement reviewer's comments.

V15: Implement reviewer comments.

V14: Add outer tpid to flow_key

V13: Fix incorrect encoding and decoding of netlink to/from key
attributes.

V12: Fix some problems and issues pointed out by reviewers. When parsing
netlink attributes Ether types other then 0x88a8 as outer tpid.

V11: Add inner tpid to flow key. Fix separate inner encap attribute
when parsing netlink attributes. Merge 2 patches to consolidate
qinq changes.

V10: Implement reviewer comments: Consolidate vlan parsing functions.
Splits netlink parsing and flow conversion into a separate patch. Uses
double encap attribute encapsulation for 802.1ad.  Netlink attributes
now look like this:

eth_type(0x88a8),vlan(vid=100),encap(eth_type(0x8100), vlan(vid=200),
 encap(eth_type(0x0800), ...))

The double encap atributes in this version of the patch is incompatible with
old versions of the user level 802.1ad patch. A new user level patch which
is also being submitted simultaneously to openvswitch dev mailing list.

V9:  Includes changes suggested by reviewers

V8:  Includes changes suggested by reviewers

V7:  Includes changes suggested by reviewers

V6:  Rebased to net-next

V5:  Use encapsulated attributes


For discussion, history  and previous versions of the kernel module
patch and the user code patch see the OVS dev mailing list,
openvswitch.org/pipermail/dev/..

Thomas F Herbert (3):
  openvswitch: 802.1ad uapi changes.
  Check for vlan ethernet types for 8021.q or 802.1ad
  802.1AD: Flow handling, actions, vlan parsing and netlink attributes

 include/linux/if_vlan.h  |  16 
 include/uapi/linux/openvswitch.h |  17 ++--
 net/openvswitch/actions.c|   6 +-
 net/openvswitch/flow.c   |  76 +++
 net/openvswitch/flow.h   |   8 +-
 net/openvswitch/flow_netlink.c   | 199 +++
 net/openvswitch/vport-netdev.c   |   4 +-
 7 files changed, 277 insertions(+), 49 deletions(-)

-- 
2.4.3

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


[ovs-dev] [PATCH net-next V17 2/3] Check for vlan ethernet types for 8021.q or 802.1ad

2015-10-25 Thread Thomas F Herbert
Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/linux/if_vlan.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 67ce5bd..d2494b5 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -627,6 +627,22 @@ static inline netdev_features_t vlan_features_check(const 
struct sk_buff *skb,
 
return features;
 }
+/**
+ * eth_type_vlan - check for valid vlan ether type.
+ * @ethertype: ether type to check
+ *
+ * Returns true if the ether type is a vlan ether type.
+ */
+static inline bool eth_type_vlan(__be16 ethertype)
+{
+   switch (ethertype) {
+   case htons(ETH_P_8021Q):
+   case htons(ETH_P_8021AD):
+   return true;
+   default:
+   return false;
+   }
+}
 
 /**
  * compare_vlan_header - Compare two vlan headers
-- 
2.4.3

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


Re: [ovs-dev] [PATCH net-next V17 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-23 Thread Thomas F Herbert

On 10/23/15 3:26 PM, Pravin Shelar wrote:

On Wed, Oct 21, 2015 at 7:39 AM, Thomas F Herbert <therb...@redhat.com> wrote:


On 10/20/15 4:34 PM, Pravin Shelar wrote:

On Tue, Oct 20, 2015 at 7:26 AM, Thomas F Herbert
<thomasfherb...@gmail.com>  wrote:

On 10/19/15 2:28 PM, Pravin Shelar wrote:

On Sat, Oct 17, 2015 at 6:12 PM, Thomas F Herbert
<thomasfherb...@gmail.com>  wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert<thomasfherb...@gmail.com>
---
net/openvswitch/actions.c  |   6 +-
net/openvswitch/flow.c |  76 +-
net/openvswitch/flow.h |   8 +-
net/openvswitch/flow_netlink.c | 172
+
net/openvswitch/vport-netdev.c |   4 +-
5 files changed, 227 insertions(+), 39 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..09cc1c9 100644

...


diff --git a/net/openvswitch/flow_netlink.c
b/net/openvswitch/flow_netlink.c
index c92d6a2..97a6d12 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c

...


@@ -1320,6 +1443,7 @@ static int __ovs_nla_put_key(const struct
sw_flow_key *swkey,
{
   struct ovs_key_ethernet *eth_key;
   struct nlattr *nla, *encap;
+   struct nlattr *in_encap = NULL;

   if (nla_put_u32(skb, OVS_KEY_ATTR_RECIRC_ID,
output->recirc_id))
   goto nla_put_failure;
@@ -1368,17 +1492,29 @@ static int __ovs_nla_put_key(const struct
sw_flow_key *swkey,
   ether_addr_copy(eth_key->eth_src, output->eth.src);
   ether_addr_copy(eth_key->eth_dst, output->eth.dst);

-   if (swkey->eth.tci || swkey->eth.type == htons(ETH_P_8021Q)) {
-   __be16 eth_type;
-   eth_type = !is_mask ? htons(ETH_P_8021Q) :
htons(0x);
-   if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type)
||
-   nla_put_be16(skb, OVS_KEY_ATTR_VLAN,
output->eth.tci))
+   if (swkey->eth.vlan.tci || eth_type_vlan(swkey->eth.type)) {
+   if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE,
+output->eth.vlan.tpid) ||
+   nla_put_be16(skb, OVS_KEY_ATTR_VLAN,
output->eth.vlan.tci))
   goto nla_put_failure;
   encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
-   if (!swkey->eth.tci)
+   if (!swkey->eth.vlan.tci)
   goto unencap;
-   } else
+   if (swkey->eth.cvlan.tci) {
+   /* Customer tci is nested but uses same key
attribute.
+*/
+   if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE,
+output->eth.cvlan.tpid) ||
+   nla_put_be16(skb, OVS_KEY_ATTR_VLAN,
+output->eth.cvlan.tci))
+   goto nla_put_failure;
+   in_encap = nla_nest_start(skb,
OVS_KEY_ATTR_ENCAP);
+   if (!swkey->eth.cvlan.tci)
+   goto unencap;
+   }
+   } else {
   encap = NULL;
+   }

After the vlan parsing changes, we need to encode cvlan in outer
netlink attribute and then encode regular vlan.

I don't understand this. cvlan is inner vlan, why would it be encoded in
outer vlan without the 2nd layer of encapsulation?


Lets start with double tagged packet.
packet: eth, vlan 10, inner vlan 20, ip.
flow key would be:
flow_key: vlan = 10, cvlan = 20
That would get serialize over netlink like:

eth_type(0x8100),vlan(vid=10,pcp=0),encap(eth_type(0x8100),vlan(vid=20,pcp=0),
encap(eth_type(0x0800),ipv4(frag=no))...
So far looks good.

Now userspace sends back same key and installs flow in kernel
datapath. But ovs_nla_get_match() parses netink key and sets vlan in
reverse order. After parsing netlink in ovs_nla_get_match() vlans
flow-key would look like:
flow_key: vlan = 20, cvlan = 10. This is not what we started with.

Now I think rather than fixing __ovs_nla_put_key (), we need to fix
ovs_nla_get_match() to keep vlan order.
I also noticed that eth.vlan.tpid is never initialized from netlink
attributes.

Yes, you are right. The code in master never encoded the tpid in the key and
I didn't add it when I modified the swkey for the addition of the vlan
struct.

Yes, you are right the code is wrong. The intention was to leave the old
code which left the outer tci in the key for later processing. In the code
in master, after checking proper vlan the function ovs_key_from_nlattrs()
encoded the tci.

Now I see th

Re: [ovs-dev] [PATCH net-next V17 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-21 Thread Thomas F Herbert



On 10/20/15 4:34 PM, Pravin Shelar wrote:

On Tue, Oct 20, 2015 at 7:26 AM, Thomas F Herbert
<thomasfherb...@gmail.com>  wrote:

On 10/19/15 2:28 PM, Pravin Shelar wrote:

On Sat, Oct 17, 2015 at 6:12 PM, Thomas F Herbert
<thomasfherb...@gmail.com>  wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert<thomasfherb...@gmail.com>
---
   net/openvswitch/actions.c  |   6 +-
   net/openvswitch/flow.c |  76 +-
   net/openvswitch/flow.h |   8 +-
   net/openvswitch/flow_netlink.c | 172
+
   net/openvswitch/vport-netdev.c |   4 +-
   5 files changed, 227 insertions(+), 39 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..09cc1c9 100644

...


diff --git a/net/openvswitch/flow_netlink.c
b/net/openvswitch/flow_netlink.c
index c92d6a2..97a6d12 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c

...


@@ -1320,6 +1443,7 @@ static int __ovs_nla_put_key(const struct
sw_flow_key *swkey,
   {
  struct ovs_key_ethernet *eth_key;
  struct nlattr *nla, *encap;
+   struct nlattr *in_encap = NULL;

  if (nla_put_u32(skb, OVS_KEY_ATTR_RECIRC_ID, output->recirc_id))
  goto nla_put_failure;
@@ -1368,17 +1492,29 @@ static int __ovs_nla_put_key(const struct
sw_flow_key *swkey,
  ether_addr_copy(eth_key->eth_src, output->eth.src);
  ether_addr_copy(eth_key->eth_dst, output->eth.dst);

-   if (swkey->eth.tci || swkey->eth.type == htons(ETH_P_8021Q)) {
-   __be16 eth_type;
-   eth_type = !is_mask ? htons(ETH_P_8021Q) : htons(0x);
-   if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type)
||
-   nla_put_be16(skb, OVS_KEY_ATTR_VLAN,
output->eth.tci))
+   if (swkey->eth.vlan.tci || eth_type_vlan(swkey->eth.type)) {
+   if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE,
+output->eth.vlan.tpid) ||
+   nla_put_be16(skb, OVS_KEY_ATTR_VLAN,
output->eth.vlan.tci))
  goto nla_put_failure;
  encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
-   if (!swkey->eth.tci)
+   if (!swkey->eth.vlan.tci)
  goto unencap;
-   } else
+   if (swkey->eth.cvlan.tci) {
+   /* Customer tci is nested but uses same key
attribute.
+*/
+   if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE,
+output->eth.cvlan.tpid) ||
+   nla_put_be16(skb, OVS_KEY_ATTR_VLAN,
+output->eth.cvlan.tci))
+   goto nla_put_failure;
+   in_encap = nla_nest_start(skb,
OVS_KEY_ATTR_ENCAP);
+   if (!swkey->eth.cvlan.tci)
+   goto unencap;
+   }
+   } else {
  encap = NULL;
+   }

After the vlan parsing changes, we need to encode cvlan in outer
netlink attribute and then encode regular vlan.

I don't understand this. cvlan is inner vlan, why would it be encoded in
outer vlan without the 2nd layer of encapsulation?


Lets start with double tagged packet.
packet: eth, vlan 10, inner vlan 20, ip.
flow key would be:
flow_key: vlan = 10, cvlan = 20
That would get serialize over netlink like:
eth_type(0x8100),vlan(vid=10,pcp=0),encap(eth_type(0x8100),vlan(vid=20,pcp=0),
encap(eth_type(0x0800),ipv4(frag=no))...
So far looks good.

Now userspace sends back same key and installs flow in kernel
datapath. But ovs_nla_get_match() parses netink key and sets vlan in
reverse order. After parsing netlink in ovs_nla_get_match() vlans
flow-key would look like:
flow_key: vlan = 20, cvlan = 10. This is not what we started with.

Now I think rather than fixing __ovs_nla_put_key (), we need to fix
ovs_nla_get_match() to keep vlan order.
I also noticed that eth.vlan.tpid is never initialized from netlink attributes.
Yes, you are right. The code in master never encoded the tpid in the key 
and I didn't add it when I modified the swkey for the addition of the 
vlan struct.


Yes, you are right the code is wrong. The intention was to leave the old 
code which left the outer tci in the key for later processing. In the 
code in master, after checking proper vlan the function 
ovs_key_from_nlattrs() encoded the tci.


Now I see that I must refactor the code in ovs_nla_get_match() and 
parse_vlan_from_nlattrs to explicitly encode the outer vlan including 
tpid before the i

Re: [ovs-dev] [PATCH net-next V17 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-20 Thread Thomas F Herbert

On 10/19/15 2:28 PM, Pravin Shelar wrote:

On Sat, Oct 17, 2015 at 6:12 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
  net/openvswitch/actions.c  |   6 +-
  net/openvswitch/flow.c |  76 +-
  net/openvswitch/flow.h |   8 +-
  net/openvswitch/flow_netlink.c | 172 +
  net/openvswitch/vport-netdev.c |   4 +-
  5 files changed, 227 insertions(+), 39 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..09cc1c9 100644

...


diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index c92d6a2..97a6d12 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c

...


@@ -1320,6 +1443,7 @@ static int __ovs_nla_put_key(const struct sw_flow_key 
*swkey,
  {
 struct ovs_key_ethernet *eth_key;
 struct nlattr *nla, *encap;
+   struct nlattr *in_encap = NULL;

 if (nla_put_u32(skb, OVS_KEY_ATTR_RECIRC_ID, output->recirc_id))
 goto nla_put_failure;
@@ -1368,17 +1492,29 @@ static int __ovs_nla_put_key(const struct sw_flow_key 
*swkey,
 ether_addr_copy(eth_key->eth_src, output->eth.src);
 ether_addr_copy(eth_key->eth_dst, output->eth.dst);

-   if (swkey->eth.tci || swkey->eth.type == htons(ETH_P_8021Q)) {
-   __be16 eth_type;
-   eth_type = !is_mask ? htons(ETH_P_8021Q) : htons(0x);
-   if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type) ||
-   nla_put_be16(skb, OVS_KEY_ATTR_VLAN, output->eth.tci))
+   if (swkey->eth.vlan.tci || eth_type_vlan(swkey->eth.type)) {
+   if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE,
+output->eth.vlan.tpid) ||
+   nla_put_be16(skb, OVS_KEY_ATTR_VLAN, output->eth.vlan.tci))
 goto nla_put_failure;
 encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
-   if (!swkey->eth.tci)
+   if (!swkey->eth.vlan.tci)
 goto unencap;
-   } else
+   if (swkey->eth.cvlan.tci) {
+   /* Customer tci is nested but uses same key attribute.
+*/
+   if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE,
+output->eth.cvlan.tpid) ||
+   nla_put_be16(skb, OVS_KEY_ATTR_VLAN,
+output->eth.cvlan.tci))
+   goto nla_put_failure;
+   in_encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
+   if (!swkey->eth.cvlan.tci)
+   goto unencap;
+   }
+   } else {
 encap = NULL;
+   }

After the vlan parsing changes, we need to encode cvlan in outer
netlink attribute and then encode regular vlan.
I don't understand this. cvlan is inner vlan, why would it be encoded in 
outer vlan without the 2nd layer of encapsulation?


One think I see I should have done is check for eth_type_vlan() on the 
inner tag as well.

Currently we are
reversing netlink encoding while sending back the vlan attributes.
cvlan and vlan is independent,
Are you talking about a corner case where the incoming packet has an 
inner vlan but no outer vlN?

therefore we need to check
swkey->eth.cvlan.tc outside of swkey->eth.vlan.tci block. Also
redundant check for swkey->eth.cvlan.tci should be removed
I must be missing something because I don't understand this either. 
First my patch encodes the outer vlan and then sets the encap bit and 
then encodes the inner vlan. The encoding shows up correctly in user space.


Can you also post changes for userspace vswitchd so that I can try next patch.
I posted a patch for user space (V14) to ovs dev on October 2nd. I 
haven't made any changes since then.

http://openvswitch.org/pipermail/dev/2015-October/060874.html

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


[ovs-dev] [PATCH net-next V17 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-17 Thread Thomas F Herbert
Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 net/openvswitch/actions.c  |   6 +-
 net/openvswitch/flow.c |  76 +-
 net/openvswitch/flow.h |   8 +-
 net/openvswitch/flow_netlink.c | 172 +
 net/openvswitch/vport-netdev.c |   4 +-
 5 files changed, 227 insertions(+), 39 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..09cc1c9 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -236,7 +236,8 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key 
*key)
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = 0;
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
return err;
 }
 
@@ -246,7 +247,8 @@ static int push_vlan(struct sk_buff *skb, struct 
sw_flow_key *key,
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = vlan->vlan_tci;
+   key->eth.vlan.tci = vlan->vlan_tci;
+   key->eth.vlan.tpid = vlan->vlan_tpid;
return skb_vlan_push(skb, vlan->vlan_tpid,
 ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
 }
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..ed19e2b 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -302,24 +302,68 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  sizeof(struct icmp6hdr));
 }
 
-static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+/* Parse vlan tag from vlan header.
+ * Returns ERROR on memory error.
+ * Returns 0 if it encounters a non-vlan or incomplete packet.
+ * Returns 1 after successfully parsing vlan tag.
+ */
+
+static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *vlan)
 {
-   struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
-   __be16 tci;
-   };
-   struct qtag_prefix *qp;
+   struct vlan_head *qp = (struct vlan_head *)skb->data;
+
+   if (likely(!eth_type_vlan(qp->tpid)))
+   return 0;
 
-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   if (unlikely(skb->len < sizeof(struct vlan_head) + sizeof(__be16)))
return 0;
 
-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct vlan_head) +
+sizeof(__be16
return -ENOMEM;
 
-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   vlan->tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   vlan->tpid = qp->tpid;
+
+   __skb_pull(skb, sizeof(struct vlan_head));
+   return 1;
+}
+
+static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+{
+   int res;
+
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
+   key->eth.cvlan.tci = 0;
+   key->eth.cvlan.tpid = 0;
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where ingress processing has already stripped
+* the outer vlan tag.
+*/
+   res = parse_vlan_tag(skb, >eth.cvlan);
+   if (res < 0)
+   return res;
+   /* For inner tag, return 0 because neither
+* non-existent nor partial inner tag is an error.
+*/
+   return 0;
+   }
+   res = parse_vlan_tag(skb, >eth.vlan);
+   if (res <= 0)
+   /* This is an outer tag in the non-accelerated VLAN
+* case. Return error unless it is a complete vlan tag.
+*/
+   return res;
+
+   /* Parse inner vlan tag if present for non-accelerated case. */
+   res = parse_vlan_tag(skb, >eth.cvlan);
+   if (res <= 0)
+   return res;
 
return 0;
 }
@@ -480,12 +524,8 @@ static int key_extract(struct sk_buff *skb, struct 
sw_flow_key *key)
 * update skb->csum here.
 */
 
-   key->eth.tci = 0;
-   if (skb_vlan_tag_present(skb))
-   key->eth.tci = htons(skb->vlan_tci);
-   else if (eth->h_proto == htons(ETH_P_8

[ovs-dev] [PATCH net-next V17 0/3] openvswitch: Add support for 802.1ad

2015-10-17 Thread Thomas F Herbert
V17,V16: Implement reviewer's comments.

V15: Implement reviewer comments.

V14: Add outer tpid to flow_key

V13: Fix incorrect encoding and decoding of netlink to/from key
attributes.

V12: Fix some problems and issues pointed out by reviewers. When parsing
netlink attributes Ether types other then 0x88a8 as outer tpid.

V11: Add inner tpid to flow key. Fix separate inner encap attribute
when parsing netlink attributes. Merge 2 patches to consolidate
qinq changes.

V10: Implement reviewer comments: Consolidate vlan parsing functions.
Splits netlink parsing and flow conversion into a separate patch. Uses
double encap attribute encapsulation for 802.1ad.  Netlink attributes
now look like this:

eth_type(0x88a8),vlan(vid=100),encap(eth_type(0x8100), vlan(vid=200),
 encap(eth_type(0x0800), ...))

The double encap atributes in this version of the patch is incompatible with
old versions of the user level 802.1ad patch. A new user level patch which
is also being submitted simultaneously to openvswitch dev mailing list.

V9:  Includes changes suggested by reviewers

V8:  Includes changes suggested by reviewers

V7:  Includes changes suggested by reviewers

V6:  Rebased to net-next

V5:  Use encapsulated attributes


For discussion, history  and previous versions of the kernel module
patch and the user code patch see the OVS dev mailing list,
openvswitch.org/pipermail/dev/..

Thomas F Herbert (3):
  openvswitch: 802.1ad uapi changes.
  Check for vlan ethernet types for 8021.q or 802.1ad
  802.1AD: Flow handling, actions, vlan parsing and netlink attributes

 include/linux/if_vlan.h  |  16 
 include/uapi/linux/openvswitch.h |  17 ++--
 net/openvswitch/actions.c|   6 +-
 net/openvswitch/flow.c   |  76 +
 net/openvswitch/flow.h   |   8 +-
 net/openvswitch/flow_netlink.c   | 172 +++
 net/openvswitch/vport-netdev.c   |   4 +-
 7 files changed, 252 insertions(+), 47 deletions(-)

-- 
2.4.3

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


Re: [ovs-dev] [PATCH net-next V16 0/3] openvswitch: Add support for 802.1ad

2015-10-16 Thread Thomas F Herbert

On 10/16/15 2:16 AM, David Miller wrote:

From: Thomas F Herbert <thomasfherb...@gmail.com>
Date: Thu, 15 Oct 2015 10:01:52 -0400


  This patch accompanies version 14 of the user level openvswitch patch
  submitted to openvswitch dev list.

  V16,15: Implement reviewer comments.

Missing signoffs, missed handling of feedback from Sergei, so sorry
this still needs work :-/
Sorry, I was focused on Pravin's review and missed that. Next series 
today will delete the redundant parens, Thanks Sergei. and some rework 
after Pravin's reviews.


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


Re: [ovs-dev] [PATCH net-next V15 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-15 Thread Thomas F Herbert

On 10/13/15 2:14 PM, Pravin Shelar wrote:

On Tue, Oct 13, 2015 at 10:39 AM, Thomas F Herbert
<thomasfherb...@gmail.com>  wrote:

Pravin,

Thanks for the review.


On 10/13/15 7:47 AM, Pravin Shelar wrote:

On Sat, Oct 10, 2015 at 4:40 PM, Thomas F Herbert
<thomasfherb...@gmail.com>  wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert<thomasfherb...@gmail.com>
---
   net/openvswitch/actions.c  |   6 +-
   net/openvswitch/flow.c |  92 +++
   net/openvswitch/flow.h |  11 ++-
   net/openvswitch/flow_netlink.c | 166
+
   net/openvswitch/vport-netdev.c |   4 +-
   5 files changed, 245 insertions(+), 34 deletions(-)


...


...


I see lot of duplicate code here. How about code below:

struct qtag_prefix {
  __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
  __be16 tci;
};

/* Return  < 0 on memory error
   * Return   == 0 on non vlan or incomplete packet packet
   * Return > 0 on successfully parsing vlan tag.
   */
static int parse_vlan_tag(__be16 vlan_proto, struct sk_buff *skb,
struct vlan_tag *cvlan)
{
  if (likely(!eth_type_vlan(skb->vlan_proto)))
  return 0;

  if (unlikely(skb->len < sizeof(struct qtag_prefix) +
sizeof(__be16))) {
  vlan->tci = 0;
  return 0;
  }

  if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
sizeof(__be16
  return -ENOMEM;

  qp = (struct qtag_prefix *)skb->data;
  key->eth.cvlan.tci = qp->tci | htons(VLAN_TAG_PRESENT);
  key->eth.cvlan.tpid = qp->eth_type;

  __skb_pull(skb, sizeof(struct qtag_prefix));
  return 1;
}

This makes for cleaner code and certainly better for maintainability so I
have just implemented it for this next revision. However, note that with
this change, we incur the overhead of an additional function call for single
tagged vlan packets.


If there is any performance issue we can fix the code later.


static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
{
  struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;

...


+   u64 mask_v_attrs = 0;
+
+   err = parse_flow_mask_nlattrs(*nla, a, _v_attrs,
log);
+   if (err)
+   return err;
+
+   if (mask_v_attrs & 1 << OVS_KEY_ATTR_ENCAP) {
+   if (!*ie_valid) {
+   OVS_NLERR(log, "Encap mask attribute is
set for non-CVLAN frame.");
+   err = -EINVAL;
+   return err;
+   }
+   encap = a[OVS_KEY_ATTR_ENCAP];
+
+   err = cust_vlan_from_nlattrs(match, a, is_mask,
log);
+   if (err)
+   return err;
+   *nla = encap;
+

There is no checking for ATTR_VLAN or ATTR_ETHERTYPE. This can result
in null pointer deference in cust_vlan_from_nlattrs().

The original vlan code does not check for these attribs in the masked case.
It does check for them in the non-masked case and then sets a boolean and
checks it in the masked case. I do the same thing for the inner vlan. I
check for the attributes in the non-masked case and set a boolean and check
the boolean in the masked case. Why is this not sufficient?

Original code is checking for attributes before referencing them. For
example  in function ovs_nla_get_match() before extracting eth_type,
it does check a[OVS_KEY_ATTR_ETHERTYPE]. But If you spot bug in
current code please send fix for net tree.
Regarding the Boolean, it is for presence of inner vlan for key
attribute, mask attribute still could be missing vlan attribute.
For vlan mask, we can keep check sanity check as outer vlan. It means
eth_type must be specified and should be 0x, and tci mask is
optional and by default initialized to 0x.
You are correct. I was thinking of something else. I had this but must 
have lost it one of the patch revisions. Fixed it in V16.


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


[ovs-dev] [PATCH net-next V16 0/3] openvswitch: Add support for 802.1ad

2015-10-15 Thread Thomas F Herbert
 This patch accompanies version 14 of the user level openvswitch patch
 submitted to openvswitch dev list.

 V16,15: Implement reviewer comments.

 V14: Add outer tpid to flow_key

 V13: Fix incorrect encoding and decoding of netlink to/from key
 attributes.

 V12: Fix some problems and issues pointed out by reviewers. When parsing
 netlink attributes Ether types other then 0x88a8 as outer tpid.

 V11: Add inner tpid to flow key. Fix separate inner encap attribute
 when parsing netlink attributes. Merge 2 patches to consolidate
 qinq changes.

 V10: Implement reviewer comments: Consolidate vlan parsing functions.
 Splits netlink parsing and flow conversion into a separate patch. Uses
 double encap attribute encapsulation for 802.1ad.  Netlink attributes
 now look like this:

  eth_type(0x88a8),vlan(vid=100),encap(eth_type(0x8100), vlan(vid=200),
   encap(eth_type(0x0800), ...))

The double encap atributes in this version of the patch is incompatible with
old versions of the user level 802.1ad patch. A new user level patch which
is also being submitted simultaneously to openvswitch dev mailing list.

V9:  Includes changes suggested by reviewers

V8:  Includes changes suggested by reviewers

V7:  Includes changes suggested by reviewers

V6:  Rebased to net-next

V5:  Use encapsulated attributes


For discussion, history  and previous versions of the kernel module
patch and the user code patch see the OVS dev mailing list,
openvswitch.org/pipermail/dev/..

Thomas F Herbert (3):
  openvswitch: 802.1ad uapi changes.
  Check for vlan ethernet types for 8021.q or 802.1ad
  802.1AD: Flow handling, actions, vlan parsing and netlink attributes

 include/linux/if_vlan.h  |  16 
 include/uapi/linux/openvswitch.h |  17 ++--
 net/openvswitch/actions.c|   6 +-
 net/openvswitch/flow.c   |  75 +
 net/openvswitch/flow.h   |   8 +-
 net/openvswitch/flow_netlink.c   | 169 +++
 net/openvswitch/vport-netdev.c   |   4 +-
 7 files changed, 253 insertions(+), 42 deletions(-)

-- 
2.4.3

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


[ovs-dev] [PATCH net-next V16 1/3] openvswitch: 802.1ad uapi changes.

2015-10-15 Thread Thomas F Herbert
openvswitch: Add support for 8021.AD

Change the description of the VLAN tpid field.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/uapi/linux/openvswitch.h | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 32e07d8..b0c959c 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -585,13 +585,13 @@ struct ovs_action_push_mpls {
  * @vlan_tci: Tag control identifier (TCI) to push.  The CFI bit must be set
  * (but it will not be set in the 802.1Q header that is pushed).
  *
- * The @vlan_tpid value is typically %ETH_P_8021Q.  The only acceptable TPID
- * values are those that the kernel module also parses as 802.1Q headers, to
- * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN
- * from having surprising results.
+ * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
+ * The only acceptable TPID values are those that the kernel module also parses
+ * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
+ * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
  */
 struct ovs_action_push_vlan {
-   __be16 vlan_tpid;   /* 802.1Q TPID. */
+   __be16 vlan_tpid;   /* 802.1Q or 802.1ad TPID. */
__be16 vlan_tci;/* 802.1Q TCI (VLAN ID and priority). */
 };
 
@@ -664,9 +664,10 @@ enum ovs_ct_attr {
  * is copied from the value to the packet header field, rest of the bits are
  * left unchanged.  The non-masked value bits must be passed in as zeroes.
  * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
- * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the
- * packet.
- * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet.
+ * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
+ * onto the packet.
+ * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
+ * from the packet.
  * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
  * the nested %OVS_SAMPLE_ATTR_* attributes.
  * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
-- 
2.4.3

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


[ovs-dev] [PATCH net-next V16 2/3] Check for vlan ethernet types for 8021.q or 802.1ad

2015-10-15 Thread Thomas F Herbert
---
 include/linux/if_vlan.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 67ce5bd..ac23521 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -627,6 +627,22 @@ static inline netdev_features_t vlan_features_check(const 
struct sk_buff *skb,
 
return features;
 }
+/**
+ * eth_type_vlan - check for valid vlan ether type.
+ * @ethertype: ether type to check
+ *
+ * Returns true if the ether type is a vlan ether type.
+ */
+static inline bool eth_type_vlan(__be16 ethertype)
+{
+   switch (ethertype) {
+   case (htons(ETH_P_8021Q)):
+   case (htons(ETH_P_8021AD)):
+   return true;
+   default:
+   return false;
+   }
+}
 
 /**
  * compare_vlan_header - Compare two vlan headers
-- 
2.4.3

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


[ovs-dev] [PATCH net-next V16 3/3] openvswitch: 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-15 Thread Thomas F Herbert
Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 net/openvswitch/actions.c  |   6 +-
 net/openvswitch/flow.c |  75 ++
 net/openvswitch/flow.h |   8 +-
 net/openvswitch/flow_netlink.c | 169 +
 net/openvswitch/vport-netdev.c |   4 +-
 5 files changed, 228 insertions(+), 34 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..09cc1c9 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -236,7 +236,8 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key 
*key)
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = 0;
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
return err;
 }
 
@@ -246,7 +247,8 @@ static int push_vlan(struct sk_buff *skb, struct 
sw_flow_key *key,
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = vlan->vlan_tci;
+   key->eth.vlan.tci = vlan->vlan_tci;
+   key->eth.vlan.tpid = vlan->vlan_tpid;
return skb_vlan_push(skb, vlan->vlan_tpid,
 ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
 }
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..8a4e298 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -302,24 +302,69 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  sizeof(struct icmp6hdr));
 }
 
-static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+struct qtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+};
+
+/* Parse vlan tag from vlan header.
+ * Returns ERROR on memory error.
+ * Returns 0 if it encounters a non-vlan or incomplete packet.
+ * Returns 1 after successfully parsing vlan tag.
+ */
+
+static int parse_vlan_tag(struct sk_buff *skb, __be16 vlan_proto,
+ __be16 vlan_tci, struct vlan_head *vlan)
 {
-   struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
-   __be16 tci;
-   };
-   struct qtag_prefix *qp;
+   if (likely(!eth_type_vlan(vlan_proto)))
+   return 0;
 
if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
return 0;
 
if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
+sizeof(__be16
return -ENOMEM;
 
-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   vlan->tci = vlan_tci | htons(VLAN_TAG_PRESENT);
+   vlan->tpid = vlan_proto;
+
__skb_pull(skb, sizeof(struct qtag_prefix));
+   return 1;
+}
+
+static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+{
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;
+   int res;
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where ingress processing has already stripped
+* the outer vlan tag.
+*/
+   res = parse_vlan_tag(skb, qp->eth_type, qp->tci,
+>eth.cvlan);
+   if (res < 0)
+   return res;
+   /* For inner tag, return 0 because neither
+* non-existant nor partial inner tag is an error.
+*/
+   return 0;
+   }
+   res = parse_vlan_tag(skb, qp->eth_type, qp->tci, >eth.vlan);
+   if (res <= 0)
+   /* This is an outer tag in the non-accelerated VLAN
+* case. Return error unless it is a complete vlan tag.
+*/
+   return res;
+
+   /* Parse inner vlan tag if present for non-accelerated case. */
+   res = parse_vlan_tag(skb, qp->eth_type, qp->tci, >eth.cvlan);
+   if (res <= 0)
+   return res;
 
return 0;
 }
@@ -480,12 +525,12 @@ static int key_extract(struct sk_buff *skb, struct 
sw_flow_key *key)
 * update skb->csum here.
 */
 
-   key->eth.tci = 0;
-   if (skb_vlan_tag_present(skb))
-   key->eth.tci = htons(skb->vlan_tci);
-   else if (eth->h_proto == htons(ETH_P_8021Q))
-   if (unlikely(parse_v

Re: [ovs-dev] [PATCH net-next V16 3/3] openvswitch: 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-15 Thread Thomas F Herbert

On 10/15/15 7:02 PM, Pravin Shelar wrote:
Thanks for the review. See my comment below.

--TFH


On Thu, Oct 15, 2015 at 7:01 AM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
  net/openvswitch/actions.c  |   6 +-
  net/openvswitch/flow.c |  75 ++
  net/openvswitch/flow.h |   8 +-
  net/openvswitch/flow_netlink.c | 169 +
  net/openvswitch/vport-netdev.c |   4 +-
  5 files changed, 228 insertions(+), 34 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..09cc1c9 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -236,7 +236,8 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key 
*key)
 if (skb_vlan_tag_present(skb))
 invalidate_flow_key(key);
 else
-   key->eth.tci = 0;
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
 return err;
  }

@@ -246,7 +247,8 @@ static int push_vlan(struct sk_buff *skb, struct 
sw_flow_key *key,
 if (skb_vlan_tag_present(skb))
 invalidate_flow_key(key);
 else
-   key->eth.tci = vlan->vlan_tci;
+   key->eth.vlan.tci = vlan->vlan_tci;
+   key->eth.vlan.tpid = vlan->vlan_tpid;
 return skb_vlan_push(skb, vlan->vlan_tpid,
  ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
  }
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..8a4e298 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -302,24 +302,69 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
   sizeof(struct icmp6hdr));
  }

-static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+struct qtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+};
+

Now we can just use newly defined struct vlan_header here.


+/* Parse vlan tag from vlan header.
+ * Returns ERROR on memory error.
+ * Returns 0 if it encounters a non-vlan or incomplete packet.
+ * Returns 1 after successfully parsing vlan tag.
+ */
+
+static int parse_vlan_tag(struct sk_buff *skb, __be16 vlan_proto,
+ __be16 vlan_tci, struct vlan_head *vlan)
  {
-   struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
-   __be16 tci;
-   };
-   struct qtag_prefix *qp;
+   if (likely(!eth_type_vlan(vlan_proto)))
+   return 0;

 if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
 return 0;

 if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
+sizeof(__be16
 return -ENOMEM;

-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   vlan->tci = vlan_tci | htons(VLAN_TAG_PRESENT);
+   vlan->tpid = vlan_proto;
+
 __skb_pull(skb, sizeof(struct qtag_prefix));
+   return 1;
+}
+
+static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+{
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;
+   int res;
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where ingress processing has already stripped
+* the outer vlan tag.
+*/
+   res = parse_vlan_tag(skb, qp->eth_type, qp->tci,
+>eth.cvlan);
+   if (res < 0)
+   return res;
+   /* For inner tag, return 0 because neither
+* non-existant nor partial inner tag is an error.
+*/
+   return 0;
+   }
+   res = parse_vlan_tag(skb, qp->eth_type, qp->tci, >eth.vlan);
+   if (res <= 0)
+   /* This is an outer tag in the non-accelerated VLAN
+* case. Return error unless it is a complete vlan tag.
+*/
+   return res;
+
+   /* Parse inner vlan tag if present for non-accelerated case. */
+   res = parse_vlan_tag(skb, qp->eth_type, qp->tci, >eth.cvlan);
+   if (res <= 0)
+   return res;


same qp pointer is passed for inner and outer vlan parameters here. It
is better to just pass skb and keep qp inside par

Re: [ovs-dev] [PATCH net-next V16 3/3] openvswitch: 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-15 Thread Thomas F Herbert

On 10/15/15 8:37 PM, Pravin Shelar wrote:

On Thu, Oct 15, 2015 at 4:48 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

On 10/15/15 7:02 PM, Pravin Shelar wrote:
Thanks for the review. See my comment below.

--TFH



On Thu, Oct 15, 2015 at 7:01 AM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
   net/openvswitch/actions.c  |   6 +-
   net/openvswitch/flow.c |  75 ++
   net/openvswitch/flow.h |   8 +-
   net/openvswitch/flow_netlink.c | 169
+
   net/openvswitch/vport-netdev.c |   4 +-
   5 files changed, 228 insertions(+), 34 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..09cc1c9 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -236,7 +236,8 @@ static int pop_vlan(struct sk_buff *skb, struct
sw_flow_key *key)
  if (skb_vlan_tag_present(skb))
  invalidate_flow_key(key);
  else
-   key->eth.tci = 0;
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
  return err;
   }

@@ -246,7 +247,8 @@ static int push_vlan(struct sk_buff *skb, struct
sw_flow_key *key,
  if (skb_vlan_tag_present(skb))
  invalidate_flow_key(key);
  else
-   key->eth.tci = vlan->vlan_tci;
+   key->eth.vlan.tci = vlan->vlan_tci;
+   key->eth.vlan.tpid = vlan->vlan_tpid;
  return skb_vlan_push(skb, vlan->vlan_tpid,
   ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
   }
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..8a4e298 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -302,24 +302,69 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
sizeof(struct icmp6hdr));
   }

-static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+struct qtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+};
+

Now we can just use newly defined struct vlan_header here.


+/* Parse vlan tag from vlan header.
+ * Returns ERROR on memory error.
+ * Returns 0 if it encounters a non-vlan or incomplete packet.
+ * Returns 1 after successfully parsing vlan tag.
+ */
+
+static int parse_vlan_tag(struct sk_buff *skb, __be16 vlan_proto,
+ __be16 vlan_tci, struct vlan_head *vlan)
   {
-   struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
-   __be16 tci;
-   };
-   struct qtag_prefix *qp;
+   if (likely(!eth_type_vlan(vlan_proto)))
+   return 0;

  if (unlikely(skb->len < sizeof(struct qtag_prefix) +
sizeof(__be16)))
  return 0;

  if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
+sizeof(__be16
  return -ENOMEM;

-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   vlan->tci = vlan_tci | htons(VLAN_TAG_PRESENT);
+   vlan->tpid = vlan_proto;
+
  __skb_pull(skb, sizeof(struct qtag_prefix));
+   return 1;
+}
+
+static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
+{
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;
+   int res;
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where ingress processing has already stripped
+* the outer vlan tag.
+*/
+   res = parse_vlan_tag(skb, qp->eth_type, qp->tci,
+>eth.cvlan);
+   if (res < 0)
+   return res;
+   /* For inner tag, return 0 because neither
+* non-existant nor partial inner tag is an error.
+*/
+   return 0;
+   }
+   res = parse_vlan_tag(skb, qp->eth_type, qp->tci, >eth.vlan);
+   if (res <= 0)
+   /* This is an outer tag in the non-accelerated VLAN
+* case. Return error unless it is a complete vlan tag.
+*/
+   return res;
+
+   /* Parse inner vlan tag if present for non-accelerated case. */
+   res = parse_vlan_tag(skb, qp->eth_type, qp->tci,
>eth.cvlan);
+   if (res <=

Re: [ovs-dev] [PATCH net-next V15 0/3] openvswitch: Add support for 802.1ad

2015-10-13 Thread Thomas F Herbert

On 10/13/15 3:58 AM, David Miller wrote:

From: Thomas F Herbert <thomasfherb...@gmail.com>
Date: Sat, 10 Oct 2015 19:40:30 -0400


Thomas F Herbert (3):
   openvswitch: 802.1ad uapi changes.
   Check for vlan ethernet types for 8021.q or 802.1ad
   802.1AD: Flow handling, actions, vlan parsing and netlink attributes

I think this patch series has gone long enough, can I get some ACK's
ASAP for this V15 posting?
Dave, For quality concerns, I think it is best if I respond to Pravin's 
latest comments with an updated series. I will submit shortly.


--TFH


Thanks.


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


Re: [ovs-dev] [PATCH net-next V15 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-13 Thread Thomas F Herbert

Pravin,

Thanks for the review.

On 10/13/15 7:47 AM, Pravin Shelar wrote:

On Sat, Oct 10, 2015 at 4:40 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
  net/openvswitch/actions.c  |   6 +-
  net/openvswitch/flow.c |  92 +++
  net/openvswitch/flow.h |  11 ++-
  net/openvswitch/flow_netlink.c | 166 +
  net/openvswitch/vport-netdev.c |   4 +-
  5 files changed, 245 insertions(+), 34 deletions(-)


...


diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..0f9479c 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -305,21 +305,83 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
  {
 struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
 __be16 tci;
 };
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;

-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key->eth.vlan.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   qp = (struct qtag_prefix *)skb->data;
+   key->eth.cvlan.tci =
+   qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
 return 0;

-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;
+   } else if (qp->eth_type == htons(ETH_P_8021AD)) {
+
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   qp = (struct qtag_prefix *)skb->data;
+   key->eth.vlan.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.vlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));

-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+

There is no check for inner protocol in the packet.
Yes, and the code should be generic to use eth_type_vlan() for both 
inner and outer TPIDs.

I think your pseudo code below fixes that.



+   key->eth.cvlan.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+
+   return 0;
+
+   } else if (qp->eth_type == htons(ETH_P_8021Q)) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+   key->eth.vlan.tci = qp->tci | htons(VLA

[ovs-dev] [PATCH net-next V15 0/3] openvswitch: Add support for 802.1ad

2015-10-10 Thread Thomas F Herbert

Thomas F Herbert (3):
  openvswitch: 802.1ad uapi changes.
  Check for vlan ethernet types for 8021.q or 802.1ad
  802.1AD: Flow handling, actions, vlan parsing and netlink attributes

 include/linux/if_vlan.h  |  17 
 include/uapi/linux/openvswitch.h |  17 ++--
 net/openvswitch/actions.c|   6 +-
 net/openvswitch/flow.c   |  92 ++
 net/openvswitch/flow.h   |  11 ++-
 net/openvswitch/flow_netlink.c   | 166 +++
 net/openvswitch/vport-netdev.c   |   4 +-
 7 files changed, 271 insertions(+), 42 deletions(-)

This patch accompanies version 14 of the user level openvswitch patch
submitted to openvswitch dev list.

V15: Implement reviewer comments.

V14: Add outer tpid to flow_key

V13: Fix incorrect encoding and decoding of netlink to/from key
attributes.

V12: Fix some problems and issues pointed out by reviewers. When parsing
netlink attributes Ether types other then 0x88a8 as outer tpid.

V11: Add inner tpid to flow key. Fix separate inner encap attribute
when parsing netlink attributes. Merge 2 patches to consolidate
qinq changes.

V10: Implement reviewer comments: Consolidate vlan parsing functions.
Splits netlink parsing and flow conversion into a separate patch. Uses
double encap attribute encapsulation for 802.1ad.  Netlink attributes
now look like this:

eth_type(0x88a8),vlan(vid=100),encap(eth_type(0x8100), vlan(vid=200),
 encap(eth_type(0x0800), ...))

The double encap atributes in this version of the patch is incompatible with
old versions of the user level 802.1ad patch. A new user level patch which
is also being submitted simultaneously to openvswitch dev mailing list.

V9:  Includes changes suggested by reviewers

V8:  Includes changes suggested by reviewers

V7:  Includes changes suggested by reviewers

V6:  Rebased to net-next

V5:  Use encapsulated attributes


For discussion, history  and previous versions of the kernel module
patch and the user code patch see the OVS dev mailing list,
openvswitch.org/pipermail/dev/..

-- 
2.4.3

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


[ovs-dev] [PATCH net-next V15 2/3] Check for vlan ethernet types for 8021.q or 802.1ad

2015-10-10 Thread Thomas F Herbert
Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/linux/if_vlan.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 67ce5bd..88d1be4 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -627,6 +627,23 @@ static inline netdev_features_t vlan_features_check(const 
struct sk_buff *skb,
 
return features;
 }
+/**
+ * eth_type_vlan - check for valid vlan ether type.
+ * @ethertype: ether type to check
+ *
+ * Returns true if the ether type is a vlan ether type.
+ */
+static inline bool eth_type_vlan(__be16 ethertype)
+{
+   switch (ethertype) {
+   case (htons(ETH_P_8021Q)):
+   return true;
+   case (htons(ETH_P_8021AD)):
+   return true;
+   default:
+   return false;
+   }
+}
 
 /**
  * compare_vlan_header - Compare two vlan headers
-- 
2.4.3

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


[ovs-dev] [PATCH net-next V15 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-10 Thread Thomas F Herbert
Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 net/openvswitch/actions.c  |   6 +-
 net/openvswitch/flow.c |  92 +++
 net/openvswitch/flow.h |  11 ++-
 net/openvswitch/flow_netlink.c | 166 +
 net/openvswitch/vport-netdev.c |   4 +-
 5 files changed, 245 insertions(+), 34 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..09cc1c9 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -236,7 +236,8 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key 
*key)
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = 0;
+   key->eth.vlan.tci = 0;
+   key->eth.vlan.tpid = 0;
return err;
 }
 
@@ -246,7 +247,8 @@ static int push_vlan(struct sk_buff *skb, struct 
sw_flow_key *key,
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = vlan->vlan_tci;
+   key->eth.vlan.tci = vlan->vlan_tci;
+   key->eth.vlan.tpid = vlan->vlan_tpid;
return skb_vlan_push(skb, vlan->vlan_tpid,
 ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
 }
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..0f9479c 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -305,21 +305,83 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
 static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
 {
struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
__be16 tci;
};
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;
 
-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key->eth.vlan.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   qp = (struct qtag_prefix *)skb->data;
+   key->eth.cvlan.tci =
+   qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
return 0;
 
-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;
+   } else if (qp->eth_type == htons(ETH_P_8021AD)) {
+
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   qp = (struct qtag_prefix *)skb->data;
+   key->eth.vlan.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.vlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
 
-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   key->eth.cvlan.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+

[ovs-dev] [PATCH net-next V15 1/3] openvswitch: 802.1ad uapi changes.

2015-10-10 Thread Thomas F Herbert
openvswitch: Add support for 8021.AD

Change the description of the VLAN tpid field.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/uapi/linux/openvswitch.h | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 32e07d8..b0c959c 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -585,13 +585,13 @@ struct ovs_action_push_mpls {
  * @vlan_tci: Tag control identifier (TCI) to push.  The CFI bit must be set
  * (but it will not be set in the 802.1Q header that is pushed).
  *
- * The @vlan_tpid value is typically %ETH_P_8021Q.  The only acceptable TPID
- * values are those that the kernel module also parses as 802.1Q headers, to
- * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN
- * from having surprising results.
+ * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
+ * The only acceptable TPID values are those that the kernel module also parses
+ * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
+ * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
  */
 struct ovs_action_push_vlan {
-   __be16 vlan_tpid;   /* 802.1Q TPID. */
+   __be16 vlan_tpid;   /* 802.1Q or 802.1ad TPID. */
__be16 vlan_tci;/* 802.1Q TCI (VLAN ID and priority). */
 };
 
@@ -664,9 +664,10 @@ enum ovs_ct_attr {
  * is copied from the value to the packet header field, rest of the bits are
  * left unchanged.  The non-masked value bits must be passed in as zeroes.
  * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
- * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the
- * packet.
- * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet.
+ * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
+ * onto the packet.
+ * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
+ * from the packet.
  * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
  * the nested %OVS_SAMPLE_ATTR_* attributes.
  * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
-- 
2.4.3

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


[ovs-dev] [PATCH V14 0/4] Add 802.1ad (qinq) support

2015-10-02 Thread Thomas F Herbert
From: "Thomas F. Herbert" <thomasfherb...@gmail.com>

This series requires the 802.1ad kernel patch V14 recently submitted to
net-next.

The kernel changes for conntrak need to be backported to OVS for
this patch to work without errors so user space and kernel are compiled
with the same uapi openvswitch.h.

ToDo: The flow structure should be updated to hold both the inner and outer
tpid's since these are encoded by the kernel module.


Version 14: Rebased to master. Tested with kernel patch V14 on 4.2-rc8
net-next tree.

Version 11: Encode inner tpid in with customer tci into netlink
in inner encapsulation. Some cleanup in code and comments. The patch
adding 802.1ad support functions, which is already merged is removed
from this series. This patch accompanies V11 kernel module patch
submitted to linux net-next.

Version 10: Use doubly nested encap attributes to encode 802.1ad. Rebase
to master. V8 and V9 were skipped and this version was called V10 to
accompany V10 kernel module patch simultaneously to net-next.

This patch will is incopatible with old versions of the kernel module and
will require V10 of the kernel module patch because of the change in
netlink attribute encoding of 802.1ad. Netlink attributes now look like
this:

eth_type(0x88a8),vlan(vid=100),encap(eth_type(0x8100), vlan(vid=200),
encap(eth_type(0x0800), ...))

Version 7 is rebased to latest master and incorporates changes from
reviewers. The accompanying kernel changes have been submitted to the
linux net-dev mailing list.

Version 6 split the changes into separate patches to make it easier on the
eyes of reviewers but otherwise is functionally the same as version 5.

Version 5 updated the patch to properly use nested attributes, fixed some
whitespace problems and allows TPID 0x88a8 tag be pushed with either
single or outer tag because Open Flow does not specifically prohibit it.

This patch has been tested along with the Linux Kernel datapath patch in
a VM based test network as well as real-world provider test environment.

Thanks to Robert Peterson for inspiring and leading the effort of
separating customer from provider traffic which led to this work and
thanks to the people at ATC for helping with configuring the test lab
and running perf tests.

Also, thanks to Entry Point LLC who were involved in this project from the
beginning.

Thanks to Ben Pfaff, Pravin Shelar and others that have commented on
previous versions of this patch and thanks to Dave Benson who
contributed the test included in this patch.

Thomas F. Herbert (4):
  Flow and action changes for 802.1AD
  Flow key and netlink parsing changes for 802.1AD
  802.1AD: Describe 802.1ad changes
  Test push and pop of vlan with both 802.1AD and 802.1Q

 NEWS |   2 +
 lib/flow.c   |   2 +-
 lib/flow.h   |  12 +-
 lib/odp-util.c   | 281 +--
 lib/ofp-actions.c|  32 +++--
 lib/ofp-actions.h|  14 ++-
 ofproto/ofproto-dpif-xlate.c |  11 ++
 tests/ofproto-dpif.at|  40 ++
 utilities/ovs-ofctl.8.in |   3 +-
 9 files changed, 336 insertions(+), 61 deletions(-)

-- 
2.4.3

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


[ovs-dev] [PATCH V14 3/4] 802.1AD: Describe 802.1ad changes

2015-10-02 Thread Thomas F Herbert
From: "Thomas F. Herbert" <thomasfherb...@gmail.com>

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 NEWS | 2 ++
 utilities/ovs-ofctl.8.in | 3 +--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index ca22c8e..abfa32e 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,8 @@ Post-v2.4.0
 
 v2.4.0 - 20 Aug 2015
 -
+   - Add support for 8021.AD as specified in OpenFlow 1.1+. Adds push and pop
+ of 802.1AD Ethertype and handling of QinQ or double stacked Vlans.
- Flow table modifications are now atomic, meaning that each packet
  now sees a coherent version of the OpenFlow pipeline.  For
  example, if a controller removes all flows with a single OpenFlow
diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in
index 8bb3715..65bf56f 100644
--- a/utilities/ovs-ofctl.8.in
+++ b/utilities/ovs-ofctl.8.in
@@ -1440,8 +1440,7 @@ Strips the VLAN tag from a packet if it is present.
 .
 .IP \fBpush_vlan\fR:\fIethertype\fR
 Push a new VLAN tag onto the packet.  Ethertype is used as the Ethertype
-for the tag. Only ethertype 0x8100 should be used. (0x88a8 which the spec
-allows isn't supported at the moment.)
+for the tag. Ethertypes 0x8100 or 0x88a8 may be used.
 A priority of zero and the tag of zero are used for the new tag.
 .
 .IP \fBpush_mpls\fR:\fIethertype\fR
-- 
2.4.3

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


[ovs-dev] [PATCH V14 2/4] Flow key and netlink parsing changes for 802.1AD

2015-10-02 Thread Thomas F Herbert
From: "Thomas F. Herbert" <thomasfherb...@gmail.com>

Netlink parsing and flow key conversion. Netlink attribute encoding is done
with double encap attributes. Netlink attributes for 802.1ad look like
the following:

eth_type(0x88a8),vlan(vid=100),encap(eth_type(0x8100), vlan(vid=200),
encap(eth_type(0x0800), ...))

V14 is rebased to recent OVS.
V11 fixes issues in the inner vlan encapsulation.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 lib/odp-util.c | 281 +
 1 file changed, 242 insertions(+), 39 deletions(-)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index d7696c9..120657b 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -3348,7 +3348,8 @@ odp_flow_key_from_flow__(const struct odp_flow_key_parms 
*parms,
  bool export_mask, struct ofpbuf *buf)
 {
 struct ovs_key_ethernet *eth_key;
-size_t encap;
+size_t encap = 0;
+size_t inner_encap = 0;
 const struct flow *flow = parms->flow;
 const struct flow *data = export_mask ? parms->mask : parms->flow;
 
@@ -3376,19 +3377,33 @@ odp_flow_key_from_flow__(const struct 
odp_flow_key_parms *parms,
sizeof *eth_key);
 get_ethernet_key(data, eth_key);
 
-if (flow->vlan_tci != htons(0) || flow->dl_type == htons(ETH_TYPE_VLAN)) {
+if ((flow->vlan_tci != htons(0)) || eth_type_vlan(flow->dl_type)) {
 if (export_mask) {
 nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, OVS_BE16_MAX);
 } else {
-nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, htons(ETH_TYPE_VLAN));
+nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE,
+htons(ETH_TYPE_VLAN_8021Q));
 }
 nl_msg_put_be16(buf, OVS_KEY_ATTR_VLAN, data->vlan_tci);
 encap = nl_msg_start_nested(buf, OVS_KEY_ATTR_ENCAP);
 if (flow->vlan_tci == htons(0)) {
 goto unencap;
 }
-} else {
-encap = 0;
+/* Now, code the inner customer vlan. */
+if ((flow->vlan_ctci != htons(0)) || eth_type_vlan(flow->vlan_tpid)) {
+if (export_mask) {
+nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, OVS_BE16_MAX);
+nl_msg_put_be16(buf, OVS_KEY_ATTR_VLAN, OVS_BE16_MAX);
+} else {
+nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, data->vlan_tpid);
+nl_msg_put_be16(buf, OVS_KEY_ATTR_VLAN, data->vlan_ctci);
+}
+/* Now, code another layer of nesting for the payload. */
+inner_encap = nl_msg_start_nested(buf, OVS_KEY_ATTR_ENCAP);
+if (flow->vlan_ctci == htons(0)) {
+goto unencap;
+}
+}
 }
 
 if (ntohs(flow->dl_type) < ETH_TYPE_MIN) {
@@ -3503,6 +3518,9 @@ odp_flow_key_from_flow__(const struct odp_flow_key_parms 
*parms,
 }
 
 unencap:
+if (inner_encap) {
+nl_msg_end_nested(buf, inner_encap);
+}
 if (encap) {
 nl_msg_end_nested(buf, encap);
 }
@@ -4024,9 +4042,36 @@ done:
   key, key_len);
 }
 
-/* Parse 802.1Q header then encapsulated L3 attributes. */
 static enum odp_key_fitness
-parse_8021q_onward(const struct nlattr *attrs[OVS_KEY_ATTR_MAX + 1],
+parse_encap_and_vlan(uint64_t present_attrs, int out_of_range_attr,
+ uint64_t expected_attrs, struct flow *flow,
+ const struct nlattr *key, size_t key_len,
+ const struct flow *src_flow)
+{
+bool is_mask = src_flow != flow;
+enum odp_key_fitness fitness;
+
+/* Calculate fitness of vlan and encap attributes. */
+if (!is_mask) {
+expected_attrs |= ((UINT64_C(1) << OVS_KEY_ATTR_VLAN) |
+  (UINT64_C(1) << OVS_KEY_ATTR_ENCAP));
+} else {
+if (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_VLAN)) {
+expected_attrs |= (UINT64_C(1) << OVS_KEY_ATTR_VLAN);
+}
+if (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_ENCAP)) {
+expected_attrs |= (UINT64_C(1) << OVS_KEY_ATTR_ENCAP);
+}
+}
+fitness = check_expectations(present_attrs, out_of_range_attr,
+ expected_attrs, key, key_len);
+
+return fitness;
+}
+
+/* Parse 802.1AD inner vlan and then parse encapsulated Attributes. */
+static enum odp_key_fitness
+parse_cvlan_onward(const struct nlattr *attrs[OVS_KEY_ATTR_MAX + 1],
uint64_t present_attrs, int out_of_range_attr,
uint64_t expected_attrs, struct flow *flow,
const struct nlattr *key, size_t key_len,
@@ -4041,27 +4086,89 @@ parse_8021q_onward(const struct nlattr 
*attrs[OVS_KEY_ATTR_MAX + 1],
 enum odp_key_fitness encap_fitness;
 enum odp_key_fitness fitness;
 
-  

[ovs-dev] [PATCH V14 1/4] Flow and action changes for 802.1AD

2015-10-02 Thread Thomas F Herbert
From: "Thomas F. Herbert" <thomasfherb...@gmail.com>

ToDo: The flow structure needs to be updated to hold both the inner and outer
tpid since these are encoded by the kernel module.

The flow structure is updated to hold the customer tci.
Flow key extraction is changed to add support for ctci and both TPIDs.
Parsing to support pushing and popping with both single and double
tagged vlans. In response to reviewers comments on V6, all changes
affected by the flow structure are gathered in this patch.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 lib/flow.c   |  2 +-
 lib/flow.h   | 12 +---
 lib/ofp-actions.c| 32 +++-
 lib/ofp-actions.h| 14 +++---
 ofproto/ofproto-dpif-xlate.c | 11 +++
 5 files changed, 51 insertions(+), 20 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index 84048e8..f90e833 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -302,7 +302,7 @@ parse_vlan(const void **datap, size_t *sizep)
 
 data_pull(datap, sizep, ETH_ADDR_LEN * 2);
 
-if (eth->eth_type == htons(ETH_TYPE_VLAN)) {
+if (eth_type_vlan(eth->eth_type)) {
 if (OVS_LIKELY(*sizep
>= sizeof(struct qtag_prefix) + sizeof(ovs_be16))) {
 const struct qtag_prefix *qp = data_pull(datap, sizep, sizeof *qp);
diff --git a/lib/flow.h b/lib/flow.h
index d8632ff..8ceb442 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -110,7 +110,13 @@ struct flow {
 struct eth_addr dl_dst; /* Ethernet destination address. */
 struct eth_addr dl_src; /* Ethernet source address. */
 ovs_be16 dl_type;   /* Ethernet frame type. */
-ovs_be16 vlan_tci;  /* If 802.1Q, TCI | VLAN_CFI; otherwise 0. */
+ovs_be16 vlan_tci;  /* If 802.1Q, TCI | VLAN_CFI; If 802.1ad,
+ * outer tag, otherwise 0. */
+ovs_be16 vlan_ctci; /* If 802.1ad, Customer TCI | VLAN_CFI,
+ * inner tag, otherwise 0. */
+ovs_be16 vlan_tpid; /* Vlan protocol type,
+ * either 802.1ad or 802.1q. */
+uint32_t pad2;  /* Pad to 64 bits. */
 ovs_be32 mpls_lse[ROUND_UP(FLOW_MAX_MPLS_LABELS, 2)]; /* MPLS label stack
  (with padding). */
 /* L3 (64-bit aligned) */
@@ -127,7 +133,7 @@ struct flow {
 struct eth_addr arp_sha;/* ARP/ND source hardware address. */
 struct eth_addr arp_tha;/* ARP/ND target hardware address. */
 ovs_be16 tcp_flags; /* TCP flags. With L3 to avoid matching L4. */
-ovs_be16 pad2;  /* Pad to 64 bits. */
+ovs_be16 pad3;  /* Pad to 64 bits. */
 
 /* L4 (64-bit aligned) */
 ovs_be16 tp_src;/* TCP/UDP/SCTP source port. */
@@ -153,7 +159,7 @@ BUILD_ASSERT_DECL(sizeof(struct flow_tnl) % 
sizeof(uint64_t) == 0);
 
 /* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */
 BUILD_ASSERT_DECL(offsetof(struct flow, igmp_group_ip4) + sizeof(uint32_t)
-  == sizeof(struct flow_tnl) + 192
+  == sizeof(struct flow_tnl) + 200
   && FLOW_WC_SEQ == 33);
 
 /* Incremental points at which flow classification may be performed in
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index c46ce97..ad88076 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -1280,16 +1280,20 @@ format_STRIP_VLAN(const struct ofpact_null *a, struct 
ds *s)
 static enum ofperr
 decode_OFPAT_RAW11_PUSH_VLAN(ovs_be16 eth_type, struct ofpbuf *out)
 {
-if (eth_type != htons(ETH_TYPE_VLAN_8021Q)) {
-/* XXX 802.1AD(QinQ) isn't supported at the moment */
+struct ofpact_push_vlan *oam;
+
+if (!eth_type_vlan(eth_type)) {
+/* XXX Only 802.1q or 802.1AD(QinQ) are supported.  */
 return OFPERR_OFPBAC_BAD_ARGUMENT;
 }
-ofpact_put_PUSH_VLAN(out);
+oam = ofpact_put_PUSH_VLAN(out);
+oam->ethertype = eth_type;
+
 return 0;
 }
 
 static void
-encode_PUSH_VLAN(const struct ofpact_null *null OVS_UNUSED,
+encode_PUSH_VLAN(const struct ofpact_push_vlan *push_vlan,
  enum ofp_version ofp_version, struct ofpbuf *out)
 {
 if (ofp_version == OFP10_VERSION) {
@@ -1297,7 +1301,7 @@ encode_PUSH_VLAN(const struct ofpact_null *null 
OVS_UNUSED,
  * follow this action. */
 } else {
 /* XXX ETH_TYPE_VLAN_8021AD case */
-put_OFPAT11_PUSH_VLAN(out, htons(ETH_TYPE_VLAN_8021Q));
+put_OFPAT11_PUSH_VLAN(out, push_vlan->ethertype);
 }
 }
 
@@ -1309,25 +1313,25 @@ parse_PUSH_VLAN(char *arg, struct ofpbuf *ofpacts,
 char *error;
 
 *usable_protocols &= OFPUTIL_P_OF11_UP;
-error = str_to_u16(arg, "ethertype", );
+error = str_to_u16(arg, "push_vlan", );
 if (error) {
 return error;
 }
 
-if (ethertyp

[ovs-dev] [PATCH V14 4/4] Test push and pop of vlan with both 802.1AD and 802.1Q

2015-10-02 Thread Thomas F Herbert
From: "Thomas F. Herbert" <thomasfherb...@gmail.com>

This patch adds tests of the user space actions for 802.1q and 802.1ad.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
Signed-off-by: Dave Benson <dben...@verdantnetworks.com>
---
 tests/ofproto-dpif.at | 40 
 1 file changed, 40 insertions(+)

diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index 121f84d..784977a 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -1542,6 +1542,46 @@ NXST_FLOW reply:
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([ofproto-dpif - VLAN with 802.1AD Ethertype])
+OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [1], [2], [3], [4])
+
+AT_DATA([flows1.txt], [dnl
+table=0 in_port=1 dl_type=0x8100 actions=pop_vlan,output:2
+table=0 in_port=1 dl_type=0x88a8 actions=pop_vlan,output:3
+])
+AT_CHECK([ovs-ofctl add-flows br0 flows1.txt])
+AT_DATA([flows2.txt], [dnl
+table=0 in_port=2 dl_type=0x0800 
actions=push_vlan:0x8100,mod_vlan_vid:9,output:1
+table=0 in_port=3 dl_type=0x0800 
actions=push_vlan:0x88a8,set_field:0x1006->vlan_tci,output:1
+table=0 in_port=4 dl_type=0x0800 
actions=push_vlan:0x88a8,mod_vlan_vid:11,output:1
+])
+AT_CHECK([ovs-ofctl -O OpenFlow11 add-flows br0 flows2.txt])
+
+AT_CHECK([ovs-appctl ofproto/trace br0 
'in_port=1,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x8100,dl_vlan=9'], [0], [stdout])
+AT_CHECK([tail -1 stdout], [0],
+  [Datapath actions: pop_vlan,2
+])
+AT_CHECK([ovs-appctl ofproto/trace br0 
'in_port=1,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x88a8,dl_vlan=9'], [0], [stdout])
+AT_CHECK([tail -1 stdout], [0],
+  [Datapath actions: pop_vlan,3
+])
+AT_CHECK([ovs-appctl ofproto/trace br0 
'in_port=2,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0800'], [0], [stdout])
+AT_CHECK([tail -1 stdout], [0],
+  [Datapath actions: push_vlan(vid=9,pcp=0),1
+])
+AT_CHECK([ovs-appctl ofproto/trace br0 
'in_port=3,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0800'], [0], [stdout])
+AT_CHECK([tail -1 stdout], [0],
+  [Datapath actions: push_vlan(tpid=0x88a8,vid=6,pcp=0),1
+])
+AT_CHECK([ovs-appctl ofproto/trace br0 
'in_port=4,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0800'], [0], [stdout])
+AT_CHECK([tail -1 stdout], [0],
+  [Datapath actions: push_vlan(tpid=0x88a8,vid=11,pcp=0),1
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
 AT_SETUP([ofproto-dpif - MPLS handling])
 OVS_VSWITCHD_START([dnl
add-port br0 p1 -- set Interface p1 type=dummy
-- 
2.4.3

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


Re: [ovs-dev] [PATCH net-next V14 3/3] openvswitch: 802.1ad: Flow handling, actions, vlan parsing and netlink attributes

2015-10-02 Thread Thomas F Herbert

On 9/30/15 11:33 PM, Thomas F Herbert wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
  net/openvswitch/actions.c  |   4 +-
  net/openvswitch/flow.c |  87 +
  net/openvswitch/flow.h |  11 ++-
  net/openvswitch/flow_netlink.c | 167 +
  net/openvswitch/vport-netdev.c |   4 +-
  5 files changed, 239 insertions(+), 34 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..c544371 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -236,7 +236,7 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key 
*key)
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = 0;
+   key->eth.vlan.tci = 0;
return err;
  }
  
@@ -246,7 +246,7 @@ static int push_vlan(struct sk_buff *skb, struct sw_flow_key *key,

if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = vlan->vlan_tci;
+   key->eth.vlan.tci = vlan->vlan_tci;
return skb_vlan_push(skb, vlan->vlan_tpid,
 ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
  }
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..86a2cb0 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -305,21 +305,78 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
  {
struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
__be16 tci;
};
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;
  
-	if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))

+   struct qinqtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+   __be16 inner_tpid; /* ETH_P_8021Q */
+   __be16 ctci;
+   };
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key->eth.vlan.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   key->eth.cvlan.tci =
+   qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
return 0;
  
-	if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +

-sizeof(__be16
-   return -ENOMEM;
+   } else if (qp->eth_type == htons(ETH_P_8021AD)) {
+   struct qinqtag_prefix *qinqp =
+   (struct qinqtag_prefix *)skb->data;
+
+   if (unlikely(skb->len < sizeof(struct qinqtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qinqtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+   key->eth.vlan.tci = qinqp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.vlan.tpid = qp->eth_type;
+   key->eth.cvlan.tci = qinqp->ctci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.tpid = qinqp->inner_tpid;
+
+   __skb_pull(skb, sizeof(struct qinqtag_prefix));
  
-	qp = (struct qtag_prefix *) skb->data;

-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   return 0;
+
+   } else if (qp->eth_type == htons(ETH_P_8021Q

[ovs-dev] [PATCH net-next V14 2/3] openvswitch: Check for vlan ethernet types for 8021.q or 802.1ad

2015-09-30 Thread Thomas F Herbert
Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/linux/if_vlan.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 67ce5bd..88d1be4 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -627,6 +627,23 @@ static inline netdev_features_t vlan_features_check(const 
struct sk_buff *skb,
 
return features;
 }
+/**
+ * eth_type_vlan - check for valid vlan ether type.
+ * @ethertype: ether type to check
+ *
+ * Returns true if the ether type is a vlan ether type.
+ */
+static inline bool eth_type_vlan(__be16 ethertype)
+{
+   switch (ethertype) {
+   case (htons(ETH_P_8021Q)):
+   return true;
+   case (htons(ETH_P_8021AD)):
+   return true;
+   default:
+   return false;
+   }
+}
 
 /**
  * compare_vlan_header - Compare two vlan headers
-- 
2.4.3

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


[ovs-dev] [PATCH net-next V14 0/3] openvswitch: Add support for 802.1ad

2015-09-30 Thread Thomas F Herbert
Although the Open Flow specification specified support for 802.1AD (qinq)
as well as push and pop vlan headers,  So far Open vSwitch has only
supported a single tag header. This patch implements 802.1AD in the kernel
module.

This patch accompanies version 14 of the user level openvswitch patch
submitted to openvswitch dev list.

V14: Add outer tpid to flow_key

V13: Fix incorrect encoding and decoding of netlink to/from key
attributes.

V12: Fix some problems and issues pointed out by reviewers. When parsing
netlink attributes Ether types other then 0x88a8 as outer tpid.

V11: Add inner tpid to flow key. Fix separate inner encap attribute
when parsing netlink attributes. Merge 2 patches to consolidate
qinq changes.

V10: Implement reviewer comments: Consolidate vlan parsing functions.
Splits netlink parsing and flow conversion into a separate patch. Uses
double encap attribute encapsulation for 802.1ad.  Netlink attributes
now look like this:

eth_type(0x88a8),vlan(vid=100),encap(eth_type(0x8100), vlan(vid=200),
 encap(eth_type(0x0800), ...))

The double encap atributes in this version of the patch is incompatible with
old versions of the user level 802.1ad patch. A new user level patch which
is also being submitted simultaneously to openvswitch dev mailing list.

V9:  Includes changes suggested by reviewers

V8:  Includes changes suggested by reviewers

V7:  Includes changes suggested by reviewers

V6:  Rebased to net-next

V5:  Use encapsulated attributes


For discussion, history  and previous versions of the kernel module
patch and the user code patch see the OVS dev mailing list,
openvswitch.org/pipermail/dev/..

Thomas F Herbert (3):
  openvswitch: 802.1ad uapi changes.
  Check for vlan ethernet types for 8021.q or 802.1ad
  802.1AD: Flow handling, actions, vlan parsing and netlink attributes

 include/linux/if_vlan.h  |  17 
 include/uapi/linux/openvswitch.h |  17 ++--
 net/openvswitch/actions.c|   4 +-
 net/openvswitch/flow.c   |  87 
 net/openvswitch/flow.h   |  11 ++-
 net/openvswitch/flow_netlink.c   | 167 +++
 net/openvswitch/vport-netdev.c   |   4 +-
 7 files changed, 265 insertions(+), 42 deletions(-)

-- 
2.4.3

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


[ovs-dev] [PATCH net-next V14 3/3] openvswitch: 802.1ad: Flow handling, actions, vlan parsing and netlink attributes

2015-09-30 Thread Thomas F Herbert
Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 net/openvswitch/actions.c  |   4 +-
 net/openvswitch/flow.c |  87 +
 net/openvswitch/flow.h |  11 ++-
 net/openvswitch/flow_netlink.c | 167 +
 net/openvswitch/vport-netdev.c |   4 +-
 5 files changed, 239 insertions(+), 34 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 315f533..c544371 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -236,7 +236,7 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key 
*key)
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = 0;
+   key->eth.vlan.tci = 0;
return err;
 }
 
@@ -246,7 +246,7 @@ static int push_vlan(struct sk_buff *skb, struct 
sw_flow_key *key,
if (skb_vlan_tag_present(skb))
invalidate_flow_key(key);
else
-   key->eth.tci = vlan->vlan_tci;
+   key->eth.vlan.tci = vlan->vlan_tci;
return skb_vlan_push(skb, vlan->vlan_tpid,
 ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
 }
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..86a2cb0 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -305,21 +305,78 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
 static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
 {
struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
__be16 tci;
};
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;
 
-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   struct qinqtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+   __be16 inner_tpid; /* ETH_P_8021Q */
+   __be16 ctci;
+   };
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key->eth.vlan.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   key->eth.cvlan.tci =
+   qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
return 0;
 
-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;
+   } else if (qp->eth_type == htons(ETH_P_8021AD)) {
+   struct qinqtag_prefix *qinqp =
+   (struct qinqtag_prefix *)skb->data;
+
+   if (unlikely(skb->len < sizeof(struct qinqtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qinqtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+   key->eth.vlan.tci = qinqp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.vlan.tpid = qp->eth_type;
+   key->eth.cvlan.tci = qinqp->ctci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.tpid = qinqp->inner_tpid;
+
+   __skb_pull(skb, sizeof(struct qinqtag_prefix));
 
-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   return 0;
+
+   } else if (qp->eth_type == htons(ETH_P_8021Q)) {
+   if (unlikely(skb->len < sizeof(struct qta

[ovs-dev] [PATCH net-next V14 1/3] openvswitch: 802.1ad uapi changes.

2015-09-30 Thread Thomas F Herbert
openvswitch: Add support for 8021.AD

Change the description of the VLAN tpid field.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/uapi/linux/openvswitch.h | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 32e07d8..b0c959c 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -585,13 +585,13 @@ struct ovs_action_push_mpls {
  * @vlan_tci: Tag control identifier (TCI) to push.  The CFI bit must be set
  * (but it will not be set in the 802.1Q header that is pushed).
  *
- * The @vlan_tpid value is typically %ETH_P_8021Q.  The only acceptable TPID
- * values are those that the kernel module also parses as 802.1Q headers, to
- * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN
- * from having surprising results.
+ * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
+ * The only acceptable TPID values are those that the kernel module also parses
+ * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
+ * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
  */
 struct ovs_action_push_vlan {
-   __be16 vlan_tpid;   /* 802.1Q TPID. */
+   __be16 vlan_tpid;   /* 802.1Q or 802.1ad TPID. */
__be16 vlan_tci;/* 802.1Q TCI (VLAN ID and priority). */
 };
 
@@ -664,9 +664,10 @@ enum ovs_ct_attr {
  * is copied from the value to the packet header field, rest of the bits are
  * left unchanged.  The non-masked value bits must be passed in as zeroes.
  * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
- * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the
- * packet.
- * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet.
+ * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
+ * onto the packet.
+ * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
+ * from the packet.
  * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
  * the nested %OVS_SAMPLE_ATTR_* attributes.
  * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
-- 
2.4.3

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


Re: [ovs-dev] [PATCH 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-09-29 Thread Thomas F Herbert

On 9/29/15 6:56 PM, Pravin Shelar wrote:

On Fri, Sep 25, 2015 at 3:35 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Pravin,

Another comment and question. Please seen inline below.

Thanks,

--Tom

On 9/24/15 7:42 PM, Pravin Shelar wrote:

On Thu, Sep 24, 2015 at 10:58 AM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
   net/openvswitch/flow.c |  83 +
   net/openvswitch/flow.h |   5 ++
   net/openvswitch/flow_netlink.c | 166
++---
   3 files changed, 230 insertions(+), 24 deletions(-)


...


@@ -1320,6 +1437,7 @@ static int __ovs_nla_put_key(const struct
sw_flow_key *swkey,
   {
  struct ovs_key_ethernet *eth_key;
  struct nlattr *nla, *encap;
+   struct nlattr *in_encap = NULL;

  if (nla_put_u32(skb, OVS_KEY_ATTR_RECIRC_ID, output->recirc_id))
  goto nla_put_failure;
@@ -1368,17 +1486,42 @@ static int __ovs_nla_put_key(const struct
sw_flow_key *swkey,
  ether_addr_copy(eth_key->eth_src, output->eth.src);
  ether_addr_copy(eth_key->eth_dst, output->eth.dst);

-   if (swkey->eth.tci || swkey->eth.type == htons(ETH_P_8021Q)) {
+   if (swkey->eth.tci || eth_type_vlan(swkey->eth.type)) {
  __be16 eth_type;
-   eth_type = !is_mask ? htons(ETH_P_8021Q) : htons(0x);
+
+   if (swkey->eth.cvlan.ctci ||
+   eth_type_vlan(swkey->eth.cvlan.c_tpid))
+   eth_type = !is_mask ? htons(ETH_P_8021AD) :
+ htons(0x);
+   else
+   eth_type = !is_mask ? htons(ETH_P_8021Q) :
+ htons(0x);
+

Here we can directly dump output->eth.type to netlink. No need to
check for inner encap.

The eth.type is set to the inner encapsulated protocol not to the tpid. We
don't "know" what the outer tpid so I assume it is 802.1Q. To address this
situation, do you think I should add the outer tpid to sw_flow_key?
Also see comment above in flow.h.


With the addition of nested vlan, we need to add outer tpid. This will
simplify vlan netlink serialization too.

Yes, thanks. I agree that this is the sensible approach.

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


Re: [ovs-dev] [PATCH 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-09-29 Thread Thomas F Herbert

On 9/25/15 1:56 PM, Joe Stringer wrote:

On 25 September 2015 at 05:10, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

On 9/24/15 7:43 PM, Pravin Shelar wrote:

On Thu, Sep 24, 2015 at 11:25 AM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Pravin,

I am you hoping you can take a look at a potential problem with my kernel
module patch submitted to net-dev today. I decided to submit it anyway
because that is the best way to get eyes on it.

I am still seeing a problem where the 4 conntrak attributes show up in an
upcall when a double tagged packet is received. The attribute lengths for
the 4 unknown attributes should be -1 but are showing up as odd lengths.
I
can't see where my patch below is causing this problem but I don't see
similar errors with missed upcall in either single tagged or untagged
packets. I have applied my companion patch to the user space for 802.1ad
so
the problem could be in that patch with de-serializing "unknown"
attributes.

Also, this may not be a problem at all because the kernel module includes
the conntrak patches but the user space does not as yet.

I am running ovs commit ca92d173 with my user space 802.1ad patch.

The error message is below:

Sep 24 14:01:34 Centos7Bld ovs-vswitchd[2666]:
recirc_id(0),dp_hash(0),skb_priority(0),in_port(3),skb_mark(0),key22(bad
key
length 1, expected -1)(00),key23(bad key length 2, expected -1)(00
00),key24(bad key length 4, expected -1)(00 00 00 00),key25(bad key
length
16, expected -1)(00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00),eth(src=52:f6:ef:24:b6:4e,dst=08:00:27:7f:8f:e1),eth_type(0x88a8),

vlan(vid=100,pcp=0),encap(eth_type(0x8100),vlan(vid=999,pcp=0),encap(eth_type(0x0800),

ipv4(src=192.168.1.3,dst=192.168.1.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)))


I am not sure. can you send me github link to user-space patch, so
that I can check.

Pravin,

OK, also I noticed that the user space patch for conntrak was submitted on
9/17. I think I will try to rebase user space patch on top of conntrak patch
and re-test after fixing issues in kernel patch.

Thanks,

Thomas,

It looks like a mismatch between your kernel module headers and
userspace headers. The conntrack changes upstream introduce four new
KEY_ATTRs, but those haven't been backported to the userspace yet. So,
if you add new KEY_ATTR numbers in
$OVS_GIT/datapath/linux/compat/include/linux/openvswitch.h, then they
may conflict with the numbers that the kernel uses in
$LINUX_GIT/include/uapi/linux/openvswich. The kernel version is the
source of truth for these.

You're right, there was patches submitted for this recently and I'm
actively working on trying to get those integrated into the OVS tree.

Yes, that is what I figured. Thanks, Joe.




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


Re: [ovs-dev] [PATCH 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-09-25 Thread Thomas F Herbert

Pravin,

Thanks for the review,

Comments in line below.

--TFH

On 9/24/15 7:42 PM, Pravin Shelar wrote:

On Thu, Sep 24, 2015 at 10:58 AM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
  net/openvswitch/flow.c |  83 +
  net/openvswitch/flow.h |   5 ++
  net/openvswitch/flow_netlink.c | 166 ++---
  3 files changed, 230 insertions(+), 24 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..db58e47 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -305,21 +305,77 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
  {
 struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
 __be16 tci;
 };
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;

-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   struct qinqtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+   __be16 inner_tpid; /* ETH_P_8021Q */
+   __be16 ctci;
+   };
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.tci = htons(skb->vlan_tci);
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key->eth.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+

qp pointer is no longer valid after pskb_may_pull() call.


+   key->eth.cvlan.ctci =
+   qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.c_tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
 return 0;
+   }

-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;

-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));


qp access is done without skb_may_pull() call.

+   if (qp->eth_type == htons(ETH_P_8021AD)) {
+   struct qinqtag_prefix *qinqp =
+   (struct qinqtag_prefix *)skb->data;
+
+   if (unlikely(skb->len < sizeof(struct qinqtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qinqtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;


same as above qinqp pointer is not valid after psk_may_pull().


+   key->eth.tci = qinqp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.ctci = qinqp->ctci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.c_tpid = qinqp->inner_tpid;
+
+   __skb_pull(skb, sizeof(struct qinqtag_prefix));
+
+   return 0;
+   }
+   if (qp->eth_type == htons(ETH_P_8021Q)) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return -ENOMEM;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return 0;

same issue as above.


+   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }

 return 0;
  }

...


diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
index fe527d2..2c491e8 100644
--- a/net/openvswitch/flow.h
+++ b/net/openvswitch/flow.h
@@ -69,6 +69,11 @@ struct sw_flow_key {
 u8 src[ETH_ALEN]; 

Re: [ovs-dev] [PATCH 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-09-25 Thread Thomas F Herbert

Pravin,

Another comment and question. Please seen inline below.

Thanks,

--Tom

On 9/24/15 7:42 PM, Pravin Shelar wrote:

On Thu, Sep 24, 2015 at 10:58 AM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
  net/openvswitch/flow.c |  83 +
  net/openvswitch/flow.h |   5 ++
  net/openvswitch/flow_netlink.c | 166 ++---
  3 files changed, 230 insertions(+), 24 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..db58e47 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -305,21 +305,77 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
  {
 struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
 __be16 tci;
 };
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;

-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   struct qinqtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+   __be16 inner_tpid; /* ETH_P_8021Q */
+   __be16 ctci;
+   };
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.tci = htons(skb->vlan_tci);
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key->eth.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+

qp pointer is no longer valid after pskb_may_pull() call.


+   key->eth.cvlan.ctci =
+   qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.c_tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
 return 0;
+   }

-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;

-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));


qp access is done without skb_may_pull() call.

+   if (qp->eth_type == htons(ETH_P_8021AD)) {
+   struct qinqtag_prefix *qinqp =
+   (struct qinqtag_prefix *)skb->data;
+
+   if (unlikely(skb->len < sizeof(struct qinqtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qinqtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;


same as above qinqp pointer is not valid after psk_may_pull().


+   key->eth.tci = qinqp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.ctci = qinqp->ctci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.c_tpid = qinqp->inner_tpid;
+
+   __skb_pull(skb, sizeof(struct qinqtag_prefix));
+
+   return 0;
+   }
+   if (qp->eth_type == htons(ETH_P_8021Q)) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return -ENOMEM;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return 0;

same issue as above.


+   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }

 return 0;
  }

...


diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
index fe527d2..2c491e8 100644
--- a/net/openvswitch/flow.h
+++ b/net/openvswitch/flow.h
@@ -69,6 +69,11 @@ struct sw_flow_key {
 u8

Re: [ovs-dev] [PATCH 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-09-25 Thread Thomas F Herbert

On 9/24/15 7:43 PM, Pravin Shelar wrote:

On Thu, Sep 24, 2015 at 11:25 AM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

Pravin,

I am you hoping you can take a look at a potential problem with my kernel
module patch submitted to net-dev today. I decided to submit it anyway
because that is the best way to get eyes on it.

I am still seeing a problem where the 4 conntrak attributes show up in an
upcall when a double tagged packet is received. The attribute lengths for
the 4 unknown attributes should be -1 but are showing up as odd lengths. I
can't see where my patch below is causing this problem but I don't see
similar errors with missed upcall in either single tagged or untagged
packets. I have applied my companion patch to the user space for 802.1ad so
the problem could be in that patch with de-serializing "unknown" attributes.

Also, this may not be a problem at all because the kernel module includes
the conntrak patches but the user space does not as yet.

I am running ovs commit ca92d173 with my user space 802.1ad patch.

The error message is below:

Sep 24 14:01:34 Centos7Bld ovs-vswitchd[2666]:
recirc_id(0),dp_hash(0),skb_priority(0),in_port(3),skb_mark(0),key22(bad key
length 1, expected -1)(00),key23(bad key length 2, expected -1)(00
00),key24(bad key length 4, expected -1)(00 00 00 00),key25(bad key length
16, expected -1)(00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00),eth(src=52:f6:ef:24:b6:4e,dst=08:00:27:7f:8f:e1),eth_type(0x88a8),
vlan(vid=100,pcp=0),encap(eth_type(0x8100),vlan(vid=999,pcp=0),encap(eth_type(0x0800),
ipv4(src=192.168.1.3,dst=192.168.1.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)))



I am not sure. can you send me github link to user-space patch, so
that I can check.

Pravin,

OK, also I noticed that the user space patch for conntrak was submitted 
on 9/17. I think I will try to rebase user space patch on top of 
conntrak patch and re-test after fixing issues in kernel patch.


Thanks,




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


[ovs-dev] [PATCH 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-09-24 Thread Thomas F Herbert
Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 net/openvswitch/flow.c |  83 +
 net/openvswitch/flow.h |   5 ++
 net/openvswitch/flow_netlink.c | 166 ++---
 3 files changed, 230 insertions(+), 24 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..db58e47 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -305,21 +305,77 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
 static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
 {
struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
__be16 tci;
};
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;
 
-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   struct qinqtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+   __be16 inner_tpid; /* ETH_P_8021Q */
+   __be16 ctci;
+   };
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.tci = htons(skb->vlan_tci);
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key->eth.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   key->eth.cvlan.ctci =
+   qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.c_tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
return 0;
+   }
 
-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;
 
-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   if (qp->eth_type == htons(ETH_P_8021AD)) {
+   struct qinqtag_prefix *qinqp =
+   (struct qinqtag_prefix *)skb->data;
+
+   if (unlikely(skb->len < sizeof(struct qinqtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qinqtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+   key->eth.tci = qinqp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.ctci = qinqp->ctci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.c_tpid = qinqp->inner_tpid;
+
+   __skb_pull(skb, sizeof(struct qinqtag_prefix));
+
+   return 0;
+   }
+   if (qp->eth_type == htons(ETH_P_8021Q)) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return -ENOMEM;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return 0;
+   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
 
return 0;
 }
@@ -481,11 +537,10 @@ static int key_extract(struct sk_buff *skb, struct 
sw_flow_key *key)
 */
 
key->eth.tci = 0;
-   if (skb_vlan_tag_present(skb))
-   key->eth.tci = htons(skb->vlan_tci);
-   else if (eth->h_proto == htons(ETH_P_8021Q))
-   if (unlikely(parse_vlan(skb, key)))
-   return -ENOMEM;
+   key->eth.cvlan.ctci = 0;
+   key->eth.cvlan.c_tpid = 0;
+   if (unlikely(parse_vlan(skb, key)))
+   return -ENOMEM;
 
key->eth.type = parse_ethertype(skb);
if (unlikely(key->eth.type == htons(0)))
diff -

[ovs-dev] [PATCH 2/3] Check for vlan ethernet types for 8021.q or 802.1ad

2015-09-24 Thread Thomas F Herbert
Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/linux/if_vlan.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 67ce5bd..88d1be4 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -627,6 +627,23 @@ static inline netdev_features_t vlan_features_check(const 
struct sk_buff *skb,
 
return features;
 }
+/**
+ * eth_type_vlan - check for valid vlan ether type.
+ * @ethertype: ether type to check
+ *
+ * Returns true if the ether type is a vlan ether type.
+ */
+static inline bool eth_type_vlan(__be16 ethertype)
+{
+   switch (ethertype) {
+   case (htons(ETH_P_8021Q)):
+   return true;
+   case (htons(ETH_P_8021AD)):
+   return true;
+   default:
+   return false;
+   }
+}
 
 /**
  * compare_vlan_header - Compare two vlan headers
-- 
2.4.3

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


[ovs-dev] [PATCH 1/3] openvswitch: 802.1ad uapi changes.

2015-09-24 Thread Thomas F Herbert
openvswitch: Add support for 8021.AD

Change the description of the VLAN tpid field.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 include/uapi/linux/openvswitch.h | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 32e07d8..b0c959c 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -585,13 +585,13 @@ struct ovs_action_push_mpls {
  * @vlan_tci: Tag control identifier (TCI) to push.  The CFI bit must be set
  * (but it will not be set in the 802.1Q header that is pushed).
  *
- * The @vlan_tpid value is typically %ETH_P_8021Q.  The only acceptable TPID
- * values are those that the kernel module also parses as 802.1Q headers, to
- * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN
- * from having surprising results.
+ * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
+ * The only acceptable TPID values are those that the kernel module also parses
+ * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
+ * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
  */
 struct ovs_action_push_vlan {
-   __be16 vlan_tpid;   /* 802.1Q TPID. */
+   __be16 vlan_tpid;   /* 802.1Q or 802.1ad TPID. */
__be16 vlan_tci;/* 802.1Q TCI (VLAN ID and priority). */
 };
 
@@ -664,9 +664,10 @@ enum ovs_ct_attr {
  * is copied from the value to the packet header field, rest of the bits are
  * left unchanged.  The non-masked value bits must be passed in as zeroes.
  * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
- * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the
- * packet.
- * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet.
+ * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
+ * onto the packet.
+ * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
+ * from the packet.
  * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
  * the nested %OVS_SAMPLE_ATTR_* attributes.
  * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
-- 
2.4.3

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


Re: [ovs-dev] [PATCH 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-09-24 Thread Thomas F Herbert

Pravin,

I am you hoping you can take a look at a potential problem with my 
kernel module patch submitted to net-dev today. I decided to submit it 
anyway because that is the best way to get eyes on it.


I am still seeing a problem where the 4 conntrak attributes show up in 
an upcall when a double tagged packet is received. The attribute lengths 
for the 4 unknown attributes should be -1 but are showing up as odd 
lengths. I can't see where my patch below is causing this problem but I 
don't see similar errors with missed upcall in either single tagged or 
untagged packets. I have applied my companion patch to the user space 
for 802.1ad so the problem could be in that patch with de-serializing 
"unknown" attributes.


Also, this may not be a problem at all because the kernel module 
includes the conntrak patches but the user space does not as yet.


I am running ovs commit ca92d173 with my user space 802.1ad patch.

The error message is below:

Sep 24 14:01:34 Centos7Bld ovs-vswitchd[2666]: 
recirc_id(0),dp_hash(0),skb_priority(0),in_port(3),skb_mark(0),key22(bad 
key length 1, expected -1)(00),key23(bad key length 2, expected -1)(00 
00),key24(bad key length 4, expected -1)(00 00 00 00),key25(bad key 
length 16, expected -1)(00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00),eth(src=52:f6:ef:24:b6:4e,dst=08:00:27:7f:8f:e1),eth_type(0x88a8),

vlan(vid=100,pcp=0),encap(eth_type(0x8100),vlan(vid=999,pcp=0),encap(eth_type(0x0800),
ipv4(src=192.168.1.3,dst=192.168.1.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)))

Thanks in advance,

Tom Herbert
Red Hat


 Forwarded Message 
Subject: [PATCH 3/3] 802.1AD: Flow handling, actions, vlan parsing and 
netlink attributes

Date: Thu, 24 Sep 2015 13:58:18 -0400
From: Thomas F Herbert <thomasfherb...@gmail.com>
To: net...@vger.kernel.org, pshe...@nicira.com
CC: therb...@redhat.com, dev@openvswitch.org, Thomas F Herbert 
<thomasfherb...@gmail.com>


Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert <thomasfherb...@gmail.com>
---
 net/openvswitch/flow.c |  83 +
 net/openvswitch/flow.h |   5 ++
 net/openvswitch/flow_netlink.c | 166 
++---

 3 files changed, 230 insertions(+), 24 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..db58e47 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -305,21 +305,77 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
 static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
 {
struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
__be16 tci;
};
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;

-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   struct qinqtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+   __be16 inner_tpid; /* ETH_P_8021Q */
+   __be16 ctci;
+   };
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.tci = htons(skb->vlan_tci);
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key->eth.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   key->eth.cvlan.ctci =
+   qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.c_tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
return 0;
+   }

-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;

-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   if (qp->eth_type == htons(ETH_P_8021AD)) {
+   struct qinqtag

Re: [ovs-dev] [PATCH 1/3] datapath: Add support for 4.1 kernel.

2015-09-23 Thread Thomas F Herbert

On 9/22/15 4:15 PM, Pravin Shelar wrote:

On Tue, Sep 22, 2015 at 1:11 PM, Thomas F Herbert
<thomasfherb...@gmail.com> wrote:

On 9/15/15 2:09 PM, Pravin B Shelar wrote:


From: Joe Stringer <joestrin...@nicira.com>

Signed-off-by: Joe Stringer <joestrin...@nicira.com>
Signed-off-by: Pravin B Shelar <pshe...@nicira.com>
---
   .travis.yml   |3 +-
   FAQ.md|1 +
   acinclude.m4  |4 +-
   datapath/datapath.c   |4 +--
   datapath/datapath.h   |9 +++
   datapath/flow.c   |4 ++-
   datapath/linux/compat/geneve.c|2 +-
   datapath/linux/compat/include/net/net_namespace.h |   27
+
   datapath/linux/compat/include/net/udp_tunnel.h|   15 +++-
   datapath/linux/compat/include/net/vxlan.h |   14 ++
   datapath/linux/compat/stt.c   |   16 +++-
   datapath/linux/compat/udp_tunnel.c|   10 
   datapath/linux/compat/vxlan.c |7 ++---
   datapath/vport-lisp.c |3 +-
   datapath/vport-vxlan.c|2 +-


Pravin, when will the changes for contrak support that were merged into
upstream net-next be backported to OVS? I don't see them in this patch.


That will be done by separate patch. Joe is working on it.
Thanks. I asked because I see the 4 CT attributes show up in user space 
when I send an upcall with a double tagged vlan from my kernel module 
with 802.1ad patch.




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


Re: [ovs-dev] [PATCH 1/3] datapath: Add support for 4.1 kernel.

2015-09-22 Thread Thomas F Herbert

On 9/15/15 2:09 PM, Pravin B Shelar wrote:

From: Joe Stringer 

Signed-off-by: Joe Stringer 
Signed-off-by: Pravin B Shelar 
---
  .travis.yml   |3 +-
  FAQ.md|1 +
  acinclude.m4  |4 +-
  datapath/datapath.c   |4 +--
  datapath/datapath.h   |9 +++
  datapath/flow.c   |4 ++-
  datapath/linux/compat/geneve.c|2 +-
  datapath/linux/compat/include/net/net_namespace.h |   27 +
  datapath/linux/compat/include/net/udp_tunnel.h|   15 +++-
  datapath/linux/compat/include/net/vxlan.h |   14 ++
  datapath/linux/compat/stt.c   |   16 +++-
  datapath/linux/compat/udp_tunnel.c|   10 
  datapath/linux/compat/vxlan.c |7 ++---
  datapath/vport-lisp.c |3 +-
  datapath/vport-vxlan.c|2 +-
Pravin, when will the changes for contrak support that were merged into 
upstream net-next be backported to OVS? I don't see them in this patch.

  15 files changed, 83 insertions(+), 38 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index d14f786..f4b9188 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,8 @@ env:
- TESTSUITE=1 KERNEL=3.18.1
- TESTSUITE=1 OPTS="--enable-shared"
- BUILD_ENV="-m32" OPTS="--disable-ssl"
-  - KERNEL=4.0.2
+  - KERNEL=4.1.6
+  - KERNEL=4.0.9
- KERNEL=3.17.7 DPDK=1
- KERNEL=3.17.7 DPDK=1 OPTS="--enable-shared"
- KERNEL=3.17.7
diff --git a/FAQ.md b/FAQ.md
index 631f6a4..cea517d 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -156,6 +156,7 @@ A: The following table lists the Linux kernel versions 
against which the
  |2.1.x | 2.6.32 to 3.11
  |2.3.x | 2.6.32 to 3.14
  |2.4.x | 2.6.32 to 4.0
+|2.5.x | 2.6.32 to 4.1

 Open vSwitch userspace should also work with the Linux kernel module
 built into Linux 3.3 and later.
diff --git a/acinclude.m4 b/acinclude.m4
index b755dc4..229f900 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -134,10 +134,10 @@ AC_DEFUN([OVS_CHECK_LINUX], [
  AC_MSG_RESULT([$kversion])

  if test "$version" -ge 4; then
-   if test "$version" = 4 && test "$patchlevel" -le 0; then
+   if test "$version" = 4 && test "$patchlevel" -le 1; then
: # Linux 4.x
 else
-  AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version 
newer than 4.0.x is not supported (please refer to the FAQ for advice)])
+  AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version 
newer than 4.1.x is not supported (please refer to the FAQ for advice)])
 fi
  elif test "$version" = 3; then
 : # Linux 3.x
diff --git a/datapath/datapath.c b/datapath/datapath.c
index 73c0b4a..1115649 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -205,7 +205,6 @@ static void destroy_dp_rcu(struct rcu_head *rcu)

ovs_flow_tbl_destroy(>table);
free_percpu(dp->stats_percpu);
-   release_net(ovs_dp_get_net(dp));
kfree(dp->ports);
kfree(dp);
  }
@@ -1527,7 +1526,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct 
genl_info *info)
if (dp == NULL)
goto err_free_reply;

-   ovs_dp_set_net(dp, hold_net(sock_net(skb->sk)));
+   ovs_dp_set_net(dp, sock_net(skb->sk));

/* Allocate table. */
err = ovs_flow_tbl_init(>table);
@@ -1601,7 +1600,6 @@ err_destroy_percpu:
  err_destroy_table:
ovs_flow_tbl_destroy(>table);
  err_free_dp:
-   release_net(ovs_dp_get_net(dp));
kfree(dp);
  err_free_reply:
kfree_skb(reply);
diff --git a/datapath/datapath.h b/datapath/datapath.h
index 526ddad..aca9407 100644
--- a/datapath/datapath.h
+++ b/datapath/datapath.h
@@ -25,6 +25,7 @@
  #include 
  #include 
  #include 
+#include 

  #include "compat.h"
  #include "flow.h"
@@ -86,10 +87,8 @@ struct datapath {
/* Stats. */
struct dp_stats_percpu __percpu *stats_percpu;

-#ifdef CONFIG_NET_NS
/* Network namespace ref. */
-   struct net *net;
-#endif
+   possible_net_t net;

u32 user_features;
  };
@@ -156,12 +155,12 @@ int lockdep_ovsl_is_held(void);

  static inline struct net *ovs_dp_get_net(const struct datapath *dp)
  {
-   return read_pnet(>net);
+   return rpl_read_pnet(>net);
  }

  static inline void ovs_dp_set_net(struct datapath *dp, struct net *net)
  {
-   write_pnet(>net, net);
+   rpl_write_pnet(>net, net);
  }

  struct vport *ovs_lookup_vport(const struct datapath *dp, u16 port_no);
diff --git a/datapath/flow.c b/datapath/flow.c
index a7a2063..8ef60d1 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -101,7 +101,9 @@ 

Re: [ovs-dev] When the attribute OVS_KEY_ATTR_ENCAP will be used?

2015-09-22 Thread Thomas F Herbert

On 9/17/15 3:50 AM, openvswitcher wrote:

Hi, all


Could you tell me when the attribute  OVS_KEY_ATTR_ENCAP will be used?
That is the encapsulation attribute used for the netlink serialization 
encoding.



If the packet is 802.1q, then OVS_KEY_ATTR_VLAN will be used to store the vlan 
tci,
so what the OVS_KEY_ATTR_ENCAP  is used for?
It marks that what follows is encapsulated within an outer header. Used 
for translation to/from netlink.



Thanks.
___
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] Status of Open vSwitch with DPDK

2015-08-14 Thread Thomas F Herbert

On 8/14/15 12:04 PM, Gray, Mark D wrote:

Hi Daniele,

Thanks for starting this conversation. It is a good list :) I have 
crossed-posted this
to dpdk.org as I feel that some of the points could be interesting to that 
community
as they are related to how DPDK is used.

How do users of OVS with DPDK feel about this list? Does anyone disagree or
does anyone have any additions? What are your experiences?

Daniele,

Although I think Mark posted this information to @openvswitch before, I 
want to mention again the new project in opnfv, openvswitch for nfv 
(tagged ovsnfv) whose purpose is to deploy Open vSwitch with sw datapath 
acceleration into opnfv. The goal is to test ovs-dpdk or other potential 
contributed accelerated datapaths into more complex user focused 
scenarios such as sfc and opnfv vsperf.




There has been some discussion lately about the status of the Open vSwitch
port to DPDK.  While part of the code has been tested for quite some time,
I think we can agree that there are a few rough spots that prevent it from
being easily deployed and used.

I was hoping to get some feedback from the community about those rough
spots,
i.e. areas where OVS+DPDK can/needs to improve to become more
production
ready and user-friendly.

- PMD threads and queues management: the code has shown several bugs
and
the
   netdev interfaces don't seem up to the job anymore.


You had a few ideas about how to refactor this before but I was concerned
about the effect it would have on throughput. I can't find the thread.

Do you have some further ideas about how to achieve this?



   There's a lot of margin of improvement: we could factor out the code from
   dpif-netdev, add configuration parameters for advanced users, and figure
out
   a way to add unit tests.



I think this is a general issue with both the kernel datapath (and netdevs)
and the userspace datapath. There isn't much unit testing (or testing) outside
of the slow path.
Well yes of course but there is quite a bit of tradecraft accumulated 
over many years about how to debug and test a kernel based protocol that 
just doesn't exist yet for dpdk.



   Related to this, the system should be as fast as possible out-of-the-box,
   without requiring too much tuning.
I know there have been some off-line discussions about the possibility 
of creating some canned tuning profiles including a default profile to 
improve the out of the box experience of dpdk so new deployers of 
dpdk/ovs could experience some of the benefits of dpdk without needing 
to deep dive into the mysteries of tuning dpdk.


This is a good point. I think the kernel datapath has a similar issue. You can
get a certain level of performance without compiling with -Ofast or
pinning threads but you will (even with the kernel datapath) get better
performance if you pin threads (and possibly compile differently). I guess
it is more visible with the dpdk datapath as performance is one of the key
values. It is also more detrimental to the performance if you don't set it
up correctly.

Perhaps we could provide scripts to help do this?

I think this is also interesting to the DPDK community. There is
knowledge required when running DPDK enabled apps to
get good performance: core pinning is one thing that comes to mind.



- Userspace tunneling: while the code has been there for quite some time it
   hasn't received the level of testing that the Linux kernel datapath
tunneling
   has.



Again, there is a lack of test infrastructure in general for OVS. vsperf is a 
good
start, and it would be great to see more people use and contribute to it!


- Documentation: other than a step by step tutorial,  it cannot be said
that
   DPDK is a first class citizen in the OVS documentation.  Manpages could
be
   improved.


Easily done. The INSTALL guide is pretty good but the structure could be better.
There is also a lack of manpages. Good point.



- Vhost: the code has not received the level of testing of the kernel
vhost.
   Another doubt shared by some developers is whether we should keep
   vhost-cuse, given its relatively low ease of use and the overlapping with
   the far more standard vhost-user.


vhost-cuse is required for older versions of qemu. I'm aware of some companies
using it as they are restricted to an older version of qemu. I think it is 
deprecated
at the moment? Is there a notice to that effect? We just need a plan for when to
remove it and make sure that plan is clear?

+1




- Interface management and naming: interfaces must be manually removed
from
   the kernel drivers.

   We still don't have an easy way to identify them. Ideas are welcome: how
can
   we make this user friendly?  Is there a better solution on the DPDK side?


This is a tough one and is interesting to the DPDK community.  The basic issue
here is that users are more familiar with linux interfaces and linux naming
conventions.

ovs-vsctl add-port bro eth0 makes a lot more sense than

dpdk_nic_bind -b igb_uio pci_id, then 

Re: [ovs-dev] [RFC] dpdk: support multiple queues in vhost

2015-08-07 Thread Thomas F Herbert

On 8/6/15 5:29 PM, Flavio Leitner wrote:

On Thu, Aug 06, 2015 at 03:24:29PM -0400, Thomas F Herbert wrote:

On 8/6/15 1:40 PM, Flavio Leitner wrote:

On Thu, Aug 06, 2015 at 12:39:29PM -0400, Thomas F Herbert wrote:

On 7/31/15 6:30 PM, Flavio Leitner wrote:

This RFC is based on the vhost multiple queues work on
dpdk-dev: http://dpdk.org/ml/archives/dev/2015-June/019345.html

Signed-off-by: Flavio Leitner f...@redhat.com
---
  lib/netdev-dpdk.c | 61 ---
  1 file changed, 40 insertions(+), 21 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 5ae805e..493172c 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -215,12 +215,9 @@ struct netdev_dpdk {
   * If the numbers match, 'txq_needs_locking' is false, otherwise it is
   * true and we will take a spinlock on transmission */
  int real_n_txq;
+int real_n_rxq;
  bool txq_needs_locking;

-/* Spinlock for vhost transmission.  Other DPDK devices use spinlocks in
- * dpdk_tx_queue */
-rte_spinlock_t vhost_tx_lock;
-
  /* virtio-net structure for vhost device */
  OVSRCU_TYPE(struct virtio_net *) virtio_dev;

@@ -602,13 +599,10 @@ dpdk_dev_parse_name(const char dev_name[], const char 
prefix[],
  static int
  vhost_construct_helper(struct netdev *netdev_) OVS_REQUIRES(dpdk_mutex)
  {
-struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_);
-
  if (rte_eal_init_ret) {
  return rte_eal_init_ret;
  }

-rte_spinlock_init(netdev-vhost_tx_lock);
  return netdev_dpdk_init(netdev_, -1, DPDK_DEV_VHOST);
  }

@@ -791,9 +785,16 @@ netdev_dpdk_vhost_set_multiq(struct netdev *netdev_, 
unsigned int n_txq,
  ovs_mutex_lock(dpdk_mutex);
  ovs_mutex_lock(netdev-mutex);

+rte_free(netdev-tx_q);
+/* FIXME: the number of vqueues needs to match */

Do you still need this FIXME? Isn't the code you added below freeing and
re-allocating the correct number of tx queues?


Yes, because that is about virtual queues provided by qemu.
Thanks,
fbl
I understand this is an RFC but I think your patch is in the right 
direction. I know the merging is complex and requires upstream changes 
to DPDK and Qemu. I ack this patch is an important step that moves the 
ball forward toward vhost user performance of DPDK accelerated OVS.


--TFH



  netdev-up.n_txq = n_txq;
-netdev-real_n_txq = 1;
-netdev-up.n_rxq = 1;
+netdev-up.n_rxq = n_rxq;
+
+/* vring has txq = rxq */
+netdev-real_n_txq = n_rxq;
+netdev-real_n_rxq = n_rxq;
+netdev-txq_needs_locking = netdev-real_n_txq != netdev-up.n_txq;
+netdev_dpdk_alloc_txq(netdev, netdev-up.n_txq);

  ovs_mutex_unlock(netdev-mutex);
  ovs_mutex_unlock(dpdk_mutex);
@@ -904,14 +905,14 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq_,
  struct netdev *netdev = rx-up.netdev;
  struct netdev_dpdk *vhost_dev = netdev_dpdk_cast(netdev);
  struct virtio_net *virtio_dev = netdev_dpdk_get_virtio(vhost_dev);
-int qid = 1;
+int qid = rxq_-queue_id;
  uint16_t nb_rx = 0;

  if (OVS_UNLIKELY(!is_vhost_running(virtio_dev))) {
  return EAGAIN;
  }

-nb_rx = rte_vhost_dequeue_burst(virtio_dev, qid,
+nb_rx = rte_vhost_dequeue_burst(virtio_dev, VIRTIO_TXQ + qid * 2,
  vhost_dev-dpdk_mp-mp,
  (struct rte_mbuf **)packets,
  NETDEV_MAX_BURST);
@@ -958,8 +959,9 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq_, struct 
dp_packet **packets,
  }

  static void
-__netdev_dpdk_vhost_send(struct netdev *netdev, struct dp_packet **pkts,
- int cnt, bool may_steal)
+__netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
+ struct dp_packet **pkts, int cnt,
+ bool may_steal)
  {
  struct netdev_dpdk *vhost_dev = netdev_dpdk_cast(netdev);
  struct virtio_net *virtio_dev = netdev_dpdk_get_virtio(vhost_dev);
@@ -974,13 +976,16 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, struct 
dp_packet **pkts,
  goto out;
  }

-/* There is vHost TX single queue, So we need to lock it for TX. */
-rte_spinlock_lock(vhost_dev-vhost_tx_lock);
+if (vhost_dev-txq_needs_locking) {
+qid = qid % vhost_dev-real_n_txq;
+rte_spinlock_lock(vhost_dev-tx_q[qid].tx_lock);
+}

  do {
+int vhost_qid = VIRTIO_RXQ + qid * VIRTIO_QNUM;
  unsigned int tx_pkts;

-tx_pkts = rte_vhost_enqueue_burst(virtio_dev, VIRTIO_RXQ,
+tx_pkts = rte_vhost_enqueue_burst(virtio_dev, vhost_qid,
cur_pkts, cnt);
  if (OVS_LIKELY(tx_pkts)) {
  /* Packets have been sent.*/
@@ -999,7 +1004,7 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, struct 
dp_packet **pkts,
   * Unable to enqueue packets to vhost interface.
   * Check available

Re: [ovs-dev] [RFC] dpdk: support multiple queues in vhost

2015-08-06 Thread Thomas F Herbert

On 7/31/15 6:30 PM, Flavio Leitner wrote:

This RFC is based on the vhost multiple queues work on
dpdk-dev: http://dpdk.org/ml/archives/dev/2015-June/019345.html

Signed-off-by: Flavio Leitner f...@redhat.com
---
  lib/netdev-dpdk.c | 61 ---
  1 file changed, 40 insertions(+), 21 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 5ae805e..493172c 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -215,12 +215,9 @@ struct netdev_dpdk {
   * If the numbers match, 'txq_needs_locking' is false, otherwise it is
   * true and we will take a spinlock on transmission */
  int real_n_txq;
+int real_n_rxq;
  bool txq_needs_locking;

-/* Spinlock for vhost transmission.  Other DPDK devices use spinlocks in
- * dpdk_tx_queue */
-rte_spinlock_t vhost_tx_lock;
-
  /* virtio-net structure for vhost device */
  OVSRCU_TYPE(struct virtio_net *) virtio_dev;

@@ -602,13 +599,10 @@ dpdk_dev_parse_name(const char dev_name[], const char 
prefix[],
  static int
  vhost_construct_helper(struct netdev *netdev_) OVS_REQUIRES(dpdk_mutex)
  {
-struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_);
-
  if (rte_eal_init_ret) {
  return rte_eal_init_ret;
  }

-rte_spinlock_init(netdev-vhost_tx_lock);
  return netdev_dpdk_init(netdev_, -1, DPDK_DEV_VHOST);
  }

@@ -791,9 +785,16 @@ netdev_dpdk_vhost_set_multiq(struct netdev *netdev_, 
unsigned int n_txq,
  ovs_mutex_lock(dpdk_mutex);
  ovs_mutex_lock(netdev-mutex);

+rte_free(netdev-tx_q);
+/* FIXME: the number of vqueues needs to match */
  netdev-up.n_txq = n_txq;
-netdev-real_n_txq = 1;
-netdev-up.n_rxq = 1;
+netdev-up.n_rxq = n_rxq;
+
+/* vring has txq = rxq */
+netdev-real_n_txq = n_rxq;
+netdev-real_n_rxq = n_rxq;
+netdev-txq_needs_locking = netdev-real_n_txq != netdev-up.n_txq;
+netdev_dpdk_alloc_txq(netdev, netdev-up.n_txq);

  ovs_mutex_unlock(netdev-mutex);
  ovs_mutex_unlock(dpdk_mutex);
@@ -904,14 +905,14 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq_,
  struct netdev *netdev = rx-up.netdev;
  struct netdev_dpdk *vhost_dev = netdev_dpdk_cast(netdev);
  struct virtio_net *virtio_dev = netdev_dpdk_get_virtio(vhost_dev);
-int qid = 1;
+int qid = rxq_-queue_id;
  uint16_t nb_rx = 0;

  if (OVS_UNLIKELY(!is_vhost_running(virtio_dev))) {
  return EAGAIN;
  }

-nb_rx = rte_vhost_dequeue_burst(virtio_dev, qid,
+nb_rx = rte_vhost_dequeue_burst(virtio_dev, VIRTIO_TXQ + qid * 2,
  vhost_dev-dpdk_mp-mp,
  (struct rte_mbuf **)packets,
  NETDEV_MAX_BURST);
@@ -958,8 +959,9 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq_, struct 
dp_packet **packets,
  }

  static void
-__netdev_dpdk_vhost_send(struct netdev *netdev, struct dp_packet **pkts,
- int cnt, bool may_steal)
+__netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
+ struct dp_packet **pkts, int cnt,
+ bool may_steal)
  {
  struct netdev_dpdk *vhost_dev = netdev_dpdk_cast(netdev);
  struct virtio_net *virtio_dev = netdev_dpdk_get_virtio(vhost_dev);
@@ -974,13 +976,16 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, struct 
dp_packet **pkts,
  goto out;
  }

-/* There is vHost TX single queue, So we need to lock it for TX. */
-rte_spinlock_lock(vhost_dev-vhost_tx_lock);
+if (vhost_dev-txq_needs_locking) {
+qid = qid % vhost_dev-real_n_txq;
+rte_spinlock_lock(vhost_dev-tx_q[qid].tx_lock);
+}

  do {
+int vhost_qid = VIRTIO_RXQ + qid * VIRTIO_QNUM;
  unsigned int tx_pkts;

-tx_pkts = rte_vhost_enqueue_burst(virtio_dev, VIRTIO_RXQ,
+tx_pkts = rte_vhost_enqueue_burst(virtio_dev, vhost_qid,
cur_pkts, cnt);
  if (OVS_LIKELY(tx_pkts)) {
  /* Packets have been sent.*/
@@ -999,7 +1004,7 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, struct 
dp_packet **pkts,
   * Unable to enqueue packets to vhost interface.
   * Check available entries before retrying.
   */
-while (!rte_vring_available_entries(virtio_dev, VIRTIO_RXQ)) {
+while (!rte_vring_available_entries(virtio_dev, vhost_qid)) {
  if (OVS_UNLIKELY((rte_get_timer_cycles() - start)  timeout)) 
{
  expired = 1;
  break;
@@ -1011,7 +1016,10 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, struct 
dp_packet **pkts,
  }
  }
  } while (cnt);
-rte_spinlock_unlock(vhost_dev-vhost_tx_lock);
+
+if (vhost_dev-txq_needs_locking) {
+rte_spinlock_unlock(vhost_dev-tx_q[qid].tx_lock);
+}

  rte_spinlock_lock(vhost_dev-stats_lock);
  

Re: [ovs-dev] [RFC] dpdk: support multiple queues in vhost

2015-08-06 Thread Thomas F Herbert

On 8/6/15 1:40 PM, Flavio Leitner wrote:

On Thu, Aug 06, 2015 at 12:39:29PM -0400, Thomas F Herbert wrote:

On 7/31/15 6:30 PM, Flavio Leitner wrote:

This RFC is based on the vhost multiple queues work on
dpdk-dev: http://dpdk.org/ml/archives/dev/2015-June/019345.html

Signed-off-by: Flavio Leitner f...@redhat.com
---
  lib/netdev-dpdk.c | 61 ---
  1 file changed, 40 insertions(+), 21 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 5ae805e..493172c 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -215,12 +215,9 @@ struct netdev_dpdk {
   * If the numbers match, 'txq_needs_locking' is false, otherwise it is
   * true and we will take a spinlock on transmission */
  int real_n_txq;
+int real_n_rxq;
  bool txq_needs_locking;

-/* Spinlock for vhost transmission.  Other DPDK devices use spinlocks in
- * dpdk_tx_queue */
-rte_spinlock_t vhost_tx_lock;
-
  /* virtio-net structure for vhost device */
  OVSRCU_TYPE(struct virtio_net *) virtio_dev;

@@ -602,13 +599,10 @@ dpdk_dev_parse_name(const char dev_name[], const char 
prefix[],
  static int
  vhost_construct_helper(struct netdev *netdev_) OVS_REQUIRES(dpdk_mutex)
  {
-struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_);
-
  if (rte_eal_init_ret) {
  return rte_eal_init_ret;
  }

-rte_spinlock_init(netdev-vhost_tx_lock);
  return netdev_dpdk_init(netdev_, -1, DPDK_DEV_VHOST);
  }

@@ -791,9 +785,16 @@ netdev_dpdk_vhost_set_multiq(struct netdev *netdev_, 
unsigned int n_txq,
  ovs_mutex_lock(dpdk_mutex);
  ovs_mutex_lock(netdev-mutex);

+rte_free(netdev-tx_q);
+/* FIXME: the number of vqueues needs to match */
Do you still need this FIXME? Isn't the code you added below freeing 
and re-allocating the correct number of tx queues?

  netdev-up.n_txq = n_txq;
-netdev-real_n_txq = 1;
-netdev-up.n_rxq = 1;
+netdev-up.n_rxq = n_rxq;
+
+/* vring has txq = rxq */
+netdev-real_n_txq = n_rxq;
+netdev-real_n_rxq = n_rxq;
+netdev-txq_needs_locking = netdev-real_n_txq != netdev-up.n_txq;
+netdev_dpdk_alloc_txq(netdev, netdev-up.n_txq);

  ovs_mutex_unlock(netdev-mutex);
  ovs_mutex_unlock(dpdk_mutex);
@@ -904,14 +905,14 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq_,
  struct netdev *netdev = rx-up.netdev;
  struct netdev_dpdk *vhost_dev = netdev_dpdk_cast(netdev);
  struct virtio_net *virtio_dev = netdev_dpdk_get_virtio(vhost_dev);
-int qid = 1;
+int qid = rxq_-queue_id;
  uint16_t nb_rx = 0;

  if (OVS_UNLIKELY(!is_vhost_running(virtio_dev))) {
  return EAGAIN;
  }

-nb_rx = rte_vhost_dequeue_burst(virtio_dev, qid,
+nb_rx = rte_vhost_dequeue_burst(virtio_dev, VIRTIO_TXQ + qid * 2,
  vhost_dev-dpdk_mp-mp,
  (struct rte_mbuf **)packets,
  NETDEV_MAX_BURST);
@@ -958,8 +959,9 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq_, struct 
dp_packet **packets,
  }

  static void
-__netdev_dpdk_vhost_send(struct netdev *netdev, struct dp_packet **pkts,
- int cnt, bool may_steal)
+__netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
+ struct dp_packet **pkts, int cnt,
+ bool may_steal)
  {
  struct netdev_dpdk *vhost_dev = netdev_dpdk_cast(netdev);
  struct virtio_net *virtio_dev = netdev_dpdk_get_virtio(vhost_dev);
@@ -974,13 +976,16 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, struct 
dp_packet **pkts,
  goto out;
  }

-/* There is vHost TX single queue, So we need to lock it for TX. */
-rte_spinlock_lock(vhost_dev-vhost_tx_lock);
+if (vhost_dev-txq_needs_locking) {
+qid = qid % vhost_dev-real_n_txq;
+rte_spinlock_lock(vhost_dev-tx_q[qid].tx_lock);
+}

  do {
+int vhost_qid = VIRTIO_RXQ + qid * VIRTIO_QNUM;
  unsigned int tx_pkts;

-tx_pkts = rte_vhost_enqueue_burst(virtio_dev, VIRTIO_RXQ,
+tx_pkts = rte_vhost_enqueue_burst(virtio_dev, vhost_qid,
cur_pkts, cnt);
  if (OVS_LIKELY(tx_pkts)) {
  /* Packets have been sent.*/
@@ -999,7 +1004,7 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, struct 
dp_packet **pkts,
   * Unable to enqueue packets to vhost interface.
   * Check available entries before retrying.
   */
-while (!rte_vring_available_entries(virtio_dev, VIRTIO_RXQ)) {
+while (!rte_vring_available_entries(virtio_dev, vhost_qid)) {
  if (OVS_UNLIKELY((rte_get_timer_cycles() - start)  timeout)) 
{
  expired = 1;
  break;
@@ -1011,7 +1016,10 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, struct 
dp_packet **pkts,
  }
  }
  } while

Re: [ovs-dev] Adding a new file to ovs-master

2015-08-04 Thread Thomas F Herbert

On 8/4/15 10:50 AM, Russell Bryant wrote:

On 08/04/2015 08:37 AM, ravali.bu...@wipro.com wrote:

Hi Team,

I have added the new file to ovs-master for MSTP but while compiling
I am unable include the new header file in the file.

I have added the reference for the new files in lib/automake.mk even
then I am able to see error like  expected ';', identifier or '('
before 'struct' .

Can you please help me linking the new files to OVS for compiling.


It's difficult to know what the problem is and provide useful input
without seeing the code and the full error you get.  Would you like to
throw it in a git repo on github or something and show the full error?

and also submit your new file and other changes as a patch.




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


Re: [ovs-dev] [PATCH net-next 3/3] openvswitch: 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-08-01 Thread Thomas F Herbert



On 8/1/15 8:45 AM, ravulakollu.ku...@wipro.com wrote:

Hi Thomas,

Thanks for your clarification.
Could you please forward me the userspace patch you are mentioning. I guess 
version 6 is the latest,
but I could not get the patch in internet. We are interested in testing this 
feature thoroughly.
This is the latest submission here, 
http://openvswitch.org/pipermail/dev/2015-June/056717.html


Also In the case of NORMAL mode as you said without patch also it should work. 
But I tested thoroughly to realize 1ad in the context of
NORMAL mode. I did not see the support in NORMAL mode. I am seeing pushing only 
1q tag(Access/Native-tagged/Native-untagged).
I think you may have some fundamental misunderstanding of Open vSwitch 
and Open Flow. You must program a flow to cause an action to be 
executed. In this case, the action is to push or pop a vlan tag.


In NORMAL mode, the switch will operate without any flows by remembering 
the egress port and flooding the packets to all ports except the ingress 
port. Anything more sophisticated will require programming flows.


If you don't want to dynamically push or pop vlan tags but you do want 
to forward packets to pre-configured double tagged vlans that are double 
tagged, you want to set up a double tagged vlan using Linux namespaces 
and add that port to open vswitch.


For example:

sudo ifconfig eth1 0.0.0.0

sudo ip link add name eth1.999 link eth1 type vlan id 999 proto 802.1q
sudo ifconfig eth1.999 up
#
# Push another tag to create double tagged vlan IF
#
sudo ip link add name eth1.999.100 link eth1.999 type vlan id 100 proto 
802.1ad

sudo ifconfig eth1.999.100 up

ovs-vsctl add-port br0 eth1.999.100




Please find my understanding from my tests

If already tagged packet received on ingress port:
1)If interface is configured as access , packet is dropped
2)If interface is configured as native-tagged/native-untagged, packet 
is just forwarded
For an untagged packet received on ingress port , in all the above three mode 
1q header is being pushed.

Thanks  Regards,
Udaya Kumar R
___
From: Thomas F Herbert therb...@redhat.com
Sent: Friday, July 31, 2015 9:58 PM
To: Ravulakollu Udaya Kumar (WT01 - Digital Marketing); 
thomasfherb...@gmail.com; net...@vger.kernel.org; pshe...@nicira.com
Cc: dev@openvswitch.org
Subject: Re: [ovs-dev] [PATCH net-next 3/3] openvswitch: 802.1AD: Flow 
handling, actions, vlan parsing and netlink attributes

On 7/31/15 5:34 AM, ravulakollu.ku...@wipro.com wrote:

Hi Thomas,

I have applied your  below mentioned 1ad patch to ovs-master code. Compiled 
successfully. I am running ovs in a centos machine.
I have created bridge and configured ports using below commands.

ovs-vsctl --no-wait add-br br0
ovs-vsctl --no-wait add-port br0 eth0 tag=100 vlan_mode=native-tagged /access
ovs-vsctl --no-wait add-port br0 eth1

Configured the bridge to work in legacy bridge mode
$ ovs-ofctl dump-flows br0
   NXST_FLOW reply (xid=0x4):
   cookie=0x0, duration=15.458s, table=0, n_packets=0, n_bytes=0, idle_age=15, 
priority=0 actions=NORMAL

And started running vswitchd

$ ovs-vswitchd --pidfile

Started pumping traffic from outside using ostinato packet generator for 
Phy-Phy scenario(sending to eth0 ,receiving back on eth1)
My observation is
1) For untagged packet received on eth0 pushing vid 100 and packet flow is fine
2) For already tagged (1q) packet received on eth0 packet is dropped , I could 
see vswitchd log throwing below error(duplicate eth_type attribute in flow key)

2015-07-31T12:13:59Z|1|ovs_numa|INFO|Discovered 4 CPU cores on NUMA node 0
2015-07-31T12:13:59Z|2|ovs_numa|INFO|Discovered 1 NUMA nodes and 4 CPU cores
2015-07-31T12:13:59Z|3|reconnect|INFO|unix:/usr/local/var/run/openvswitch/db.sock:
 connecting...
2015-07-31T12:13:59Z|4|reconnect|INFO|unix:/usr/local/var/run/openvswitch/db.sock:
 connected
2015-07-31T12:13:59Z|5|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2015-07-31T12:13:59Z|6|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2015-07-31T12:13:59Z|7|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2015-07-31T12:13:59Z|1|ofproto_dpif_upcall(handler1)|INFO|received packet 
on unassociated datapath port 0
2015-07-31T12:13:59Z|8|bridge|INFO|bridge br0: added interface eth0 on port 
1
2015-07-31T12:13:59Z|9|bridge|INFO|bridge br0: added interface br0 on port 
65534
2015-07-31T12:13:59Z|00010|bridge|INFO|bridge br0: added interface eth1 on port 
2
2015-07-31T12:13:59Z|00011|bridge|INFO|bridge br0: using datapath ID 
eac07aea5143
2015-07-31T12:13:59Z|00012|connmgr|INFO|br0: added service controller 
punix:/usr/local/var/run/openvswitch/br0.mgmt
2015-07-31T12:13:59Z|00013|bridge|INFO|ovs-vswitchd (Open vSwitch) 2.3.90
2015-07-31T12:14:09Z|00014|memory|INFO|2420 kB peak resident set size after 
10.0 seconds
2015-07-31T12:14:09Z|00015|memory|INFO|handlers:2 ports:3

Re: [ovs-dev] [PATCH net-next 3/3] openvswitch: 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-07-31 Thread Thomas F Herbert



On 7/31/15 5:34 AM, ravulakollu.ku...@wipro.com wrote:

Hi Thomas,

I have applied your  below mentioned 1ad patch to ovs-master code. Compiled 
successfully. I am running ovs in a centos machine.
I have created bridge and configured ports using below commands.

ovs-vsctl --no-wait add-br br0
ovs-vsctl --no-wait add-port br0 eth0 tag=100 vlan_mode=native-tagged /access
ovs-vsctl --no-wait add-port br0 eth1

Configured the bridge to work in legacy bridge mode
$ ovs-ofctl dump-flows br0
  NXST_FLOW reply (xid=0x4):
  cookie=0x0, duration=15.458s, table=0, n_packets=0, n_bytes=0, idle_age=15, 
priority=0 actions=NORMAL

And started running vswitchd

$ ovs-vswitchd --pidfile

Started pumping traffic from outside using ostinato packet generator for 
Phy-Phy scenario(sending to eth0 ,receiving back on eth1)
My observation is
1) For untagged packet received on eth0 pushing vid 100 and packet flow is fine
2) For already tagged (1q) packet received on eth0 packet is dropped , I could 
see vswitchd log throwing below error(duplicate eth_type attribute in flow key)

2015-07-31T12:13:59Z|1|ovs_numa|INFO|Discovered 4 CPU cores on NUMA node 0
2015-07-31T12:13:59Z|2|ovs_numa|INFO|Discovered 1 NUMA nodes and 4 CPU cores
2015-07-31T12:13:59Z|3|reconnect|INFO|unix:/usr/local/var/run/openvswitch/db.sock:
 connecting...
2015-07-31T12:13:59Z|4|reconnect|INFO|unix:/usr/local/var/run/openvswitch/db.sock:
 connected
2015-07-31T12:13:59Z|5|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2015-07-31T12:13:59Z|6|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2015-07-31T12:13:59Z|7|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2015-07-31T12:13:59Z|1|ofproto_dpif_upcall(handler1)|INFO|received packet 
on unassociated datapath port 0
2015-07-31T12:13:59Z|8|bridge|INFO|bridge br0: added interface eth0 on port 
1
2015-07-31T12:13:59Z|9|bridge|INFO|bridge br0: added interface br0 on port 
65534
2015-07-31T12:13:59Z|00010|bridge|INFO|bridge br0: added interface eth1 on port 
2
2015-07-31T12:13:59Z|00011|bridge|INFO|bridge br0: using datapath ID 
eac07aea5143
2015-07-31T12:13:59Z|00012|connmgr|INFO|br0: added service controller 
punix:/usr/local/var/run/openvswitch/br0.mgmt
2015-07-31T12:13:59Z|00013|bridge|INFO|ovs-vswitchd (Open vSwitch) 2.3.90
2015-07-31T12:14:09Z|00014|memory|INFO|2420 kB peak resident set size after 
10.0 seconds
2015-07-31T12:14:09Z|00015|memory|INFO|handlers:2 ports:3 revalidators:2 rules:5
2015-07-31T12:16:31Z|1|odp_util(handler6)|ERR|duplicate eth_type attribute 
in flow key
2015-07-31T12:26:51Z|2|odp_util(handler6)|ERR|duplicate eth_type attribute 
in flow key

I believe this may be a bug in the patch.

Also, what you are doing above should work without the patch.



Please, let me know whether I missed anything in the configuration. It would be 
helpful  if someone could let me
Know how I can insert 1ad tag on ingress.


The patch supports pushing and popping outer tags for 802.1ad. The 
previously submitted user space patch is required as well.


To test: take the switch out of NORMAL mode so it won't flood packets, 
set up veths, bridges and ports. The test should accept  untagged 
traffic in eth p1p1 and double tagged traffic in eth em4


sudo ip link add type veth
sudo ifconfig veth0 up
sudo ifconfig veth1 up

sudo ovs-vsctl add-br br0

sudo ovs-vsctl -- set bridge br0 fail-mode=secure

sudo ovs-vsctl -- set bridge br0 protocols=[OpenFlow11]

sudo ovs-vsctl add-port br0 em4

sudo ovs-vsctl add-port br0 veth0
#
# Add Customer bridge
#
sudo ovs-vsctl add-br br1

sudo ovs-vsctl -- set bridge br1 fail-mode=secure

sudo ovs-vsctl -- set bridge br1 protocols=[OpenFlow11]

sudo ovs-vsctl add-port br1 veth1

sudo ovs-vsctl add-port br1 p1p2


Then add flows to push and pop vlans as follows.

sudo ovs-ofctl --protocols=OpenFlow11 add-flow br0 
in_port=1,dl_vlan=100,actions=pop_vlan,output:2

#
# Packets to Core
#
sudo ovs-ofctl --protocols=OpenFlow11 add-flow br0 
in_port=2,actions=push_vlan:0x88a8,load:100-\OXM_OF_VLAN_VID[],output:1

#
# Strip c-tag
#
# Ctag Packets from br0,VID:998
#
sudo ovs-ofctl --protocols=OpenFlow11 add-flow br1 
in_port=1,dl_vlan=998,actions=pop_vlan,output:2

#
# Ctag Packets from  cpe to VID:998
#
sudo ovs-ofctl --protocols=OpenFlow11 add-flow br1 
in_port=2,actions=push_vlan:0x8100,load:998-\OXM_OF_VLAN_VID[],output:1



--TFH



Thanks  Regards,
Uday


-Original Message-
From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Thomas F Herbert
Sent: Sunday, July 26, 2015 8:23 PM
To: net...@vger.kernel.org; pshe...@nicira.com
Cc: dev@openvswitch.org; therb...@redhat.com
Subject: [ovs-dev] [PATCH net-next 3/3] openvswitch: 802.1AD: Flow handling, 
actions, vlan parsing and netlink attributes

Add support for 802.1ad including the ability to push and pop double tagged 
vlans. Add support for 802.1ad to netlink parsing and flow conversion. Uses 
double

Re: [ovs-dev] kernel module testing

2015-07-28 Thread Thomas F Herbert

On 7/28/15 3:19 AM, Finucane, Stephen wrote:

For what it's worth, I also think that something like Gerrit would be
useful given the number of platforms that OVS is running on. Right
now, it's seems like we're doing the human-powered version, which is
Guru, Daniele, or Ben complain when something breaks Windows, DPDK,
32-bit respectively. It also effectively provides the features of
Patchwork in a way that is more maintainable.

I agree that the Gerrit UI sucks (I haven't tried the OpenStack
interface) and maybe there are alternatives, like Github's set of
tools. But I think the status quo that we have isn't all that great
either and I also would like to avoid having a collection of
independent tools that fall apart over time.


I'm happy to encourage people to submit changes via Github, as an
experiment.


I think this is a reasonable place to start, especially since we
already have the infrastructure set up. I think the main thing to try
out is whether we are OK with this type of workflow for reviewing
patches as opposed to the mailing list, so at some level it doesn't
matter where we start.

I don't think that Travis CI is good enough to handle all of the
pre-checkin tests that we would like to do (kernel, Windows,
performance, etc.) but it looks like there are other tools that have
integration with Github that minimally should be the same as what
Gerrit can do.


I'm obliged to point out the work that's ongoing to get some level of automated 
testing going in patchwork (for use with DPDK):

https://lists.ozlabs.org/pipermail/patchwork/2015-July/001363.html

Stephen, thanks for bringing this up.


However, I still think Gerrit is the more mature, feature-filled solution if 
mailing list-based development isn't an absolute necessity. OpenStack really 
have the Gerrit process nailed.

My question would be how to handle multi-architecture support required 
for testing kernel module. It seems like a mechanism that we are working 
on for DPDK would work well because it is decentralized. The testing for 
each arch and target environment, Linux revision etc. is farmed out to 
jenkins or some other CI tool that only have to report the result via 
email which is in turn is summarized by patchwork.

Someone really needs to fix that web UI though...

Stephen

PS: Third party CI support (a lá OpenStack) would be an incredibly useful 
feature to offload some level of testing (like performance testing of the DPDK 
element of OVS). It's probably not an option with GerritHub (I haven't 
checked), but if you're deciding to go all in on Gerrit or not then this is one 
for the PROS column.
___
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 net-next 3/3] openvswitch: 802.1AD: Flow handling, actions, and vlan parsing

2015-07-26 Thread Thomas F Herbert



On 7/26/15 9:57 AM, ravulakollu.ku...@wipro.com wrote:

Hi Thomas,

I am currently using the beta version of ovs(2.3.90). In my phy-phy scenario  , 
I am configuring the two physical ports(eth0, eth1) attached to ovs bridge
as trunk ports using the below commands.

ovs-vsctl --no-wait add-port br0 eth0 vlan_mode=trunk
ovs-vsctl --no-wait add-port br0 eth1 vlan_mode=trunk

I configured the bridge to work in legacy mode as shown below

$ ovs-ofctl dump-flows br0
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=15.458s, table=0, n_packets=0, n_bytes=0, idle_age=15, 
priority=0 actions=NORMAL

I tried sending 802.1ad tagged(outer tag tpid=0x88a8, inter tag tpid=ox8100) 
packet from packetgen to phyport1 (eth0), and receiving back on phyport2(eth2).
When I captured the received packet on eth1 , the received packet is not same 
as sent packet, means outer vlan TPID is not 0x88a8(instead 0x8100).

This patch supports pushing and popping of double tagged vlans. It 
shouldn't affect double tagged traffic flowing through the switch unless 
your ovs bridge has flows to pop or push a vlan.


Are you using tcpdump to look at the packets? There is a bug in libpcap 
where the outer TPID of outgoing packets is miss-reported as 0x8100 
whether or not the tpid is actually 0x88a8



Could you please let me know , whether the below mentioned patch helps here.

Thanks in Advance,
Uday

-Original Message-
From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Thomas F Herbert
Sent: Sunday, July 26, 2015 6:03 AM
To: Pravin Shelar
Cc: dev@openvswitch.org; netdev; therb...@redhat.com
Subject: Re: [ovs-dev] [PATCH net-next 3/3] openvswitch: 802.1AD: Flow 
handling, actions, and vlan parsing

On 6/30/15 12:16 AM, Pravin Shelar wrote:

On Tue, Jun 23, 2015 at 11:26 AM, Thomas F Herbert

Pravin, I apologize because I realize now that I am finishing V12 of this patch 
that I never responded to your comments in this email.

thomasfherb...@gmail.com wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert thomasfherb...@gmail.com
---
   net/openvswitch/flow.c |  84 +++---
   net/openvswitch/flow.h |   5 ++
   net/openvswitch/flow_netlink.c | 195 
++---
   3 files changed, 242 insertions(+), 42 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c index
2dacc7b..e268865 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -298,21 +298,80 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
   static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
   {
  struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
  __be16 tci;
  };
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb-data;

-   if (unlikely(skb-len  sizeof(struct qtag_prefix) + sizeof(__be16)))
+   struct qinqtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+   __be16 inner_tpid; /* ETH_P_8021Q */
+   __be16 ctci;
+   };
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key-eth.tci = htons(skb-vlan_tci);
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb-vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb-len  sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key-eth.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16 {
+   return -ENOMEM;
+   }
+
+   if (likely(qp-eth_type == htons(ETH_P_8021Q))) {
+   key-eth.cvlan.ctci =
+   qp-tci | htons(VLAN_TAG_PRESENT);
+   key-eth.cvlan.c_tpid =
+ skb-vlan_proto;


We should directly copy qp-inner_tpid here. As you have done it for
non offloaded case below.

Thanks! It is copied but it is set to the wrong tpid. The c_tpid field in the 
key should be set to the ethertype in the packet itself which is the inner 
tpid, not the offloaded skb-vlan_proto which is the outer tpid. Fixed in V12.



+   __skb_pull(skb, sizeof(struct qtag_prefix

[ovs-dev] [PATCH net-next V12 0/3] openvswitch: Add support for 802.1AD

2015-07-26 Thread Thomas F Herbert
V12: Fix some problems and issues pointed out by reviewers. When parsing
netlink attributes Ether types other then 0x88a8 as outer tpid.

V11: Add inner tpid to flow key. Fix separate inner encap attribute
when parsing netlink attributes. Merge 2 patches to consolidate
qinq changes.

V10: Implement reviewer comments: Consolidate vlan parsing functions.
Splits netlink parsing and flow conversion into a separate patch. Uses
double encap attribute encapsulation for 802.1ad.  Netlink attributes
now look like this:

eth_type(0x88a8),vlan(vid=100),encap(eth_type(0x8100), vlan(vid=200),
encap(eth_type(0x0800), ...))

The double encap atributes in this version of the patch is incompatible with
old versions of the user level 802.1ad patch. A new user level patch which
is also being submitted simultaneously to openvswitch dev mailing list.

V9:  Includes changes suggested by reviewers

V8:  Includes changes suggested by reviewers

V7:  Includes changes suggested by reviewers

V6:  Rebased to net-next

V5:  Use encapsulated attributes

Although the Open Flow specification specified support for 802.1AD (qinq)
as well as push and pop vlan headers,  So far Open vSwitch has only
supported a single tag header.

This patch accompanies version 10 of the user level openvswitch patch
submitted to openvswitch dev list.
For discussion, history  and previous versions of the kernel module
patch and the user code patch see the OVS dev mailing list,
openvswitch.org/pipermail/dev/..


Thomas F Herbert (3):
  openvswitch: 802.1ad uapi changes.
  Check for vlan ethernet types for 8021.q or 802.1ad
  802.1AD: Flow handling, actions, vlan parsing and netlink attributes

 include/linux/if_vlan.h  |  17 
 include/uapi/linux/openvswitch.h |  17 ++--
 net/openvswitch/flow.c   |  84 ++---
 net/openvswitch/flow.h   |   5 +
 net/openvswitch/flow_netlink.c   | 196 +--
 5 files changed, 269 insertions(+), 50 deletions(-)

-- 
2.4.3

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


[ovs-dev] [PATCH net-next 3/3] openvswitch: 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-07-26 Thread Thomas F Herbert
Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes. Allows
either 0x8100 or 0x88a8 on inner or outer tags.

Signed-off-by: Thomas F Herbert thomasfherb...@gmail.com
---
 net/openvswitch/flow.c |  84 +++---
 net/openvswitch/flow.h |   5 ++
 net/openvswitch/flow_netlink.c | 196 ++---
 3 files changed, 243 insertions(+), 42 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 8db22ef..0abab37 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -298,21 +298,80 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
 static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
 {
struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
__be16 tci;
};
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb-data;
 
-   if (unlikely(skb-len  sizeof(struct qtag_prefix) + sizeof(__be16)))
+   struct qinqtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+   __be16 inner_tpid; /* ETH_P_8021Q */
+   __be16 ctci;
+   };
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key-eth.tci = htons(skb-vlan_tci);
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb-vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb-len  sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key-eth.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16 {
+   return -ENOMEM;
+   }
+
+   if (likely(qp-eth_type == htons(ETH_P_8021Q))) {
+   key-eth.cvlan.ctci =
+   qp-tci | htons(VLAN_TAG_PRESENT);
+   key-eth.cvlan.c_tpid = qp-eth_type;
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
+   }
return 0;
+   }
 
-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;
 
-   qp = (struct qtag_prefix *) skb-data;
-   key-eth.tci = qp-tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   if (qp-eth_type == htons(ETH_P_8021AD)) {
+   struct qinqtag_prefix *qinqp =
+   (struct qinqtag_prefix *)skb-data;
+
+   if (unlikely(skb-len  sizeof(struct qinqtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qinqtag_prefix) +
+   sizeof(__be16 {
+   return -ENOMEM;
+   }
+   key-eth.tci = qinqp-tci | htons(VLAN_TAG_PRESENT);
+   key-eth.cvlan.ctci = qinqp-ctci | htons(VLAN_TAG_PRESENT);
+   key-eth.cvlan.c_tpid = qinqp-inner_tpid;
+
+   __skb_pull(skb, sizeof(struct qinqtag_prefix));
+
+   return 0;
+   }
+   if (qp-eth_type == htons(ETH_P_8021Q)) {
+   if (unlikely(skb-len  sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return -ENOMEM;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return 0;
+   key-eth.tci = qp-tci | htons(VLAN_TAG_PRESENT);
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
 
return 0;
 }
@@ -474,9 +533,10 @@ static int key_extract(struct sk_buff *skb, struct 
sw_flow_key *key)
 */
 
key-eth.tci = 0;
-   if (skb_vlan_tag_present(skb))
-   key-eth.tci = htons(skb-vlan_tci);
-   else if (eth-h_proto == htons(ETH_P_8021Q))
+   key-eth.cvlan.ctci = 0;
+   key-eth.cvlan.c_tpid = 0;
+   if ((skb_vlan_tag_present(skb)) ||
+   eth_type_vlan(eth-h_proto))
if (unlikely(parse_vlan(skb, key)))
return -ENOMEM;
 
diff --git a/net/openvswitch

[ovs-dev] [PATCH net-next V12 1/3] openvswitch: 802.1ad uapi changes.

2015-07-26 Thread Thomas F Herbert
openvswitch: Add support for 802.1AD

Change the description of the VLAN tpid field.

Signed-off-by: Thomas F Herbert thomasfherb...@gmail.com
---
 include/uapi/linux/openvswitch.h | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index d6b8854..59141f8 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -563,13 +563,13 @@ struct ovs_action_push_mpls {
  * @vlan_tci: Tag control identifier (TCI) to push.  The CFI bit must be set
  * (but it will not be set in the 802.1Q header that is pushed).
  *
- * The @vlan_tpid value is typically %ETH_P_8021Q.  The only acceptable TPID
- * values are those that the kernel module also parses as 802.1Q headers, to
- * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN
- * from having surprising results.
+ * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
+ * The only acceptable TPID values are those that the kernel module also parses
+ * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
+ * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
  */
 struct ovs_action_push_vlan {
-   __be16 vlan_tpid;   /* 802.1Q TPID. */
+   __be16 vlan_tpid;   /* 802.1Q or 802.1ad TPID. */
__be16 vlan_tci;/* 802.1Q TCI (VLAN ID and priority). */
 };
 
@@ -609,9 +609,10 @@ struct ovs_action_hash {
  * is copied from the value to the packet header field, rest of the bits are
  * left unchanged.  The non-masked value bits must be passed in as zeroes.
  * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
- * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the
- * packet.
- * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet.
+ * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
+ * onto the packet.
+ * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
+ * from the packet.
  * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
  * the nested %OVS_SAMPLE_ATTR_* attributes.
  * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
-- 
2.4.3

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


[ovs-dev] [PATCH net-next V12 2/3] Check for vlan ethernet types for 8021.q or 802.1ad

2015-07-26 Thread Thomas F Herbert
Signed-off-by: Thomas F Herbert thomasfherb...@gmail.com
---
 include/linux/if_vlan.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 67ce5bd..88d1be4 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -627,6 +627,23 @@ static inline netdev_features_t vlan_features_check(const 
struct sk_buff *skb,
 
return features;
 }
+/**
+ * eth_type_vlan - check for valid vlan ether type.
+ * @ethertype: ether type to check
+ *
+ * Returns true if the ether type is a vlan ether type.
+ */
+static inline bool eth_type_vlan(__be16 ethertype)
+{
+   switch (ethertype) {
+   case (htons(ETH_P_8021Q)):
+   return true;
+   case (htons(ETH_P_8021AD)):
+   return true;
+   default:
+   return false;
+   }
+}
 
 /**
  * compare_vlan_header - Compare two vlan headers
-- 
2.4.3

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


Re: [ovs-dev] [PATCH net-next 3/3] openvswitch: 802.1AD: Flow handling, actions, and vlan parsing

2015-07-25 Thread Thomas F Herbert

On 6/30/15 12:16 AM, Pravin Shelar wrote:

On Tue, Jun 23, 2015 at 11:26 AM, Thomas F Herbert
Pravin, I apologize because I realize now that I am finishing V12 of 
this patch that I never responded to your comments in this email.

thomasfherb...@gmail.com wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert thomasfherb...@gmail.com
---
  net/openvswitch/flow.c |  84 +++---
  net/openvswitch/flow.h |   5 ++
  net/openvswitch/flow_netlink.c | 195 ++---
  3 files changed, 242 insertions(+), 42 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 2dacc7b..e268865 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -298,21 +298,80 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
  {
 struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
 __be16 tci;
 };
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb-data;

-   if (unlikely(skb-len  sizeof(struct qtag_prefix) + sizeof(__be16)))
+   struct qinqtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+   __be16 inner_tpid; /* ETH_P_8021Q */
+   __be16 ctci;
+   };
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key-eth.tci = htons(skb-vlan_tci);
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb-vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb-len  sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key-eth.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16 {
+   return -ENOMEM;
+   }
+
+   if (likely(qp-eth_type == htons(ETH_P_8021Q))) {
+   key-eth.cvlan.ctci =
+   qp-tci | htons(VLAN_TAG_PRESENT);
+   key-eth.cvlan.c_tpid = skb-vlan_proto;


We should directly copy qp-inner_tpid here. As you have done it for
non offloaded case below.
Thanks! It is copied but it is set to the wrong tpid. The c_tpid field 
in the key should be set to the ethertype in the packet itself which is 
the inner tpid, not the offloaded skb-vlan_proto which is the outer 
tpid. Fixed in V12.



+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
+   }
 return 0;
+   }

-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;

-   qp = (struct qtag_prefix *) skb-data;
-   key-eth.tci = qp-tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   if (qp-eth_type == htons(ETH_P_8021AD)) {
+   struct qinqtag_prefix *qinqp =
+   (struct qinqtag_prefix *)skb-data;
+
+   if (unlikely(skb-len  sizeof(struct qinqtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qinqtag_prefix) +
+   sizeof(__be16 {
+   return -ENOMEM;
+   }
+   key-eth.tci = qinqp-tci | htons(VLAN_TAG_PRESENT);
+   key-eth.cvlan.ctci = qinqp-ctci | htons(VLAN_TAG_PRESENT);
+   key-eth.cvlan.c_tpid = qinqp-inner_tpid;
+
+   __skb_pull(skb, sizeof(struct qinqtag_prefix));
+
+   return 0;
+   }
+   if (qp-eth_type == htons(ETH_P_8021Q)) {
+   if (unlikely(skb-len  sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return -ENOMEM;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return 0;
+   key-eth.tci = qp-tci | htons(VLAN_TAG_PRESENT);
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }

 return 0

Re: [ovs-dev] [PATCH 0/5 V6] Add 802.1ad (qinq) support

2015-07-13 Thread Thomas F Herbert

On 7/13/15 8:05 AM, ravulakollu.ku...@wipro.com wrote:

Hi All,

I am trying to configure vlan stacking (802.1ad) to few ovs bridge ports, in 
Normal mode bridge operation. I am using ovs-master code
Version 2.3.9 for my experiments.
I am seeing no support for stacked vlans both from the configuration interface 
perspective and datapath as well.

I am trying to come up with the design and implementation of configuration 
interface support for 802.1ad  (ovs-vsctl) and also datapath support.
Currently as I understand ovs-vsctl vlan configuration has the following modes 
defined in ovsdb: access, native−tagged, native−untagged, and trunk.

I have the following configuration in my mind for 1ad support.
 1.Access port : 
Adds C-VLAN ,does 802.1q tagging as usual, Ex: tag =10)
 3.Trunk port without qinq support   : On ingress by default 
receives all vlan tagged traffic(single) , sends the same out of egress. 
(double tagged traffic currently misbehaving)
 4.Trunk port with qinq support  : On ingress adds a 
specific S-VLAN for a specific customer. On egress pops S-VLAN.

As I understand access port doesn’t require qinq support , so supporting the 
same for trunk ports only

It would be really helpful , if you could let me know your suggestions and 
comments towards my approach. Also let me know how the ovs community is 
approaching towards
802.1ad, So that it will be in sync with ovs community thoughts.
Version 11 of the 802.1ad patch was submitted about 1 week ago. I am 
currently working on version 12 which incorporates some comments from 
reviewers.


Also I am seeing multiple patches for 1ad support in datapath, though few not 
working for me. Please, let me know if any working patch is available that 
would greatly save my
time in this experiment.
Please send information about what version of the patch you tried and 
with information about the failure case.


Thanks in Advance,
Uday
The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments. WARNING: Computer viruses can be transmitted via email. The 
recipient should check this email and any attachments for the presence of 
viruses. The company accepts no liability for any damage caused by any virus 
transmitted by this email. www.wipro.com
___
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 V11 1/4] Flow and action changes for 802.1AD

2015-06-29 Thread Thomas F Herbert



On 6/29/15 4:38 PM, Jarno Rajahalme wrote:



On Jun 23, 2015, at 11:38 AM, Thomas F Herbert thomasfherb...@gmail.com wrote:

From: Thomas F. Herbert thomasfherb...@gmail.com

The flow structure is updated to hold the customer tci.
Flow key extraction is changed to add support for ctci and both TPIDs.
Parsing to support pushing and popping with both single and double
tagged vlans. In response to reviewers comments on V6, all changes
affected by the flow structure are gathered in this patch.

Signed-off-by: Thomas F Herbert thomasfherb...@gmail.com
---
lib/flow.c   | 14 +++---
lib/flow.h   | 16 +++-
lib/match.c  |  2 +-
lib/nx-match.c   |  2 +-
lib/ofp-actions.c| 32 +++-
lib/ofp-actions.h| 14 +++---
lib/ofp-util.c   |  2 +-
ofproto/ofproto-dpif-rid.h   |  2 +-
ofproto/ofproto-dpif-xlate.c | 13 -
9 files changed, 64 insertions(+), 33 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index 3e99d5e..3bfcb26 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -123,7 +123,7 @@ struct mf_ctx {
  * away.  Some GCC versions gave warnings on ALWAYS_INLINE, so these are
  * defined as macros. */

-#if (FLOW_WC_SEQ != 31)
+#if (FLOW_WC_SEQ != 32)
#define MINIFLOW_ASSERT(X) ovs_assert(X)
BUILD_MESSAGE(FLOW_WC_SEQ changed: miniflow_extract() will have runtime 
assertions enabled. Consider updating FLOW_WC_SEQ after 
@@ -291,7 +291,7 @@ parse_vlan(const void **datap, size_t *sizep)

 data_pull(datap, sizep, ETH_ADDR_LEN * 2);

-if (eth-eth_type == htons(ETH_TYPE_VLAN)) {
+if (eth_type_vlan(eth-eth_type)) {
 if (OVS_LIKELY(*sizep
= sizeof(struct qtag_prefix) + sizeof(ovs_be16))) {
 const struct qtag_prefix *qp = data_pull(datap, sizep, sizeof *qp);


Maybe I am missing something, but I am surprised that the new struct flow 
fields are not populated in miniflow_extract() following the call to 
parse_vlan(). Or is the customer TCI not present in the packet?

   Jarno

Hi Jarno,

Thanks for looking at this and I don't think you are missing anything. I 
agree that miniflow_extract should have been changed to populate ctci 
and tpid fields. I will add the code to do it in version 12.


--Tom




@@ -766,7 +766,7 @@ flow_get_metadata(const struct flow *flow, struct match 
*flow_metadata)
{
 int i;

-BUILD_ASSERT_DECL(FLOW_WC_SEQ == 31);
+BUILD_ASSERT_DECL(FLOW_WC_SEQ == 32);

 match_init_catchall(flow_metadata);
 if (flow-tunnel.tun_id != htonll(0)) {
@@ -942,7 +942,7 @@ void flow_wildcards_init_for_packet(struct flow_wildcards 
*wc,
 memset(wc-masks, 0x0, sizeof wc-masks);

 /* Update this function whenever struct flow changes. */
-BUILD_ASSERT_DECL(FLOW_WC_SEQ == 31);
+BUILD_ASSERT_DECL(FLOW_WC_SEQ == 32);

 if (flow-tunnel.ip_dst) {
 if (flow-tunnel.flags  FLOW_TNL_F_KEY) {
@@ -1041,7 +1041,7 @@ uint64_t
flow_wc_map(const struct flow *flow)
{
 /* Update this function whenever struct flow changes. */
-BUILD_ASSERT_DECL(FLOW_WC_SEQ == 31);
+BUILD_ASSERT_DECL(FLOW_WC_SEQ == 32);

 uint64_t map = (flow-tunnel.ip_dst) ? MINIFLOW_MAP(tunnel) : 0;

@@ -1093,7 +1093,7 @@ void
flow_wildcards_clear_non_packet_fields(struct flow_wildcards *wc)
{
 /* Update this function whenever struct flow changes. */
-BUILD_ASSERT_DECL(FLOW_WC_SEQ == 31);
+BUILD_ASSERT_DECL(FLOW_WC_SEQ == 32);

 memset(wc-masks.metadata, 0, sizeof wc-masks.metadata);
 memset(wc-masks.regs, 0, sizeof wc-masks.regs);
@@ -1648,7 +1648,7 @@ flow_push_mpls(struct flow *flow, int n, ovs_be16 
mpls_eth_type,
 flow-mpls_lse[0] = set_mpls_lse_values(ttl, tc, 1, htonl(label));

 /* Clear all L3 and L4 fields and dp_hash. */
-BUILD_ASSERT(FLOW_WC_SEQ == 31);
+BUILD_ASSERT(FLOW_WC_SEQ == 32);
 memset((char *) flow + FLOW_SEGMENT_2_ENDS_AT, 0,
sizeof(struct flow) - FLOW_SEGMENT_2_ENDS_AT);
 flow-dp_hash = 0;
diff --git a/lib/flow.h b/lib/flow.h
index 70554e4..9d34775 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -39,7 +39,7 @@ struct match;
/* This sequence number should be incremented whenever anything involving flows
  * or the wildcarding of flows changes.  This will cause build assertion
  * failures in places which likely need to be updated. */
-#define FLOW_WC_SEQ 31
+#define FLOW_WC_SEQ 32

/* Number of Open vSwitch extension 32-bit registers. */
#define FLOW_N_REGS 8
@@ -114,7 +114,13 @@ struct flow {
 uint8_t dl_dst[ETH_ADDR_LEN]; /* Ethernet destination address. */
 uint8_t dl_src[ETH_ADDR_LEN]; /* Ethernet source address. */
 ovs_be16 dl_type;   /* Ethernet frame type. */
-ovs_be16 vlan_tci;  /* If 802.1Q, TCI | VLAN_CFI; otherwise 0. */
+ovs_be16 vlan_tci;  /* If 802.1Q, TCI | VLAN_CFI; If 802.1ad,
+ * outer tag

  1   2   >