Subject: Re: [PATCH] net: ipmr_base: Check iif when returning a (*, G) MFC

From: Ido Schimmel <[email-masked]>
Date: Thu, 2 Nov 2023 11:52:51 +0200

+ Nicolas

On Tue, Oct 31, 2023 at 09:57:56AM +0800, Yang Sun wrote:
> Looking for a (*, G) MFC returns the first match without checking
> the iif. This can return a MFC not intended for a packet's iif and
> forwarding the packet with this MFC will not work correctly.
> 
> When looking up for a (*, G) MFC, check that the MFC's iif is
> the same as the packet's iif.

Is this a regression (doesn't seem that way)? If not, the change should
be targeted at net-next which is closed right now:

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

> 
> Signed-off-by: Yang Sun <[email-masked]>
> ---
>  net/ipv4/ipmr_base.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/ipmr_base.c b/net/ipv4/ipmr_base.c
> index 271dc03fc6db..5cf7c7088dfe 100644
> --- a/net/ipv4/ipmr_base.c
> +++ b/net/ipv4/ipmr_base.c
> @@ -97,7 +97,7 @@ void *mr_mfc_find_any(struct mr_table *mrt, int vifi, void *hasharg)
>  
>  	list = rhltable_lookup(&mrt->mfc_hash, hasharg, *mrt->ops.rht_params);
>  	rhl_for_each_entry_rcu(c, tmp, list, mnode) {
> -		if (c->mfc_un.res.ttls[vifi] < 255)
> +		if (c->mfc_parent == vifi && c->mfc_un.res.ttls[vifi] < 255)

What happens if the route doesn't have an iif (-1)? It won't match
anymore?

>  			return c;
>  
>  		/* It's ok if the vifi is part of the static tree */
> -- 
> 2.42.0.820.g83a721a137-goog
> 
>