Skip to content

Commit

Permalink
ip_tunnels: allow VXLAN/GENEVE to inherit TOS/TTL from VLAN
Browse files Browse the repository at this point in the history
The current code allows for VXLAN and GENEVE to inherit the TOS
respective the TTL when skb-protocol is ETH_P_IP or ETH_P_IPV6.
However when the payload is VLAN encapsulated, then this inheriting
does not work, because the visible skb-protocol is of type
ETH_P_8021Q or ETH_P_8021AD.

Instead of skb->protocol use skb_protocol().

Signed-off-by: Matthias May <matthias.may@westermo.com>
Link: https://lore.kernel.org/r/20220721202718.10092-1-matthias.may@westermo.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Matthias May authored and Jakub Kicinski committed Jul 23, 2022
1 parent 7446b15 commit 7074732
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions include/net/ip_tunnels.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,11 @@ static inline int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,
static inline u8 ip_tunnel_get_dsfield(const struct iphdr *iph,
const struct sk_buff *skb)
{
if (skb->protocol == htons(ETH_P_IP))
__be16 payload_protocol = skb_protocol(skb, true);

if (payload_protocol == htons(ETH_P_IP))
return iph->tos;
else if (skb->protocol == htons(ETH_P_IPV6))
else if (payload_protocol == htons(ETH_P_IPV6))
return ipv6_get_dsfield((const struct ipv6hdr *)iph);
else
return 0;
Expand All @@ -398,9 +400,11 @@ static inline u8 ip_tunnel_get_dsfield(const struct iphdr *iph,
static inline u8 ip_tunnel_get_ttl(const struct iphdr *iph,
const struct sk_buff *skb)
{
if (skb->protocol == htons(ETH_P_IP))
__be16 payload_protocol = skb_protocol(skb, true);

if (payload_protocol == htons(ETH_P_IP))
return iph->ttl;
else if (skb->protocol == htons(ETH_P_IPV6))
else if (payload_protocol == htons(ETH_P_IPV6))
return ((const struct ipv6hdr *)iph)->hop_limit;
else
return 0;
Expand Down

0 comments on commit 7074732

Please sign in to comment.