openvswitch: Add support for 802.1ad
Subsystems (3)
v20 cover openvswitch: Add support for 802.1ad
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(-)
Signature · 1 line
2.4.3
A message that is not in the archive (sent off-list or not yet received): 1446752045-5227-1-git-send-email-thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v20 2/3 Check for vlan ethernet types for 8021.q or 802.1ad
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
@@ -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 · 6 lines
2.4.3 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
PATCH v20 1/3 openvswitch: 802.1ad uapi changes.
In reply to Thomas F Herbertopenvswitch: 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
@@ -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
PATCH v20 3/3 openvswitch: 802.1AD: Flow handling, actions, vlan parsing and netlink attributes
In reply to Thomas F HerbertAdd 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.
--- 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(-)
net/openvswitch/actions.c +4 -2
@@ -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
@@ -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 +173 -60
325 lines not on this page · raw message
net/openvswitch/vport.c +3 -1
@@ -484,7 +484,9 @@ static unsigned int packet_length(const struct sk_buff *skb) {unsigned int length = skb->len -ETH_HLEN ; -if (skb->protocol ==htons (ETH_P_8021Q )) +if (eth_type_vlan (skb->protocol)) + length -=VLAN_HLEN ; +if (skb->protocol ==htons (ETH_P_8021AD )) length -=VLAN_HLEN ;return length;
Signature · 1 line
2.4.3