• Stefano Brivio's avatar
    vti4: Don't count header length twice on tunnel setup · dd1df247
    Stefano Brivio authored
    This re-introduces the effect of commit a3245236 ("vti4:
    Don't count header length twice.") which was accidentally
    reverted by merge commit f895f0cf ("Merge branch 'master' of
    git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec").
    
    The commit message from Steffen Klassert said:
    
        We currently count the size of LL_MAX_HEADER and struct iphdr
        twice for vti4 devices, this leads to a wrong device mtu.
        The size of LL_MAX_HEADER and struct iphdr is already counted in
        ip_tunnel_bind_dev(), so don't do it again in vti_tunnel_init().
    
    And this is still the case now: ip_tunnel_bind_dev() already
    accounts for the header length of the link layer (not
    necessarily LL_MAX_HEADER, if the output device is found), plus
    one IP header.
    
    For example, with a vti device on top of veth, with MTU of 1500,
    the existing implementation would set the initial vti MTU to
    1332, accounting once for LL_MAX_HEADER (128, included in
    hard_header_len by vti) and twice for the same IP header (once
    from hard_header_len, once from ip_tunnel_bind_dev()).
    
    It should instead be 1480, because ip_tunnel_bind_dev() is able
    to figure out that the output device is veth, so no additional
    link layer header is attached, and will properly count one
    single IP header.
    
    The existing issue had the side effect of avoiding PMTUD for
    most xfrm policies, by arbitrarily lowering the initial MTU.
    However, the only way to get a consistent PMTU value is to let
    the xfrm PMTU discovery do its course, and commit d6af1a31
    ("vti: Add pmtu handling to vti_xmit.") now takes care of local
    delivery cases where the application ignores local socket
    notifications.
    
    Fixes: b9959fd3 ("vti: switch to new ip tunnel code")
    Fixes: f895f0cf ("Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec")
    Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
    Acked-by: default avatarSabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
    dd1df247
ip_vti.c 14.9 KB