All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next V10 0/4] openvswitch: Add support for 802.1AD
@ 2015-06-02 17:50 Thomas F Herbert
       [not found] ` <1433267444-26025-1-git-send-email-thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Thomas F Herbert @ 2015-06-02 17:50 UTC (permalink / raw)
  To: netdev, pshelar; +Cc: therbert, dev, Thomas F Herbert

Add support for 802.1AD to the openvswitch kernel module.

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 (4):
  openvswitch: 802.1ad uapi changes.
  Check for vlan ethernet types for 8021.q or 802.1ad
  8021AD: Flow handling actions and parsing
  8021AD: Flow key parsing and netlink attributes.

 include/linux/if_vlan.h          |   9 ++
 include/uapi/linux/openvswitch.h |  17 ++--
 net/openvswitch/flow.c           |  82 ++++++++++++++---
 net/openvswitch/flow.h           |   3 +
 net/openvswitch/flow_netlink.c   | 186 +++++++++++++++++++++++++++++++++------
 5 files changed, 248 insertions(+), 49 deletions(-)

-- 
2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH net-next V10 1/4] openvswitch: 802.1ad uapi changes.
       [not found] ` <1433267444-26025-1-git-send-email-thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-06-02 17:50   ` Thomas F Herbert
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas F Herbert @ 2015-06-02 17:50 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA, pshelar-l0M0P4e3n4LQT0dZR+AlfA
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, therbert-H+wXaHxf7aLQT0dZR+AlfA

openvswitch: Add support for 8021.AD

Change the description of the VLAN tpid field.

Signed-off-by: Thomas F Herbert <thomasfherbert@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 bbd49a0..f2ccdef 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -559,13 +559,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). */
 };
 
@@ -605,9 +605,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.1.0

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next V10 2/4] General check for vlan ethernet types
  2015-06-02 17:50 [PATCH net-next V10 0/4] openvswitch: Add support for 802.1AD Thomas F Herbert
       [not found] ` <1433267444-26025-1-git-send-email-thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-06-02 17:50 ` Thomas F Herbert
  2015-06-02 17:50 ` [PATCH net-next V10 3/4] 802.1AD: Flow handling, actions and vlan parsing Thomas F Herbert
  2015-06-02 17:50 ` [PATCH net-next V10 4/4] 8021AD: Flow key parsing and netlink attributes Thomas F Herbert
  3 siblings, 0 replies; 11+ messages in thread
From: Thomas F Herbert @ 2015-06-02 17:50 UTC (permalink / raw)
  To: netdev, pshelar; +Cc: therbert, dev, Thomas F Herbert

This patch adds a function to check for vlan ethernet types. There is a
use case in openvswitch and it should be useful elsewhere.

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

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 920e445..3713454 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -627,5 +627,14 @@ static inline netdev_features_t vlan_features_check(const struct sk_buff *skb,
 
 	return features;
 }
+/**
+ * Check for legal valid vlan ether type.
+ */
+static inline bool eth_type_vlan(__be16 ethertype)
+{
+	if (ethertype == htons(ETH_P_8021Q) || ethertype == htons(ETH_P_8021AD))
+		return true;
+	return false;
+}
 
 #endif /* !(_LINUX_IF_VLAN_H_) */
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next V10 3/4] 802.1AD: Flow handling, actions and vlan parsing
  2015-06-02 17:50 [PATCH net-next V10 0/4] openvswitch: Add support for 802.1AD Thomas F Herbert
       [not found] ` <1433267444-26025-1-git-send-email-thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2015-06-02 17:50 ` [PATCH net-next V10 2/4] General check for vlan ethernet types Thomas F Herbert
@ 2015-06-02 17:50 ` Thomas F Herbert
  2015-06-04 17:45   ` Pravin Shelar
  2015-06-02 17:50 ` [PATCH net-next V10 4/4] 8021AD: Flow key parsing and netlink attributes Thomas F Herbert
  3 siblings, 1 reply; 11+ messages in thread
From: Thomas F Herbert @ 2015-06-02 17:50 UTC (permalink / raw)
  To: netdev, pshelar; +Cc: therbert, dev, Thomas F Herbert

Add support for 802.1ad including the ability to push and pop double
tagged vlans.

Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
---
 net/openvswitch/flow.c | 82 ++++++++++++++++++++++++++++++++++++++++++--------
 net/openvswitch/flow.h |  3 ++
 2 files changed, 73 insertions(+), 12 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 2dacc7b..9c73a2e 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -298,21 +298,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.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.ctci = qp->tci |
