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

Phil Sutter <phil@nwl.cc> wrote:
> 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?

I think its a good idea.

      reply	other threads:[~2022-11-24 15:45 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
2022-11-24 15:44     ` Florian Westphal [this message]

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=20221124154459.GF2753@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=phil@nwl.cc \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).