On Thu, Oct 8, 2020 at 2:48 PM Willem de Bruijn <willemdebruijn.ker...@gmail.com> wrote: > > > I see the ipgre_xmit function would pull the header our header_ops > > creates, and then call __gre_xmit. __gre_xmit will call > > gre_build_header to complete the GRE header. gre_build_header expects > > to find the base GRE header after pushing tunnel->tun_hlen. However, > > if tunnel->encap_hlen is not 0, it couldn't find the base GRE header > > there. Is there a problem? > > > > Where exactly should we put the tunnel->encap_hlen header? Before the > > GRE header or after? > > The L4 tunnel infra uses the two callbacks encap_hlen (e.g., > fou_encap_hlen) and build_header (fou_build_header) in struct > ip_tunnel_encap_ops to first allocate more space and later call back > into the specific implementation to fill that data. build_header is > called from __gre6_xmit -> ip6_tnl_xmit (or its ipv4 equivalent). > This happens after gre has pushed its header, so the headers > will come before that.
OK. If the t->encap_hlen header needs to be placed before the GRE header, then I think the ipgre_header function should leave some space before the GRE header to place the t->encap_hlen header, rather than leaving space after the GRE header.