Commit c65a6a93 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'net-Geneve-options-support-for-TC-act_tunnel_key'



Jakub Kicinski says:

====================
net: Geneve options support for TC act_tunnel_key

Simon & Pieter say:

This set adds Geneve Options support to the TC tunnel key action.
It provides the plumbing required to configure Geneve variable length
options.  The options can be configured in the form CLASS:TYPE:DATA,
where CLASS is represented as a 16bit hexadecimal value, TYPE as an 8bit
hexadecimal value and DATA as a variable length hexadecimal value.
Additionally multiple options may be listed using a comma delimiter.

v2:
 - fix sparse warnings in patches 3 and 4 (first one reported by
   build bot).
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c90d1604 0ed5269f
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -236,7 +236,8 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
		}
		}
		/* Update tunnel dst according to Geneve options. */
		/* Update tunnel dst according to Geneve options. */
		ip_tunnel_info_opts_set(&tun_dst->u.tun_info,
		ip_tunnel_info_opts_set(&tun_dst->u.tun_info,
					gnvh->options, gnvh->opt_len * 4);
					gnvh->options, gnvh->opt_len * 4,
					TUNNEL_GENEVE_OPT);
	} else {
	} else {
		/* Drop packets w/ critical options,
		/* Drop packets w/ critical options,
		 * since we don't support any...
		 * since we don't support any...
@@ -675,6 +676,7 @@ static void geneve_build_header(struct genevehdr *geneveh,
	geneveh->proto_type = htons(ETH_P_TEB);
	geneveh->proto_type = htons(ETH_P_TEB);
	geneveh->rsvd2 = 0;
	geneveh->rsvd2 = 0;


	if (info->key.tun_flags & TUNNEL_GENEVE_OPT)
		ip_tunnel_info_opts_get(geneveh->options, info);
		ip_tunnel_info_opts_get(geneveh->options, info);
}
}


+2 −1
Original line number Original line Diff line number Diff line
@@ -2122,7 +2122,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
		vni = tunnel_id_to_key32(info->key.tun_id);
		vni = tunnel_id_to_key32(info->key.tun_id);
		ifindex = 0;
		ifindex = 0;
		dst_cache = &info->dst_cache;
		dst_cache = &info->dst_cache;
		if (info->options_len)
		if (info->options_len &&
		    info->key.tun_flags & TUNNEL_VXLAN_OPT)
			md = ip_tunnel_info_opts(info);
			md = ip_tunnel_info_opts(info);
		ttl = info->key.ttl;
		ttl = info->key.ttl;
		tos = info->key.tos;
		tos = info->key.tos;
+6 −2
Original line number Original line Diff line number Diff line
@@ -466,10 +466,12 @@ static inline void ip_tunnel_info_opts_get(void *to,
}
}


static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
					   const void *from, int len)
					   const void *from, int len,
					   __be16 flags)
{
{
	memcpy(ip_tunnel_info_opts(info), from, len);
	memcpy(ip_tunnel_info_opts(info), from, len);
	info->options_len = len;
	info->options_len = len;
	info->key.tun_flags |= flags;
}
}


static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstate)
static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstate)
@@ -511,9 +513,11 @@ static inline void ip_tunnel_info_opts_get(void *to,
}
}


static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
					   const void *from, int len)
					   const void *from, int len,
					   __be16 flags)
{
{
	info->options_len = 0;
	info->options_len = 0;
	info->key.tun_flags |= flags;
}
}


#endif /* CONFIG_INET */
#endif /* CONFIG_INET */
+26 −0
Original line number Original line Diff line number Diff line
@@ -36,9 +36,35 @@ enum {
	TCA_TUNNEL_KEY_PAD,
	TCA_TUNNEL_KEY_PAD,
	TCA_TUNNEL_KEY_ENC_DST_PORT,	/* be16 */
	TCA_TUNNEL_KEY_ENC_DST_PORT,	/* be16 */
	TCA_TUNNEL_KEY_NO_CSUM,		/* u8 */
	TCA_TUNNEL_KEY_NO_CSUM,		/* u8 */
	TCA_TUNNEL_KEY_ENC_OPTS,	/* Nested TCA_TUNNEL_KEY_ENC_OPTS_
					 * attributes
					 */
	__TCA_TUNNEL_KEY_MAX,
	__TCA_TUNNEL_KEY_MAX,
};
};


#define TCA_TUNNEL_KEY_MAX (__TCA_TUNNEL_KEY_MAX - 1)
#define TCA_TUNNEL_KEY_MAX (__TCA_TUNNEL_KEY_MAX - 1)


enum {
	TCA_TUNNEL_KEY_ENC_OPTS_UNSPEC,
	TCA_TUNNEL_KEY_ENC_OPTS_GENEVE,		/* Nested
						 * TCA_TUNNEL_KEY_ENC_OPTS_
						 * attributes
						 */
	__TCA_TUNNEL_KEY_ENC_OPTS_MAX,
};

#define TCA_TUNNEL_KEY_ENC_OPTS_MAX (__TCA_TUNNEL_KEY_ENC_OPTS_MAX - 1)

enum {
	TCA_TUNNEL_KEY_ENC_OPT_GENEVE_UNSPEC,
	TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS,		/* be16 */
	TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE,		/* u8 */
	TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA,		/* 4 to 128 bytes */

	__TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX,
};

#define TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX \
	(__TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX - 1)

#endif
#endif
+1 −1
Original line number Original line Diff line number Diff line
@@ -3582,7 +3582,7 @@ BPF_CALL_3(bpf_skb_set_tunnel_opt, struct sk_buff *, skb,
	if (unlikely(size > IP_TUNNEL_OPTS_MAX))
	if (unlikely(size > IP_TUNNEL_OPTS_MAX))
		return -ENOMEM;
		return -ENOMEM;


	ip_tunnel_info_opts_set(info, from, size);
	ip_tunnel_info_opts_set(info, from, size, TUNNEL_OPTIONS_PRESENT);


	return 0;
	return 0;
}
}
Loading