ip6_tunnel: allow to inherit from VLAN encapsulated IP
The current code allows to inherit the TTL (hop_limit) from the payload when skb->protocol is ETH_P_IP or ETH_P_IPV6. However when the payload is VLAN encapsulated (e.g because the tunnel is of type GRETAP), 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> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
3f8a8447fd
Коммит
b09ab9c92e
|
@ -1080,10 +1080,13 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
|
||||||
unsigned int eth_hlen = t->dev->type == ARPHRD_ETHER ? ETH_HLEN : 0;
|
unsigned int eth_hlen = t->dev->type == ARPHRD_ETHER ? ETH_HLEN : 0;
|
||||||
unsigned int psh_hlen = sizeof(struct ipv6hdr) + t->encap_hlen;
|
unsigned int psh_hlen = sizeof(struct ipv6hdr) + t->encap_hlen;
|
||||||
unsigned int max_headroom = psh_hlen;
|
unsigned int max_headroom = psh_hlen;
|
||||||
|
__be16 payload_protocol;
|
||||||
bool use_cache = false;
|
bool use_cache = false;
|
||||||
u8 hop_limit;
|
u8 hop_limit;
|
||||||
int err = -1;
|
int err = -1;
|
||||||
|
|
||||||
|
payload_protocol = skb_protocol(skb, true);
|
||||||
|
|
||||||
if (t->parms.collect_md) {
|
if (t->parms.collect_md) {
|
||||||
hop_limit = skb_tunnel_info(skb)->key.ttl;
|
hop_limit = skb_tunnel_info(skb)->key.ttl;
|
||||||
goto route_lookup;
|
goto route_lookup;
|
||||||
|
@ -1093,7 +1096,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
|
||||||
|
|
||||||
/* NBMA tunnel */
|
/* NBMA tunnel */
|
||||||
if (ipv6_addr_any(&t->parms.raddr)) {
|
if (ipv6_addr_any(&t->parms.raddr)) {
|
||||||
if (skb->protocol == htons(ETH_P_IPV6)) {
|
if (payload_protocol == htons(ETH_P_IPV6)) {
|
||||||
struct in6_addr *addr6;
|
struct in6_addr *addr6;
|
||||||
struct neighbour *neigh;
|
struct neighbour *neigh;
|
||||||
int addr_type;
|
int addr_type;
|
||||||
|
@ -1114,7 +1117,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
|
||||||
|
|
||||||
memcpy(&fl6->daddr, addr6, sizeof(fl6->daddr));
|
memcpy(&fl6->daddr, addr6, sizeof(fl6->daddr));
|
||||||
neigh_release(neigh);
|
neigh_release(neigh);
|
||||||
} else if (skb->protocol == htons(ETH_P_IP)) {
|
} else if (payload_protocol == htons(ETH_P_IP)) {
|
||||||
const struct rtable *rt = skb_rtable(skb);
|
const struct rtable *rt = skb_rtable(skb);
|
||||||
|
|
||||||
if (!rt)
|
if (!rt)
|
||||||
|
@ -1225,9 +1228,9 @@ route_lookup:
|
||||||
skb_dst_set(skb, dst);
|
skb_dst_set(skb, dst);
|
||||||
|
|
||||||
if (hop_limit == 0) {
|
if (hop_limit == 0) {
|
||||||
if (skb->protocol == htons(ETH_P_IP))
|
if (payload_protocol == htons(ETH_P_IP))
|
||||||
hop_limit = ip_hdr(skb)->ttl;
|
hop_limit = ip_hdr(skb)->ttl;
|
||||||
else if (skb->protocol == htons(ETH_P_IPV6))
|
else if (payload_protocol == htons(ETH_P_IPV6))
|
||||||
hop_limit = ipv6_hdr(skb)->hop_limit;
|
hop_limit = ipv6_hdr(skb)->hop_limit;
|
||||||
else
|
else
|
||||||
hop_limit = ip6_dst_hoplimit(dst);
|
hop_limit = ip6_dst_hoplimit(dst);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче