Commit 7c383fb2 authored by Jiri Benc's avatar Jiri Benc Committed by David S. Miller

ip_tunnels: use tos and ttl fields also for IPv6

Rename the ipv4_tos and ipv4_ttl fields to just 'tos' and 'ttl', as they'll
be used with IPv6 tunnels, too.
Signed-off-by: default avatarJiri Benc <jbenc@redhat.com>
Acked-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c1ea5d67
...@@ -1278,8 +1278,8 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb) ...@@ -1278,8 +1278,8 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
info = &tun_dst->u.tun_info; info = &tun_dst->u.tun_info;
info->key.u.ipv4.src = iph->saddr; info->key.u.ipv4.src = iph->saddr;
info->key.u.ipv4.dst = iph->daddr; info->key.u.ipv4.dst = iph->daddr;
info->key.ipv4_tos = iph->tos; info->key.tos = iph->tos;
info->key.ipv4_ttl = iph->ttl; info->key.ttl = iph->ttl;
info->key.tp_src = udp_hdr(skb)->source; info->key.tp_src = udp_hdr(skb)->source;
info->key.tp_dst = udp_hdr(skb)->dest; info->key.tp_dst = udp_hdr(skb)->dest;
...@@ -1960,8 +1960,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -1960,8 +1960,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
else else
flags &= ~VXLAN_F_UDP_CSUM; flags &= ~VXLAN_F_UDP_CSUM;
ttl = info->key.ipv4_ttl; ttl = info->key.ttl;
tos = info->key.ipv4_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, sizeof(*md));
......
...@@ -44,8 +44,8 @@ struct ip_tunnel_key { ...@@ -44,8 +44,8 @@ struct ip_tunnel_key {
} ipv6; } ipv6;
} u; } u;
__be16 tun_flags; __be16 tun_flags;
u8 ipv4_tos; u8 tos; /* TOS for IPv4, TC for IPv6 */
u8 ipv4_ttl; u8 ttl; /* TTL for IPv4, HL for IPv6 */
__be16 tp_src; __be16 tp_src;
__be16 tp_dst; __be16 tp_dst;
}; };
...@@ -195,8 +195,8 @@ static inline void __ip_tunnel_info_init(struct ip_tunnel_info *tun_info, ...@@ -195,8 +195,8 @@ static inline void __ip_tunnel_info_init(struct ip_tunnel_info *tun_info,
tun_info->key.u.ipv4.dst = daddr; tun_info->key.u.ipv4.dst = daddr;
memset((unsigned char *)&tun_info->key + IP_TUNNEL_KEY_IPV4_PAD, memset((unsigned char *)&tun_info->key + IP_TUNNEL_KEY_IPV4_PAD,
0, IP_TUNNEL_KEY_IPV4_PAD_LEN); 0, IP_TUNNEL_KEY_IPV4_PAD_LEN);
tun_info->key.ipv4_tos = tos; tun_info->key.tos = tos;
tun_info->key.ipv4_ttl = ttl; tun_info->key.ttl = ttl;
tun_info->key.tun_flags = tun_flags; tun_info->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
......
...@@ -409,8 +409,8 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi) ...@@ -409,8 +409,8 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
info = &tun_dst->u.tun_info; info = &tun_dst->u.tun_info;
info->key.u.ipv4.src = iph->saddr; info->key.u.ipv4.src = iph->saddr;
info->key.u.ipv4.dst = iph->daddr; info->key.u.ipv4.dst = iph->daddr;
info->key.ipv4_tos = iph->tos; info->key.tos = iph->tos;
info->key.ipv4_ttl = iph->ttl; info->key.ttl = iph->ttl;
info->mode = IP_TUNNEL_INFO_RX; info->mode = IP_TUNNEL_INFO_RX;
info->key.tun_flags = tpi->flags & info->key.tun_flags = tpi->flags &
...@@ -529,7 +529,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -529,7 +529,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev)
memset(&fl, 0, sizeof(fl)); memset(&fl, 0, sizeof(fl));
fl.daddr = key->u.ipv4.dst; fl.daddr = key->u.ipv4.dst;
fl.saddr = key->u.ipv4.src; fl.saddr = key->u.ipv4.src;
fl.flowi4_tos = RT_TOS(key->ipv4_tos); fl.flowi4_tos = RT_TOS(key->tos);
fl.flowi4_mark = skb->mark; fl.flowi4_mark = skb->mark;
fl.flowi4_proto = IPPROTO_GRE; fl.flowi4_proto = IPPROTO_GRE;
...@@ -565,7 +565,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -565,7 +565,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev)
df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
err = iptunnel_xmit(skb->sk, rt, skb, fl.saddr, err = iptunnel_xmit(skb->sk, rt, skb, fl.saddr,
key->u.ipv4.dst, IPPROTO_GRE, key->u.ipv4.dst, IPPROTO_GRE,
key->ipv4_tos, key->ipv4_ttl, df, false); key->tos, key->ttl, df, false);
iptunnel_xmit_stats(err, &dev->stats, dev->tstats); iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
return; return;
......
...@@ -233,10 +233,10 @@ static int ip_tun_build_state(struct net_device *dev, struct nlattr *attr, ...@@ -233,10 +233,10 @@ static int ip_tun_build_state(struct net_device *dev, struct nlattr *attr,
tun_info->key.u.ipv4.src = nla_get_be32(tb[LWTUNNEL_IP_SRC]); tun_info->key.u.ipv4.src = nla_get_be32(tb[LWTUNNEL_IP_SRC]);
if (tb[LWTUNNEL_IP_TTL]) if (tb[LWTUNNEL_IP_TTL])
tun_info->key.ipv4_ttl = nla_get_u8(tb[LWTUNNEL_IP_TTL]); tun_info->key.ttl = nla_get_u8(tb[LWTUNNEL_IP_TTL]);
if (tb[LWTUNNEL_IP_TOS]) if (tb[LWTUNNEL_IP_TOS])
tun_info->key.ipv4_tos = nla_get_u8(tb[LWTUNNEL_IP_TOS]); tun_info->key.tos = nla_get_u8(tb[LWTUNNEL_IP_TOS]);
if (tb[LWTUNNEL_IP_SPORT]) if (tb[LWTUNNEL_IP_SPORT])
tun_info->key.tp_src = nla_get_be16(tb[LWTUNNEL_IP_SPORT]); tun_info->key.tp_src = nla_get_be16(tb[LWTUNNEL_IP_SPORT]);
...@@ -264,8 +264,8 @@ static int ip_tun_fill_encap_info(struct sk_buff *skb, ...@@ -264,8 +264,8 @@ static int ip_tun_fill_encap_info(struct sk_buff *skb,
if (nla_put_u64(skb, LWTUNNEL_IP_ID, tun_info->key.tun_id) || if (nla_put_u64(skb, LWTUNNEL_IP_ID, tun_info->key.tun_id) ||
nla_put_be32(skb, LWTUNNEL_IP_DST, tun_info->key.u.ipv4.dst) || nla_put_be32(skb, LWTUNNEL_IP_DST, tun_info->key.u.ipv4.dst) ||
nla_put_be32(skb, LWTUNNEL_IP_SRC, tun_info->key.u.ipv4.src) || nla_put_be32(skb, LWTUNNEL_IP_SRC, tun_info->key.u.ipv4.src) ||
nla_put_u8(skb, LWTUNNEL_IP_TOS, tun_info->key.ipv4_tos) || nla_put_u8(skb, LWTUNNEL_IP_TOS, tun_info->key.tos) ||
nla_put_u8(skb, LWTUNNEL_IP_TTL, tun_info->key.ipv4_ttl) || nla_put_u8(skb, LWTUNNEL_IP_TTL, tun_info->key.ttl) ||
nla_put_u16(skb, LWTUNNEL_IP_SPORT, tun_info->key.tp_src) || nla_put_u16(skb, LWTUNNEL_IP_SPORT, tun_info->key.tp_src) ||
nla_put_u16(skb, LWTUNNEL_IP_DPORT, tun_info->key.tp_dst) || nla_put_u16(skb, LWTUNNEL_IP_DPORT, tun_info->key.tp_dst) ||
nla_put_u16(skb, LWTUNNEL_IP_FLAGS, tun_info->key.tun_flags)) nla_put_u16(skb, LWTUNNEL_IP_FLAGS, tun_info->key.tun_flags))
......
...@@ -542,11 +542,11 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr, ...@@ -542,11 +542,11 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr,
nla_get_in_addr(a), is_mask); nla_get_in_addr(a), is_mask);
break; break;
case OVS_TUNNEL_KEY_ATTR_TOS: case OVS_TUNNEL_KEY_ATTR_TOS:
SW_FLOW_KEY_PUT(match, tun_key.ipv4_tos, SW_FLOW_KEY_PUT(match, tun_key.tos,
nla_get_u8(a), is_mask); nla_get_u8(a), is_mask);
break; break;
case OVS_TUNNEL_KEY_ATTR_TTL: case OVS_TUNNEL_KEY_ATTR_TTL:
SW_FLOW_KEY_PUT(match, tun_key.ipv4_ttl, SW_FLOW_KEY_PUT(match, tun_key.ttl,
nla_get_u8(a), is_mask); nla_get_u8(a), is_mask);
ttl = true; ttl = true;
break; break;
...@@ -655,10 +655,10 @@ static int __ipv4_tun_to_nlattr(struct sk_buff *skb, ...@@ -655,10 +655,10 @@ static int __ipv4_tun_to_nlattr(struct sk_buff *skb,
nla_put_in_addr(skb, OVS_TUNNEL_KEY_ATTR_IPV4_DST, nla_put_in_addr(skb, OVS_TUNNEL_KEY_ATTR_IPV4_DST,
output->u.ipv4.dst)) output->u.ipv4.dst))
return -EMSGSIZE; return -EMSGSIZE;
if (output->ipv4_tos && if (output->tos &&
nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TOS, output->ipv4_tos)) nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TOS, output->tos))
return -EMSGSIZE; return -EMSGSIZE;
if (nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TTL, output->ipv4_ttl)) if (nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TTL, output->ttl))
return -EMSGSIZE; return -EMSGSIZE;
if ((output->tun_flags & TUNNEL_DONT_FRAGMENT) && if ((output->tun_flags & TUNNEL_DONT_FRAGMENT) &&
nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT)) nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT))
......
...@@ -203,8 +203,8 @@ static int geneve_tnl_send(struct vport *vport, struct sk_buff *skb) ...@@ -203,8 +203,8 @@ static int geneve_tnl_send(struct vport *vport, struct sk_buff *skb)
} }
err = geneve_xmit_skb(geneve_port->gs, rt, skb, fl.saddr, err = geneve_xmit_skb(geneve_port->gs, rt, skb, fl.saddr,
tun_key->u.ipv4.dst, tun_key->ipv4_tos, tun_key->u.ipv4.dst, tun_key->tos,
tun_key->ipv4_ttl, df, sport, dport, tun_key->ttl, df, sport, dport,
tun_key->tun_flags, vni, opts_len, opts, tun_key->tun_flags, vni, opts_len, opts,
!!(tun_key->tun_flags & TUNNEL_CSUM), false); !!(tun_key->tun_flags & TUNNEL_CSUM), false);
if (err < 0) if (err < 0)
......
...@@ -604,8 +604,8 @@ int ovs_tunnel_get_egress_info(struct ip_tunnel_info *egress_tun_info, ...@@ -604,8 +604,8 @@ int ovs_tunnel_get_egress_info(struct ip_tunnel_info *egress_tun_info,
*/ */
__ip_tunnel_info_init(egress_tun_info, __ip_tunnel_info_init(egress_tun_info,
fl.saddr, tun_key->u.ipv4.dst, fl.saddr, tun_key->u.ipv4.dst,
tun_key->ipv4_tos, tun_key->tos,
tun_key->ipv4_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,
......
...@@ -256,7 +256,7 @@ static inline struct rtable *ovs_tunnel_route_lookup(struct net *net, ...@@ -256,7 +256,7 @@ static inline struct rtable *ovs_tunnel_route_lookup(struct net *net,
memset(fl, 0, sizeof(*fl)); memset(fl, 0, sizeof(*fl));
fl->daddr = key->u.ipv4.dst; fl->daddr = key->u.ipv4.dst;
fl->saddr = key->u.ipv4.src; fl->saddr = key->u.ipv4.src;
fl->flowi4_tos = RT_TOS(key->ipv4_tos); fl->flowi4_tos = RT_TOS(key->tos);
fl->flowi4_mark = mark; fl->flowi4_mark = mark;
fl->flowi4_proto = protocol; fl->flowi4_proto = protocol;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment