From patchwork Thu Sep 19 21:26:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1164883 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="V5IutmnG"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Z90C5S2cz9sNf for ; Fri, 20 Sep 2019 07:26:51 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5F137CCA; Thu, 19 Sep 2019 21:26:16 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 1A816CC1 for ; Thu, 19 Sep 2019 21:26:15 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8E5BD86E for ; Thu, 19 Sep 2019 21:26:14 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id q10so3145945pfl.0 for ; Thu, 19 Sep 2019 14:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JX8sqWsKleyS+qRbGych6C6cUwbwNVqYjWahd3Ljomw=; b=V5IutmnGE3G7sB0nDNQZl+nx2YFhxg/EIoCZkxqXQ3upntPmMhfILcvNFKnhdh7zWf vZ5wWdncotCVQ/ybvj3GmCXg6hFQTB5DAPuILDD+yfwHihV2XGQOUEiXEI6s8JBej9pz tom00vvFOhxV3UbMLssMC3+aRfqrIiNch2ivocKQBTiSYaXCfyOEdUl5YMbOrF/h7NLw uvTF82Sn16ZXPWh8ydNu6S5DPwyGb0BU+2nGvAX0Guljqbd/+1t7C4TtZUI7lgdGP2nG G7oOe9zwEVrYbxT6Zyb/fVLLIXIPjL5LVaXRLjrpkNYXt4wpheyYO20J+VCQDitb0KtF jCDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JX8sqWsKleyS+qRbGych6C6cUwbwNVqYjWahd3Ljomw=; b=i+C/paiMlzJ9PPyafiOUUZABf2jM0A+WmiHVjodEatiFnHR9KcOnjF9nFAE/871u9q PJYjaYxR4L/0eAKr/6gif344a/FgJK3ePun4NajwmwsyV54KWu6jrC4uAq6VpvEv+6J2 XTSia18hxkoUNTHKr0XlDlnuxwUO0n89nfgU2W0vDz6gSkpyNja43oCcCdrmiR5mY7N/ yin0mis7Es4eNxGk3dvG1RUND43uV+KS/98fM9FSG+92dgzqVCjRXtn0QbC8LqkzH6cP Ku4uppcYf3j2iyaDQtEOk89eCd2bNoxzN4ebW1Nte4yU/RmEVnGzx3BNAa+YTKq9fbDZ vgMA== X-Gm-Message-State: APjAAAWUXif5boYO3ZTO7QzjiCE08v6/Y7+ZtZ08xnx0/tIBIHt8nbXu 3AqzdZzv3BIKB+mW2Xtg/nIjY2oe X-Google-Smtp-Source: APXvYqxIJkskHdcqzULl8bDD0BBMUzBwXw2cmuYTq0oeB0SonSMR9GNzSfqnA+IWmEuxmiEFrz5bXQ== X-Received: by 2002:a63:115c:: with SMTP id 28mr11107592pgr.69.1568928373631; Thu, 19 Sep 2019 14:26:13 -0700 (PDT) Received: from gizo.domain (97-115-119-26.ptld.qwest.net. [97.115.119.26]) by smtp.gmail.com with ESMTPSA id j9sm3072601pjn.3.2019.09.19.14.26.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Sep 2019 14:26:12 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org, vishal.deep.ajmera@ericsson.com Date: Thu, 19 Sep 2019 14:26:10 -0700 Message-Id: <1568928370-14241-1-git-send-email-gvrose8192@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH branch-2.8] compat: Fixup ipv6 fragmentation on 4.9.135+ kernels X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Upstream commit 648700f76b03 ("inet: frags: use rhashtables...") changed how ipv6 fragmentation is implemented. This patch was backported to the upstream stable 4.9.x kernel starting at 4.9.135. This patch creates the compatibility layer changes required to both compile and also operate correctly with ipv6 fragmentation on these kernels. Check if the inet_frags 'rnd' field is present to key on whether the upstream patch is present. Also update Travis to the latest 4.9 kernel release so that this patch is compile tested. Passes Travis with just a few unrelated errors: https://travis-ci.org/gvrose8192/ovs-experimental/builds/587124329 Cc: William Tu Cc: Yi-Hung Wei Cc: Yifeng Sun Acked-by: Yi-Hung Wei Signed-off-by: Greg Rose Signed-off-by: Ben Pfaff --- .travis.yml | 2 +- acinclude.m4 | 3 ++ datapath/linux/compat/nf_conntrack_reasm.c | 54 ++++++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 935424b..37ed0bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ env: - KERNEL=3.16.46 DPDK=1 OPTS="--enable-shared" - KERNEL=4.12.2 - KERNEL=4.11.11 - - KERNEL=4.9.38 + - KERNEL=4.9.149 - KERNEL=4.4.77 - KERNEL=4.1.42 - KERNEL=3.10.107 diff --git a/acinclude.m4 b/acinclude.m4 index e0dca2a..8a515d6 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -769,6 +769,9 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_helper.h], [nf_conntrack_helper_put], [OVS_DEFINE(HAVE_NF_CONNTRACK_HELPER_PUT)]) + OVS_FIND_FIELD_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frags], + [rnd], + [OVS_DEFINE([HAVE_INET_FRAGS_RND])]) if cmp -s datapath/linux/kcompat.h.new \ datapath/linux/kcompat.h >/dev/null 2>&1; then diff --git a/datapath/linux/compat/nf_conntrack_reasm.c b/datapath/linux/compat/nf_conntrack_reasm.c index ce13112..9d77d98 100644 --- a/datapath/linux/compat/nf_conntrack_reasm.c +++ b/datapath/linux/compat/nf_conntrack_reasm.c @@ -99,6 +99,7 @@ static inline u8 ip6_frag_ecn(const struct ipv6hdr *ipv6h) return 1 << (ipv6_get_dsfield(ipv6h) & INET_ECN_MASK); } +#ifdef HAVE_INET_FRAGS_RND static unsigned int nf_hash_frag(__be32 id, const struct in6_addr *saddr, const struct in6_addr *daddr) { @@ -125,6 +126,7 @@ static unsigned int nf_hashfn(struct inet_frag_queue *q) return nf_hash_frag(nq->id, &nq->saddr, &nq->daddr); } +#endif /* HAVE_INET_FRAGS_RND */ static void nf_ct_frag6_expire(unsigned long data) { struct frag_queue *fq; @@ -133,9 +135,14 @@ static void nf_ct_frag6_expire(unsigned long data) fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q); net = get_net_from_netns_frags6(fq->q.net); +#ifdef HAVE_INET_FRAGS_RND ip6_expire_frag_queue(net, fq, &nf_frags); +#else + ip6_expire_frag_queue(net, fq); +#endif } +#ifdef HAVE_INET_FRAGS_RND /* Creation primitives. */ static inline struct frag_queue *fq_find(struct net *net, __be32 id, u32 user, struct in6_addr *src, @@ -168,7 +175,27 @@ static inline struct frag_queue *fq_find(struct net *net, __be32 id, } return container_of(q, struct frag_queue, q); } +#else +static struct frag_queue *fq_find(struct net *net, __be32 id, u32 user, + const struct ipv6hdr *hdr, int iif) +{ + struct frag_v6_compare_key key = { + .id = id, + .saddr = hdr->saddr, + .daddr = hdr->daddr, + .user = user, + .iif = iif, + }; + struct inet_frag_queue *q; + + q = inet_frag_find(&net->nf_frag.frags, &key); + if (!q) + return NULL; + + return container_of(q, struct frag_queue, q); +} +#endif /* HAVE_INET_FRAGS_RND */ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, const struct frag_hdr *fhdr, int nhoff) @@ -317,7 +344,11 @@ found: return 0; discard_fq: +#ifdef HAVE_INET_FRAGS_RND inet_frag_kill(&fq->q, &nf_frags); +#else + inet_frag_kill(&fq->q); +#endif err: return -1; } @@ -339,7 +370,11 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *prev, struct net_devic int payload_len; u8 ecn; +#ifdef HAVE_INET_FRAGS_RND inet_frag_kill(&fq->q, &nf_frags); +#else + inet_frag_kill(&fq->q); +#endif WARN_ON(head == NULL); WARN_ON(NFCT_FRAG6_CB(head)->offset != 0); @@ -561,8 +596,13 @@ int rpl_nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user) #endif skb_orphan(skb); +#ifdef HAVE_INET_FRAGS_RND fq = fq_find(net, fhdr->identification, user, &hdr->saddr, &hdr->daddr, ip6_frag_ecn(hdr)); +#else + fq = fq_find(net, fhdr->identification, user, hdr, + skb->dev ? skb->dev->ifindex : 0); +#endif if (fq == NULL) return -ENOMEM; @@ -584,7 +624,11 @@ int rpl_nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user) out_unlock: spin_unlock_bh(&fq->q.lock); +#ifdef HAVE_INET_FRAGS_RND inet_frag_put(&fq->q, &nf_frags); +#else + inet_frag_put(&fq->q); +#endif return ret; } @@ -614,10 +658,12 @@ void ovs_netns_frags6_init(struct net *net) void ovs_netns_frags6_exit(struct net *net) { +#ifdef HAVE_INET_FRAGS_RND struct netns_frags *frags; frags = get_netns_frags6_from_net(net); inet_frags_exit_net(frags, &nf_frags); +#endif } static struct pernet_operations nf_ct_net_ops = { @@ -634,13 +680,17 @@ int rpl_nf_ct_frag6_init(void) #ifndef HAVE_DEFRAG_ENABLE_TAKES_NET nf_defrag_ipv6_enable(); #endif +#ifdef HAVE_INET_FRAGS_RND nf_frags.hashfn = nf_hashfn; + nf_frags.match = ip6_frag_match; +#else + nf_frags.rhash_params = ip6_rhash_params; +#endif nf_frags.constructor = ip6_frag_init; nf_frags.destructor = NULL; nf_frags.qsize = sizeof(struct frag_queue); - nf_frags.match = ip6_frag_match; nf_frags.frag_expire = nf_ct_frag6_expire; -#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK +#if defined(HAVE_INET_FRAGS_WITH_FRAGS_WORK) || !defined(HAVE_INET_FRAGS_RND) nf_frags.frags_cache_name = nf_frags_cache_name; #endif #if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(8,0)