Re: [PATCH net-next] ip6_gre: Factor out common ip6gre tunnel match into helper

From: Markus Elfring
Date: Sun Jul 20 2025 - 03:06:13 EST


> Extract common ip6gre tunnel match from ip6gre_tunnel_lookup() into new
> helper function ip6gre_tunnel_match() to reduces code duplication.


reduce?


> +++ b/net/ipv6/ip6_gre.c
> @@ -111,8 +111,32 @@ static u32 HASH_ADDR(const struct in6_addr *addr)

-/* Given src, dst and key, find appropriate for input tunnel. */
+static bool ip6gre_tunnel_match(struct ip6_tnl *t, int dev_type, int link,
+ int *cand_score, struct ip6_tnl **ret)
+{
+ int score = 0;
+
+ if (t->dev->type != ARPHRD_IP6GRE &&
+ t->dev->type != dev_type)
+ return false;


May the scope be reduced (behind the input parameter validation)
also for this local variable?

Regards,
Markus