]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: Remove unnecessary NULL check for lwtunnel_fill_encap()
authorYue Haibing <yuehaibing@huawei.com>
Tue, 24 Jun 2025 14:00:15 +0000 (22:00 +0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 25 Jun 2025 23:52:46 +0000 (16:52 -0700)
lwtunnel_fill_encap() has NULL check and return 0, so no need
to check before call it.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250624140015.3929241-1-yuehaibing@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/fib_semantics.c
net/ipv4/nexthop.c
net/ipv4/route.c
net/ipv6/route.c

index d643bd1a0d9df46e2c946ce2696f73ebe8c40b14..f7c9c6a9f53e4248d42f6afc44e01e4fd3137509 100644 (file)
@@ -1640,8 +1640,7 @@ int fib_nexthop_info(struct sk_buff *skb, const struct fib_nh_common *nhc,
            nla_put_u32(skb, RTA_OIF, nhc->nhc_dev->ifindex))
                goto nla_put_failure;
 
-       if (nhc->nhc_lwtstate &&
-           lwtunnel_fill_encap(skb, nhc->nhc_lwtstate,
+       if (lwtunnel_fill_encap(skb, nhc->nhc_lwtstate,
                                RTA_ENCAP, RTA_ENCAP_TYPE) < 0)
                goto nla_put_failure;
 
index 4397e89d3123a01bb76a104f208e6e50b636dd4f..e808801ab9b818268aa370ecd789c0596bc3fbb4 100644 (file)
@@ -985,8 +985,7 @@ static int nh_fill_node(struct sk_buff *skb, struct nexthop *nh,
                break;
        }
 
-       if (nhi->fib_nhc.nhc_lwtstate &&
-           lwtunnel_fill_encap(skb, nhi->fib_nhc.nhc_lwtstate,
+       if (lwtunnel_fill_encap(skb, nhi->fib_nhc.nhc_lwtstate,
                                NHA_ENCAP, NHA_ENCAP_TYPE) < 0)
                goto nla_put_failure;
 
index 3ff2bd56d05010e1b8f8d65ae3808bf20313a9c8..a2b7cadf66afef44fbca60e8cc61127a82e5a9bd 100644 (file)
@@ -2978,8 +2978,7 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
        if (rt->dst.dev &&
            nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex))
                goto nla_put_failure;
-       if (rt->dst.lwtstate &&
-           lwtunnel_fill_encap(skb, rt->dst.lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0)
+       if (lwtunnel_fill_encap(skb, rt->dst.lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0)
                goto nla_put_failure;
 #ifdef CONFIG_IP_ROUTE_CLASSID
        if (rt->dst.tclassid &&
index d7a9b5bf30c8bd882b6e61ccf4e03e023940ad02..46a4f9d1900fcd1afbb0de82b007d85fc1e1d6c8 100644 (file)
@@ -5852,8 +5852,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
                if (dst->dev && nla_put_u32(skb, RTA_OIF, dst->dev->ifindex))
                        goto nla_put_failure;
 
-               if (dst->lwtstate &&
-                   lwtunnel_fill_encap(skb, dst->lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0)
+               if (lwtunnel_fill_encap(skb, dst->lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0)
                        goto nla_put_failure;
        } else if (rt->fib6_nsiblings) {
                struct fib6_info *sibling;