+						htons(VLAN_TAG_PRESENT);
+				__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.ctci = qinqp->ctci | htons(VLAN_TAG_PRESENT);
+
+		__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 +531,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.ctci = 0;
+	if ((skb_vlan_tag_present(skb)) ||
+	    (eth->h_proto == htons(ETH_P_8021Q)) ||
+	    (eth->h_proto == htons(ETH_P_8021AD)))
 		if (unlikely(parse_vlan(skb, key)))
 			return -ENOMEM;
 
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
index a076e44..fa83c61 100644
--- a/net/openvswitch/flow.h
+++ b/net/openvswitch/flow.h
@@ -134,6 +134,9 @@ struct sw_flow_key {
 		u8     src[ETH_ALEN];	/* Ethernet source address. */
 		u8     dst[ETH_ALEN];	/* Ethernet destination address. */
 		__be16 tci;		/* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */
+		__be16 ctci;		/* 0 if no CVLAN, VLAN_TAG_PRESENT set
+					 * otherwise.
+					 */
 		__be16 type;		/* Ethernet frame type. */
 	} eth;
 	union {
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next V10 4/4] 8021AD: Flow key parsing and netlink attributes.
  2015-06-02 17:50 [PATCH net-next V10 0/4] openvswitch: Add support for 802.1AD Thomas F Herbert
                   ` (2 preceding siblings ...)
  2015-06-02 17:50 ` [PATCH net-next V10 3/4] 802.1AD: Flow handling, actions and vlan parsing Thomas F Herbert
@ 2015-06-02 17:50 ` Thomas F Herbert
  2015-06-09  3:45   ` Pravin Shelar
  3 siblings, 1 reply; 11+ messages in thread
From: Thomas F Herbert @ 2015-06-02 17:50 UTC (permalink / raw)
  To: netdev, pshelar; +Cc: therbert, dev, Thomas F Herbert

Add support for 802.1ad to netlink parsing and flow conversation. Uses
double nested encap attributes to represent double tagged vlan.

Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
---
 net/openvswitch/flow_netlink.c | 186 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 157 insertions(+), 29 deletions(-)

diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index c691b1a..8fd4f63 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -771,6 +771,28 @@ static int metadata_from_nlattrs(struct sw_flow_match *match,  u64 *attrs,
 	return 0;
 }
 
+static int cust_vlan_from_nlattrs(struct sw_flow_match *match, u64 attrs,
+				  const struct nlattr **a, bool is_mask,
+				  bool log)
+{
+	/* This should be nested inner or "customer" tci" */
+	if (attrs & (1 << OVS_KEY_ATTR_VLAN)) {
+		__be16 ctci;
+
+		ctci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
+		if (!(ctci & htons(VLAN_TAG_PRESENT))) {
+			if (is_mask)
+				OVS_NLERR(log, "VLAN CTCI mask does not have exact match for VLAN_TAG_PRESENT bit.");
+			else
+				OVS_NLERR(log, "VLAN CTCI does not have VLAN_TAG_PRESENT bit set.");
+
+			return -EINVAL;
+		}
+		SW_FLOW_KEY_PUT(match, eth.ctci, ctci, is_mask);
+	}
+	return 0;
+}
+
 static int ovs_key_from_nlattrs(struct sw_flow_match *match, u64 attrs,
 				const struct nlattr **a, bool is_mask,
 				bool log)
@@ -1024,6 +1046,105 @@ static void mask_set_nlattr(struct nlattr *attr, u8 val)
 	nlattr_set(attr, val, ovs_key_lens);
 }
 
