• Guillaume Nault's avatar
    ipv4: Initialise ->flowi4_scope properly in ICMP handlers. · b1ad4138
    Guillaume Nault authored
    All the *_redirect() and *_update_pmtu() functions initialise their
    struct flowi4 variable with either __build_flow_key() or
    build_sk_flow_key(). When sk is provided, these functions use
    RT_CONN_FLAGS() to set ->flowi4_tos and always use RT_SCOPE_UNIVERSE
    for ->flowi4_scope. Then they rely on ip_rt_fix_tos() to adjust the
    scope based on the RTO_ONLINK bit and to mask the tos with
    IPTOS_RT_MASK.
    
    This patch modifies __build_flow_key() and build_sk_flow_key() to
    properly initialise ->flowi4_tos and ->flowi4_scope, so that the
    ICMP redirects and PMTU handlers don't need an extra call to
    ip_rt_fix_tos() before doing a fib lookup. That is, we:
    
      * Drop RT_CONN_FLAGS(): use ip_sock_rt_tos() and ip_sock_rt_scope()
        instead, so that we don't have to rely on ip_rt_fix_tos() to adjust
        the scope anymore.
    
      * Apply IPTOS_RT_MASK to the tos, so that we don't need
        ip_rt_fix_tos() to do it for us.
    
      * Drop the ip_rt_fix_tos() calls that now become useless.
    
    The only remaining ip_rt_fix_tos() caller is ip_route_output_key_hash()
    which needs it as long as external callers still use the RTO_ONLINK
    flag.
    
    Note:
      This patch also drops some useless RT_TOS() calls as IPTOS_RT_MASK is
      a stronger mask.
    Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
    Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    b1ad4138
route.c 94.7 KB