openvswitch: Add support for 802.1ad
Subsystems (3)
v18 cover openvswitch: Add support for 802.1ad
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(-)
Signature · 1 line
2.4.3
A message that is not in the archive (sent off-list or not yet received): 1445818286-4870-1-git-send-email-thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v17 1/3 openvswitch: 802.1ad uapi changes.
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
@@ -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
Signature · 6 lines
2.4.3 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
PATCH v17 2/3 Check for vlan ethernet types for 8021.q or 802.1ad
In reply to Thomas F Herbert--- 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 · 1 line
2.4.3
Re: [PATCH net-next V17 2/3] Check for vlan ethernet types for 8021.q or 802.1ad
2015-10-25 22:11 GMT-02:00 Thomas F Herbert <[email protected]>:
Quoted 22 lines
Signed-off-by Thomas F Herbert <[email protected]>--- include/linux/if_vlan.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)include/linux/if_vlan.h +9
-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) {
include/linux/if_vlan.h static inline netdev_features_t vlan_features_check(const struct sk_buff *skb, · line 648
Quoted 10 lines
include/linux/if_vlan.h +7
-0+case htons (ETH_P_8021Q ): +case htons (ETH_P_8021AD ): +return true; +default : +return false; + } +}/** * compare_vlan_header - Compare two vlan headers
Description ?
Albino
Re: [PATCH net-next V17 2/3] Check for vlan ethernet types for 8021.q or 802.1ad
Quoted 31 lines · Albino B Neto
2015-10-25 22:11 GMT-02:00 Thomas F Herbert <[email protected]>:
Quoted 30 lines
Signed-off-by Thomas F Herbert <[email protected]>--- 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; + } +}
Quoted 3 lines
include/linux/if_vlan.h static inline netdev_features_t vlan_features_check(const struct sk_buff *skb, · line 648
Quoted 2 lines
include/linux/if_vlan.h +0
-0/** * 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?
Quoted 2 lines
Albino
PATCH v18 3/3 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. Outer TPID is also encoded in the flow key.
--- 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(-)
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))
@@ -68,7 +73,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 +180 -19
284 lines not on this page · raw message
net/openvswitch/vport-netdev.c +3 -1
@@ -194,7 +194,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
A message that is not in the archive (sent off-list or not yet received): 1445818286-4870-4-git-send-email-thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH net-next V18 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes
Quoted 7 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. Outer TPID is also encoded in the flow key.
Signed-off-by Thomas F Herbert <[email protected]>
This patch does not apply on current master due to conflicts related net-branch merge.
Quoted 28 lines
--- 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(-)net/openvswitch/flow.c +7
-4@@ -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;
net/openvswitch/flow.c static bool icmp6hdr_ok(struct sk_buff *skb) · line 319
Quoted 10 lines
net/openvswitch/flow.c +5
-3- }; -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?
Quoted 17 lines
net/openvswitch/flow.c +9
-5-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 ; +} +
...
Quoted 4 lines
net/openvswitch/flow_netlink.c +0
-0
...
Quoted 43 lines
net/openvswitch/flow_netlink.c +43
-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) +{ +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; + +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); +if (err) +return err; + *key_attrs |= v_attrs; + } + }else { + err =__parse_vlan_from_nlattrs (nla, match, key_attrs, + false, a, is_mask, log);
net/openvswitch/flow_netlink.c static void mask_set_nlattr(struct nlattr *attr, u8 val) · line 1190
Quoted 10 lines
net/openvswitch/flow_netlink.c +10
-0+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 ) {
Missing parentheses
...
net/openvswitch/flow_netlink.c int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, · line 1247
Quoted 12 lines
net/openvswitch/flow_netlink.c +3
-3@@ -1099,25 +1240,27 @@ int ovs_nla_get_match(struct net *net, 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 ))) { +eth_type_vlan (nla_get_be16 (a[OVS_KEY_ATTR_ETHERTYPE ]))) {__be16 tci; -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 )))) {
This is not required change.
net/openvswitch/flow_netlink.c int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, · line 1256
Quoted 11 lines
net/openvswitch/flow_netlink.c +0
-2OVS_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 )) {
After checks in encode_vlan_from_nlattrs() function there is no need to have checks here.
net/openvswitch/flow_netlink.c int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, · line 1263
Quoted 8 lines
net/openvswitch/flow_netlink.c +5
-1- err =parse_flow_nlattrs (encap, a, &key_attrs, log); + err =parse_vlan_from_nlattrs (&encap, match, + &key_attrs, + &i_encap_valid, a, false, + log);if (err)return err; +
Added white space.
net/openvswitch/flow_netlink.c int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, · line 1315
Quoted 9 lines
net/openvswitch/flow_netlink.c +1
-1}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 (0xffff ), true); +SW_FLOW_KEY_PUT (match, eth.vlan.tci,htons (0xffff ), true);
Also need to exact match on inner tci.
net/openvswitch/flow_netlink.c int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, · line 1331
Quoted 5 lines
net/openvswitch/flow_netlink.c +0
-0if (mask_attrs &1 <<OVS_KEY_ATTR_ENCAP ) {__be16 eth_type =0 ;@@ -1188,10 +1331,13 @@ int ovs_nla_get_match(struct net *net, struct sw_flow_match *match,if (eth_type ==htons (0xffff )) {
Same as above, after checks in encode_vlan_from_nlattrs() these checks looks redundant.
Quoted 14 lines
net/openvswitch/flow_netlink.c +5
-2mask_attrs &= ~(1 <<OVS_KEY_ATTR_ETHERTYPE ); encap = a[OVS_KEY_ATTR_ENCAP ]; - err =parse_flow_mask_nlattrs (encap, a, - &mask_attrs, log); + err =parse_vlan_from_nlattrs (&nla_mask, match, + &mask_attrs, + &i_encap_valid, + a, true, log);if (err) goto free_newmask; + }else {OVS_NLERR (log,"VLAN frames must have an exact match on the TPID (mask=%x)." ,ntohs (eth_type));
...
Quoted 20 lines
net/openvswitch/flow_netlink.c +6
-7@@ -1368,17 +1515,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 (0xffff ); -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) {
net/openvswitch/flow_netlink.c static int __ovs_nla_put_key(const struct sw_flow_key *swkey, · line 1536
Quoted 10 lines
net/openvswitch/flow_netlink.c +10
-0+/* 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;
(!swkey->eth.cvlan.tci) is never going to be true. since inside if (swkey->eth.cvlan.tci) block.
_______________________________________________
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): CALnjE+rcP1trUt2zSSGoUF9r1XwNgtRiLgsS2soejhd4j0zyHQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH net-next V18 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes
On 10/26/15 10:10 PM, Pravin Shelar wrote:
Thanks for the review.
Quoted 11 lines
Quoted 7 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. Outer TPID is also encoded in the flow key.
Signed-off-by Thomas F Herbert <[email protected]>This patch does not apply on current master due to conflicts related net-branch merge.
OK, I will rebase.
Quoted 36 lines
Quoted 36 lines
--- 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(-)net/openvswitch/flow.c +11
-6@@ -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 ;
Quoted 4 lines
net/openvswitch/flow.c static bool icmp6hdr_ok(struct sk_buff *skb) · line 319
Quoted 3 lines
net/openvswitch/flow.c +1
-1-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.
Quoted 71 lines
Quoted 17 lines
net/openvswitch/flow.c +9
-5-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 ; +} +...
Quoted 4 lines
net/openvswitch/flow_netlink.c +0
-0...
Quoted 46 lines
net/openvswitch/flow_netlink.c +46
-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) +{ +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; + +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); +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; +
Quoted 8 lines
net/openvswitch/flow_netlink.c static void mask_set_nlattr(struct nlattr *attr, u8 val) · line 1190
Quoted 7 lines
net/openvswitch/flow_netlink.c +7
-0+ 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 ) {Missing parentheses
Yes, thanks for spotting this.
Quoted 10 lines
...
Quoted 8 lines
net/openvswitch/flow_netlink.c +1
-1@@ -1099,25 +1240,27 @@ int ovs_nla_get_match(struct net *net, 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 ))) { +eth_type_vlan (nla_get_be16 (a[OVS_KEY_ATTR_ETHERTYPE ]))) {__be16 tci;
Quoted 5 lines
net/openvswitch/flow_netlink.c int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, · line 1247
Quoted 4 lines
net/openvswitch/flow_netlink.c +2
-2-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 )))) {This is not required change.
Yes, we already agreed that forcing to a 64 bit constant was not necessary and should be removed for consistency. Sorry but it crept back into this version via cut and paste when refactoring. Thanks for spotting this and I will fix.
Quoted 11 lines
Quoted 11 lines
net/openvswitch/flow_netlink.c +0
-2OVS_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;
Quoted 3 lines
net/openvswitch/flow_netlink.c int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, · line 1256
Quoted 1 line
net/openvswitch/flow_netlink.c +0
-0if (tci &htons (VLAN_TAG_PRESENT )) {After checks in
encode_vlan_from_nlattrs()function there is no need to have checks here.
Yes, some of this code is redundant and should be removed.
Quoted 10 lines
net/openvswitch/flow_netlink.c int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, · line 1263
Quoted 9 lines
net/openvswitch/flow_netlink.c +5
-1- err =parse_flow_nlattrs (encap, a, &key_attrs, log); + err =parse_vlan_from_nlattrs (&encap, match, + &key_attrs, + &i_encap_valid, a, false, + log);if (err)return err; +Added white space.
Fixed in next version.
Quoted 10 lines
net/openvswitch/flow_netlink.c int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, · line 1315
Quoted 9 lines
net/openvswitch/flow_netlink.c +1
-1}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 (0xffff ), true); +SW_FLOW_KEY_PUT (match, eth.vlan.tci,htons (0xffff ), 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.
Quoted 7 lines
net/openvswitch/flow_netlink.c int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, · line 1331
Quoted 5 lines
net/openvswitch/flow_netlink.c +0
-0if (mask_attrs &1 <<OVS_KEY_ATTR_ENCAP ) {__be16 eth_type =0 ;@@ -1188,10 +1331,13 @@ int ovs_nla_get_match(struct net *net, struct sw_flow_match *match,if (eth_type ==htons (0xffff )) {Same as above, after checks in
encode_vlan_from_nlattrs()these checks looks redundant.
I agree. This patch makes this the extra check redundant with new code in encode_vlan_from_nlattrs() and can be removed.
Quoted 40 lines
Quoted 15 lines
net/openvswitch/flow_netlink.c +5
-2mask_attrs &= ~(1 <<OVS_KEY_ATTR_ETHERTYPE ); encap = a[OVS_KEY_ATTR_ENCAP ]; - err =parse_flow_mask_nlattrs (encap, a, - &mask_attrs, log); + err =parse_vlan_from_nlattrs (&nla_mask, match, + &mask_attrs, + &i_encap_valid, + a, true, log);if (err) goto free_newmask; + }else {OVS_NLERR (log,"VLAN frames must have an exact match on the TPID (mask=%x)." ,ntohs (eth_type));...
Quoted 24 lines
net/openvswitch/flow_netlink.c +10
-7@@ -1368,17 +1515,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 (0xffff ); -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) ||
Quoted 8 lines
net/openvswitch/flow_netlink.c static int __ovs_nla_put_key(const struct sw_flow_key *swkey, · line 1536
Quoted 6 lines
net/openvswitch/flow_netlink.c +6
-0+ 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;(!swkey->eth.cvlan.tci) is never going to be true. since inside if (
swkey->eth.cvlan.tci) block.
Yes, it will be removed.
_______________________________________________
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): [email protected]
Re: [PATCH net-next V18 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes
Quoted 65 lines · Thomas F Herbert
On 10/26/15 10:10 PM, Pravin Shelar wrote:
Thanks for the review.Quoted 11 lines
Quoted 8 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. Outer
TPID is also encoded in the flow key.Quoted 4 lines
Quoted 1 line
Signed-off-by Thomas F Herbert <[email protected]>This patch does not apply on current master due to conflicts related net-branch merge.
OK, I will rebase.
Quoted 37 lines
Quoted 37 lines
--- 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(-)net/openvswitch/flow.c +11
-6@@ -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 ;Quoted 7 lines
net/openvswitch/flow.c static bool icmp6hdr_ok(struct sk_buff *skb) · line 321
Quoted 5 lines
net/openvswitch/flow.c +1
-1-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?
Quoted 6 lines
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.
Quoted 15 lines
Quoted 8 lines
Quoted 8 lines
net/openvswitch/flow.c +0
-0}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, structsw_flow_match *match, goto free_newmask;Quoted 6 lines
net/openvswitch/flow.c int ovs_nla_get_match(struct net *net, struct · line 1317
Quoted 4 lines
net/openvswitch/flow.c +1
-1/* Always match on tci. */ -SW_FLOW_KEY_PUT (match, eth.tci,htons (0xffff ), true); +SW_FLOW_KEY_PUT (match, eth.vlan.tci,htons (0xffff ), true);Also need to exact match on inner tci.
Quoted 3 lines
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.
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev
Re: [PATCH net-next V18 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes
Pravin, please look at comment inline below:
Quoted 13 lines · Pravin Shelar
Quoted 11 lines · Thomas F Herbert
On 10/26/15 10:10 PM, Pravin Shelar wrote:
Thanks for the review.Quoted 9 lines
Quoted 7 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. Outer
TPID is also encoded in the flow key.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Thomas F Herbert <[email protected]>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.
Quoted 68 lines
Quoted 43 lines
Quoted 37 lines
Quoted 37 lines
--- 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(-)net/openvswitch/flow.c +11
-6@@ -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 ;Quoted 6 lines
net/openvswitch/flow.c static bool icmp6hdr_ok(struct sk_buff *skb) · line 321
Quoted 5 lines
net/openvswitch/flow.c +1
-1-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?Quoted 6 lines
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.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
net/openvswitch/flow.c +0
-0}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, structsw_flow_match *match, goto free_newmask;Quoted 8 lines
Quoted 5 lines
net/openvswitch/flow.c int ovs_nla_get_match(struct net *net, struct · line 1317
Quoted 4 lines
net/openvswitch/flow.c +1
-1/* Always match on tci. */ -SW_FLOW_KEY_PUT (match, eth.tci,htons (0xffff ), true); +SW_FLOW_KEY_PUT (match, eth.vlan.tci,htons (0xffff ), 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.
Signature · 1 line
Thomas F Herbert Red Hat