+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;
+	__be16 tci;
+	const struct nlattr *encap;
+
+	if (!is_mask) {
+		u64 v_attrs = 0;
+
+		tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
+
+		if (tci & htons(VLAN_TAG_PRESENT)) {
+			if (unlikely((nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]) ==
+				      htons(ETH_P_8021AD)))) {
+				err = parse_flow_nlattrs(nla, a, &v_attrs, log);
+				if (err)
+					return err;
+				if (!v_attrs)
+					return -EINVAL;
+
+				if (!((v_attrs &
+				       (1ULL << OVS_KEY_ATTR_VLAN)) &&
+				      (v_attrs &
+				       (1ULL << OVS_KEY_ATTR_ENCAP)))) {
+					OVS_NLERR(log, "Invalid Vlan frame.");
+					return -EINVAL;
+				}
+				v_attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE);
+				encap = a[OVS_KEY_ATTR_ENCAP];
+				v_attrs &= ~(1 << OVS_KEY_ATTR_ENCAP);
+				*ie_valid = true;
+
+				err = cust_vlan_from_nlattrs(match, v_attrs,
+							     &encap, is_mask,
+							     log);
+				if (err)
+					return err;
+				/* Insure that tci key attribute isn't
+				 * overwritten by encapsulated customer tci.
+				 */
+				v_attrs &= ~(1 << OVS_KEY_ATTR_VLAN);
+				*key_attrs |= v_attrs;
+			} else {
+				*key_attrs &= ~(1 << OVS_KEY_ATTR_VLAN);
+				err = parse_flow_nlattrs(nla, a, key_attrs,
+							 log);
+				if (err)
+					return err;
+			}
+		} else if (!tci) {
+			/* Corner case for truncated 802.1Q header. */
+			if (nla_len(nla)) {
+				OVS_NLERR(log, "Truncated 802.1Q header has non-zero encap attribute.");
+				return -EINVAL;
+			}
+		} else {
+			OVS_NLERR(log, "Encap attr is set for non-VLAN frame");
+			return  -EINVAL;
+		}
+
+	} else {
+		u64 mask_v_attrs = 0;
+
+		tci = 0;
+		if (a[OVS_KEY_ATTR_VLAN])
+			tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
+
+		if (!(tci & htons(VLAN_TAG_PRESENT))) {
+			OVS_NLERR(log, "VLAN tag present bit must have an exact match (tci_mask=%x).",
+				  ntohs(tci));
+			err = -EINVAL;
+			return err;
+		}
+		err = parse_flow_mask_nlattrs(nla, a, &mask_v_attrs,
+					      log);
+		if (err)
+			return err;
+
+		if (mask_v_attrs & (1ULL << OVS_KEY_ATTR_VLAN)) {
+			err = cust_vlan_from_nlattrs(match, mask_v_attrs,
+						     a, is_mask, log);
+			if (err)
+				return err;
+
+			mask_v_attrs &= ~(1ULL << OVS_KEY_ATTR_VLAN);
+			*key_attrs |= mask_v_attrs;
+	       } else {
+			*key_attrs &= ~(1 << OVS_KEY_ATTR_VLAN);
+			if (err)
+				return err;
+		}
+	}
+	return 0;
+}
+
 /**
  * ovs_nla_get_match - parses Netlink attributes into a flow key and
  * mask. In case the 'mask' is NULL, the flow is treated as exact match
@@ -1050,6 +1171,7 @@ int ovs_nla_get_match(struct sw_flow_match *match,
 	u64 key_attrs = 0;
 	u64 mask_attrs = 0;
 	bool encap_valid = false;
+	bool i_encap_valid = false;
 	int err;
 
 	err = parse_flow_nlattrs(nla_key, a, &key_attrs, log);
@@ -1058,35 +1180,24 @@ int ovs_nla_get_match(struct sw_flow_match *match,
 
 	if ((key_attrs & (1 << OVS_KEY_ATTR_ETHERNET)) &&
 	    (key_attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) &&
-	    (nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]) == htons(ETH_P_8021Q))) {
-		__be16 tci;
+	    eth_type_vlan(nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]))) {
 
-		if (!((key_attrs & (1 << OVS_KEY_ATTR_VLAN)) &&
-		      (key_attrs & (1 << OVS_KEY_ATTR_ENCAP)))) {
+		if (!((key_attrs & (1ULL << OVS_KEY_ATTR_VLAN)) &&
+		      (key_attrs & (1ULL << OVS_KEY_ATTR_ENCAP)))) {
 			OVS_NLERR(log, "Invalid Vlan frame.");
 			return -EINVAL;
 		}
 
 		key_attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE);
-		tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
 		encap = a[OVS_KEY_ATTR_ENCAP];
 		key_attrs &= ~(1 << OVS_KEY_ATTR_ENCAP);
 		encap_valid = true;
 
-		if (tci & htons(VLAN_TAG_PRESENT)) {
-			err = parse_flow_nlattrs(encap, a, &key_attrs, log);
-			if (err)
-				return err;
-		} else if (!tci) {
-			/* Corner case for truncated 802.1Q header. */
-			if (nla_len(encap)) {
-				OVS_NLERR(log, "Truncated 802.1Q header has non-zero encap attribute.");
-				return -EINVAL;
-			}
-		} else {
-			OVS_NLERR(log, "Encap attr is set for non-VLAN frame");
-			return  -EINVAL;
-		}
+		err = parse_vlan_from_nlattrs(encap, match, &key_attrs,
+					      &i_encap_valid, a, false, log);
+		if (err)
+			return err;
+
 	}
 
 	err = ovs_key_from_nlattrs(match, key_attrs, a, false, log);
