Re: [PATCH 6/6] conntrack: fix -o save dump for unknown protocols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 23, 2022 at 07:50:00PM +0200, Mikhail Sennikovsky wrote:
> Make sure the protocol (-p) option is included in the -o save
> ct entry dumps for L4 protocols unknown to the conntrack tool
> 
> Signed-off-by: Mikhail Sennikovsky <mikhail.sennikovskii@xxxxxxxxx>
> ---
>  src/conntrack.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/src/conntrack.c b/src/conntrack.c
> index dca7da6..f8a228f 100644
> --- a/src/conntrack.c
> +++ b/src/conntrack.c
> @@ -870,9 +870,18 @@ static int ct_save_snprintf(char *buf, size_t len,
>  
>  		ret = ct_snprintf_opts(buf + offset, len, ct, cur->print_opts);
>  		BUFFER_SIZE(ret, size, len, offset);
> -		break;
> +		goto done_proto4;

I'd suggest:

                l4proto_set = true;

so you can remove this goto.

>  	}
>  
> +	/**
> +	 * Do not use getprotobynumber here to ensure
> +	 * "-o save" data incompatibility between hosts having
> +	 * different /etc/protocols contents
> +	 */

No need for this comment, explain this in the commit message, git
annotate will help to find the reason for this.

> +	ret = snprintf(buf + offset, len, "-p %d ", l4proto);
> +	BUFFER_SIZE(ret, size, len, offset);

        if (!l4proto_set) {
                ret = snprintf(buf + offset, len, "-p %d ", l4proto);
                BUFFER_SIZE(ret, size, len, offset);
        }

> +
> +done_proto4:
>  	/* skip trailing space, if any */
>  	for (; size && buf[size-1] == ' '; --size)
>  		buf[size-1] = '\0';
> -- 
> 2.25.1
> 



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux