Skip to content

Commit 9df46ae

Browse files
osctobedavem330
authored andcommitted
OVS: remove use of VLAN_TAG_PRESENT
This is a minimal change to allow removing of VLAN_TAG_PRESENT. It leaves OVS unable to use CFI bit, as fixing this would need a deeper surgery involving userspace interface. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f723a1a commit 9df46ae

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

net/openvswitch/actions.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static int push_vlan(struct sk_buff *skb, struct sw_flow_key *key,
301301
key->eth.vlan.tpid = vlan->vlan_tpid;
302302
}
303303
return skb_vlan_push(skb, vlan->vlan_tpid,
304-
ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
304+
ntohs(vlan->vlan_tci) & ~VLAN_CFI_MASK);
305305
}
306306

307307
/* 'src' is already properly masked. */
@@ -822,8 +822,10 @@ static int ovs_vport_output(struct net *net, struct sock *sk, struct sk_buff *sk
822822
__skb_dst_copy(skb, data->dst);
823823
*OVS_CB(skb) = data->cb;
824824
skb->inner_protocol = data->inner_protocol;
825-
skb->vlan_tci = data->vlan_tci;
826-
skb->vlan_proto = data->vlan_proto;
825+
if (data->vlan_tci & VLAN_CFI_MASK)
826+
__vlan_hwaccel_put_tag(skb, data->vlan_proto, data->vlan_tci & ~VLAN_CFI_MASK);
827+
else
828+
__vlan_hwaccel_clear_tag(skb);
827829

828830
/* Reconstruct the MAC header. */
829831
skb_push(skb, data->l2_len);
@@ -867,7 +869,10 @@ static void prepare_frag(struct vport *vport, struct sk_buff *skb,
867869
data->cb = *OVS_CB(skb);
868870
data->inner_protocol = skb->inner_protocol;
869871
data->network_offset = orig_network_offset;
870-
data->vlan_tci = skb->vlan_tci;
872+
if (skb_vlan_tag_present(skb))
873+
data->vlan_tci = skb_vlan_tag_get(skb) | VLAN_CFI_MASK;
874+
else
875+
data->vlan_tci = 0;
871876
data->vlan_proto = skb->vlan_proto;
872877
data->mac_proto = mac_proto;
873878
data->l2_len = hlen;

net/openvswitch/flow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *key_vh,
325325
return -ENOMEM;
326326

327327
vh = (struct vlan_head *)skb->data;
328-
key_vh->tci = vh->tci | htons(VLAN_TAG_PRESENT);
328+
key_vh->tci = vh->tci | htons(VLAN_CFI_MASK);
329329
key_vh->tpid = vh->tpid;
330330

331331
if (unlikely(untag_vlan)) {
@@ -358,7 +358,7 @@ static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
358358
int res;
359359

360360
if (skb_vlan_tag_present(skb)) {
361-
key->eth.vlan.tci = htons(skb->vlan_tci);
361+
key->eth.vlan.tci = htons(skb->vlan_tci) | htons(VLAN_CFI_MASK);
362362
key->eth.vlan.tpid = skb->vlan_proto;
363363
} else {
364364
/* Parse outer vlan tag in the non-accelerated case. */

net/openvswitch/flow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct ovs_tunnel_info {
6060

6161
struct vlan_head {
6262
__be16 tpid; /* Vlan type. Generally 802.1q or 802.1ad.*/
63-
__be16 tci; /* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */
63+
__be16 tci; /* 0 if no VLAN, VLAN_CFI_MASK set otherwise. */
6464
};
6565

6666
#define OVS_SW_FLOW_KEY_METADATA_SIZE \

net/openvswitch/flow_netlink.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -990,9 +990,9 @@ static int validate_vlan_from_nlattrs(const struct sw_flow_match *match,
990990
if (a[OVS_KEY_ATTR_VLAN])
991991
tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
992992

993-
if (!(tci & htons(VLAN_TAG_PRESENT))) {
993+
if (!(tci & htons(VLAN_CFI_MASK))) {
994994
if (tci) {
995-
OVS_NLERR(log, "%s TCI does not have VLAN_TAG_PRESENT bit set.",
995+
OVS_NLERR(log, "%s TCI does not have VLAN_CFI_MASK bit set.",
996996
(inner) ? "C-VLAN" : "VLAN");
997997
return -EINVAL;
998998
} else if (nla_len(a[OVS_KEY_ATTR_ENCAP])) {
@@ -1013,9 +1013,9 @@ static int validate_vlan_mask_from_nlattrs(const struct sw_flow_match *match,
10131013
__be16 tci = 0;
10141014
__be16 tpid = 0;
10151015
bool encap_valid = !!(match->key->eth.vlan.tci &
1016-
htons(VLAN_TAG_PRESENT));
1016+
htons(VLAN_CFI_MASK));
10171017
bool i_encap_valid = !!(match->key->eth.cvlan.tci &
1018-
htons(VLAN_TAG_PRESENT));
1018+
htons(VLAN_CFI_MASK));
10191019

10201020
if (!(key_attrs & (1 << OVS_KEY_ATTR_ENCAP))) {
10211021
/* Not a VLAN. */
@@ -1039,8 +1039,8 @@ static int validate_vlan_mask_from_nlattrs(const struct sw_flow_match *match,
10391039
(inner) ? "C-VLAN" : "VLAN", ntohs(tpid));
10401040
return -EINVAL;
10411041
}
1042-
if (!(tci & htons(VLAN_TAG_PRESENT))) {
1043-
OVS_NLERR(log, "%s TCI mask does not have exact match for VLAN_TAG_PRESENT bit.",
1042+
if (!(tci & htons(VLAN_CFI_MASK))) {
1043+
OVS_NLERR(log, "%s TCI mask does not have exact match for VLAN_CFI_MASK bit.",
10441044
(inner) ? "C-VLAN" : "VLAN");
10451045
return -EINVAL;
10461046
}
@@ -1095,7 +1095,7 @@ static int parse_vlan_from_nlattrs(struct sw_flow_match *match,
10951095
if (err)
10961096
return err;
10971097

1098-
encap_valid = !!(match->key->eth.vlan.tci & htons(VLAN_TAG_PRESENT));
1098+
encap_valid = !!(match->key->eth.vlan.tci & htons(VLAN_CFI_MASK));
10991099
if (encap_valid) {
11001100
err = __parse_vlan_from_nlattrs(match, key_attrs, true, a,
11011101
is_mask, log);
@@ -2943,7 +2943,7 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
29432943
vlan = nla_data(a);
29442944
if (!eth_type_vlan(vlan->vlan_tpid))
29452945
return -EINVAL;
2946-
if (!(vlan->vlan_tci & htons(VLAN_TAG_PRESENT)))
2946+
if (!(vlan->vlan_tci & htons(VLAN_CFI_MASK)))
29472947
return -EINVAL;
29482948
vlan_tci = vlan->vlan_tci;
29492949
break;
@@ -2959,7 +2959,7 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
29592959
/* Prohibit push MPLS other than to a white list
29602960
* for packets that have a known tag order.
29612961
*/
2962-
if (vlan_tci & htons(VLAN_TAG_PRESENT) ||
2962+
if (vlan_tci & htons(VLAN_CFI_MASK) ||
29632963
(eth_type != htons(ETH_P_IP) &&
29642964
eth_type != htons(ETH_P_IPV6) &&
29652965
eth_type != htons(ETH_P_ARP) &&
@@ -2971,7 +2971,7 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
29712971
}
29722972

29732973
case OVS_ACTION_ATTR_POP_MPLS:
2974-
if (vlan_tci & htons(VLAN_TAG_PRESENT) ||
2974+
if (vlan_tci & htons(VLAN_CFI_MASK) ||
29752975
!eth_p_mpls(eth_type))
29762976
return -EINVAL;
29772977

@@ -3036,7 +3036,7 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
30363036
case OVS_ACTION_ATTR_POP_ETH:
30373037
if (mac_proto != MAC_PROTO_ETHERNET)
30383038
return -EINVAL;
3039-
if (vlan_tci & htons(VLAN_TAG_PRESENT))
3039+
if (vlan_tci & htons(VLAN_CFI_MASK))
30403040
return -EINVAL;
30413041
mac_proto = MAC_PROTO_NONE;
30423042
break;

0 commit comments

Comments
 (0)