Commit 60a77d11 authored by Beniamino Galvani's avatar Beniamino Galvani Committed by David S. Miller

geneve: add dsfield helper function

Add a helper function to compute the tos/dsfield. In this way, we can
factor out some duplicate code. Also, the helper will be called from
more places in the next commit.
Suggested-by: default avatarGuillaume Nault <gnault@redhat.com>
Signed-off-by: default avatarBeniamino Galvani <b.galvani@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3ae983a6
...@@ -784,6 +784,22 @@ static int geneve_build_skb(struct dst_entry *dst, struct sk_buff *skb, ...@@ -784,6 +784,22 @@ static int geneve_build_skb(struct dst_entry *dst, struct sk_buff *skb,
return err; return err;
} }
static u8 geneve_get_dsfield(struct sk_buff *skb, struct net_device *dev,
const struct ip_tunnel_info *info,
bool *use_cache)
{
struct geneve_dev *geneve = netdev_priv(dev);
u8 dsfield;
dsfield = info->key.tos;
if (dsfield == 1 && !geneve->cfg.collect_md) {
dsfield = ip_tunnel_get_dsfield(ip_hdr(skb), skb);
*use_cache = false;
}
return dsfield;
}
static struct rtable *geneve_get_v4_rt(struct sk_buff *skb, static struct rtable *geneve_get_v4_rt(struct sk_buff *skb,
struct net_device *dev, struct net_device *dev,
struct geneve_sock *gs4, struct geneve_sock *gs4,
...@@ -810,11 +826,7 @@ static struct rtable *geneve_get_v4_rt(struct sk_buff *skb, ...@@ -810,11 +826,7 @@ static struct rtable *geneve_get_v4_rt(struct sk_buff *skb,
fl4->fl4_sport = sport; fl4->fl4_sport = sport;
fl4->flowi4_flags = info->key.flow_flags; fl4->flowi4_flags = info->key.flow_flags;
tos = info->key.tos; tos = geneve_get_dsfield(skb, dev, info, &use_cache);
if ((tos == 1) && !geneve->cfg.collect_md) {
tos = ip_tunnel_get_dsfield(ip_hdr(skb), skb);
use_cache = false;
}
fl4->flowi4_tos = RT_TOS(tos); fl4->flowi4_tos = RT_TOS(tos);
if (full_tos) if (full_tos)
*full_tos = tos; *full_tos = tos;
...@@ -865,12 +877,7 @@ static struct dst_entry *geneve_get_v6_dst(struct sk_buff *skb, ...@@ -865,12 +877,7 @@ static struct dst_entry *geneve_get_v6_dst(struct sk_buff *skb,
fl6->fl6_dport = dport; fl6->fl6_dport = dport;
fl6->fl6_sport = sport; fl6->fl6_sport = sport;
prio = info->key.tos; prio = geneve_get_dsfield(skb, dev, info, &use_cache);
if ((prio == 1) && !geneve->cfg.collect_md) {
prio = ip_tunnel_get_dsfield(ip_hdr(skb), skb);
use_cache = false;
}
fl6->flowlabel = ip6_make_flowinfo(prio, info->key.label); fl6->flowlabel = ip6_make_flowinfo(prio, info->key.label);
dst_cache = (struct dst_cache *)&info->dst_cache; dst_cache = (struct dst_cache *)&info->dst_cache;
if (use_cache) { if (use_cache) {
......
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