• Julian Wiedmann's avatar
    net: ip_tunnel: clean up endianness conversions · fda4fde2
    Julian Wiedmann authored
    sparse complains about some harmless endianness issues:
    
    > net/ipv4/ip_tunnel_core.c:225:43: warning: cast to restricted __be16
    > net/ipv4/ip_tunnel_core.c:225:43: warning: incorrect type in initializer (different base types)
    > net/ipv4/ip_tunnel_core.c:225:43:    expected restricted __be16 [usertype] mtu
    > net/ipv4/ip_tunnel_core.c:225:43:    got unsigned short [usertype]
    
    iptunnel_pmtud_build_icmp() uses the wrong flavour of byte-order conversion
    when storing the MTU into the ICMPv4 packet. Use htons(), just like
    iptunnel_pmtud_build_icmpv6() does.
    
    > net/ipv4/ip_tunnel_core.c:248:35: warning: cast from restricted __be16
    > net/ipv4/ip_tunnel_core.c:248:35: warning: incorrect type in argument 3 (different base types)
    > net/ipv4/ip_tunnel_core.c:248:35:    expected unsigned short type
    > net/ipv4/ip_tunnel_core.c:248:35:    got restricted __be16 [usertype]
    > net/ipv4/ip_tunnel_core.c:341:35: warning: cast from restricted __be16
    > net/ipv4/ip_tunnel_core.c:341:35: warning: incorrect type in argument 3 (different base types)
    > net/ipv4/ip_tunnel_core.c:341:35:    expected unsigned short type
    > net/ipv4/ip_tunnel_core.c:341:35:    got restricted __be16 [usertype]
    
    eth_header() wants the Ethertype in host-order, use the correct flavour of
    byte-order conversion.
    
    > net/ipv4/ip_tunnel_core.c:600:45: warning: restricted __be16 degrades to integer
    > net/ipv4/ip_tunnel_core.c:609:30: warning: incorrect type in assignment (different base types)
    > net/ipv4/ip_tunnel_core.c:609:30:    expected int type
    > net/ipv4/ip_tunnel_core.c:609:30:    got restricted __be16 [usertype]
    > net/ipv4/ip_tunnel_core.c:619:30: warning: incorrect type in assignment (different base types)
    > net/ipv4/ip_tunnel_core.c:619:30:    expected int type
    > net/ipv4/ip_tunnel_core.c:619:30:    got restricted __be16 [usertype]
    > net/ipv4/ip_tunnel_core.c:629:30: warning: incorrect type in assignment (different base types)
    > net/ipv4/ip_tunnel_core.c:629:30:    expected int type
    > net/ipv4/ip_tunnel_core.c:629:30:    got restricted __be16 [usertype]
    
    The TUNNEL_* types are big-endian, so adjust the type of the local
    variable in ip_tun_parse_opts().
    Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
    Link: https://lore.kernel.org/r/20210107144008.25777-1-jwi@linux.ibm.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    fda4fde2
ip_tunnel_core.c 29 KB