@@ -1132,7 +1243,6 @@ int ovs_nla_get_match(struct sw_flow_match *match,
 
 		if (mask_attrs & 1 << OVS_KEY_ATTR_ENCAP) {
 			__be16 eth_type = 0;
-			__be16 tci = 0;
 
 			if (!encap_valid) {
 				OVS_NLERR(log, "Encap mask attribute is set for non-VLAN frame.");
@@ -1158,15 +1268,13 @@ int ovs_nla_get_match(struct sw_flow_match *match,
 				goto free_newmask;
 			}
 
-			if (a[OVS_KEY_ATTR_VLAN])
-				tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
-
-			if (!(tci & htons(VLAN_TAG_PRESENT))) {
-				OVS_NLERR(log, "VLAN tag present bit must have an exact match (tci_mask=%x).",
-					  ntohs(tci));
-				err = -EINVAL;
+			err = parse_vlan_from_nlattrs(encap, match,
+						      &mask_attrs,
+						      &i_encap_valid, a, true,
+						      log);
+			if (err)
 				goto free_newmask;
-			}
+
 		}
 
 		err = ovs_key_from_nlattrs(match, mask_attrs, a, true, log);
@@ -1331,6 +1439,25 @@ static int __ovs_nla_put_key(const struct sw_flow_key *swkey,
 		encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
 		if (!swkey->eth.tci)
 			goto unencap;
+	} else if (swkey->eth.ctci || swkey->eth.type == htons(ETH_P_8021AD)) {
+		__be16 eth_type;
+
+		eth_type = !is_mask ? htons(ETH_P_8021AD) : htons(0xffff);
+		if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type) ||
+		    nla_put_be16(skb, OVS_KEY_ATTR_VLAN, output->eth.tci))
+			goto nla_put_failure;
+		encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
+		if (!swkey->eth.tci)
+			goto unencap;
+		/* Customer tci is nested but uses same key attribute.
+		 */
+		eth_type = !is_mask ? htons(ETH_P_8021Q) : htons(0xffff);
+		if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type) ||
+		    nla_put_be16(skb, OVS_KEY_ATTR_VLAN, output->eth.ctci))
+			goto nla_put_failure;
+		encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
+		if (!swkey->eth.ctci)
+			goto unencap;
 	} else
 		encap = NULL;
 
@@ -2078,7 +2205,8 @@ static int __ovs_nla_copy_actions(const struct nlattr *attr,
 
 		case OVS_ACTION_ATTR_PUSH_VLAN:
 			vlan = nla_data(a);
-			if (vlan->vlan_tpid != htons(ETH_P_8021Q))
+			if ((vlan->vlan_tpid != htons(ETH_P_8021Q)) &&
+			    (vlan->vlan_tpid != htons(ETH_P_8021AD)))
 				return -EINVAL;
 			if (!(vlan->vlan_tci & htons(VLAN_TAG_PRESENT)))
 				return -EINVAL;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next V10 3/4] 802.1AD: Flow handling, actions and vlan parsing
  2015-06-02 17:50 ` [PATCH net-next V10 3/4] 802.1AD: Flow handling, actions and vlan parsing Thomas F Herbert
@ 2015-06-04 17:45   ` Pravin Shelar
       [not found]     ` <CALnjE+p8tuUFoXOFvfrp154rb80o_8XhtJ+Z8RrL1Y67kw12jw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Pravin Shelar @ 2015-06-04 17:45 UTC (permalink / raw)
  To: Thomas F Herbert; +Cc: netdev, therbert, dev

On Tue, Jun 2, 2015 at 10:50 AM, Thomas F Herbert
<thomasfherbert@gmail.com> wrote:
> Add support for 802.1ad including the ability to push and pop double
> tagged vlans.
>
> Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
> ---
>  net/openvswitch/flow.c | 82 ++++++++++++++++++++++++++++++++++++++++++--------
>  net/openvswitch/flow.h |  3 ++
>  2 files changed, 73 insertions(+), 12 deletions(-)
>
> diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
> index 2dacc7b..9c73a2e 100644
> --- a/net/openvswitch/flow.c
> +++ b/net/openvswitch/flow.c
> @@ -298,21 +298,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;
> +       };
> +
...

>
> diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
> index a076e44..fa83c61 100644
> --- a/net/openvswitch/flow.h
> +++ b/net/openvswitch/flow.h
> @@ -134,6 +134,9 @@ struct sw_flow_key {
>                 u8     src[ETH_ALEN];   /* Ethernet source address. */
>                 u8     dst[ETH_ALEN];   /* Ethernet destination address. */
>                 __be16 tci;             /* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */
> +               __be16 ctci;            /* 0 if no CVLAN, VLAN_TAG_PRESENT set
> +                                        * otherwise.
> +                                        */
>                 __be16 type;            /* Ethernet frame type. */
>         } eth;
>         union {
> --
> 2.1.0
>
Currently you have restricted the datapath implementation to support
only 8021AD. We can extend this to support double tagging by adding
inner_tpid field to struct sw_flow_key. OVS netlink interface already
allows this type of configuration. So is there reason not to do it in
this series?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next V10 3/4] 802.1AD: Flow handling, actions and vlan parsing
       [not found]     ` <CALnjE+p8tuUFoXOFvfrp154rb80o_8XhtJ+Z8RrL1Y67kw12jw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-06-04 18:18       ` Thomas F Herbert
  2015-06-04 20:39         ` Pravin Shelar
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas F Herbert @ 2015-06-04 18:18 UTC (permalink / raw)
  To: Pravin Shelar
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev, therbert-H+wXaHxf7aLQT0dZR+AlfA

