Skip to contentSkip to conversation

openvswitch: Add support for 802.1ad

PATCH Superseded Thomas F Herbert 4 participants 6 messages Oct 30, 2015 – Oct 31, 2015 1 message not in the archive

Subsystems (3)

v19 of 20 Superseded Latest is v20 →

lore
Share & tools
lore
#0 lore raw

v19 cover openvswitch: Add support for 802.1ad

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(-)
Signature · 6 lines
2.4.3

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

A message that is not in the archive (sent off-list or not yet received): 1446224902-21246-1-git-send-email-thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH v19 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 nested encap attributes to represent double tagged vlan. Inner TPID encoded along with ctci in nested attributes.

---
 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(-)
net/openvswitch/actions.c +4 -2
index 221fa8b..2b4d001 100644
@@ -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);
 }
net/openvswitch/flow.c +58 -18

94 lines not on this page · raw message

net/openvswitch/flow.h +7 -1
index 1d055c5..97821dd 100644
@@ -50,6 +50,11 @@ struct ovs_tunnel_info {
 	struct metadata_dst	*tun_dst;
 };
 
+struct vlan_head {
+	__be16 tpid;	/* Vlan type. Generally 802.1q or 802.1ad.*/
+	__be16 tci;	/* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */
+};
+
 #define OVS_SW_FLOW_KEY_METADATA_SIZE			\
 	(offsetof(struct sw_flow_key, recirc_id) +	\
 	FIELD_SIZEOF(struct sw_flow_key, recirc_id))
@@ -69,7 +74,8 @@ struct sw_flow_key {
 	struct {
 		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. */
+		struct vlan_head vlan;
+		struct vlan_head cvlan;
 		__be16 type;		/* Ethernet frame type. */
 	} eth;
 	union {
net/openvswitch/flow_netlink.c +182 -53

318 lines not on this page · raw message

Signature · 6 lines
2.4.3

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev
#3 lore raw

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

Quoted 13 lines · 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.

---
 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(-)

...
...

net/openvswitch/flow_netlink.c static void mask_set_nlattr(struct nlattr *attr, u8 val) · line 1212

Quoted 7 lines
net/openvswitch/flow_netlink.c +7 -0
+
+static int __parse_vlan_from_nlattrs(const struct nlattr **nla,
+                                    struct sw_flow_match *match,
+                                    u64 *key_attrs, bool inner,
+                                    const struct nlattr **a, bool is_mask,
+                                    bool log)
+{

**nla is unused argument in this function.

Quoted 17 lines
net/openvswitch/flow_netlink.c +17 -0
+       int err;
+       u64 v_attrs = *key_attrs;
+
+       err = encode_vlan_from_nlattrs(match, a, is_mask, inner, log);
+       if (err)
+               return err;
+
+       v_attrs &= ~(1 << OVS_KEY_ATTR_ENCAP);
+
+       /* Insure that tci key attribute isn't
+        * overwritten by encapsulated customer tci.
+        * Ethertype is cleared because it is c_tpid.
+        */
+       v_attrs &= ~(1 << OVS_KEY_ATTR_VLAN);
+       v_attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE);
+
+       *key_attrs = v_attrs;

net/openvswitch/flow_netlink.c static void mask_set_nlattr(struct nlattr *attr, u8 val) · line 1239

Quoted 10 lines
net/openvswitch/flow_netlink.c +10 -0
+
+       return 0;
+}
+
+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)
+{

encap passed by reference here, but caller does not make use of this, So we can just pass pointer to encap.

Quoted 19 lines
net/openvswitch/flow_netlink.c +19 -0
+       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, &v_attrs, log);
+               if (err)
+                       return err;
+

net/openvswitch/flow_netlink.c static void mask_set_nlattr(struct nlattr *attr, u8 val) · line 1268

Quoted 10 lines
net/openvswitch/flow_netlink.c +10 -0
+               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(&encap, match, &v_attrs,
+                                                       true, a, is_mask, log);

__parse_vlan_from_nlattrs() is not parsing inner encap nlattr in this case. If we move above call to parse_flow_nlattrs() to __parse_vlan_from_nlattrs() we can fix this issue.

Quoted 33 lines
net/openvswitch/flow_netlink.c +33 -0
+                       if (err)
+                               return err;
+                       *key_attrs |= v_attrs;
+               }
+       } else {
+               err = __parse_vlan_from_nlattrs(nla, match, key_attrs,
+                                               false, a, is_mask, log);
+               if (err)
+                       return err;
+
+               encap = a[OVS_KEY_ATTR_ENCAP];
+
+               err = parse_flow_nlattrs(encap, a, &v_attrs, log);
+               if (err)
+                       return err;
+
+               if (v_attrs & (1 << OVS_KEY_ATTR_ENCAP)) {
+                       if (!*ie_valid) {
+                               OVS_NLERR(log, "Encap mask attribute is set for non-CVLAN frame.");
+                               return -EINVAL;
+                       }
+                       err = __parse_vlan_from_nlattrs(nla, match,
+                                                       &v_attrs, true, a,
+                                                       is_mask,
+                                                       log);
+                       if (err)
+                               return err;
+                       *key_attrs |= v_attrs;
+               }
+       }
+       return 0;
+}
+
#4 lore raw
In reply to a message not in the archive
Quoted 10 lines · 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.

dev_queue_xmit is effectively called from ovs_vport_send. vlan len check can be done in this ovs_vport_send() function.
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

#5 lore raw

PATCH v19 1/3 openvswitch: 802.1ad uapi changes.

In reply to Thomas F Herbert

openvswitch: Add support for 8021.AD

Change the description of the VLAN tpid field.

---
 include/uapi/linux/openvswitch.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
include/uapi/linux/openvswitch.h +9 -8
index 28ccedd..2e7339d 100644
@@ -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
Signature · 1 line
2.4.3
#6 lore raw

PATCH v19 2/3 Check for vlan ethernet types for 8021.q or 802.1ad

In reply to 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.

---
 include/linux/if_vlan.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
include/linux/if_vlan.h +16 -0
index 67ce5bd..d2494b5 100644
@@ -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
Signature · 1 line
2.4.3