From patchwork Tue Feb 7 22:52:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13132173 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61604C636CD for ; Tue, 7 Feb 2023 22:52:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbjBGWwX (ORCPT ); Tue, 7 Feb 2023 17:52:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbjBGWwR (ORCPT ); Tue, 7 Feb 2023 17:52:17 -0500 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6859023666 for ; Tue, 7 Feb 2023 14:52:16 -0800 (PST) Received: by mail-qt1-x830.google.com with SMTP id h24so18807305qtr.0 for ; Tue, 07 Feb 2023 14:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=79Ovqe76w/JYL9kRl2YoGLdQuqI8hAu0+om6jffVsHE=; b=V3U49d6z5OYhAeyt2xoO1Y2Kn9BtqizqwokFlXBCLJ5SVd1VH88PD2bvxziKDhhMcG q/nrFjoLnpXzp5UyWoTB4XqjR0lUrb2lD3v8FDlwEULpr1YfTkqL/bOJwyqts3rgK3LB 5fzubb04dP0qAixuTGvW0TCegImRdcHccgCgJLdasmy9RQiYf0A3mQaN9B1yS4lpxKKa VtpfIbQBOauQ/8A+JXlGSBznLiy1aJPxgzkdjrmvq2mNdYSnOe6yiyRYohLLxmAL8+rS XrmImcefhHbVqMLMmOqSbgIoShJ2NibSY6kNKdrdl63vicw/VeZfO2+IsFlYKMC5wzed mNCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=79Ovqe76w/JYL9kRl2YoGLdQuqI8hAu0+om6jffVsHE=; b=myfl6sS7RE+ozdB4lYN82p7TlBmNKVfDhS404Pbv1+op8/xStGiRrxsQQeeRKiBGLc kQeouXyvji9rYHZC+FfpQhBxA3xij6IvhGFuSE8AgLCvu5uZym7XMVAC51M+QjbidcjV MMBglzawrq8hsw1fHWqXv3Hz1MzfE4w+sdBQOweeD5i0gaFBZXdJO173+BNyLnmaTJey 3c6HQR/A9ToOZ2mxAahNVqzZuj5zfH19jt7tRE8hZ6BybBOwaXgLzYqHSqv7AqXS40an qLkp9CEq6xAJwZEZl75bPdSmijz7djuvsWSgNQ+dGE0GBP3GSmJX7X3XXyYsutTVRiKL KVAQ== X-Gm-Message-State: AO0yUKXbo70OHG9yYtO+1NnevgBw6Jn+ADmPKMVLS8GXNtK+3WYAAgu/ wbZjp5QjAW/xUHuw3/6eJt4t0fiOJ8Rkjw== X-Google-Smtp-Source: AK7set/pfz6hn0sILXxjPof2UMe1UrW2TeXrk48vQr5P2/F6mQyZUJpcyqLbr7OY67NzxBxH5hq8Pg== X-Received: by 2002:a05:622a:1653:b0:3b8:2a6c:d1e3 with SMTP id y19-20020a05622a165300b003b82a6cd1e3mr7768191qtj.21.1675810335375; Tue, 07 Feb 2023 14:52:15 -0800 (PST) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id w15-20020a05620a444f00b007296805f607sm10622037qkp.17.2023.02.07.14.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 14:52:15 -0800 (PST) From: Xin Long To: network dev , dev@openvswitch.org Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Pravin B Shelar , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Pablo Neira Ayuso , Florian Westphal , Marcelo Ricardo Leitner , Ilya Maximets , Aaron Conole Subject: [PATCHv2 net-next 3/5] openvswitch: move key and ovs_cb update out of handle_fragments Date: Tue, 7 Feb 2023 17:52:08 -0500 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch has no functional changes and just moves key and ovs_cb update out of handle_fragments, and skb_clear_hash() and skb->ignore_df change into handle_fragments(), to make it easier to move the duplicate code from handle_fragments() into nf_conntrack_ovs later. Note that it changes to pass info->family to handle_fragments() instead of key for the packet type check, as info->family is set according to key->eth.type in ovs_ct_copy_action() when creating the action. Signed-off-by: Xin Long Reviewed-by: Simon Horman Reviewed-by: Aaron Conole --- net/openvswitch/conntrack.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 47a58657b1e4..962e2f70e597 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -437,13 +437,12 @@ static int ovs_ct_set_labels(struct nf_conn *ct, struct sw_flow_key *key, /* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero * value if 'skb' is freed. */ -static int handle_fragments(struct net *net, struct sw_flow_key *key, - u16 zone, struct sk_buff *skb) +static int handle_fragments(struct net *net, struct sk_buff *skb, + u16 zone, u8 family, u8 *proto, u16 *mru) { - struct ovs_skb_cb ovs_cb = *OVS_CB(skb); int err; - if (key->eth.type == htons(ETH_P_IP)) { + if (family == NFPROTO_IPV4) { enum ip_defrag_users user = IP_DEFRAG_CONNTRACK_IN + zone; memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); @@ -451,9 +450,9 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key, if (err) return err; - ovs_cb.mru = IPCB(skb)->frag_max_size; + *mru = IPCB(skb)->frag_max_size; #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) - } else if (key->eth.type == htons(ETH_P_IPV6)) { + } else if (family == NFPROTO_IPV6) { enum ip6_defrag_users user = IP6_DEFRAG_CONNTRACK_IN + zone; memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm)); @@ -464,22 +463,35 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key, return err; } - key->ip.proto = ipv6_hdr(skb)->nexthdr; - ovs_cb.mru = IP6CB(skb)->frag_max_size; + *proto = ipv6_hdr(skb)->nexthdr; + *mru = IP6CB(skb)->frag_max_size; #endif } else { kfree_skb(skb); return -EPFNOSUPPORT; } + skb_clear_hash(skb); + skb->ignore_df = 1; + + return 0; +} + +static int ovs_ct_handle_fragments(struct net *net, struct sw_flow_key *key, + u16 zone, int family, struct sk_buff *skb) +{ + struct ovs_skb_cb ovs_cb = *OVS_CB(skb); + int err; + + err = handle_fragments(net, skb, zone, family, &key->ip.proto, &ovs_cb.mru); + if (err) + return err; + /* The key extracted from the fragment that completed this datagram * likely didn't have an L4 header, so regenerate it. */ ovs_flow_key_update_l3l4(skb, key); - key->ip.frag = OVS_FRAG_TYPE_NONE; - skb_clear_hash(skb); - skb->ignore_df = 1; *OVS_CB(skb) = ovs_cb; return 0; @@ -1111,7 +1123,8 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb, } if (key->ip.frag != OVS_FRAG_TYPE_NONE) { - err = handle_fragments(net, key, info->zone.id, skb); + err = ovs_ct_handle_fragments(net, key, info->zone.id, + info->family, skb); if (err) return err; }