Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c8b1b83 authored by Pravin B Shelar's avatar Pravin B Shelar
Browse files

openvswitch: Use tun_key only for egress tunnel path.



Currently tun_key is used for passing tunnel information
on ingress and egress path, this cause confusion.  Following
patch removes its use on ingress path make it egress only parameter.

Signed-off-by: default avatarPravin B Shelar <pshelar@nicira.com>
Acked-by: default avatarAndy Zhou <azhou@nicira.com>
parent 83c8df26
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -510,7 +510,7 @@ static int execute_set_action(struct sk_buff *skb,
		break;

	case OVS_KEY_ATTR_IPV4_TUNNEL:
		OVS_CB(skb)->tun_key = nla_data(nested_attr);
		OVS_CB(skb)->egress_tun_key = nla_data(nested_attr);
		break;

	case OVS_KEY_ATTR_ETHERNET:
@@ -613,7 +613,6 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
{
	struct sw_flow_actions *acts = rcu_dereference(OVS_CB(skb)->flow->sf_acts);

	OVS_CB(skb)->tun_key = NULL;
	return do_execute_actions(dp, skb, key,
				  acts->actions, acts->actions_len);
}
+6 −14
Original line number Diff line number Diff line
@@ -237,33 +237,25 @@ void ovs_dp_detach_port(struct vport *p)
}

/* Must be called with rcu_read_lock. */
void ovs_dp_process_received_packet(struct sk_buff *skb)
void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
{
	const struct vport *p = OVS_CB(skb)->input_vport;
	struct datapath *dp = p->dp;
	struct sw_flow *flow;
	struct dp_stats_percpu *stats;
	struct sw_flow_key key;
	u64 *stats_counter;
	u32 n_mask_hit;
	int error;

	stats = this_cpu_ptr(dp->stats_percpu);

	/* Extract flow from 'skb' into 'key'. */
	error = ovs_flow_key_extract(skb, &key);
	if (unlikely(error)) {
		kfree_skb(skb);
		return;
	}

	/* Look up flow. */
	flow = ovs_flow_tbl_lookup_stats(&dp->table, &key, &n_mask_hit);
	flow = ovs_flow_tbl_lookup_stats(&dp->table, key, &n_mask_hit);
	if (unlikely(!flow)) {
		struct dp_upcall_info upcall;
		int error;

		upcall.cmd = OVS_PACKET_CMD_MISS;
		upcall.key = &key;
		upcall.key = key;
		upcall.userdata = NULL;
		upcall.portid = ovs_vport_find_upcall_portid(p, skb);
		error = ovs_dp_upcall(dp, skb, &upcall);
@@ -277,8 +269,8 @@ void ovs_dp_process_received_packet(struct sk_buff *skb)

	OVS_CB(skb)->flow = flow;

	ovs_flow_stats_update(OVS_CB(skb)->flow, key.tp.flags, skb);
	ovs_execute_actions(dp, skb, &key);
	ovs_flow_stats_update(OVS_CB(skb)->flow, key->tp.flags, skb);
	ovs_execute_actions(dp, skb, key);
	stats_counter = &stats->n_hit;

out:
+4 −4
Original line number Diff line number Diff line
@@ -95,15 +95,15 @@ struct datapath {
/**
 * struct ovs_skb_cb - OVS data in skb CB
 * @flow: The flow associated with this packet.  May be %NULL if no flow.
 * @tun_key: Key for the tunnel that encapsulated this packet. NULL if the
 * packet is not being tunneled.
 * @egress_tun_key: Tunnel information about this packet on egress path.
 * NULL if the packet is not being tunneled.
 * @input_vport: The original vport packet came in on. This value is cached
 * when a packet is received by OVS.
 */
struct ovs_skb_cb {
	struct sw_flow		*flow;
	struct ovs_key_ipv4_tunnel  *tun_key;
	struct vport		*input_vport;
	struct ovs_key_ipv4_tunnel  *egress_tun_key;
};
#define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb)

@@ -184,7 +184,7 @@ static inline struct vport *ovs_vport_ovsl(const struct datapath *dp, int port_n
extern struct notifier_block ovs_dp_device_notifier;
extern struct genl_family dp_vport_genl_family;

void ovs_dp_process_received_packet(struct sk_buff *);
void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key);
void ovs_dp_detach_port(struct vport *);
int ovs_dp_upcall(struct datapath *, struct sk_buff *,
		  const struct dp_upcall_info *);
+4 −3
Original line number Diff line number Diff line
@@ -606,12 +606,13 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
	return 0;
}

int ovs_flow_key_extract(struct sk_buff *skb, struct sw_flow_key *key)
int ovs_flow_key_extract(struct ovs_key_ipv4_tunnel *tun_key,
			 struct sk_buff *skb, struct sw_flow_key *key)
{
	/* Extract metadata from packet. */
	memset(key, 0, sizeof(*key));
	if (OVS_CB(skb)->tun_key)
		memcpy(&key->tun_key, OVS_CB(skb)->tun_key, sizeof(key->tun_key));
	if (tun_key)
		memcpy(&key->tun_key, tun_key, sizeof(key->tun_key));

	key->phy.priority = skb->priority;
	key->phy.in_port = OVS_CB(skb)->input_vport->port_no;
+2 −1
Original line number Diff line number Diff line
@@ -187,7 +187,8 @@ void ovs_flow_stats_get(const struct sw_flow *, struct ovs_flow_stats *,
void ovs_flow_stats_clear(struct sw_flow *);
u64 ovs_flow_used_time(unsigned long flow_jiffies);

int ovs_flow_key_extract(struct sk_buff *skb, struct sw_flow_key *key);
int ovs_flow_key_extract(struct ovs_key_ipv4_tunnel *tun_key,
			 struct sk_buff *skb, struct sw_flow_key *key);
/* Extract key from packet coming from userspace. */
int ovs_flow_key_extract_userspace(const struct nlattr *attr,
				   struct sk_buff *skb,
Loading