[ovs-dev] [PATCH 2/5] datapath: Proposed fixes for MPLS code

Simon Horman horms at verge.net.au
Fri Oct 5 08:05:53 UTC 2012


Cc: Leo Alterman <lalterman at nicira.com>
Signed-off-by: Simon Horman <horms at verge.net.au>
---
 datapath/datapath.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 79c50af..8ff244c 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -80,6 +80,8 @@ void skb_cb_set_mpls_stack(struct sk_buff *skb)
 	int nh_ofs;
 	__be16 dl_type = 0;
 
+	skb_reset_mac_header(skb);
+
 	eth = eth_hdr(skb);
 	nh_ofs = sizeof(struct ethhdr);
 	if (likely(eth->h_proto >= htons(ETH_TYPE_MIN))) {
@@ -101,7 +103,7 @@ void skb_cb_set_mpls_stack(struct sk_buff *skb)
 unsigned char *skb_cb_mpls_stack(const struct sk_buff *skb)
 {
 	return OVS_CB(skb)->mpls_stack ?
-					skb_mac_header(skb) + OVS_CB(skb)->mpls_stack : 0;
+		skb_mac_header(skb) + OVS_CB(skb)->mpls_stack : 0;
 }
 
 ptrdiff_t skb_cb_mpls_stack_offset(const struct sk_buff *skb)
@@ -731,12 +733,13 @@ static int validate_actions(const struct nlattr *attr,
 				return -EINVAL;
 			break;
 
-		case OVS_ACTION_ATTR_PUSH_MPLS:
-			mpls_ethertype = nla_get_be16(a);
-			if (mpls_ethertype != htons(ETH_P_MPLS_UC) &&
-				mpls_ethertype != htons(ETH_P_MPLS_MC))
+		case OVS_ACTION_ATTR_PUSH_MPLS: {
+			const struct ovs_action_push_mpls *mpls = nla_data(a);
+			if (mpls->mpls_ethertype != htons(ETH_P_MPLS_UC) &&
+			    mpls->mpls_ethertype != htons(ETH_P_MPLS_MC))
 				return -EINVAL;
 			break;
+		}
 
 		case OVS_ACTION_ATTR_POP_MPLS:
 			break;
@@ -861,6 +864,8 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
 	OVS_CB(packet)->flow = flow;
 	packet->priority = flow->key.phy.priority;
 
+	skb_cb_set_mpls_stack(packet);
+
 	rcu_read_lock();
 	dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
 	err = -ENODEV;
-- 
1.7.10.4




More information about the dev mailing list