On 6/4/15 1:45 PM, Pravin Shelar wrote:
> On Tue, Jun 2, 2015 at 10:50 AM, Thomas F Herbert
> <thomasfherbert@gmail.com> wrote:
>> Add support for 802.1ad including the ability to push and pop double
>> tagged vlans.
>>
>> Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
>> ---
>>   net/openvswitch/flow.c | 82 ++++++++++++++++++++++++++++++++++++++++++--------
>>   net/openvswitch/flow.h |  3 ++
>>   2 files changed, 73 insertions(+), 12 deletions(-)
>>
>> diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
>> index 2dacc7b..9c73a2e 100644
>> --- a/net/openvswitch/flow.c
>> +++ b/net/openvswitch/flow.c
>> @@ -298,21 +298,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;
>> +       };
>> +
> ...
>
>>
>> diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
>> index a076e44..fa83c61 100644
>> --- a/net/openvswitch/flow.h
>> +++ b/net/openvswitch/flow.h
>> @@ -134,6 +134,9 @@ struct sw_flow_key {
>>                  u8     src[ETH_ALEN];   /* Ethernet source address. */
>>                  u8     dst[ETH_ALEN];   /* Ethernet destination address. */
>>                  __be16 tci;             /* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */
>> +               __be16 ctci;            /* 0 if no CVLAN, VLAN_TAG_PRESENT set
>> +                                        * otherwise.
>> +                                        */
>>                  __be16 type;            /* Ethernet frame type. */
>>          } eth;
>>          union {
>> --
>> 2.1.0
>>
> Currently you have restricted the datapath implementation to support
> only 8021AD. We can extend this to support double tagging by adding
> inner_tpid field to struct sw_flow_key. OVS netlink interface already
> allows this type of configuration. So is there reason not to do it in
> this series?
Pravin, thanks for the review.

In the original implementation, I thought I would make only the 
minimally necessary changes and I have been carrying that forward 
through each revision.

If only one tag, tci is present that implies tpid of 0x8100, if two tags 
are present, both tci and ctci, that implies a tpid of 0x88a8 and this 
is in fact how the code works and is how it supports both 802.1q and 
802.1ad. The tpid's are not strictly necessary in the flow key for both 
802.1q and 802.1ad to work. OF doesn't support the ability to push and 
pop vlans with non valid tpid's so there's no ambiguity.

Contrarily and despite my comment above, although not strictly 
necessary, I don't have any objection to adding the tpid and to the flow 
key and I can make it work either way.

--TFH
>


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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next V10 3/4] 802.1AD: Flow handling, actions and vlan parsing
  2015-06-04 18:18       ` Thomas F Herbert
@ 2015-06-04 20:39         ` Pravin Shelar
  2015-06-04 22:00           ` Thomas F Herbert
  0 siblings, 1 reply; 11+ messages in thread
From: Pravin Shelar @ 2015-06-04 20:39 UTC (permalink / raw)
  To: Thomas F Herbert; +Cc: netdev, therbert, dev

On Thu, Jun 4, 2015 at 11:18 AM, Thomas F Herbert
<thomasfherbert@gmail.com> wrote:
> On 6/4/15 1:45 PM, Pravin Shelar wrote:
>>
>> On Tue, Jun 2, 2015 at 10:50 AM, Thomas F Herbert
>> <thomasfherbert@gmail.com> wrote:
>>>
>>> Add support for 802.1ad including the ability to push and pop double
>>> tagged vlans.
>>>
>>> Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
>>> ---
>>>   net/openvswitch/flow.c | 82
>>> ++++++++++++++++++++++++++++++++++++++++++--------
>>>   net/openvswitch/flow.h |  3 ++
>>>   2 files changed, 73 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
>>> index 2dacc7b..9c73a2e 100644
>>> --- a/net/openvswitch/flow.c
>>> +++ b/net/openvswitch/flow.c
>>> @@ -298,21 +298,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;
>>> +       };
>>> +
>>
>> ...
>>
>>>
>>> diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
>>> index a076e44..fa83c61 100644
>>> --- a/net/openvswitch/flow.h
>>> +++ b/net/openvswitch/flow.h
>>> @@ -134,6 +134,9 @@ struct sw_flow_key {
>>>                  u8     src[ETH_ALEN];   /* Ethernet source address. */
>>>                  u8     dst[ETH_ALEN];   /* Ethernet destination address.
>>> */
>>>                  __be16 tci;             /* 0 if no VLAN,
>>> VLAN_TAG_PRESENT set otherwise. */
>>> +               __be16 ctci;            /* 0 if no CVLAN,
>>> VLAN_TAG_PRESENT set
>>> +                                        * otherwise.
>>> +                                        */
>>>                  __be16 type;            /* Ethernet frame type. */
>>>          } eth;
>>>          union {
>>> --
>>> 2.1.0
>>>
>> Currently you have restricted the datapath implementation to support
>> only 8021AD. We can extend this to support double tagging by adding
>> inner_tpid field to struct sw_flow_key. OVS netlink interface already
>> allows this type of configuration. So is there reason not to do it in
>> this series?
>
> Pravin, thanks for the review.
>
> In the original implementation, I thought I would make only the minimally
> necessary changes and I have been carrying that forward through each
> revision.
>
> If only one tag, tci is present that implies tpid of 0x8100, if two tags are
> present, both tci and ctci, that implies a tpid of 0x88a8 and this is in
> fact how the code works and is how it supports both 802.1q and 802.1ad. The
> tpid's are not strictly necessary in the flow key for both 802.1q and
> 802.1ad to work. OF doesn't support the ability to push and pop vlans with
> non valid tpid's so there's no ambiguity.
>
> Contrarily and despite my comment above, although not strictly necessary, I
> don't have any objection to adding the tpid and to the flow key and I can
> make it work either way.
>
inner_tpid is must here. We need to pass this information up to the
userspace when we serialize the flow-key. Otherwise we would loose
this information.
I think we can add another struct to represent inner-vlan which keep
track of the tci and tpid.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next V10 3/4] 802.1AD: Flow handling, actions and vlan parsing
  2015-06-04 20:39         ` Pravin Shelar
