All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH iptables-nft 3/3] extensions: remove trailing spaces
Date: Thu, 24 Nov 2022 15:18:24 +0100	[thread overview]
Message-ID: <Y399MCSuWa64CTAZ@orbyte.nwl.cc> (raw)
In-Reply-To: <20221124134939.8245-4-fw@strlen.de>

On Thu, Nov 24, 2022 at 02:49:39PM +0100, Florian Westphal wrote:
> Previous patches cause minor test breakage, e.g:
> exp: nft 'add rule ip mangle INPUT iifname "iifname" tcp dport 80 ct state invalid,untracked  counter synproxy sack-perm timestamp wscale 7 mss 1460'
> res: nft 'add rule ip mangle INPUT iifname "iifname" tcp dport 80 ct state invalid,untracked  counter synproxy sack-perm timestamp wscale 7 mss 1460 '
> 
> So fix up the ->xlate callbacks of the affected modules to not print a
> tailing space character.

I am considering something like this:

| diff --git a/libxtables/xtables.c b/libxtables/xtables.c
| index 479dbae078156..367eefaba8e74 100644
| --- a/libxtables/xtables.c
| +++ b/libxtables/xtables.c
| @@ -2496,6 +2496,11 @@ static void __xt_xlate_add(struct xt_xlate *xl, enum xt_xlate_type type,
|         struct xt_xlate_buf *buf = &xl->buf[type];
|         int len;
|  
| +       if (buf->off && !isspace(buf->data[buf->off - 1])) {
| +               buf->data[buf->off] = ' ';
| +               buf->off++;
| +               buf->rem--;
| +       }
|         len = vsnprintf(buf->data + buf->off, buf->rem, fmt, ap);
|         if (len < 0 || len >= buf->rem)
|                 xtables_error(RESOURCE_PROBLEM, "OOM");

Maybe it needs an extra xt_xlate_add_nospc() but it should eliminate the
majority of the "whitespace here or there or not at all" fiddling all over the
code. WDYT?

Cheers, Phil

  reply	other threads:[~2022-11-24 14:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 13:49 [PATCH iptables-nft 0/3] remove escape_quotes support Florian Westphal
2022-11-24 13:49 ` [PATCH iptables-nft 1/3] xlate: get rid of escape_quotes Florian Westphal
2022-11-24 14:05   ` Phil Sutter
2022-11-24 15:43     ` Florian Westphal
2022-11-24 13:49 ` [PATCH iptables-nft 2/3] extensions: change expected output for new format Florian Westphal
2022-11-24 13:49 ` [PATCH iptables-nft 3/3] extensions: remove trailing spaces Florian Westphal
2022-11-24 14:18   ` Phil Sutter [this message]
2022-11-24 15:44     ` Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y399MCSuWa64CTAZ@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.