Skip to contentSkip to conversation

Set DF bit for IPv4 GRE tunnels with fixed TTL

PATCH In review Konstantin Shemyak 3 participants 3 messages Dec 5, 2015 – Dec 7, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Set DF bit for IPv4 GRE tunnels with fixed TTL

The DF bit on IPv4 GRE tunnels with fixed TTL is enforced in order to prevent networking loops. This was the original behavior of GRE tunnels, lost in the refactoring.

---
 net/ipv4/ip_gre.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv4/ip_gre.c +4 -0
index 6145214..485bf27 100644
@@ -679,6 +679,10 @@ static int ipgre_tunnel_ioctl(struct net_device *dev,
 		    ((p.i_flags|p.o_flags)&(GRE_VERSION|GRE_ROUTING)))
 			return -EINVAL;
 	}
+
+        if (p.iph.ttl)
+                p.iph.frag_off |= htons(IP_DF);
+
 	p.i_flags = gre_flags_to_tnl_flags(p.i_flags);
 	p.o_flags = gre_flags_to_tnl_flags(p.o_flags);
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 14 lines · Konstantin Shemyak

The DF bit on IPv4 GRE tunnels with fixed TTL is enforced in order to prevent networking loops. This was the original behavior of GRE tunnels, lost in the refactoring.

---
 net/ipv4/ip_gre.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv4/ip_gre.c +0 -0
index 6145214..485bf27 100644

net/ipv4/ip_gre.c static int ipgre_tunnel_ioctl(struct net_device *dev, · line 685

Quoted 7 lines
net/ipv4/ip_gre.c +4 -0
@@ -679,6 +679,10 @@ static int ipgre_tunnel_ioctl(struct net_device *dev,
                    ((p.i_flags|p.o_flags)&(GRE_VERSION|GRE_ROUTING)))
                        return -EINVAL;
        }
+
+        if (p.iph.ttl)
+                p.iph.frag_off |= htons(IP_DF);
+

Same code already exist in ip_tunnel_ioctl() which is common function for IP based tunnel modules. Why does that not work?

Quoted 6 lines
net/ipv4/ip_gre.c +0 -1
        p.i_flags = gre_flags_to_tnl_flags(p.i_flags);
        p.o_flags = gre_flags_to_tnl_flags(p.o_flags);
 
--

1.9.1