]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ipv4: remove unnecessary judgment in ip_route_output_key_hash_rcu
authorZhengchao Shao <shaozhengchao@163.com>
Wed, 9 Apr 2025 03:33:21 +0000 (11:33 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 11 Apr 2025 03:15:26 +0000 (20:15 -0700)
In the ip_route_output_key_cash_rcu function, the input fl4 member saddr is
first checked to be non-zero before entering multicast, broadcast and
arbitrary IP address checks. However, the fact that the IP address is not
0 has already ruled out the possibility of any address, so remove
unnecessary judgment.

Signed-off-by: Zhengchao Shao <shaozhengchao@163.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20250409033321.108244-1-shaozhengchao@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/route.c

index 753704f75b2c65d79c9c4dc19a329de5cdbd8514..22dfc971aab4b69e859511157a60aa90826b2539 100644 (file)
@@ -2699,8 +2699,7 @@ struct rtable *ip_route_output_key_hash_rcu(struct net *net, struct flowi4 *fl4,
 
        if (fl4->saddr) {
                if (ipv4_is_multicast(fl4->saddr) ||
-                   ipv4_is_lbcast(fl4->saddr) ||
-                   ipv4_is_zeronet(fl4->saddr)) {
+                   ipv4_is_lbcast(fl4->saddr)) {
                        rth = ERR_PTR(-EINVAL);
                        goto out;
                }