On Sun, Aug 17, 2025 at 10:49:23PM +0300, Alex Kalenyuk wrote:
> Previously this would compare to the wrong index
> since the enum has an additional UNDEF entry

Are you actually seeing multipath getting misconfigured here, because
the code doesn't look wrong to me.  We didn't and the "undef" elements
because we don't want to accept "undef" as a valid value from the config
file.

This code is admittedly a little confusing.  We aren't looping from 0 to
the last value, we are looping from FIND_MULTIPATHS_OFF or FLUSH_NEVER
(which have the value of 1). The way the loop works, we won't even check
the config text against the array elements you added. We intentionally
only set elements in those arrays at the values we want to start
checking at: FIND_MULTIPATHS_OFF and FLUSH_NEVER. As long as the text in
the optvals array is correct for the value we are using as its index, if
we match the config text with the optvals text, 'i' must be equal to the
value we want (since the value we want is array index of the matching
text).

If you are seeing a configuration issue, we do want to hear about it.
I'm not saying there isn't a bug, but unless I'm missing something, I
don't think that this is it. Also multipath's configuration priority
isn't always super intuitive, so sometimes it is working as designed,
but not you might intuitively expect.

-Ben

> 
> Signed-off-by: Alex Kalenyuk <akale...@redhat.com>
> ---
>  libmultipath/dict.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libmultipath/dict.c b/libmultipath/dict.c
> index a06a6138..2e820b2e 100644
> --- a/libmultipath/dict.c
> +++ b/libmultipath/dict.c
> @@ -550,6 +550,7 @@ static int snprint_def_partition_delim(struct config 
> *conf, struct strbuf *buff,
>  }
>  
>  static const char * const find_multipaths_optvals[] = {
> +     [FIND_MULTIPATHS_UNDEF] = "undef",
>       [FIND_MULTIPATHS_OFF] = "off",
>       [FIND_MULTIPATHS_ON] = "on",
>       [FIND_MULTIPATHS_STRICT] = "strict",
> @@ -793,6 +794,7 @@ declare_def_snprint(allow_usb_devices, print_yes_no)
>  
>  
>  static const char * const flush_on_last_del_optvals[] = {
> +     [FLUSH_UNDEF] = "undef",
>       [FLUSH_NEVER] = "never",
>       [FLUSH_ALWAYS] = "always",
>       [FLUSH_UNUSED] = "unused",
> -- 
> 2.50.1


Reply via email to