@ 2015-06-04 22:00           ` Thomas F Herbert
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas F Herbert @ 2015-06-04 22:00 UTC (permalink / raw)
  To: Pravin Shelar; +Cc: netdev, therbert, dev

On 6/4/15 4:39 PM, Pravin Shelar wrote:
> On Thu, Jun 4, 2015 at 11:18 AM, Thomas F Herbert
> <thomasfherbert@gmail.com> wrote:
>> On 6/4/15 1:45 PM, Pravin Shelar wrote:
>>>
>>> On Tue, Jun 2, 2015 at 10:50 AM, Thomas F Herbert
>>> <thomasfherbert@gmail.com> wrote:
>>>>
>>>> Add support for 802.1ad including the ability to push and pop double
>>>> tagged vlans.
>>>>
>>>> Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
>>>> ---
>>>>    net/openvswitch/flow.c | 82
>>>> ++++++++++++++++++++++++++++++++++++++++++--------
>>>>    net/openvswitch/flow.h |  3 ++
>>>>    2 files changed, 73 insertions(+), 12 deletions(-)
>>>>
>>>> diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
>>>> index 2dacc7b..9c73a2e 100644
>>>> --- a/net/openvswitch/flow.c
>>>> +++ b/net/openvswitch/flow.c
>>>> @@ -298,21 +298,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;
>>>> +       };
>>>> +
>>>
>>> ...
>>>
>>>>
>>>> diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
>>>> index a076e44..fa83c61 100644
>>>> --- a/net/openvswitch/flow.h
>>>> +++ b/net/openvswitch/flow.h
>>>> @@ -134,6 +134,9 @@ struct sw_flow_key {
>>>>                   u8     src[ETH_ALEN];   /* Ethernet source address. */
>>>>                   u8     dst[ETH_ALEN];   /* Ethernet destination address.
>>>> */
>>>>                   __be16 tci;             /* 0 if no VLAN,
>>>> VLAN_TAG_PRESENT set otherwise. */
>>>> +               __be16 ctci;            /* 0 if no CVLAN,
>>>> VLAN_TAG_PRESENT set
>>>> +                                        * otherwise.
>>>> +                                        */
>>>>                   __be16 type;            /* Ethernet frame type. */
>>>>           } eth;
>>>>           union {
>>>> --
>>>> 2.1.0
>>>>
>>> Currently you have restricted the datapath implementation to support
>>> only 8021AD. We can extend this to support double tagging by adding
>>> inner_tpid field to struct sw_flow_key. OVS netlink interface already
>>> allows this type of configuration. So is there reason not to do it in
>>> this series?
>>
>> Pravin, thanks for the review.
>>
>> In the original implementation, I thought I would make only the minimally
>> necessary changes and I have been carrying that forward through each
>> revision.
>>
>> If only one tag, tci is present that implies tpid of 0x8100, if two tags are
>> present, both tci and ctci, that implies a tpid of 0x88a8 and this is in
>> fact how the code works and is how it supports both 802.1q and 802.1ad. The
>> tpid's are not strictly necessary in the flow key for both 802.1q and
>> 802.1ad to work. OF doesn't support the ability to push and pop vlans with
>> non valid tpid's so there's no ambiguity.
>>
>> Contrarily and despite my comment above, although not strictly necessary, I
>> don't have any objection to adding the tpid and to the flow key and I can
>> make it work either way.
>>
> inner_tpid is must here. We need to pass this information up to the
> userspace when we serialize the flow-key. Otherwise we would loose
> this information.
Right, I understand the need for this and my code currently deduces the 
tpid by the combination or absence of the tci and ctci.
> I think we can add another struct to represent inner-vlan which keep
> track of the tci and tpid.
OK, I do think what you suggest is a better way to do it and will 
simplify the code quite a bit. I will make the change, add the struct 
with both the inner tci and the tpid to the struct.  I will also make 
the corresponding change for in the user space patch. I will get code 
and tested and submit is as V11.
>


-- 
Thomas F. Herbert

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next V10 4/4] 8021AD: Flow key parsing and netlink attributes.
  2015-06-02 17:50 ` [PATCH net-next V10 4/4] 8021AD: Flow key parsing and netlink attributes Thomas F Herbert
