netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Stringer <joe@ovn.org>
To: Jarno Rajahalme <jarno@ovn.org>
Cc: netfilter-devel@vger.kernel.org, ovs dev <dev@openvswitch.org>,
	netdev <netdev@vger.kernel.org>
Subject: Re: [ovs-dev] [PATCH nf-next v7 6/7] openvswitch: Delay conntrack helper call for new connections.
Date: Wed, 17 Feb 2016 16:00:27 -0800	[thread overview]
Message-ID: <CAPWQB7FrMyad6D-wGyPQow079uW=uhTAW5azjKVTOV378k-TmA@mail.gmail.com> (raw)
In-Reply-To: <1454722865-59558-7-git-send-email-jarno@ovn.org>

On 5 February 2016 at 17:41, Jarno Rajahalme <jarno@ovn.org> wrote:
> There is no need to help connections that are not confirmed, so we can
> delay helping new connections to the time when they are confirmed.
> This change is needed for NAT support, and having this as a separate
> patch will make the following NAT patch a bit easier to review.
>
> Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
> ---
>  net/openvswitch/conntrack.c | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
> index fa9ab25..fc0ef11 100644
> --- a/net/openvswitch/conntrack.c
> +++ b/net/openvswitch/conntrack.c
> @@ -464,6 +464,7 @@ static bool skb_nfct_cached(struct net *net,
>  /* Pass 'skb' through conntrack in 'net', using zone configured in 'info', if
>   * not done already.  Update key with new CT state after passing the packet
>   * through conntrack.
> + * Note that invalid packets are accepted while the skb->nfct remains unset!
>   */
>  static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
>                            const struct ovs_conntrack_info *info,

This seems unrelated to the patch.

I *think* that you're trying to say that 'if the packet is deemed
invalid by conntrack, skb->nfct will be set to NULL and 0 will be
returned.' I think that this is a documentation issue separate from
this patch (Maybe could be combined with one of the earlier fragments
in the series?).

> @@ -474,7 +475,11 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
>          * actually run the packet through conntrack twice unless it's for a
>          * different zone.
>          */
> -       if (!skb_nfct_cached(net, key, info, skb)) {
> +       bool cached = skb_nfct_cached(net, key, info, skb);
> +       enum ip_conntrack_info ctinfo;
> +       struct nf_conn *ct;
> +
> +       if (!cached) {
>                 struct nf_conn *tmpl = info->ct;
>                 int err;
>
> @@ -497,11 +502,16 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
>                         return -ENOENT;
>
>                 ovs_ct_update_key(skb, info, key, true);
> +       }
>
> -               if (ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
> -                       WARN_ONCE(1, "helper rejected packet");
> -                       return -EINVAL;
> -               }
> +       /* Call the helper right after nf_conntrack_in() for confirmed
> +        * connections, but only when commiting for unconfirmed connections.
> +        */
> +       ct = nf_ct_get(skb, &ctinfo);
> +       if (ct && (nf_ct_is_confirmed(ct) ? !cached : info->commit)
> +           && ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
> +               WARN_ONCE(1, "helper rejected packet");
> +               return -EINVAL;
>         }

The comment points out what I think is the more obvious piece here:
that the helper should be executed when the connection is/will be
committed. The piece that I found less obvious was that "cached"
implies that the helper was already executed (and therefore it
shouldn't be run again). I don't know if there's a way to make this
more obvious, for example with a "helper_executed" variable or
similar. Up to you.

  reply	other threads:[~2016-02-18  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-06  1:40 [PATCH nf-next v7 0/7] openvswitch: NAT support Jarno Rajahalme
     [not found] ` <1454722865-59558-1-git-send-email-jarno-LZ6Gd1LRuIk@public.gmane.org>
2016-02-06  1:40   ` [PATCH nf-next v7 1/7] netfilter: Remove IP_CT_NEW_REPLY definition Jarno Rajahalme
2016-02-06  1:41   ` [PATCH nf-next v7 2/7] netfilter: Allow calling into nat helper without skb_dst Jarno Rajahalme
2016-02-06  1:41   ` [PATCH nf-next v7 3/7] openvswitch: Update the CT state key only after nf_conntrack_in() Jarno Rajahalme
2016-02-06  1:41   ` [PATCH nf-next v7 4/7] openvswitch: Find existing conntrack entry after upcall Jarno Rajahalme
     [not found]     ` <1454722865-59558-5-git-send-email-jarno-LZ6Gd1LRuIk@public.gmane.org>
2016-02-17 22:03       ` Joe Stringer
2016-02-17 23:50     ` Joe Stringer
2016-02-06  1:41   ` [PATCH nf-next v7 5/7] openvswitch: Handle NF_REPEAT in conntrack action Jarno Rajahalme
     [not found]     ` <1454722865-59558-6-git-send-email-jarno-LZ6Gd1LRuIk@public.gmane.org>
2016-02-17 22:06       ` Joe Stringer
2016-02-18 13:09         ` Pablo Neira Ayuso
2016-02-06  1:41   ` [PATCH nf-next v7 6/7] openvswitch: Delay conntrack helper call for new connections Jarno Rajahalme
2016-02-18  0:00     ` Joe Stringer [this message]
     [not found]       ` <CAPWQB7FrMyad6D-wGyPQow079uW=uhTAW5azjKVTOV378k-TmA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-09  0:28         ` Jarno Rajahalme
2016-02-06  1:41   ` [PATCH nf-next v7 7/7] openvswitch: Interface with NAT Jarno Rajahalme

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='CAPWQB7FrMyad6D-wGyPQow079uW=uhTAW5azjKVTOV378k-TmA@mail.gmail.com' \
    --to=joe@ovn.org \
    --cc=dev@openvswitch.org \
    --cc=jarno@ovn.org \
    --cc=netdev@vger.kernel.org \
    --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 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).