Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp665326pxb; Fri, 22 Apr 2022 08:50:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsrt+LUPc22FLLoUdlLacRgPzVpgsCFXz/IMQUm1AV1s+KyetMpniJijRCW5+0yXWjOKtg X-Received: by 2002:a65:60c1:0:b0:39d:9c28:909a with SMTP id r1-20020a6560c1000000b0039d9c28909amr4456585pgv.352.1650642651773; Fri, 22 Apr 2022 08:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650642651; cv=none; d=google.com; s=arc-20160816; b=em/M4NAMVpggsxRKRd0QhEzTp/aKYyxQ6hB3dkd7iy4wUIGG0AdvTq5xRq0aMTCjZk 3JOezgREOtZBeKhzxvrUFPon9UGbGox7WdMytMOG2P956Zpj1+N3h85ndk/6/ha2iAI1 MTQqtg++pgfeRtJQ7pcodPs/LUvH0YXijx81g7ohd9X0resbLyV2jRIvj9GmkohLLgkd Ae69NvhXKL4L1yM6ml6zjZbTnQHi+SaLD11jrzHXEqVQ90Oaqyf3sdYQ3ED8kAvVZaCw Pk2Z72qdxiNrIhbQOfYR+LF1Oe+YDLtOB+QaNIb5RTK6G7uiAk0xYisVsgE/cIL5tXA4 g+Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=dHjxXbwqQtvuaoMXA8rnRVhFdDW5Qn6yct5S95Sj8t8=; b=rvPaIV5ttdiY9xNwgGTatRgs8qhPJsks9z8Qw1cgEM8eQgwF/ju1qcWi5JtbG82cWt FaefCWqr2RlP3HZpzfVs/ZhtpXEBoC23jI8WPALt9jqYz1zz6/F4YUQs2CXq29oUqbcT 1CVpd6lVbgODAkR3ND59bakclOW5E3+8m37/hVZZA+LWk5uX/9d/e1diFq8wvJGuYLD/ W1htx7bLOoY6i/Jc9B5A9K72c3lv8rMFCFD0KPqztf2Hz44w/19mxR1V5HpHjQ75EzLL whq14+5+cWfbzTodeTPG4ca9faSrJ2LdHC48sRkNKLsAZAI9MmNv4TpRGyNqQBnuiOE1 bsYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=R0K21wwZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw7-20020a17090b4d0700b001d2a904dad6si13529371pjb.19.2022.04.22.08.50.35; Fri, 22 Apr 2022 08:50:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=R0K21wwZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442337AbiDUWKM (ORCPT + 99 others); Thu, 21 Apr 2022 18:10:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442329AbiDUWKJ (ORCPT ); Thu, 21 Apr 2022 18:10:09 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D8FC43EDA; Thu, 21 Apr 2022 15:07:18 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id d19so4628956qko.3; Thu, 21 Apr 2022 15:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dHjxXbwqQtvuaoMXA8rnRVhFdDW5Qn6yct5S95Sj8t8=; b=R0K21wwZUQgYRQkZyYk2MgjbTh1op68EOEMB7a/0wZzSCvNxKBK3SRr5scZjRjXTUv YgqDfK4ojDnh5VQHbHZ1u39MdB536P2yphnBnttiKbXnAutfBLX8Eio2FVU3PSeEPh/F gMeiRyzfQJxk61Ggkh5gk7XQM1OSWry9buPnbswlOraYP5J5JBsjQhpuTFzgqdeYprKH eGjGGbmllXxtBERoK2KbhVGlUziL9Y3gtCBjpSnPy5QfUeprGtBxqjSMfp0iDJ7AAjMd dxW/qCbFh3K4Qh8VNmCz19Pbo4oXTC1dWK2q/zMqeUJwy+76Q2p34Ddf/7N/sDUxybUJ PBdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dHjxXbwqQtvuaoMXA8rnRVhFdDW5Qn6yct5S95Sj8t8=; b=OqJzbvnwQj96Xk8o+paMQPaHw7R9QPnLi7kl/RB79VfFhhL5RuIdisQ/nYSUelSy62 KVuS0HBZi0oQ/yBAuS3a2qYBYgJeWMo+znm4dYiSNNoO1CmsHQtCaz9OnT0IivUCqI+k +nLNQULQWaJWtv1TEiL2kISEyZEohWZudrYfBK12x7SObaob/5oUYtqYp7gI7i3kfzNU o2bLoIcUOFo1XAPibCx/OMy+y+E0RUe2T8o//wPdR+qWi2cmCMK9mrH+L0AztBNP5TUD 5MW2NC4BaASnhqd193eHF90SwF/5ZwrO/HdMsOs6DUo7rYOcNTq+itxeh52hRtZardRp NtIg== X-Gm-Message-State: AOAM53251cO9kjLtEGH2t9H3I1rv9357i1bvmftX8S+eZxhz26V+U3Vz ti0hKNf96lhlck1/TqWuoQ== X-Received: by 2002:a05:620a:13fc:b0:69e:90a3:e1bc with SMTP id h28-20020a05620a13fc00b0069e90a3e1bcmr941061qkl.645.1650578837697; Thu, 21 Apr 2022 15:07:17 -0700 (PDT) Received: from bytedance.attlocal.net (ec2-13-57-97-131.us-west-1.compute.amazonaws.com. [13.57.97.131]) by smtp.gmail.com with ESMTPSA id b84-20020ae9eb57000000b0069c8ca73b94sm89468qkg.115.2022.04.21.15.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 15:07:17 -0700 (PDT) From: Peilin Ye To: "David S. Miller" , Jakub Kicinski , Hideaki YOSHIFUJI , David Ahern , Paolo Abeni Cc: Peilin Ye , "xeb@mail.ru" , William Tu , Daniel Borkmann , Cong Wang , Eric Dumazet , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Peilin Ye Subject: [PATCH net 0/3] ip_gre, ip6_gre: o_seqno fixes Date: Thu, 21 Apr 2022 15:06:39 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peilin Ye Hi all, As pointed out [1] by Jakub Kicinski, currently using TUNNEL_SEQ in collect_md mode is racy for [IP6]GRE[TAP] devices, since they (typically, e.g. if created using "ip") use lockless TX. Patch [3/3] fixes it by making o_seqno atomic_t. As mentioned by Eric Dumazet in commit b790e01aee74 ("ip_gre: lockless xmit"), making o_seqno atomic_t increases "chance for packets being out of order at receiver" when using lockless TX. Another way to fix it would be: users must specify "external" and "oseq" at the same time if they want the kernel to allow using TUNNEL_SEQ (e.g. via eBPF) in collect_md mode, but that would break userspace. I found another issue while reading the code: patches [1,2/3] make o_seqno start from 0 in native mode, as described in RFC 2890 [2] section 2.2.: "The first datagram is sent with a sequence number of 0." Now we could make [IP6]GRE[TAP] (and probably [IP6]ERSPAN ?) devices completely NETIF_F_LLTX, but that's out of scope of this fix and will be sent as separate [net-next] patches. [1] https://lore.kernel.org/netdev/20220415191133.0597a79a@kernel.org/ [2] https://datatracker.ietf.org/doc/html/rfc2890#section-2.2 Thanks, Peilin Ye (3): ip_gre: Make o_seqno start from 0 in native mode ip6_gre: Make o_seqno start from 0 in native mode ip_gre, ip6_gre: Fix race condition on o_seqno in collect_md mode include/net/ip6_tunnel.h | 2 +- include/net/ip_tunnels.h | 2 +- net/ipv4/ip_gre.c | 12 +++++------- net/ipv6/ip6_gre.c | 16 ++++++++-------- 4 files changed, 15 insertions(+), 17 deletions(-) -- 2.20.1