@ 2015-06-09  3:45   ` Pravin Shelar
  2015-06-10  0:13     ` Thomas F Herbert
  0 siblings, 1 reply; 11+ messages in thread
From: Pravin Shelar @ 2015-06-09  3:45 UTC (permalink / raw)
  To: Thomas F Herbert; +Cc: netdev, therbert, dev

On Tue, Jun 2, 2015 at 10:50 AM, Thomas F Herbert
<thomasfherbert@gmail.com> wrote:
> Add support for 802.1ad to netlink parsing and flow conversation. Uses
> double nested encap attributes to represent double tagged vlan.
>
This patch needs to be merged with earlier patch since it is part of
qinq support.

> Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
> ---
>  net/openvswitch/flow_netlink.c | 186 ++++++++++++++++++++++++++++++++++-------
>  1 file changed, 157 insertions(+), 29 deletions(-)
>
> diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
> index c691b1a..8fd4f63 100644
> --- a/net/openvswitch/flow_netlink.c
> +++ b/net/openvswitch/flow_netlink.c
> @@ -771,6 +771,28 @@ static int metadata_from_nlattrs(struct sw_flow_match *match,  u64 *attrs,
...
>                 err = ovs_key_from_nlattrs(match, mask_attrs, a, true, log);
> @@ -1331,6 +1439,25 @@ static int __ovs_nla_put_key(const struct sw_flow_key *swkey,
>                 encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
>                 if (!swkey->eth.tci)
>                         goto unencap;
> +       } else if (swkey->eth.ctci || swkey->eth.type == htons(ETH_P_8021AD)) {
> +               __be16 eth_type;
> +
> +               eth_type = !is_mask ? htons(ETH_P_8021AD) : htons(0xffff);
> +               if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type) ||
> +                   nla_put_be16(skb, OVS_KEY_ATTR_VLAN, output->eth.tci))
> +                       goto nla_put_failure;
> +               encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
> +               if (!swkey->eth.tci)
> +                       goto unencap;
> +               /* Customer tci is nested but uses same key attribute.
> +                */
> +               eth_type = !is_mask ? htons(ETH_P_8021Q) : htons(0xffff);
> +               if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type) ||
> +                   nla_put_be16(skb, OVS_KEY_ATTR_VLAN, output->eth.ctci))
> +                       goto nla_put_failure;
> +               encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
> +               if (!swkey->eth.ctci)
> +                       goto unencap;
>         } else
>                 encap = NULL;
>
For qinq we need to keep track of two encap attributes to finalize
nesting of attributes.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next V10 4/4] 8021AD: Flow key parsing and netlink attributes.
  2015-06-09  3:45   ` Pravin Shelar
@ 2015-06-10  0:13     ` Thomas F Herbert
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas F Herbert @ 2015-06-10  0:13 UTC (permalink / raw)
  To: Pravin Shelar, Thomas F Herbert; +Cc: netdev, dev



