Netdev List
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber-dcUjhNyLwpNeoWH0uzbU5w@public.gmane.org>
To: Jarno Rajahalme <jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
Cc: dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC PATCH net-next v2 7/8] openvswitch: Delay conntrack helper call for new connections.
Date: Mon, 9 Nov 2015 13:26:01 +0000	[thread overview]
Message-ID: <20151109132601.GB8098@macbook.localdomain> (raw)
In-Reply-To: <1446854768-38299-8-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>

On 06.11, Jarno Rajahalme 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.

For the first packet a helper receives the connection is always unconfirmed.
It makes no sense to confirm it if the helper drops the packet.

> Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
> ---
>  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 7aa38fa..ba44287 100644
> --- a/net/openvswitch/conntrack.c
> +++ b/net/openvswitch/conntrack.c
> @@ -458,6 +458,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,
> @@ -468,7 +469,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;
>  
> @@ -491,11 +496,16 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
>  			return -ENOENT;
>  
>  		ovs_ct_update_key(skb, 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;
>  	}
>  
>  	return 0;
> -- 
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

  parent reply	other threads:[~2015-11-09 13:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-07  0:06 [RFC PATCH net-next v2 0/8] openvswitch: NAT support Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 1/8] netfilter: Remove IP_CT_NEW_REPLY definition Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 2/8] netfilter: Factor out nf_ct_get_info() Jarno Rajahalme
     [not found] ` <1446854768-38299-1-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2015-11-07  0:06   ` [RFC PATCH net-next v2 3/8] netfilter: Allow calling into nat helper without skb_dst Jarno Rajahalme
2015-11-07  0:06   ` [RFC PATCH net-next v2 4/8] openvswitch: Update the CT state key only after nf_conntrack_in() Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 5/8] openvswitch: Find existing conntrack entry after upcall Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 6/8] openvswitch: Handle NF_REPEAT in conntrack action Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 7/8] openvswitch: Delay conntrack helper call for new connections Jarno Rajahalme
     [not found]   ` <1446854768-38299-8-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2015-11-09 13:26     ` Patrick McHardy [this message]
2015-11-10 20:58       ` Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 8/8] openvswitch: Interface with NAT Jarno Rajahalme
2015-11-09 13:31 ` [RFC PATCH net-next v2 0/8] openvswitch: NAT support Patrick McHardy
     [not found]   ` <20151109133122.GC8098-uXGAPMMVk8YB9AHHLWeGtNQXobZC6xk2@public.gmane.org>
2015-11-09 23:21     ` Jarno Rajahalme
2015-11-09 23:45     ` Jarno Rajahalme
2015-11-09 23:48   ` 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=20151109132601.GB8098@macbook.localdomain \
    --to=kaber-dcujhnylwpneowh0uzbu5w@public.gmane.org \
    --cc=dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org \
    --cc=jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netfilter-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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