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

Commit f0b128c1 authored by Jesse Gross's avatar Jesse Gross Committed by David S. Miller
Browse files

openvswitch: Wrap struct ovs_key_ipv4_tunnel in a new structure.



Currently, the flow information that is matched for tunnels and
the tunnel data passed around with packets is the same. However,
as additional information is added this is not necessarily desirable,
as in the case of pointers.

This adds a new structure for tunnel metadata which currently contains
only the existing struct. This change is purely internal to the kernel
since the current OVS_KEY_ATTR_IPV4_TUNNEL is simply a compressed version
of OVS_KEY_ATTR_TUNNEL that is translated at flow setup.

Signed-off-by: default avatarJesse Gross <jesse@nicira.com>
Signed-off-by: default avatarAndy Zhou <azhou@nicira.com>
Acked-by: default avatarPravin B Shelar <pshelar@nicira.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 67fa0341
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -294,7 +294,7 @@ enum ovs_key_attr {
	OVS_KEY_ATTR_RECIRC_ID, /* u32 recirc id */

#ifdef __KERNEL__
	OVS_KEY_ATTR_IPV4_TUNNEL,  /* struct ovs_key_ipv4_tunnel */
	OVS_KEY_ATTR_TUNNEL_INFO,  /* struct ovs_tunnel_info */
#endif
	__OVS_KEY_ATTR_MAX
};
+3 −2
Original line number Diff line number Diff line
@@ -590,8 +590,8 @@ static int execute_set_action(struct sk_buff *skb,
		skb->mark = nla_get_u32(nested_attr);
		break;

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

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

	this_cpu_inc(exec_actions_level);
	OVS_CB(skb)->egress_tun_info = NULL;
	err = do_execute_actions(dp, skb, key,
				 acts->actions, acts->actions_len);

+1 −1
Original line number Diff line number Diff line
@@ -102,8 +102,8 @@ struct datapath {
 */
struct ovs_skb_cb {
	struct sw_flow		*flow;
	struct ovs_tunnel_info  *egress_tun_info;
	struct vport		*input_vport;
	struct ovs_key_ipv4_tunnel  *egress_tun_key;
};
#define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb)

+3 −3
Original line number Diff line number Diff line
@@ -642,12 +642,12 @@ int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key)
	return key_extract(skb, key);
}

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

+17 −13
Original line number Diff line number Diff line
@@ -49,20 +49,24 @@ struct ovs_key_ipv4_tunnel {
	u8   ipv4_ttl;
} __packed __aligned(4); /* Minimize padding. */

static inline void ovs_flow_tun_key_init(struct ovs_key_ipv4_tunnel *tun_key,
					 const struct iphdr *iph, __be64 tun_id,
					 __be16 tun_flags)
struct ovs_tunnel_info {
	struct ovs_key_ipv4_tunnel tunnel;
};

static inline void ovs_flow_tun_info_init(struct ovs_tunnel_info *tun_info,
					  const struct iphdr *iph,
					  __be64 tun_id, __be16 tun_flags)
{
	tun_key->tun_id = tun_id;
	tun_key->ipv4_src = iph->saddr;
	tun_key->ipv4_dst = iph->daddr;
	tun_key->ipv4_tos = iph->tos;
	tun_key->ipv4_ttl = iph->ttl;
	tun_key->tun_flags = tun_flags;
	tun_info->tunnel.tun_id = tun_id;
	tun_info->tunnel.ipv4_src = iph->saddr;
	tun_info->tunnel.ipv4_dst = iph->daddr;
	tun_info->tunnel.ipv4_tos = iph->tos;
	tun_info->tunnel.ipv4_ttl = iph->ttl;
	tun_info->tunnel.tun_flags = tun_flags;

	/* clear struct padding. */
	memset((unsigned char *) tun_key + OVS_TUNNEL_KEY_SIZE, 0,
	       sizeof(*tun_key) - OVS_TUNNEL_KEY_SIZE);
	memset((unsigned char *)&tun_info->tunnel + OVS_TUNNEL_KEY_SIZE, 0,
	       sizeof(tun_info->tunnel) - OVS_TUNNEL_KEY_SIZE);
}

struct sw_flow_key {
@@ -190,8 +194,8 @@ void ovs_flow_stats_clear(struct sw_flow *);
u64 ovs_flow_used_time(unsigned long flow_jiffies);

int ovs_flow_key_update(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);
int ovs_flow_key_extract(struct ovs_tunnel_info *tun_info, 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