On 6/8/15 11:45 PM, Pravin Shelar wrote:
> On Tue, Jun 2, 2015 at 10:50 AM, Thomas F Herbert
> <thomasfherbert@gmail.com> wrote:
>> Add support for 802.1ad to netlink parsing and flow conversation. Uses
>> double nested encap attributes to represent double tagged vlan.
>>
> This patch needs to be merged with earlier patch since it is part of
> qinq support.
>
>> Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
>> ---
>>   net/openvswitch/flow_netlink.c | 186 ++++++++++++++++++++++++++++++++++-------
>>   1 file changed, 157 insertions(+), 29 deletions(-)
>>
>> diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
>> index c691b1a..8fd4f63 100644
>> --- a/net/openvswitch/flow_netlink.c
>> +++ b/net/openvswitch/flow_netlink.c
>> @@ -771,6 +771,28 @@ static int metadata_from_nlattrs(struct sw_flow_match *match,  u64 *attrs,
> ...
>>                  err = ovs_key_from_nlattrs(match, mask_attrs, a, true, log);
>> @@ -1331,6 +1439,25 @@ static int __ovs_nla_put_key(const struct sw_flow_key *swkey,
>>                  encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
>>                  if (!swkey->eth.tci)
>>                          goto unencap;
>> +       } else if (swkey->eth.ctci || swkey->eth.type == htons(ETH_P_8021AD)) {
>> +               __be16 eth_type;
>> +
>> +               eth_type = !is_mask ? htons(ETH_P_8021AD) : htons(0xffff);
>> +               if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type) ||
>> +                   nla_put_be16(skb, OVS_KEY_ATTR_VLAN, output->eth.tci))
>> +                       goto nla_put_failure;
>> +               encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
>> +               if (!swkey->eth.tci)
>> +                       goto unencap;
>> +               /* Customer tci is nested but uses same key attribute.
>> +                */
>> +               eth_type = !is_mask ? htons(ETH_P_8021Q) : htons(0xffff);
>> +               if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type) ||
>> +                   nla_put_be16(skb, OVS_KEY_ATTR_VLAN, output->eth.ctci))
>> +                       goto nla_put_failure;
>> +               encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
>> +               if (!swkey->eth.ctci)
>> +                       goto unencap;
>>          } else
>>                  encap = NULL;
>>
> For qinq we need to keep track of two encap attributes to finalize
> nesting of attributes.
Thanks! This was an oversight on my part and I am fixing it in V11.
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-06-10  0:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-02 17:50 [PATCH net-next V10 0/4] openvswitch: Add support for 802.1AD Thomas F Herbert
     [not found] ` <1433267444-26025-1-git-send-email-thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-06-02 17:50   ` [PATCH net-next V10 1/4] openvswitch: 802.1ad uapi changes Thomas F Herbert
2015-06-02 17:50 ` [PATCH net-next V10 2/4] General check for vlan ethernet types Thomas F Herbert
2015-06-02 17:50 ` [PATCH net-next V10 3/4] 802.1AD: Flow handling, actions and vlan parsing Thomas F Herbert
2015-06-04 17:45   ` Pravin Shelar
     [not found]     ` <CALnjE+p8tuUFoXOFvfrp154rb80o_8XhtJ+Z8RrL1Y67kw12jw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-04 18:18       ` Thomas F Herbert
2015-06-04 20:39         ` Pravin Shelar
2015-06-04 22:00           ` Thomas F Herbert
2015-06-02 17:50 ` [PATCH net-next V10 4/4] 8021AD: Flow key parsing and netlink attributes Thomas F Herbert
2015-06-09  3:45   ` Pravin Shelar
2015-06-10  0:13     ` Thomas F Herbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.