mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
ip-tunnel: Use API to access tunnel metadata options.
Currently tun-info options pointer is used in few cases to pass options around. But tunnel options can be accessed using ip_tunnel_info_opts() API without using the pointer. Following patch removes the redundant pointer and consistently make use of API. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Thomas Graf <tgraf@suug.ch> Reviewed-by: Jesse Gross <jesse@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d1bfc62591
commit
4c22279848
@ -143,7 +143,6 @@ static void geneve_rx(struct geneve_sock *gs, struct sk_buff *skb)
|
|||||||
|
|
||||||
if (ip_tunnel_collect_metadata() || gs->collect_md) {
|
if (ip_tunnel_collect_metadata() || gs->collect_md) {
|
||||||
__be16 flags;
|
__be16 flags;
|
||||||
void *opts;
|
|
||||||
|
|
||||||
flags = TUNNEL_KEY | TUNNEL_GENEVE_OPT |
|
flags = TUNNEL_KEY | TUNNEL_GENEVE_OPT |
|
||||||
(gnvh->oam ? TUNNEL_OAM : 0) |
|
(gnvh->oam ? TUNNEL_OAM : 0) |
|
||||||
@ -154,11 +153,9 @@ static void geneve_rx(struct geneve_sock *gs, struct sk_buff *skb)
|
|||||||
gnvh->opt_len * 4);
|
gnvh->opt_len * 4);
|
||||||
if (!tun_dst)
|
if (!tun_dst)
|
||||||
goto drop;
|
goto drop;
|
||||||
|
|
||||||
/* Update tunnel dst according to Geneve options. */
|
/* Update tunnel dst according to Geneve options. */
|
||||||
opts = ip_tunnel_info_opts(&tun_dst->u.tun_info,
|
ip_tunnel_info_opts_set(&tun_dst->u.tun_info,
|
||||||
gnvh->opt_len * 4);
|
gnvh->options, gnvh->opt_len * 4);
|
||||||
memcpy(opts, gnvh->options, gnvh->opt_len * 4);
|
|
||||||
} else {
|
} else {
|
||||||
/* Drop packets w/ critical options,
|
/* Drop packets w/ critical options,
|
||||||
* since we don't support any...
|
* since we don't support any...
|
||||||
@ -663,7 +660,7 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
|
|||||||
|
|
||||||
tunnel_id_to_vni(key->tun_id, vni);
|
tunnel_id_to_vni(key->tun_id, vni);
|
||||||
if (key->tun_flags & TUNNEL_GENEVE_OPT)
|
if (key->tun_flags & TUNNEL_GENEVE_OPT)
|
||||||
opts = ip_tunnel_info_opts(info, info->options_len);
|
opts = ip_tunnel_info_opts(info);
|
||||||
|
|
||||||
udp_csum = !!(key->tun_flags & TUNNEL_CSUM);
|
udp_csum = !!(key->tun_flags & TUNNEL_CSUM);
|
||||||
err = geneve_build_skb(rt, skb, key->tun_flags, vni,
|
err = geneve_build_skb(rt, skb, key->tun_flags, vni,
|
||||||
|
@ -1271,7 +1271,7 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
|
|||||||
goto drop;
|
goto drop;
|
||||||
|
|
||||||
info = &tun_dst->u.tun_info;
|
info = &tun_dst->u.tun_info;
|
||||||
md = ip_tunnel_info_opts(info, sizeof(*md));
|
md = ip_tunnel_info_opts(info);
|
||||||
} else {
|
} else {
|
||||||
memset(md, 0, sizeof(*md));
|
memset(md, 0, sizeof(*md));
|
||||||
}
|
}
|
||||||
@ -1948,7 +1948,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
|
|||||||
tos = info->key.tos;
|
tos = info->key.tos;
|
||||||
|
|
||||||
if (info->options_len)
|
if (info->options_len)
|
||||||
md = ip_tunnel_info_opts(info, sizeof(*md));
|
md = ip_tunnel_info_opts(info);
|
||||||
} else {
|
} else {
|
||||||
md->gbp = skb->mark;
|
md->gbp = skb->mark;
|
||||||
}
|
}
|
||||||
|
@ -48,21 +48,16 @@ static inline bool skb_valid_dst(const struct sk_buff *skb)
|
|||||||
struct metadata_dst *metadata_dst_alloc(u8 optslen, gfp_t flags);
|
struct metadata_dst *metadata_dst_alloc(u8 optslen, gfp_t flags);
|
||||||
struct metadata_dst __percpu *metadata_dst_alloc_percpu(u8 optslen, gfp_t flags);
|
struct metadata_dst __percpu *metadata_dst_alloc_percpu(u8 optslen, gfp_t flags);
|
||||||
|
|
||||||
static inline struct metadata_dst *tun_rx_dst(__be16 flags,
|
static inline struct metadata_dst *tun_rx_dst(int md_size)
|
||||||
__be64 tunnel_id, int md_size)
|
|
||||||
{
|
{
|
||||||
struct metadata_dst *tun_dst;
|
struct metadata_dst *tun_dst;
|
||||||
struct ip_tunnel_info *info;
|
|
||||||
|
|
||||||
tun_dst = metadata_dst_alloc(md_size, GFP_ATOMIC);
|
tun_dst = metadata_dst_alloc(md_size, GFP_ATOMIC);
|
||||||
if (!tun_dst)
|
if (!tun_dst)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
info = &tun_dst->u.tun_info;
|
tun_dst->u.tun_info.options_len = 0;
|
||||||
info->key.tun_flags = flags;
|
tun_dst->u.tun_info.mode = 0;
|
||||||
info->key.tun_id = tunnel_id;
|
|
||||||
info->key.tp_src = 0;
|
|
||||||
info->key.tp_dst = 0;
|
|
||||||
return tun_dst;
|
return tun_dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,17 +68,14 @@ static inline struct metadata_dst *ip_tun_rx_dst(struct sk_buff *skb,
|
|||||||
{
|
{
|
||||||
const struct iphdr *iph = ip_hdr(skb);
|
const struct iphdr *iph = ip_hdr(skb);
|
||||||
struct metadata_dst *tun_dst;
|
struct metadata_dst *tun_dst;
|
||||||
struct ip_tunnel_info *info;
|
|
||||||
|
|
||||||
tun_dst = tun_rx_dst(flags, tunnel_id, md_size);
|
tun_dst = tun_rx_dst(md_size);
|
||||||
if (!tun_dst)
|
if (!tun_dst)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
info = &tun_dst->u.tun_info;
|
ip_tunnel_key_init(&tun_dst->u.tun_info.key,
|
||||||
info->key.u.ipv4.src = iph->saddr;
|
iph->saddr, iph->daddr, iph->tos, iph->ttl,
|
||||||
info->key.u.ipv4.dst = iph->daddr;
|
0, 0, tunnel_id, flags);
|
||||||
info->key.tos = iph->tos;
|
|
||||||
info->key.ttl = iph->ttl;
|
|
||||||
return tun_dst;
|
return tun_dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,16 +88,21 @@ static inline struct metadata_dst *ipv6_tun_rx_dst(struct sk_buff *skb,
|
|||||||
struct metadata_dst *tun_dst;
|
struct metadata_dst *tun_dst;
|
||||||
struct ip_tunnel_info *info;
|
struct ip_tunnel_info *info;
|
||||||
|
|
||||||
tun_dst = tun_rx_dst(flags, tunnel_id, md_size);
|
tun_dst = tun_rx_dst(md_size);
|
||||||
if (!tun_dst)
|
if (!tun_dst)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
info = &tun_dst->u.tun_info;
|
info = &tun_dst->u.tun_info;
|
||||||
|
info->mode = IP_TUNNEL_INFO_IPV6;
|
||||||
|
info->key.tun_flags = flags;
|
||||||
|
info->key.tun_id = tunnel_id;
|
||||||
|
info->key.tp_src = 0;
|
||||||
|
info->key.tp_dst = 0;
|
||||||
|
|
||||||
info->key.u.ipv6.src = ip6h->saddr;
|
info->key.u.ipv6.src = ip6h->saddr;
|
||||||
info->key.u.ipv6.dst = ip6h->daddr;
|
info->key.u.ipv6.dst = ip6h->daddr;
|
||||||
info->key.tos = ipv6_get_dsfield(ip6h);
|
info->key.tos = ipv6_get_dsfield(ip6h);
|
||||||
info->key.ttl = ip6h->hop_limit;
|
info->key.ttl = ip6h->hop_limit;
|
||||||
info->mode = IP_TUNNEL_INFO_IPV6;
|
|
||||||
return tun_dst;
|
return tun_dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ struct ip_tunnel_key {
|
|||||||
|
|
||||||
struct ip_tunnel_info {
|
struct ip_tunnel_info {
|
||||||
struct ip_tunnel_key key;
|
struct ip_tunnel_key key;
|
||||||
const void *options;
|
|
||||||
u8 options_len;
|
u8 options_len;
|
||||||
u8 mode;
|
u8 mode;
|
||||||
};
|
};
|
||||||
@ -180,49 +179,32 @@ int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *op,
|
|||||||
int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op,
|
int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op,
|
||||||
unsigned int num);
|
unsigned int num);
|
||||||
|
|
||||||
static inline void __ip_tunnel_info_init(struct ip_tunnel_info *tun_info,
|
static inline void ip_tunnel_key_init(struct ip_tunnel_key *key,
|
||||||
__be32 saddr, __be32 daddr,
|
__be32 saddr, __be32 daddr,
|
||||||
u8 tos, u8 ttl,
|
u8 tos, u8 ttl,
|
||||||
__be16 tp_src, __be16 tp_dst,
|
__be16 tp_src, __be16 tp_dst,
|
||||||
__be64 tun_id, __be16 tun_flags,
|
__be64 tun_id, __be16 tun_flags)
|
||||||
const void *opts, u8 opts_len)
|
|
||||||
{
|
{
|
||||||
tun_info->key.tun_id = tun_id;
|
key->tun_id = tun_id;
|
||||||
tun_info->key.u.ipv4.src = saddr;
|
key->u.ipv4.src = saddr;
|
||||||
tun_info->key.u.ipv4.dst = daddr;
|
key->u.ipv4.dst = daddr;
|
||||||
memset((unsigned char *)&tun_info->key + IP_TUNNEL_KEY_IPV4_PAD,
|
memset((unsigned char *)key + IP_TUNNEL_KEY_IPV4_PAD,
|
||||||
0, IP_TUNNEL_KEY_IPV4_PAD_LEN);
|
0, IP_TUNNEL_KEY_IPV4_PAD_LEN);
|
||||||
tun_info->key.tos = tos;
|
key->tos = tos;
|
||||||
tun_info->key.ttl = ttl;
|
key->ttl = ttl;
|
||||||
tun_info->key.tun_flags = tun_flags;
|
key->tun_flags = tun_flags;
|
||||||
|
|
||||||
/* For the tunnel types on the top of IPsec, the tp_src and tp_dst of
|
/* For the tunnel types on the top of IPsec, the tp_src and tp_dst of
|
||||||
* the upper tunnel are used.
|
* the upper tunnel are used.
|
||||||
* E.g: GRE over IPSEC, the tp_src and tp_port are zero.
|
* E.g: GRE over IPSEC, the tp_src and tp_port are zero.
|
||||||
*/
|
*/
|
||||||
tun_info->key.tp_src = tp_src;
|
key->tp_src = tp_src;
|
||||||
tun_info->key.tp_dst = tp_dst;
|
key->tp_dst = tp_dst;
|
||||||
|
|
||||||
/* Clear struct padding. */
|
/* Clear struct padding. */
|
||||||
if (sizeof(tun_info->key) != IP_TUNNEL_KEY_SIZE)
|
if (sizeof(*key) != IP_TUNNEL_KEY_SIZE)
|
||||||
memset((unsigned char *)&tun_info->key + IP_TUNNEL_KEY_SIZE,
|
memset((unsigned char *)key + IP_TUNNEL_KEY_SIZE,
|
||||||
0, sizeof(tun_info->key) - IP_TUNNEL_KEY_SIZE);
|
0, sizeof(*key) - IP_TUNNEL_KEY_SIZE);
|
||||||
|
|
||||||
tun_info->options = opts;
|
|
||||||
tun_info->options_len = opts_len;
|
|
||||||
|
|
||||||
tun_info->mode = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void ip_tunnel_info_init(struct ip_tunnel_info *tun_info,
|
|
||||||
const struct iphdr *iph,
|
|
||||||
__be16 tp_src, __be16 tp_dst,
|
|
||||||
__be64 tun_id, __be16 tun_flags,
|
|
||||||
const void *opts, u8 opts_len)
|
|
||||||
{
|
|
||||||
__ip_tunnel_info_init(tun_info, iph->saddr, iph->daddr,
|
|
||||||
iph->tos, iph->ttl, tp_src, tp_dst,
|
|
||||||
tun_id, tun_flags, opts, opts_len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned short ip_tunnel_info_af(const struct ip_tunnel_info
|
static inline unsigned short ip_tunnel_info_af(const struct ip_tunnel_info
|
||||||
@ -317,11 +299,24 @@ static inline void iptunnel_xmit_stats(int err,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *ip_tunnel_info_opts(struct ip_tunnel_info *info, size_t n)
|
static inline void *ip_tunnel_info_opts(struct ip_tunnel_info *info)
|
||||||
{
|
{
|
||||||
return info + 1;
|
return info + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void ip_tunnel_info_opts_get(void *to,
|
||||||
|
const struct ip_tunnel_info *info)
|
||||||
|
{
|
||||||
|
memcpy(to, info + 1, info->options_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
|
||||||
|
const void *from, int len)
|
||||||
|
{
|
||||||
|
memcpy(ip_tunnel_info_opts(info), from, len);
|
||||||
|
info->options_len = len;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
return (struct ip_tunnel_info *)lwtstate->data;
|
return (struct ip_tunnel_info *)lwtstate->data;
|
||||||
|
@ -249,7 +249,6 @@ static int ip_tun_build_state(struct net_device *dev, struct nlattr *attr,
|
|||||||
tun_info->key.tun_flags = nla_get_u16(tb[LWTUNNEL_IP_FLAGS]);
|
tun_info->key.tun_flags = nla_get_u16(tb[LWTUNNEL_IP_FLAGS]);
|
||||||
|
|
||||||
tun_info->mode = IP_TUNNEL_INFO_TX;
|
tun_info->mode = IP_TUNNEL_INFO_TX;
|
||||||
tun_info->options = NULL;
|
|
||||||
tun_info->options_len = 0;
|
tun_info->options_len = 0;
|
||||||
|
|
||||||
*ts = new_state;
|
*ts = new_state;
|
||||||
@ -357,7 +356,6 @@ static int ip6_tun_build_state(struct net_device *dev, struct nlattr *attr,
|
|||||||
tun_info->key.tun_flags = nla_get_u16(tb[LWTUNNEL_IP6_FLAGS]);
|
tun_info->key.tun_flags = nla_get_u16(tb[LWTUNNEL_IP6_FLAGS]);
|
||||||
|
|
||||||
tun_info->mode = IP_TUNNEL_INFO_TX | IP_TUNNEL_INFO_IPV6;
|
tun_info->mode = IP_TUNNEL_INFO_TX | IP_TUNNEL_INFO_IPV6;
|
||||||
tun_info->options = NULL;
|
|
||||||
tun_info->options_len = 0;
|
tun_info->options_len = 0;
|
||||||
|
|
||||||
*ts = new_state;
|
*ts = new_state;
|
||||||
|
@ -793,11 +793,13 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
|
|||||||
if (vport) {
|
if (vport) {
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
upcall.egress_tun_info = &info;
|
||||||
err = ovs_vport_get_egress_tun_info(vport, skb,
|
err = ovs_vport_get_egress_tun_info(vport, skb,
|
||||||
&info);
|
&upcall);
|
||||||
if (!err)
|
if (err)
|
||||||
upcall.egress_tun_info = &info;
|
upcall.egress_tun_info = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +491,8 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
|
|||||||
if (upcall_info->egress_tun_info) {
|
if (upcall_info->egress_tun_info) {
|
||||||
nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_EGRESS_TUN_KEY);
|
nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_EGRESS_TUN_KEY);
|
||||||
err = ovs_nla_put_egress_tunnel_key(user_skb,
|
err = ovs_nla_put_egress_tunnel_key(user_skb,
|
||||||
upcall_info->egress_tun_info);
|
upcall_info->egress_tun_info,
|
||||||
|
upcall_info->egress_tun_opts);
|
||||||
BUG_ON(err);
|
BUG_ON(err);
|
||||||
nla_nest_end(user_skb, nla);
|
nla_nest_end(user_skb, nla);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,8 @@ struct ovs_skb_cb {
|
|||||||
* @mru: If not zero, Maximum received IP fragment size.
|
* @mru: If not zero, Maximum received IP fragment size.
|
||||||
*/
|
*/
|
||||||
struct dp_upcall_info {
|
struct dp_upcall_info {
|
||||||
const struct ip_tunnel_info *egress_tun_info;
|
struct ip_tunnel_info *egress_tun_info;
|
||||||
|
const void *egress_tun_opts;
|
||||||
const struct nlattr *userdata;
|
const struct nlattr *userdata;
|
||||||
const struct nlattr *actions;
|
const struct nlattr *actions;
|
||||||
int actions_len;
|
int actions_len;
|
||||||
|
@ -702,12 +702,13 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
memcpy(&key->tun_key, &tun_info->key, sizeof(key->tun_key));
|
memcpy(&key->tun_key, &tun_info->key, sizeof(key->tun_key));
|
||||||
|
|
||||||
if (tun_info->options) {
|
if (tun_info->options_len) {
|
||||||
BUILD_BUG_ON((1 << (sizeof(tun_info->options_len) *
|
BUILD_BUG_ON((1 << (sizeof(tun_info->options_len) *
|
||||||
8)) - 1
|
8)) - 1
|
||||||
> sizeof(key->tun_opts));
|
> sizeof(key->tun_opts));
|
||||||
memcpy(TUN_METADATA_OPTS(key, tun_info->options_len),
|
|
||||||
tun_info->options, tun_info->options_len);
|
ip_tunnel_info_opts_get(TUN_METADATA_OPTS(key, tun_info->options_len),
|
||||||
|
tun_info);
|
||||||
key->tun_opts_len = tun_info->options_len;
|
key->tun_opts_len = tun_info->options_len;
|
||||||
} else {
|
} else {
|
||||||
key->tun_opts_len = 0;
|
key->tun_opts_len = 0;
|
||||||
|
@ -716,10 +716,11 @@ static int ipv4_tun_to_nlattr(struct sk_buff *skb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ovs_nla_put_egress_tunnel_key(struct sk_buff *skb,
|
int ovs_nla_put_egress_tunnel_key(struct sk_buff *skb,
|
||||||
const struct ip_tunnel_info *egress_tun_info)
|
const struct ip_tunnel_info *egress_tun_info,
|
||||||
|
const void *egress_tun_opts)
|
||||||
{
|
{
|
||||||
return __ipv4_tun_to_nlattr(skb, &egress_tun_info->key,
|
return __ipv4_tun_to_nlattr(skb, &egress_tun_info->key,
|
||||||
egress_tun_info->options,
|
egress_tun_opts,
|
||||||
egress_tun_info->options_len);
|
egress_tun_info->options_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1876,20 +1877,14 @@ static int validate_and_copy_set_tun(const struct nlattr *attr,
|
|||||||
tun_info = &tun_dst->u.tun_info;
|
tun_info = &tun_dst->u.tun_info;
|
||||||
tun_info->mode = IP_TUNNEL_INFO_TX;
|
tun_info->mode = IP_TUNNEL_INFO_TX;
|
||||||
tun_info->key = key.tun_key;
|
tun_info->key = key.tun_key;
|
||||||
tun_info->options_len = key.tun_opts_len;
|
|
||||||
|
|
||||||
if (tun_info->options_len) {
|
|
||||||
/* We need to store the options in the action itself since
|
|
||||||
* everything else will go away after flow setup. We can append
|
|
||||||
* it to tun_info and then point there.
|
|
||||||
*/
|
|
||||||
memcpy((tun_info + 1),
|
|
||||||
TUN_METADATA_OPTS(&key, key.tun_opts_len), key.tun_opts_len);
|
|
||||||
tun_info->options = (tun_info + 1);
|
|
||||||
} else {
|
|
||||||
tun_info->options = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* We need to store the options in the action itself since
|
||||||
|
* everything else will go away after flow setup. We can append
|
||||||
|
* it to tun_info and then point there.
|
||||||
|
*/
|
||||||
|
ip_tunnel_info_opts_set(tun_info,
|
||||||
|
TUN_METADATA_OPTS(&key, key.tun_opts_len),
|
||||||
|
key.tun_opts_len);
|
||||||
add_nested_action_end(*sfa, start);
|
add_nested_action_end(*sfa, start);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@ -2345,7 +2340,7 @@ static int set_action_to_attr(const struct nlattr *a, struct sk_buff *skb)
|
|||||||
|
|
||||||
err = ipv4_tun_to_nlattr(skb, &tun_info->key,
|
err = ipv4_tun_to_nlattr(skb, &tun_info->key,
|
||||||
tun_info->options_len ?
|
tun_info->options_len ?
|
||||||
tun_info->options : NULL,
|
ip_tunnel_info_opts(tun_info) : NULL,
|
||||||
tun_info->options_len);
|
tun_info->options_len);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -56,7 +56,8 @@ int ovs_nla_get_match(struct net *, struct sw_flow_match *,
|
|||||||
const struct nlattr *key, const struct nlattr *mask,
|
const struct nlattr *key, const struct nlattr *mask,
|
||||||
bool log);
|
bool log);
|
||||||
int ovs_nla_put_egress_tunnel_key(struct sk_buff *,
|
int ovs_nla_put_egress_tunnel_key(struct sk_buff *,
|
||||||
const struct ip_tunnel_info *);
|
const struct ip_tunnel_info *,
|
||||||
|
const void *egress_tun_opts);
|
||||||
|
|
||||||
bool ovs_nla_get_ufid(struct sw_flow_id *, const struct nlattr *, bool log);
|
bool ovs_nla_get_ufid(struct sw_flow_id *, const struct nlattr *, bool log);
|
||||||
int ovs_nla_get_identifier(struct sw_flow_id *sfid, const struct nlattr *ufid,
|
int ovs_nla_get_identifier(struct sw_flow_id *sfid, const struct nlattr *ufid,
|
||||||
|
@ -53,15 +53,14 @@ static int geneve_get_options(const struct vport *vport,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int geneve_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
static int geneve_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
||||||
struct ip_tunnel_info *egress_tun_info)
|
struct dp_upcall_info *upcall)
|
||||||
{
|
{
|
||||||
struct geneve_port *geneve_port = geneve_vport(vport);
|
struct geneve_port *geneve_port = geneve_vport(vport);
|
||||||
struct net *net = ovs_dp_get_net(vport->dp);
|
struct net *net = ovs_dp_get_net(vport->dp);
|
||||||
__be16 dport = htons(geneve_port->port_no);
|
__be16 dport = htons(geneve_port->port_no);
|
||||||
__be16 sport = udp_flow_src_port(net, skb, 1, USHRT_MAX, true);
|
__be16 sport = udp_flow_src_port(net, skb, 1, USHRT_MAX, true);
|
||||||
|
|
||||||
return ovs_tunnel_get_egress_info(egress_tun_info,
|
return ovs_tunnel_get_egress_info(upcall, ovs_dp_get_net(vport->dp),
|
||||||
ovs_dp_get_net(vport->dp),
|
|
||||||
skb, IPPROTO_UDP, sport, dport);
|
skb, IPPROTO_UDP, sport, dport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,10 +85,9 @@ static struct vport *gre_create(const struct vport_parms *parms)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int gre_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
static int gre_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
||||||
struct ip_tunnel_info *egress_tun_info)
|
struct dp_upcall_info *upcall)
|
||||||
{
|
{
|
||||||
return ovs_tunnel_get_egress_info(egress_tun_info,
|
return ovs_tunnel_get_egress_info(upcall, ovs_dp_get_net(vport->dp),
|
||||||
ovs_dp_get_net(vport->dp),
|
|
||||||
skb, IPPROTO_GRE, 0, 0);
|
skb, IPPROTO_GRE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ static struct vport *vxlan_create(const struct vport_parms *parms)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
||||||
struct ip_tunnel_info *egress_tun_info)
|
struct dp_upcall_info *upcall)
|
||||||
{
|
{
|
||||||
struct vxlan_dev *vxlan = netdev_priv(vport->dev);
|
struct vxlan_dev *vxlan = netdev_priv(vport->dev);
|
||||||
struct net *net = ovs_dp_get_net(vport->dp);
|
struct net *net = ovs_dp_get_net(vport->dp);
|
||||||
@ -159,7 +159,7 @@ static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
|||||||
inet_get_local_port_range(net, &port_min, &port_max);
|
inet_get_local_port_range(net, &port_min, &port_max);
|
||||||
src_port = udp_flow_src_port(net, skb, 0, 0, true);
|
src_port = udp_flow_src_port(net, skb, 0, 0, true);
|
||||||
|
|
||||||
return ovs_tunnel_get_egress_info(egress_tun_info, net,
|
return ovs_tunnel_get_egress_info(upcall, net,
|
||||||
skb, IPPROTO_UDP,
|
skb, IPPROTO_UDP,
|
||||||
src_port, dst_port);
|
src_port, dst_port);
|
||||||
}
|
}
|
||||||
|
@ -487,13 +487,14 @@ void ovs_vport_deferred_free(struct vport *vport)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(ovs_vport_deferred_free);
|
EXPORT_SYMBOL_GPL(ovs_vport_deferred_free);
|
||||||
|
|
||||||
int ovs_tunnel_get_egress_info(struct ip_tunnel_info *egress_tun_info,
|
int ovs_tunnel_get_egress_info(struct dp_upcall_info *upcall,
|
||||||
struct net *net,
|
struct net *net,
|
||||||
struct sk_buff *skb,
|
struct sk_buff *skb,
|
||||||
u8 ipproto,
|
u8 ipproto,
|
||||||
__be16 tp_src,
|
__be16 tp_src,
|
||||||
__be16 tp_dst)
|
__be16 tp_dst)
|
||||||
{
|
{
|
||||||
|
struct ip_tunnel_info *egress_tun_info = upcall->egress_tun_info;
|
||||||
const struct ip_tunnel_info *tun_info = skb_tunnel_info(skb);
|
const struct ip_tunnel_info *tun_info = skb_tunnel_info(skb);
|
||||||
const struct ip_tunnel_key *tun_key;
|
const struct ip_tunnel_key *tun_key;
|
||||||
u32 skb_mark = skb->mark;
|
u32 skb_mark = skb->mark;
|
||||||
@ -520,26 +521,26 @@ int ovs_tunnel_get_egress_info(struct ip_tunnel_info *egress_tun_info,
|
|||||||
/* Generate egress_tun_info based on tun_info,
|
/* Generate egress_tun_info based on tun_info,
|
||||||
* saddr, tp_src and tp_dst
|
* saddr, tp_src and tp_dst
|
||||||
*/
|
*/
|
||||||
__ip_tunnel_info_init(egress_tun_info,
|
ip_tunnel_key_init(&egress_tun_info->key,
|
||||||
fl.saddr, tun_key->u.ipv4.dst,
|
fl.saddr, tun_key->u.ipv4.dst,
|
||||||
tun_key->tos,
|
tun_key->tos,
|
||||||
tun_key->ttl,
|
tun_key->ttl,
|
||||||
tp_src, tp_dst,
|
tp_src, tp_dst,
|
||||||
tun_key->tun_id,
|
tun_key->tun_id,
|
||||||
tun_key->tun_flags,
|
tun_key->tun_flags);
|
||||||
tun_info->options,
|
egress_tun_info->options_len = tun_info->options_len;
|
||||||
tun_info->options_len);
|
egress_tun_info->mode = tun_info->mode;
|
||||||
|
upcall->egress_tun_opts = ip_tunnel_info_opts(egress_tun_info);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(ovs_tunnel_get_egress_info);
|
EXPORT_SYMBOL_GPL(ovs_tunnel_get_egress_info);
|
||||||
|
|
||||||
int ovs_vport_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
int ovs_vport_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
||||||
struct ip_tunnel_info *info)
|
struct dp_upcall_info *upcall)
|
||||||
{
|
{
|
||||||
/* get_egress_tun_info() is only implemented on tunnel ports. */
|
/* get_egress_tun_info() is only implemented on tunnel ports. */
|
||||||
if (unlikely(!vport->ops->get_egress_tun_info))
|
if (unlikely(!vport->ops->get_egress_tun_info))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return vport->ops->get_egress_tun_info(vport, skb, info);
|
return vport->ops->get_egress_tun_info(vport, skb, upcall);
|
||||||
}
|
}
|
||||||
|
@ -53,14 +53,15 @@ int ovs_vport_set_upcall_portids(struct vport *, const struct nlattr *pids);
|
|||||||
int ovs_vport_get_upcall_portids(const struct vport *, struct sk_buff *);
|
int ovs_vport_get_upcall_portids(const struct vport *, struct sk_buff *);
|
||||||
u32 ovs_vport_find_upcall_portid(const struct vport *, struct sk_buff *);
|
u32 ovs_vport_find_upcall_portid(const struct vport *, struct sk_buff *);
|
||||||
|
|
||||||
int ovs_tunnel_get_egress_info(struct ip_tunnel_info *egress_tun_info,
|
int ovs_tunnel_get_egress_info(struct dp_upcall_info *upcall,
|
||||||
struct net *net,
|
struct net *net,
|
||||||
struct sk_buff *,
|
struct sk_buff *,
|
||||||
u8 ipproto,
|
u8 ipproto,
|
||||||
__be16 tp_src,
|
__be16 tp_src,
|
||||||
__be16 tp_dst);
|
__be16 tp_dst);
|
||||||
|
|
||||||
int ovs_vport_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
int ovs_vport_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
|
||||||
struct ip_tunnel_info *info);
|
struct dp_upcall_info *upcall);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct vport_portids - array of netlink portids of a vport.
|
* struct vport_portids - array of netlink portids of a vport.
|
||||||
@ -154,7 +155,7 @@ struct vport_ops {
|
|||||||
|
|
||||||
void (*send)(struct vport *, struct sk_buff *);
|
void (*send)(struct vport *, struct sk_buff *);
|
||||||
int (*get_egress_tun_info)(struct vport *, struct sk_buff *,
|
int (*get_egress_tun_info)(struct vport *, struct sk_buff *,
|
||||||
struct ip_tunnel_info *);
|
struct dp_upcall_info *upcall);
|
||||||
|
|
||||||
struct module *owner;
|
struct module *owner;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
|
Loading…
Reference in New Issue
Block a user