title: Linux gretap - net/ipv4/ip_gre.c - how to set value of key->tun_flags
body: <p>I'm trying to transport over a gretap tunnel between two Linux (Centos 6) hosts some cloned IP pkts in order to feed an IDS style device.</p>
  
  <p>Given that PMTU discovery will not work on the cloned pkts I'm trying to transport I have to find a way to clear the DF bit in the header of the GRE pkt, so that it can be fragmented by the sending host and re-assembled at the other end. Otherwise largish pkts (... near the 1500 bytes nmark) will be silently dropped, after the GRE overhead is added.</p>
  
  <p>I've found a working solution that involves configuring an iptables plugin in order to clear the said DF bit, but that solution is a bit too convoluted. See here: <a href="http://backreference.org/2013/07/23/gre-bridging-ipsec-and-nfqueue/" rel="nofollow noreferrer">http://backreference.org/2013/07/23/gre-bridging-ipsec-and-nfqueue/</a> .</p>
  
  <p>I had a peek at the source code of net/ipv4/ip_gre.c and in there I've found these interesting lines (around line 432 from here: <a href="https://github.com/torvalds/linux/blob/master/net/ipv4/ip_gre.c" rel="nofollow noreferrer">https://github.com/torvalds/linux/blob/master/net/ipv4/ip_gre.c</a> ):</p>
  
  <pre><code>df = key-&gt;tun_flags &amp; TUNNEL_DONT_FRAGMENT ?  htons(IP_DF) : 0;
  
  iptunnel_xmit(skb-&gt;sk, rt, skb, fl.saddr, key-&gt;u.ipv4.dst, IPPROTO_GRE,
            key-&gt;tos, key-&gt;ttl, df, false);
  return;
  </code></pre>
  
  <p>The first line in particular seems to enable some logic to conditionally set the DF bit on the outgoing GRE pkt. Assuming I understand the code correctly, that would allow pkts to leave my Linux host without a DF bit set, which should in turn allow for fragmentation.</p>
  
  <p>I've been trying to figure out how I could set the value of key->tun_flags, so that the conditional statement results in a "0" but I couldn't find any CLU that would allow me to do that (ip li, ifconfig, udevadm, etc...).</p>
  
  <p>Does anybody know how the value of key->tun_flags can be manipulated?</p>