From patchwork Tue May 29 12:54:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 922072 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="KDahF9sc"; 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 40wDGl0gTPz9s0W for ; Tue, 29 May 2018 22:55:26 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AE00F7A9; Tue, 29 May 2018 12:55:23 +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 76B0788D for ; Tue, 29 May 2018 12:55:22 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B47F56F2 for ; Tue, 29 May 2018 12:55:21 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id e21-v6so6564421pgv.0 for ; Tue, 29 May 2018 05:55:21 -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=SQQg/T38WjNqpfYHzFx0BPqS6hQdbNmt0lKcrzZljWM=; b=KDahF9scOPfW4G18osc9PFscCqZVD/VJz147CO1CJ/l5jU0O8FUsUD+qyvH/WbwMgB Nl+EJdF0jAJmgsYqBi1OiZpP3MP/CRQn2IFIDKwI6m778c54LiEoKahQbglPdUAxB3p7 PzK31BEsJVRlH0CpGQkY7l+V+mOnCa/AscsTugMOXBMfwQTyZRJA/aJBhxq5lN649n5o jpnZ80puolmLlzbzsJ2MBsOuIfPWKknnxjQzNPXOLjCOMTuqS7Tt6FV2tKUiSglN7wD4 lDHSuKI7hbSo9W0WBeTKxg7L79eVsveC6LdryZ4a4ETOuBCbid2/2Bu2hocXSZ3YclfE GOlw== 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=SQQg/T38WjNqpfYHzFx0BPqS6hQdbNmt0lKcrzZljWM=; b=Aa1L4w2ph4r+bN0WWDyUesxOKbUG/p7i32KkKQNs/ugc6czaL2DiuQjCfxbL90wHV+ hRIA/MCb3bCojK9A1HNqGv/QYFi8RQXIeuqzlUg1syEOxYV9cqS0SxA9aW6aciwCKsdy 3NIamoIzhNH8LWEmiIgr4lOB/gP+Kclqfq74bhROeMo3xY6UqfGLiIW7TZACQ8c4TUql tDr2MFut5m4J2ZkrH5fcqANj0x/r/Qt7yQJF0LPQfpD4GPMBlBMa6NV3sqEamFWP+Hr5 IksITyyfCAniS9uTEMXJkzkxkiDStPUd2ltMN0lmU3cu8azk973Xr0nvMf+naAJ5mbQi rhQA== X-Gm-Message-State: ALKqPwcMZRW3+kvH4//vJEJ0Bv/OobRcaoqLrYe/0kahvgEbyK4vo0n6 WDfeTcRJcr02emltPCJ2+cZEa3Sa X-Google-Smtp-Source: AB8JxZo8wJW19pFq+6htErj/0G4X7n7jwmh1lehFhdVcYL86m04OxDu1D7e0q7cnrUlmpF4ABmpHTQ== X-Received: by 2002:a63:7905:: with SMTP id u5-v6mr13690480pgc.411.1527598520874; Tue, 29 May 2018 05:55:20 -0700 (PDT) Received: from ovs.eng.vmware.com ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id l67-v6sm17151739pfj.66.2018.05.29.05.55.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 05:55:20 -0700 (PDT) From: William Tu To: dev@openvswitch.org Date: Tue, 29 May 2018 05:54:58 -0700 Message-Id: <1527598505-22648-1-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 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 1/8] net: ip6_gre: Request headroom in __gre6_xmit() 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: commit 01b8d064d58b4c1f0eff47f8fe8a8508cb3b3840 Author: Petr Machata Date: Thu May 17 16:36:10 2018 +0200 net: ip6_gre: Request headroom in __gre6_xmit() __gre6_xmit() pushes GRE headers before handing over to ip6_tnl_xmit() for generic IP-in-IP processing. However it doesn't make sure that there is enough headroom to push the header to. That can lead to the panic cited below. (Reproducer below that). Fix by requesting either needed_headroom if already primed, or just the bare minimum needed for the header otherwise. [ 158.576725] kernel BUG at net/core/skbuff.c:104! [ 158.581510] invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI [ 158.587174] Modules linked in: act_mirred cls_matchall ip6_gre ip6_tunnel tunnel6 gre sch_ingress vrf veth x86_pkg_t emp_thermal mlx_platform nfsd e1000e leds_mlxcpld [ 158.602268] CPU: 1 PID: 16 Comm: ksoftirqd/1 Not tainted 4.17.0-rc4-net_master-custom-139 #10 [ 158.610938] Hardware name: Mellanox Technologies Ltd. "MSN2410-CB2F"/"SA000874", BIOS 4.6.5 03/08/2016 [ 158.620426] RIP: 0010:skb_panic+0xc3/0x100 [ 158.624586] RSP: 0018:ffff8801d3f27110 EFLAGS: 00010286 [ 158.629882] RAX: 0000000000000082 RBX: ffff8801c02cc040 RCX: 0000000000000000 [ 158.637127] RDX: 0000000000000082 RSI: dffffc0000000000 RDI: ffffed003a7e4e18 [ 158.644366] RBP: ffff8801bfec8020 R08: ffffed003aabce19 R09: ffffed003aabce19 [ 158.651574] R10: 000000000000000b R11: ffffed003aabce18 R12: ffff8801c364de66 [ 158.658786] R13: 000000000000002c R14: 00000000000000c0 R15: ffff8801c364de68 [ 158.666007] FS: 0000000000000000(0000) GS:ffff8801d5400000(0000) knlGS:0000000000000000 [ 158.674212] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 158.680036] CR2: 00007f4b3702dcd0 CR3: 0000000003228002 CR4: 00000000001606e0 [ 158.687228] Call Trace: [ 158.689752] ? __gre6_xmit+0x246/0xd80 [ip6_gre] [ 158.694475] ? __gre6_xmit+0x246/0xd80 [ip6_gre] [ 158.699141] skb_push+0x78/0x90 [ 158.702344] __gre6_xmit+0x246/0xd80 [ip6_gre] [ 158.706872] ip6gre_tunnel_xmit+0x3bc/0x610 [ip6_gre] [ 158.711992] ? __gre6_xmit+0xd80/0xd80 [ip6_gre] [ 158.716668] ? debug_check_no_locks_freed+0x210/0x210 [ 158.721761] ? print_irqtrace_events+0x120/0x120 [ 158.726461] ? sched_clock_cpu+0x18/0x210 [ 158.730572] ? sched_clock_cpu+0x18/0x210 [ 158.734692] ? cyc2ns_read_end+0x10/0x10 [ 158.738705] ? skb_network_protocol+0x76/0x200 [ 158.743216] ? netif_skb_features+0x1b2/0x550 [ 158.747648] dev_hard_start_xmit+0x137/0x770 [ 158.752010] sch_direct_xmit+0x2ef/0x5d0 [ 158.755992] ? pfifo_fast_dequeue+0x3fa/0x670 [ 158.760460] ? pfifo_fast_change_tx_queue_len+0x810/0x810 [ 158.765975] ? __lock_is_held+0xa0/0x160 [ 158.770002] __qdisc_run+0x39e/0xfc0 [ 158.773673] ? _raw_spin_unlock+0x29/0x40 [ 158.777781] ? pfifo_fast_enqueue+0x24b/0x3e0 [ 158.782191] ? sch_direct_xmit+0x5d0/0x5d0 [ 158.786372] ? pfifo_fast_dequeue+0x670/0x670 [ 158.790818] ? __dev_queue_xmit+0x172/0x1770 [ 158.795195] ? preempt_count_sub+0xf/0xd0 [ 158.799313] __dev_queue_xmit+0x410/0x1770 [ 158.803512] ? ___slab_alloc+0x605/0x930 [ 158.807525] ? ___slab_alloc+0x605/0x930 [ 158.811540] ? memcpy+0x34/0x50 [ 158.814768] ? netdev_pick_tx+0x1c0/0x1c0 [ 158.818895] ? __skb_clone+0x2fd/0x3d0 [ 158.822712] ? __copy_skb_header+0x270/0x270 [ 158.827079] ? rcu_read_lock_sched_held+0x93/0xa0 [ 158.831903] ? kmem_cache_alloc+0x344/0x4d0 [ 158.836199] ? skb_clone+0x123/0x230 [ 158.839869] ? skb_split+0x820/0x820 [ 158.843521] ? tcf_mirred+0x554/0x930 [act_mirred] [ 158.848407] tcf_mirred+0x554/0x930 [act_mirred] [ 158.853104] ? tcf_mirred_act_wants_ingress.part.2+0x10/0x10 [act_mirred] [ 158.860005] ? __lock_acquire+0x706/0x26e0 [ 158.864162] ? mark_lock+0x13d/0xb40 [ 158.867832] tcf_action_exec+0xcf/0x2a0 [ 158.871736] tcf_classify+0xfa/0x340 [ 158.875402] __netif_receive_skb_core+0x8e1/0x1c60 [ 158.880334] ? nf_ingress+0x500/0x500 [ 158.884059] ? process_backlog+0x347/0x4b0 [ 158.888241] ? lock_acquire+0xd8/0x320 [ 158.892050] ? process_backlog+0x1b6/0x4b0 [ 158.896228] ? process_backlog+0xc2/0x4b0 [ 158.900291] process_backlog+0xc2/0x4b0 [ 158.904210] net_rx_action+0x5cc/0x980 [ 158.908047] ? napi_complete_done+0x2c0/0x2c0 [ 158.912525] ? rcu_read_unlock+0x80/0x80 [ 158.916534] ? __lock_is_held+0x34/0x160 [ 158.920541] __do_softirq+0x1d4/0x9d2 [ 158.924308] ? trace_event_raw_event_irq_handler_exit+0x140/0x140 [ 158.930515] run_ksoftirqd+0x1d/0x40 [ 158.934152] smpboot_thread_fn+0x32b/0x690 [ 158.938299] ? sort_range+0x20/0x20 [ 158.941842] ? preempt_count_sub+0xf/0xd0 [ 158.945940] ? schedule+0x5b/0x140 [ 158.949412] kthread+0x206/0x300 [ 158.952689] ? sort_range+0x20/0x20 [ 158.956249] ? kthread_stop+0x570/0x570 [ 158.960164] ret_from_fork+0x3a/0x50 [ 158.963823] Code: 14 3e ff 8b 4b 78 55 4d 89 f9 41 56 41 55 48 c7 c7 a0 cf db 82 41 54 44 8b 44 24 2c 48 8b 54 24 30 48 8b 74 24 20 e8 16 94 13 ff <0f> 0b 48 c7 c7 60 8e 1f 85 48 83 c4 20 e8 55 ef a6 ff 89 74 24 [ 158.983235] RIP: skb_panic+0xc3/0x100 RSP: ffff8801d3f27110 [ 158.988935] ---[ end trace 5af56ee845aa6cc8 ]--- [ 158.993641] Kernel panic - not syncing: Fatal exception in interrupt [ 159.000176] Kernel Offset: disabled [ 159.003767] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]--- Reproducer: ip link add h1 type veth peer name swp1 ip link add h3 type veth peer name swp3 ip link set dev h1 up ip address add 192.0.2.1/28 dev h1 ip link add dev vh3 type vrf table 20 ip link set dev h3 master vh3 ip link set dev vh3 up ip link set dev h3 up ip link set dev swp3 up ip address add dev swp3 2001:db8:2::1/64 ip link set dev swp1 up tc qdisc add dev swp1 clsact ip link add name gt6 type ip6gretap \ local 2001:db8:2::1 remote 2001:db8:2::2 ip link set dev gt6 up sleep 1 tc filter add dev swp1 ingress pref 1000 matchall skip_hw \ action mirred egress mirror dev gt6 ping -I h1 192.0.2.2 Fixes: c12b395a4664 ("gre: Support GRE over IPv6") Signed-off-by: Petr Machata Acked-by: William Tu Signed-off-by: David S. Miller Cc: Greg Rose Signed-off-by: William Tu Reviewed-by: Greg Rose Tested-by: Greg Rose --- datapath/linux/compat/ip6_gre.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c index c48c389d6c0b..be981cda4870 100644 --- a/datapath/linux/compat/ip6_gre.c +++ b/datapath/linux/compat/ip6_gre.c @@ -848,6 +848,9 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb, if (tunnel->parms.o_flags & TUNNEL_SEQ) tunnel->o_seqno++; + if (skb_cow_head(skb, dev->needed_headroom ?: tunnel->hlen)) + return -ENOMEM; + /* Push GRE header. */ protocol = (dev->type == ARPHRD_ETHER) ? htons(ETH_P_TEB) : proto; From patchwork Tue May 29 12:54:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 922073 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="B5i7+SOc"; 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 40wDHK5CMJz9s0W for ; Tue, 29 May 2018 22:55:57 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D5336927; Tue, 29 May 2018 12:55:25 +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 96EB615 for ; Tue, 29 May 2018 12:55:23 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl0-f68.google.com (mail-pl0-f68.google.com [209.85.160.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id ED5A36F2 for ; Tue, 29 May 2018 12:55:22 +0000 (UTC) Received: by mail-pl0-f68.google.com with SMTP id az12-v6so8905931plb.8 for ; Tue, 29 May 2018 05:55:22 -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:in-reply-to:references; bh=IOT1kg1hSvGb3iSyQXec6gly0YHYByeUsHERLzWndM4=; b=B5i7+SOcL1SoGX8CsR3Hk/GsaS6iStjsU1bsHWnoX/DSMylLHtYyylHWDglsENctXx gyiMcXr9agYY1TdiZJOFg0eOjikThLQ4O5XLV7ra88V7VHC0SRf6UncnG7Iqj6lAGdpr m3tIGaHkSvusePZ1joAsDMVp86afrsGnMk9iOijTV/tC1eqvw5BSicqlgedVsGAGYJ59 gQGEKz6OK5Q1nqozZ4P6/nQloimk2XbJUr0HLF/YelmGDEVOtXxOl7J05vQuamYBC8Ey aP4DA5xQWEB7wQtO/oVf5XOvOjLJMYYSSN40c9sAqzkDfJBJ62XzFmXcJQnKz7eXvZ05 8TXg== 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:in-reply-to :references; bh=IOT1kg1hSvGb3iSyQXec6gly0YHYByeUsHERLzWndM4=; b=Xi0k+EncKFVbYoswWIwRgaNQxU2nZKxM5KKDLFmgrgOXx5SXoRPMRDbFksCmKfBHeZ hJ3oFGe3HM6VdxcNgnb2p2aJ+4LSZCKkomHBfDCGfF2VNVYnZwjItUS5hqKymal4jicU XYUim2wAvwwEiQLqBdI0NEOHzL5PVl4pdB9GTNGmeqA8l3yGUHRo82eaNsekLv0V+oms PyoGcXqyI+uLwZVz3Q1fyA+CKGTwjgOpqqBWwofqaCRfJuT0ERfJmtJaI0aRUjPntuO9 yPS34VaE5uSxGKpxsSIkwFreOtB9eFfO3Guj0FlzcnhQ0KR67R/M51QbC7APSRArqjvU N2Hw== X-Gm-Message-State: ALKqPweJyqUwyNrOnmxo9udY16NxD2FHlHsDWkxit9n7qtnrPEq9WC47 4xISfLopi2DL1nyfvVorSknd2Nii X-Google-Smtp-Source: AB8JxZqozBw/alfYSiGLhARv98vybE5termpnQdBSJy3mvf+jIR7HjIj8ivbsFRL0feI2Xk36x4CBA== X-Received: by 2002:a17:902:42a3:: with SMTP id h32-v6mr17706426pld.72.1527598522126; Tue, 29 May 2018 05:55:22 -0700 (PDT) Received: from ovs.eng.vmware.com ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id l67-v6sm17151739pfj.66.2018.05.29.05.55.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 05:55:21 -0700 (PDT) From: William Tu To: dev@openvswitch.org Date: Tue, 29 May 2018 05:54:59 -0700 Message-Id: <1527598505-22648-2-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527598505-22648-1-git-send-email-u9012063@gmail.com> References: <1527598505-22648-1-git-send-email-u9012063@gmail.com> 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 2/8] net: ip6_gre: Fix headroom request in ip6erspan_tunnel_xmit() 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 commit 5691484df961aff897d824bcc26cd1a2aa036b5b Author: Petr Machata Date: Thu May 17 16:36:15 2018 +0200 net: ip6_gre: Fix headroom request in ip6erspan_tunnel_xmit() dev->needed_headroom is not primed until ip6_tnl_xmit(), so it starts out zero. Thus the call to skb_cow_head() fails to actually make sure there's enough headroom to push the ERSPAN headers to. That can lead to the panic cited below. (Reproducer below that). Fix by requesting either needed_headroom if already primed, or just the bare minimum needed for the header otherwise. [ 190.703567] kernel BUG at net/core/skbuff.c:104! [ 190.708384] invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI [ 190.714007] Modules linked in: act_mirred cls_matchall ip6_gre ip6_tunnel tunnel6 gre sch_ingress vrf veth x86_pkg_t emp_thermal mlx_platform nfsd e1000e leds_mlxcpld [ 190.728975] CPU: 1 PID: 959 Comm: kworker/1:2 Not tainted 4.17.0-rc4-net_master-custom-139 #10 [ 190.737647] Hardware name: Mellanox Technologies Ltd. "MSN2410-CB2F"/"SA000874", BIOS 4.6.5 03/08/2016 [ 190.747006] Workqueue: ipv6_addrconf addrconf_dad_work [ 190.752222] RIP: 0010:skb_panic+0xc3/0x100 [ 190.756358] RSP: 0018:ffff8801d54072f0 EFLAGS: 00010282 [ 190.761629] RAX: 0000000000000085 RBX: ffff8801c1a8ecc0 RCX: 0000000000000000 [ 190.768830] RDX: 0000000000000085 RSI: dffffc0000000000 RDI: ffffed003aa80e54 [ 190.776025] RBP: ffff8801bd1ec5a0 R08: ffffed003aabce19 R09: ffffed003aabce19 [ 190.783226] R10: 0000000000000001 R11: ffffed003aabce18 R12: ffff8801bf695dbe [ 190.790418] R13: 0000000000000084 R14: 00000000000006c0 R15: ffff8801bf695dc8 [ 190.797621] FS: 0000000000000000(0000) GS:ffff8801d5400000(0000) knlGS:0000000000000000 [ 190.805786] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 190.811582] CR2: 000055fa929aced0 CR3: 0000000003228004 CR4: 00000000001606e0 [ 190.818790] Call Trace: [ 190.821264] [ 190.823314] ? ip6erspan_tunnel_xmit+0x5e4/0x1982 [ip6_gre] [ 190.828940] ? ip6erspan_tunnel_xmit+0x5e4/0x1982 [ip6_gre] [ 190.834562] skb_push+0x78/0x90 [ 190.837749] ip6erspan_tunnel_xmit+0x5e4/0x1982 [ip6_gre] [ 190.843219] ? ip6gre_tunnel_ioctl+0xd90/0xd90 [ip6_gre] [ 190.848577] ? debug_check_no_locks_freed+0x210/0x210 [ 190.853679] ? debug_check_no_locks_freed+0x210/0x210 [ 190.858783] ? print_irqtrace_events+0x120/0x120 [ 190.863451] ? sched_clock_cpu+0x18/0x210 [ 190.867496] ? cyc2ns_read_end+0x10/0x10 [ 190.871474] ? skb_network_protocol+0x76/0x200 [ 190.875977] dev_hard_start_xmit+0x137/0x770 [ 190.880317] ? do_raw_spin_trylock+0x6d/0xa0 [ 190.884624] sch_direct_xmit+0x2ef/0x5d0 [ 190.888589] ? pfifo_fast_dequeue+0x3fa/0x670 [ 190.892994] ? pfifo_fast_change_tx_queue_len+0x810/0x810 [ 190.898455] ? __lock_is_held+0xa0/0x160 [ 190.902422] __qdisc_run+0x39e/0xfc0 [ 190.906041] ? _raw_spin_unlock+0x29/0x40 [ 190.910090] ? pfifo_fast_enqueue+0x24b/0x3e0 [ 190.914501] ? sch_direct_xmit+0x5d0/0x5d0 [ 190.918658] ? pfifo_fast_dequeue+0x670/0x670 [ 190.923047] ? __dev_queue_xmit+0x172/0x1770 [ 190.927365] ? preempt_count_sub+0xf/0xd0 [ 190.931421] __dev_queue_xmit+0x410/0x1770 [ 190.935553] ? ___slab_alloc+0x605/0x930 [ 190.939524] ? print_irqtrace_events+0x120/0x120 [ 190.944186] ? memcpy+0x34/0x50 [ 190.947364] ? netdev_pick_tx+0x1c0/0x1c0 [ 190.951428] ? __skb_clone+0x2fd/0x3d0 [ 190.955218] ? __copy_skb_header+0x270/0x270 [ 190.959537] ? rcu_read_lock_sched_held+0x93/0xa0 [ 190.964282] ? kmem_cache_alloc+0x344/0x4d0 [ 190.968520] ? cyc2ns_read_end+0x10/0x10 [ 190.972495] ? skb_clone+0x123/0x230 [ 190.976112] ? skb_split+0x820/0x820 [ 190.979747] ? tcf_mirred+0x554/0x930 [act_mirred] [ 190.984582] tcf_mirred+0x554/0x930 [act_mirred] [ 190.989252] ? tcf_mirred_act_wants_ingress.part.2+0x10/0x10 [act_mirred] [ 190.996109] ? __lock_acquire+0x706/0x26e0 [ 191.000239] ? sched_clock_cpu+0x18/0x210 [ 191.004294] tcf_action_exec+0xcf/0x2a0 [ 191.008179] tcf_classify+0xfa/0x340 [ 191.011794] __netif_receive_skb_core+0x8e1/0x1c60 [ 191.016630] ? debug_check_no_locks_freed+0x210/0x210 [ 191.021732] ? nf_ingress+0x500/0x500 [ 191.025458] ? process_backlog+0x347/0x4b0 [ 191.029619] ? print_irqtrace_events+0x120/0x120 [ 191.034302] ? lock_acquire+0xd8/0x320 [ 191.038089] ? process_backlog+0x1b6/0x4b0 [ 191.042246] ? process_backlog+0xc2/0x4b0 [ 191.046303] process_backlog+0xc2/0x4b0 [ 191.050189] net_rx_action+0x5cc/0x980 [ 191.053991] ? napi_complete_done+0x2c0/0x2c0 [ 191.058386] ? mark_lock+0x13d/0xb40 [ 191.062001] ? clockevents_program_event+0x6b/0x1d0 [ 191.066922] ? print_irqtrace_events+0x120/0x120 [ 191.071593] ? __lock_is_held+0xa0/0x160 [ 191.075566] __do_softirq+0x1d4/0x9d2 [ 191.079282] ? ip6_finish_output2+0x524/0x1460 [ 191.083771] do_softirq_own_stack+0x2a/0x40 [ 191.087994] [ 191.090130] do_softirq.part.13+0x38/0x40 [ 191.094178] __local_bh_enable_ip+0x135/0x190 [ 191.098591] ip6_finish_output2+0x54d/0x1460 [ 191.102916] ? ip6_forward_finish+0x2f0/0x2f0 [ 191.107314] ? ip6_mtu+0x3c/0x2c0 [ 191.110674] ? ip6_finish_output+0x2f8/0x650 [ 191.114992] ? ip6_output+0x12a/0x500 [ 191.118696] ip6_output+0x12a/0x500 [ 191.122223] ? ip6_route_dev_notify+0x5b0/0x5b0 [ 191.126807] ? ip6_finish_output+0x650/0x650 [ 191.131120] ? ip6_fragment+0x1a60/0x1a60 [ 191.135182] ? icmp6_dst_alloc+0x26e/0x470 [ 191.139317] mld_sendpack+0x672/0x830 [ 191.143021] ? igmp6_mcf_seq_next+0x2f0/0x2f0 [ 191.147429] ? __local_bh_enable_ip+0x77/0x190 [ 191.151913] ipv6_mc_dad_complete+0x47/0x90 [ 191.156144] addrconf_dad_completed+0x561/0x720 [ 191.160731] ? addrconf_rs_timer+0x3a0/0x3a0 [ 191.165036] ? mark_held_locks+0xc9/0x140 [ 191.169095] ? __local_bh_enable_ip+0x77/0x190 [ 191.173570] ? addrconf_dad_work+0x50d/0xa20 [ 191.177886] ? addrconf_dad_work+0x529/0xa20 [ 191.182194] addrconf_dad_work+0x529/0xa20 [ 191.186342] ? addrconf_dad_completed+0x720/0x720 [ 191.191088] ? __lock_is_held+0xa0/0x160 [ 191.195059] ? process_one_work+0x45d/0xe20 [ 191.199302] ? process_one_work+0x51e/0xe20 [ 191.203531] ? rcu_read_lock_sched_held+0x93/0xa0 [ 191.208279] process_one_work+0x51e/0xe20 [ 191.212340] ? pwq_dec_nr_in_flight+0x200/0x200 [ 191.216912] ? get_lock_stats+0x4b/0xf0 [ 191.220788] ? preempt_count_sub+0xf/0xd0 [ 191.224844] ? worker_thread+0x219/0x860 [ 191.228823] ? do_raw_spin_trylock+0x6d/0xa0 [ 191.233142] worker_thread+0xeb/0x860 [ 191.236848] ? process_one_work+0xe20/0xe20 [ 191.241095] kthread+0x206/0x300 [ 191.244352] ? process_one_work+0xe20/0xe20 [ 191.248587] ? kthread_stop+0x570/0x570 [ 191.252459] ret_from_fork+0x3a/0x50 [ 191.256082] Code: 14 3e ff 8b 4b 78 55 4d 89 f9 41 56 41 55 48 c7 c7 a0 cf db 82 41 54 44 8b 44 24 2c 48 8b 54 24 30 48 8b 74 24 20 e8 16 94 13 ff <0f> 0b 48 c7 c7 60 8e 1f 85 48 83 c4 20 e8 55 ef a6 ff 89 74 24 [ 191.275327] RIP: skb_panic+0xc3/0x100 RSP: ffff8801d54072f0 [ 191.281024] ---[ end trace 7ea51094e099e006 ]--- [ 191.285724] Kernel panic - not syncing: Fatal exception in interrupt [ 191.292168] Kernel Offset: disabled [ 191.295697] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]--- Reproducer: ip link add h1 type veth peer name swp1 ip link add h3 type veth peer name swp3 ip link set dev h1 up ip address add 192.0.2.1/28 dev h1 ip link add dev vh3 type vrf table 20 ip link set dev h3 master vh3 ip link set dev vh3 up ip link set dev h3 up ip link set dev swp3 up ip address add dev swp3 2001:db8:2::1/64 ip link set dev swp1 up tc qdisc add dev swp1 clsact ip link add name gt6 type ip6erspan \ local 2001:db8:2::1 remote 2001:db8:2::2 oseq okey 123 ip link set dev gt6 up sleep 1 tc filter add dev swp1 ingress pref 1000 matchall skip_hw \ action mirred egress mirror dev gt6 ping -I h1 192.0.2.2 Fixes: e41c7c68ea77 ("ip6erspan: make sure enough headroom at xmit.") Signed-off-by: Petr Machata Acked-by: William Tu Signed-off-by: David S. Miller Cc: Greg Rose Signed-off-by: William Tu Reviewed-by: Greg Rose Tested-by: Greg Rose --- datapath/linux/compat/ip6_gre.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c index be981cda4870..90dddece61c4 100644 --- a/datapath/linux/compat/ip6_gre.c +++ b/datapath/linux/compat/ip6_gre.c @@ -1103,7 +1103,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb, (ntohs(ipv6_hdr(skb)->payload_len) > skb->len - thoff)) truncate = true; - if (skb_cow_head(skb, dev->needed_headroom)) + if (skb_cow_head(skb, dev->needed_headroom ? : t->hlen)) goto tx_err; t->parms.o_flags &= ~TUNNEL_KEY; From patchwork Tue May 29 12:55:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 922074 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="SjgUPgY2"; 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 40wDHw47JLz9s0W for ; Tue, 29 May 2018 22:56:28 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id DD5B0951; Tue, 29 May 2018 12:55:26 +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 9BF7D84B for ; Tue, 29 May 2018 12:55:24 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl0-f65.google.com (mail-pl0-f65.google.com [209.85.160.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 27FE36F2 for ; Tue, 29 May 2018 12:55:24 +0000 (UTC) Received: by mail-pl0-f65.google.com with SMTP id t12-v6so8908576plo.7 for ; Tue, 29 May 2018 05:55:23 -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:in-reply-to:references; bh=qGffXmDiBKXoOVSp8CoakSzTKjA+6a8R337Pfff0TJk=; b=SjgUPgY2uGP2nrRDOdULinTQgUWhDXqKCuNkingut26SBhC9AqF4o8+ZdBqHU+bNJQ FgaBO8bQy3jBLicjnmFFQE1+OetBfHmfC8fbQbEQiKZyA6gi5WbQzNuVlyWFN3BBf1Hk mLXRXxwxUCJ6k7czajs9uvq3ZDabgtQtO2nRto8DYjNwnEBZewrpcN/IZiuD+DuHBY5D 5MAyZSEMbBtVCSYMp1+nZIQVSlYCwhwC4D5Vy2faExUDYu6S0lPp56A9LqNJ+/A00naW Adtnhn+iL6SJUm+/u9Mn4ZwCvGzfFbJ7yq+sj9QGmLTWXccYuz3c062DtIR286TRRbC0 Zr6A== 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:in-reply-to :references; bh=qGffXmDiBKXoOVSp8CoakSzTKjA+6a8R337Pfff0TJk=; b=jlz+5eBoN5l4NogZ5MTw7HUeHsECzMvZxUPTCH3Dl0NR8tAEShCUfbxGwK908ELXrt a0rVP7fbXbEE/+WR431gtGYQQtNANHb/ZTK8qEr/ujM2vC12F9sywCgvbV+RuSMJQxlb BRLzohDfKkoJb88TzLvgTy8jEwKNnJsVF0ry0lM27FNZqfzb9UdSyWK4Pebzl56FAP/A KSCTO8jvK5ZXWI5Gvc6N3UpmvBZQEjNtrMK7o7VfRB7zPGkQxOELY7a8ShIdoOqls0uY pz2KQZe2Eh0FdI8f9madRrZk4yPYKZ1dcnnG6WXkrQeJ3/32St0yX252duDEXL9edZW5 1vqg== X-Gm-Message-State: ALKqPweoTdy4FOSil2pUd5ibb9agUG/q/60iSuhSioxSGWmXktWOI41S 1QCTn/3Ub3SjP5E1chjD9okBaZn9 X-Google-Smtp-Source: AB8JxZpWz69aQ/UQLW7EchTD8yjr6ZuFXv0CdQBa1meZhJrFpgFyixlcjJco97NygWHNaHdW8TxQMg== X-Received: by 2002:a17:902:c5:: with SMTP id a63-v6mr17586355pla.149.1527598523472; Tue, 29 May 2018 05:55:23 -0700 (PDT) Received: from ovs.eng.vmware.com ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id l67-v6sm17151739pfj.66.2018.05.29.05.55.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 05:55:22 -0700 (PDT) From: William Tu To: dev@openvswitch.org Date: Tue, 29 May 2018 05:55:00 -0700 Message-Id: <1527598505-22648-3-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527598505-22648-1-git-send-email-u9012063@gmail.com> References: <1527598505-22648-1-git-send-email-u9012063@gmail.com> 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 3/8] net: ip6_gre: Split up ip6gre_tnl_link_config() 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 commit a483373ead61e6079bc8ebe27e2dfdb2e3c1559f Author: Petr Machata Date: Thu May 17 16:36:27 2018 +0200 net: ip6_gre: Split up ip6gre_tnl_link_config() The function ip6gre_tnl_link_config() is used for setting up configuration of both ip6gretap and ip6erspan tunnels. Split the function into the common part and the route-lookup part. The latter then takes the calculated header length as an argument. This split will allow the patches down the line to sneak in a custom header length computation for the ERSPAN tunnel. Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support") Signed-off-by: Petr Machata Acked-by: William Tu Signed-off-by: David S. Miller Cc: Greg Rose Signed-off-by: William Tu Reviewed-by: Greg Rose Tested-by: Greg Rose --- datapath/linux/compat/ip6_gre.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c index 90dddece61c4..c55ca56ed4b5 100644 --- a/datapath/linux/compat/ip6_gre.c +++ b/datapath/linux/compat/ip6_gre.c @@ -1183,12 +1183,11 @@ static netdev_tx_t __ip6erspan_tunnel_xmit(struct sk_buff *skb) return ip6erspan_tunnel_xmit(skb, skb->dev); } -static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) +static void ip6gre_tnl_link_config_common(struct ip6_tnl *t) { struct net_device *dev = t->dev; struct __ip6_tnl_parm *p = &t->parms; struct flowi6 *fl6 = &t->fl.u.ip6; - int t_hlen; if (dev->type != ARPHRD_ETHER) { memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr)); @@ -1215,12 +1214,13 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) dev->flags |= IFF_POINTOPOINT; else dev->flags &= ~IFF_POINTOPOINT; +} - t->tun_hlen = gre_calc_hlen(t->parms.o_flags); - - t->hlen = t->encap_hlen + t->tun_hlen; - - t_hlen = t->hlen + sizeof(struct ipv6hdr); +static void ip6gre_tnl_link_config_route(struct ip6_tnl *t, int set_mtu, + int t_hlen) +{ + const struct __ip6_tnl_parm *p = &t->parms; + struct net_device *dev = t->dev; if (p->flags & IP6_TNL_F_CAP_XMIT) { int strict = (ipv6_addr_type(&p->raddr) & @@ -1252,6 +1252,24 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) } } +static int ip6gre_calc_hlen(struct ip6_tnl *tunnel) +{ + int t_hlen; + + tunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags); + tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen; + + t_hlen = tunnel->hlen + sizeof(struct ipv6hdr); + tunnel->dev->hard_header_len = LL_MAX_HEADER + t_hlen; + return t_hlen; +} + +static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) +{ + ip6gre_tnl_link_config_common(t); + ip6gre_tnl_link_config_route(t, set_mtu, ip6gre_calc_hlen(t)); +} + static int ip6gre_tnl_change(struct ip6_tnl *t, const struct __ip6_tnl_parm *p, int set_mtu) { @@ -1553,11 +1571,7 @@ static int ip6gre_tunnel_init_common(struct net_device *dev) return ret; } - tunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags); - tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen; - t_hlen = tunnel->hlen + sizeof(struct ipv6hdr); - - dev->hard_header_len = LL_MAX_HEADER + t_hlen; + t_hlen = ip6gre_calc_hlen(tunnel); dev->mtu = ETH_DATA_LEN - t_hlen; if (dev->type == ARPHRD_ETHER) dev->mtu -= ETH_HLEN; From patchwork Tue May 29 12:55:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 922075 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="EOLYtpBR"; 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 40wDJX2Sz2z9s0W for ; Tue, 29 May 2018 22:57:00 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 09F07BC5; Tue, 29 May 2018 12:55:28 +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 4B04584B for ; Tue, 29 May 2018 12:55:25 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0C6426F2 for ; Tue, 29 May 2018 12:55:24 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id a14-v6so7254468pfi.1 for ; Tue, 29 May 2018 05:55:24 -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:in-reply-to:references; bh=L2vGhNVDVAoKH9SMdKEo2HdzlLb5lFEMgVhdF0Q6rok=; b=EOLYtpBRivjg9guRH132uXDezwMjOPNdj+pDKAJeyFAufR4DZ/kepSTqQT59+LsaPr n3aExjGAMPVoavbplmlbfjqrBYmkkPy2G6I3YaeC0bKIWgwrvXz9NvZCvOt7aaOFmMtc RKjq1PuMZ1j61DVeLZQYEMY3nkk1HPBQQ2rCZPxuHDRsiOs4yw2lV7Uy3I+4oCB6uBHS iCREywAkK/ZzR7jN48b7uM0s9ko4PR5yl9Nc5GkOMrTIj+mBdVGF8C0cb0UzOVnqmRn5 flirSOvhd59RnKpxFpHmt8V7j795xpJpi41h/+TWZXIK3cp94sdARPGRo/Enf4ZF/eHb EVFQ== 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:in-reply-to :references; bh=L2vGhNVDVAoKH9SMdKEo2HdzlLb5lFEMgVhdF0Q6rok=; b=RXDQyUgI0F/DMiOJftvPKU9YMRfhh1IekR9qHwwE5YhVOwHCALvnChO0KPpktZ/tjp LV1yq0+Jc+GeqNSSAS+Sy2zl7hxu2DEnOvwdRPiTUYsz/PrivMEmn6w+osx/dfsgi7F1 +isnb9xS0jO4/WNk1zrrORNl2tnG0a07avHk5WI4Rj2ERBkPyF1OyedL4gLjgky67O76 HEdovBFBMcvp/EWl/jbtqbhk5KLqH5Kb6u4dbTYFecvsh8rwkdgDW4Uzbt4BeA0z1d0X w+3/ueJLcZCHIhbyZDUIPSLxqyhlNhxgMJP8tsJJ+bhnqojmaxCEg3PU+ySJ7n2dWji8 fVFA== X-Gm-Message-State: ALKqPwfPGdjq3ruylOlmyNqPw3lsdYxJ+MFfsqxEv3s1iuEg2X16FknY vWFrdZeaF9eSj8L0MGxY7tOd+rAX X-Google-Smtp-Source: AB8JxZqnsVIrGhHPqkHMqSQ2Tb1BDql/lqg5mF/pVUYfkE8baToZOkvrvEK54JwMWSYbJSzecpYAdg== X-Received: by 2002:a63:2a89:: with SMTP id q131-v6mr13606793pgq.379.1527598524422; Tue, 29 May 2018 05:55:24 -0700 (PDT) Received: from ovs.eng.vmware.com ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id l67-v6sm17151739pfj.66.2018.05.29.05.55.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 05:55:23 -0700 (PDT) From: William Tu To: dev@openvswitch.org Date: Tue, 29 May 2018 05:55:01 -0700 Message-Id: <1527598505-22648-4-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527598505-22648-1-git-send-email-u9012063@gmail.com> References: <1527598505-22648-1-git-send-email-u9012063@gmail.com> 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 4/8] net: ip6_gre: Split up ip6gre_tnl_change() 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 commit a6465350ef495f5cbd76a3e505d25a01d648477e Author: Petr Machata Date: Thu May 17 16:36:33 2018 +0200 net: ip6_gre: Split up ip6gre_tnl_change() Split a reusable function ip6gre_tnl_copy_tnl_parm() from ip6gre_tnl_change(). This will allow ERSPAN-specific code to reuse the common parts while customizing the behavior for ERSPAN. Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support") Signed-off-by: Petr Machata Acked-by: William Tu Signed-off-by: David S. Miller Cc: Greg Rose Signed-off-by: William Tu Reviewed-by: Greg Rose Tested-by: Greg Rose --- datapath/linux/compat/ip6_gre.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c index c55ca56ed4b5..d8c5a83d8531 100644 --- a/datapath/linux/compat/ip6_gre.c +++ b/datapath/linux/compat/ip6_gre.c @@ -1270,8 +1270,8 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) ip6gre_tnl_link_config_route(t, set_mtu, ip6gre_calc_hlen(t)); } -static int ip6gre_tnl_change(struct ip6_tnl *t, - const struct __ip6_tnl_parm *p, int set_mtu) +static void ip6gre_tnl_copy_tnl_parm(struct ip6_tnl *t, + const struct __ip6_tnl_parm *p) { t->parms.laddr = p->laddr; t->parms.raddr = p->raddr; @@ -1287,6 +1287,12 @@ static int ip6gre_tnl_change(struct ip6_tnl *t, t->parms.o_flags = p->o_flags; t->parms.fwmark = p->fwmark; dst_cache_reset(&t->dst_cache); +} + +static int ip6gre_tnl_change(struct ip6_tnl *t, const struct __ip6_tnl_parm *p, + int set_mtu) +{ + ip6gre_tnl_copy_tnl_parm(t, p); ip6gre_tnl_link_config(t, set_mtu); return 0; } From patchwork Tue May 29 12:55:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 922076 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="PtJzWDnj"; 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 40wDKD072vz9s0W for ; Tue, 29 May 2018 22:57:36 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9405EC00; Tue, 29 May 2018 12:55:33 +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 3664115 for ; Tue, 29 May 2018 12:55:26 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D86AA6F8 for ; Tue, 29 May 2018 12:55:25 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id b74-v6so3791959pfl.5 for ; Tue, 29 May 2018 05:55:25 -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:in-reply-to:references; bh=uoRmizr0Ij+xTj6TA3vvd4s4GOjt6mSJwk0DTUWBdRI=; b=PtJzWDnjl7H+DMCYLFpXs01lfDXUYHwjQdFMGg/xe+1pqyqJBufGe7HTn9VN7T8yO6 WQpguG74iCFair2ZYT/Ape0i8Io7NjgEp/7Kkk+NdGW1CERt6dHM8a6iGjdmr1IKwu7d NikYBrtDKWA1qFPEp/6+glhltcsdSZkJT7Zy2CqV8iYcyRGvUkU++YH3KvzqygqV48Wj p8+soD35QvgLsPgyzdNA/IragvslvQQFFh6Ym7chbj13hh8KCkgZTt//tnNAEVqv76pL VF9IeGQhNZmfxAsatn01zMccQCkZ0Y28G4CelLwJ4y6s3PG1wXT8AgRoW1SAq0TeCDkI Qljg== 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:in-reply-to :references; bh=uoRmizr0Ij+xTj6TA3vvd4s4GOjt6mSJwk0DTUWBdRI=; b=gHP1gWxZCAqdKPNTPKjoahvkeoefqWBv6Q5gr9IcSfr6+MuCU9WtgpGKozkTeygolx ILxd9p8yzXQot6hhwEYKYjaVpc4gEzfC+O4COIx2lyppqBlmOM5fRPF/66k+H3nBQxrh KnKZVhe8mqLo/r8C8svE6+AjDYvfq3hvhbxXhBuxtIcuXHbcV3IgwerGsVatMHQHCmSN SlVXHBYy/eRvVjEpVAHthjlA8ikLyUn72n+DEnqcgVEOOv0a9umGyK5fZxwVGAIJ+9p3 t6ieysJeFHuHGe/D1I0EXPaM/9hwLGwQV1/mbUgbTz43BJb/fIVqy8Z04+Bnrz1teQvV kUpQ== X-Gm-Message-State: ALKqPwc5EdAu6stLmg2dUbFpHG221X7UDvh/nVQcVu88PiUTSFwC4XUE zO89/JVRAZC2VxGsYE0pBLhHDp31 X-Google-Smtp-Source: ADUXVKI5XP8XOni61CR/nBP96hiq5bNZdob+oYXuQ4PjJpV1tE/Cm0xERCPPhYlfjHpDf8oy1aRevg== X-Received: by 2002:a62:1fd6:: with SMTP id l83-v6mr8860279pfj.182.1527598525304; Tue, 29 May 2018 05:55:25 -0700 (PDT) Received: from ovs.eng.vmware.com ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id l67-v6sm17151739pfj.66.2018.05.29.05.55.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 05:55:24 -0700 (PDT) From: William Tu To: dev@openvswitch.org Date: Tue, 29 May 2018 05:55:02 -0700 Message-Id: <1527598505-22648-5-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527598505-22648-1-git-send-email-u9012063@gmail.com> References: <1527598505-22648-1-git-send-email-u9012063@gmail.com> 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 5/8] net: ip6_gre: Split up ip6gre_newlink() 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 commit 7fa38a7c852ec99e3a7fc375eb2c21c50c2e46b8 Author: Petr Machata Date: Thu May 17 16:36:39 2018 +0200 net: ip6_gre: Split up ip6gre_newlink() Extract from ip6gre_newlink() a reusable function ip6gre_newlink_common(). The ip6gre_tnl_link_config() call needs to be made customizable for ERSPAN, thus reorder it with calls to ip6_tnl_change_mtu() and dev_hold(), and extract the whole tail to the caller, ip6gre_newlink(). Thus enable an ERSPAN-specific _newlink() function without a lot of duplicity. Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support") Signed-off-by: Petr Machata Acked-by: William Tu Signed-off-by: David S. Miller Cc: Greg Rose Signed-off-by: William Tu Reviewed-by: Greg Rose Tested-by: Greg Rose --- datapath/linux/compat/ip6_gre.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c index d8c5a83d8531..4cd877bcf32e 100644 --- a/datapath/linux/compat/ip6_gre.c +++ b/datapath/linux/compat/ip6_gre.c @@ -2089,11 +2089,11 @@ static bool ip6gre_netlink_encap_parms(struct nlattr *data[], } #ifdef HAVE_IP6GRE_EXTACK -static int rpl_ip6gre_newlink(struct net *src_net, struct net_device *dev, +static int rpl_ip6gre_newlink_common(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) #else -static int rpl_ip6gre_newlink(struct net *src_net, struct net_device *dev, +static int rpl_ip6gre_newlink_common(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[]) #endif { @@ -2132,17 +2132,41 @@ static int rpl_ip6gre_newlink(struct net *src_net, struct net_device *dev, if (err) goto out; - ip6gre_tnl_link_config(nt, !tb[IFLA_MTU]); - if (tb[IFLA_MTU]) ip6_tnl_change_mtu(dev, nla_get_u32(tb[IFLA_MTU])); dev_hold(dev); - ip6gre_tunnel_link(ign, nt); out: return err; } +#define ip6gre_newlink_common rpl_ip6gre_newlink_common + +#ifdef HAVE_IP6GRE_EXTACK +static int rpl_ip6gre_newlink(struct net *src_net, struct net_device *dev, + struct nlattr *tb[], struct nlattr *data[], + struct netlink_ext_ack *extack) +#else +static int rpl_ip6gre_newlink(struct net *src_net, struct net_device *dev, + struct nlattr *tb[], struct nlattr *data[]) +#endif +{ + +#ifdef HAVE_IP6GRE_EXTACK + int err = ip6gre_newlink_common(src_net, dev, tb, data, extack); +#else + int err = ip6gre_newlink_common(src_net, dev, tb, data); +#endif + struct ip6_tnl *nt = netdev_priv(dev); + struct net *net = dev_net(dev); + + if (!err) { + ip6gre_tnl_link_config(nt, !tb[IFLA_MTU]); + ip6gre_tunnel_link(net_generic(net, ip6gre_net_id), nt); + } + return err; +} + #define ip6gre_newlink rpl_ip6gre_newlink #ifdef HAVE_IP6GRE_EXTACK From patchwork Tue May 29 12:55:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 922077 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="POE9lvhe"; 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 40wDKn6FQNz9s0W for ; Tue, 29 May 2018 22:58:05 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C95C2C0C; Tue, 29 May 2018 12:55:34 +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 31871ACC for ; Tue, 29 May 2018 12:55:27 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CC22F6F2 for ; Tue, 29 May 2018 12:55:26 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id p9-v6so6551551pgc.9 for ; Tue, 29 May 2018 05:55:26 -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:in-reply-to:references; bh=FS0sIQsrtsGV/43AGowfWSV3YPpASJZt/iQ8XnFV8WY=; b=POE9lvheOXPOILSMP9+xTQqH2sCXWLVob3+/40k6MnoefsVqhf5IkJ7oKDlv6MK7Nl cCuyq1re3Bl+ya+kJDrN52GrbvaTPpuzEH6fojelClaammIFxEkxB/sK/KnsWTDiS8bG C3+f259J2ZSmOvL4lRubomDiHHFm1DCWnYfLZgss2tONFQjiXgaYU96vVSTsolOS+wmC 0Z6u36ovrOLBQrGKa2IQ9+LIkiTzQwSN+6G9a9rCSlOnzwJbG8coxE+uiFh20DmWCbdo m9FXqTZY6Bw7erK0DDcfEN5qATwACGFxU9ZpHWQPjZDQ7mepOU8aGw2mzxsfwqDjc7tV UwJw== 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:in-reply-to :references; bh=FS0sIQsrtsGV/43AGowfWSV3YPpASJZt/iQ8XnFV8WY=; b=B91g1zGDmUHJX8W/Vwwh7Eh4/LVanGa+9NpuuSR+jEE2XQe7/h5/LFgTN/n9wlvfaQ G6GZhpbHcMAE0TqcWvupPFiB3VviKmwWaeyUquKFQhr7sG+Lx1iHyy0JL/qA/8I/6A+P UhPHAJvVX9WFpBApKgf1DjHINKYkYSeR2JmhsEpa3iN6kyZ6A7DkiNfZHZsiAls904Jo 5Zo0ndV/MjmGCGAIVZ0uL4jNVk41i75lTAg/CmPkAcDbKXP4Gz3GQF/itEC78PfB23UK yJRpzjC2gDVLl153XHN7FehAPONMYS3sqa3wS+4/6RuP9YgWUp4o/97HmhB98oIZ0vTG FySw== X-Gm-Message-State: ALKqPwdcjiefSyRNTy1QSxVgiXJO3k/bWtX4LMGFk3inyqQYoxPjgjKz p+R+rNihUvrKcTRL4CrAGTf9iwYL X-Google-Smtp-Source: AB8JxZpwkCfvhUjSsjkCANPvMz14OrKa9jZljKuwsbuT0AeTvXkKFgtMPkSFl6B6lepa5zD7Gz/Apg== X-Received: by 2002:a62:c6d9:: with SMTP id x86-v6mr17308871pfk.192.1527598526212; Tue, 29 May 2018 05:55:26 -0700 (PDT) Received: from ovs.eng.vmware.com ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id l67-v6sm17151739pfj.66.2018.05.29.05.55.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 05:55:25 -0700 (PDT) From: William Tu To: dev@openvswitch.org Date: Tue, 29 May 2018 05:55:03 -0700 Message-Id: <1527598505-22648-6-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527598505-22648-1-git-send-email-u9012063@gmail.com> References: <1527598505-22648-1-git-send-email-u9012063@gmail.com> 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 6/8] net: ip6_gre: Split up ip6gre_changelink() 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 commit c8632fc30bb03aa0c3bd7bcce85355a10feb8149 Author: Petr Machata Date: Thu May 17 16:36:45 2018 +0200 net: ip6_gre: Split up ip6gre_changelink() Extract from ip6gre_changelink() a reusable function ip6gre_changelink_common(). This will allow introduction of ERSPAN-specific _changelink() function with not a lot of code duplication. Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support") Signed-off-by: Petr Machata Acked-by: William Tu Signed-off-by: David S. Miller Cc: Greg Rose Signed-off-by: William Tu Reviewed-by: Greg Rose Tested-by: Greg Rose --- datapath/linux/compat/ip6_gre.c | 48 +++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c index 4cd877bcf32e..7c06d732285c 100644 --- a/datapath/linux/compat/ip6_gre.c +++ b/datapath/linux/compat/ip6_gre.c @@ -2170,41 +2170,67 @@ static int rpl_ip6gre_newlink(struct net *src_net, struct net_device *dev, #define ip6gre_newlink rpl_ip6gre_newlink #ifdef HAVE_IP6GRE_EXTACK -static int rpl_ip6gre_changelink(struct net_device *dev, struct nlattr *tb[], - struct nlattr *data[], - struct netlink_ext_ack *extack) +static struct ip6_tnl * +rpl_ip6gre_changelink_common(struct net_device *dev, struct nlattr *tb[], + struct nlattr *data[], struct __ip6_tnl_parm *p_p, + struct netlink_ext_ack *extack) #else -static int rpl_ip6gre_changelink(struct net_device *dev, struct nlattr *tb[], - struct nlattr *data[]) +static struct ip6_tnl * +rpl_ip6gre_changelink_common(struct net_device *dev, struct nlattr *tb[], + struct nlattr *data[], struct __ip6_tnl_parm *p_p) #endif { struct ip6_tnl *t, *nt = netdev_priv(dev); struct net *net = nt->net; struct ip6gre_net *ign = net_generic(net, ip6gre_net_id); - struct __ip6_tnl_parm p; struct ip_tunnel_encap ipencap; if (dev == ign->fb_tunnel_dev) - return -EINVAL; + return ERR_PTR(-EINVAL); if (ip6gre_netlink_encap_parms(data, &ipencap)) { int err = ip6_tnl_encap_setup(nt, &ipencap); if (err < 0) - return err; + return ERR_PTR(err); } - ip6gre_netlink_parms(data, &p); + ip6gre_netlink_parms(data, p_p); - t = ip6gre_tunnel_locate(net, &p, 0); + t = ip6gre_tunnel_locate(net, p_p, 0); if (t) { if (t->dev != dev) - return -EEXIST; + return ERR_PTR(-EEXIST); } else { t = nt; } + return t; +} +#define ip6gre_changelink_common rpl_ip6gre_changelink_common + +#ifdef HAVE_IP6GRE_EXTACK +static int rpl_ip6gre_changelink(struct net_device *dev, struct nlattr *tb[], + struct nlattr *data[], + struct netlink_ext_ack *extack) +#else +static int rpl_ip6gre_changelink(struct net_device *dev, struct nlattr *tb[], + struct nlattr *data[]) +#endif +{ + struct ip6gre_net *ign = net_generic(dev_net(dev), ip6gre_net_id); + struct __ip6_tnl_parm p; + struct ip6_tnl *t; + +#ifdef HAVE_IP6GRE_EXTACK + t = ip6gre_changelink_common(dev, tb, data, &p, extack); +#else + t = ip6gre_changelink_common(dev, tb, data, &p); +#endif + if (IS_ERR(t)) + return PTR_ERR(t); + ip6gre_tunnel_unlink(ign, t); ip6gre_tnl_change(t, &p, !tb[IFLA_MTU]); ip6gre_tunnel_link(ign, t); From patchwork Tue May 29 12:55:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 922082 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="t0Ltygk6"; 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 40wDM05pvTz9s0W for ; Tue, 29 May 2018 22:59:08 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 90B0BC21; Tue, 29 May 2018 12:55:41 +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 24F35BCF for ; Tue, 29 May 2018 12:55:29 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DEBC36F8 for ; Tue, 29 May 2018 12:55:27 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id a13-v6so6553095pgu.4 for ; Tue, 29 May 2018 05:55:27 -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:in-reply-to:references; bh=4IzijfizQXmGFCSfgSC/IACYg3RBAqr4Pv/UcHPln/w=; b=t0Ltygk6N44VFNNGTR2EBqIGKItSrXkDpalziOMKbktb5sC3Te0LtFd6FFMMKPEHQM j1EiOY1pureWjSCGiXWx4tCtVGwamsw9Ad4J6l5DZryQeelO5yB/vngi6Fjvd3W89GR0 7Fdf2BfV7MEMbbHxecXDYOYEEZjL4f82eWfeyJQiuqXDTkjLSWGgmkonpZ1Qw8wNvdd/ rrlB2ltYtdrIxBmICbotByI3aloAUn04PpLhutOjgAgELTZJGJ4w/gZhnCm+7nuP/HVT a+XAzCJFx088jgJKw4qudNPQ7zmVOdFiqyQfbmT8rCebPojDdG2tbPWb3L3y33rHnEAZ EjXQ== 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:in-reply-to :references; bh=4IzijfizQXmGFCSfgSC/IACYg3RBAqr4Pv/UcHPln/w=; b=dpTKfA8cTOl6/vL95uFOnbdqQRH192KUfDkk237cnge7Gtjwc20LkBWIQqK3tpUnwD O07+zPBz9mZwaEonfyBt0jqLA0FULx8xvzkDk6RWMfSOSHJWVjM29Si8wmaSTI4NwkoH iZRV87bGa4S8KGg1wAL5AdGaxDlHM4ijd1A2GNEBaV7OR8BjEunAWF729O4J0HrRKiAl 7J69l50otn/7MG5Npb0753rnC94WDs/b66OOaRrOd4Jvh81uttPyCFMTIXdHJWcxpOer rFCSyjK5gK6NNFGAw2ZC2tniEcsiM6OL5AKvTOV/r+8Xo0YmIiLjNRDSyzSU6vrYxmHF QQaQ== X-Gm-Message-State: ALKqPweWY09mkMGeQ84duTqa9nYb6N47t07+DbTwSM3Ieaxfcw2WBQ+e VreUYMxcByZr9B7eij2k5XRjkngi X-Google-Smtp-Source: AB8JxZpcTryj3Lc6VMahm45upkhBo3+RgkMF/MK5wxYwe5dYfu8eddbGSpTimyD/zYTCaL09RbMCPA== X-Received: by 2002:a63:b80a:: with SMTP id p10-v6mr14131105pge.207.1527598527115; Tue, 29 May 2018 05:55:27 -0700 (PDT) Received: from ovs.eng.vmware.com ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id l67-v6sm17151739pfj.66.2018.05.29.05.55.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 05:55:26 -0700 (PDT) From: William Tu To: dev@openvswitch.org Date: Tue, 29 May 2018 05:55:04 -0700 Message-Id: <1527598505-22648-7-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527598505-22648-1-git-send-email-u9012063@gmail.com> References: <1527598505-22648-1-git-send-email-u9012063@gmail.com> 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 7/8] net: ip6_gre: Fix ip6erspan hlen calculation 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 commit 2d665034f239412927b1e71329f20f001c92da09 Author: Petr Machata Date: Thu May 17 16:36:51 2018 +0200 net: ip6_gre: Fix ip6erspan hlen calculation Even though ip6erspan_tap_init() sets up hlen and tun_hlen according to what ERSPAN needs, it goes ahead to call ip6gre_tnl_link_config() which overwrites these settings with GRE-specific ones. Similarly for changelink callbacks, which are handled by ip6gre_changelink() calls ip6gre_tnl_change() calls ip6gre_tnl_link_config() as well. The difference ends up being 12 vs. 20 bytes, and this is generally not a problem, because a 12-byte request likely ends up allocating more and the extra 8 bytes are thus available. However correct it is not. So replace the newlink and changelink callbacks with an ERSPAN-specific ones, reusing the newly-introduced _common() functions. Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support") Signed-off-by: Petr Machata Acked-by: William Tu Signed-off-by: David S. Miller Cc: Greg Rose Signed-off-by: William Tu Reviewed-by: Greg Rose Tested-by: Greg Rose --- datapath/linux/compat/ip6_gre.c | 93 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 84 insertions(+), 9 deletions(-) diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c index 7c06d732285c..3a82c3d0fc6b 100644 --- a/datapath/linux/compat/ip6_gre.c +++ b/datapath/linux/compat/ip6_gre.c @@ -79,6 +79,7 @@ static int ip6gre_tunnel_init(struct net_device *dev); static void ip6gre_tunnel_setup(struct net_device *dev); static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t); static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu); +static void ip6erspan_tnl_link_config(struct ip6_tnl *t, int set_mtu); #define gre_calc_hlen rpl_ip_gre_calc_hlen static int rpl_ip_gre_calc_hlen(__be16 o_flags) @@ -1979,6 +1980,19 @@ static const struct net_device_ops ip6gre_tap_netdev_ops = { #endif }; +static int ip6erspan_calc_hlen(struct ip6_tnl *tunnel) +{ + int t_hlen; + + tunnel->tun_hlen = 8; + tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen + + erspan_hdr_len(tunnel->parms.erspan_ver); + + t_hlen = tunnel->hlen + sizeof(struct ipv6hdr); + tunnel->dev->hard_header_len = LL_MAX_HEADER + t_hlen; + return t_hlen; +} + static int ip6erspan_tap_init(struct net_device *dev) { struct ip6_tnl *tunnel; @@ -2002,12 +2016,7 @@ static int ip6erspan_tap_init(struct net_device *dev) return ret; } - tunnel->tun_hlen = 8; - tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen + - erspan_hdr_len(tunnel->parms.erspan_ver); - t_hlen = tunnel->hlen + sizeof(struct ipv6hdr); - - dev->hard_header_len = LL_MAX_HEADER + t_hlen; + t_hlen = ip6erspan_calc_hlen(tunnel); dev->mtu = ETH_DATA_LEN - t_hlen; if (dev->type == ARPHRD_ETHER) dev->mtu -= ETH_HLEN; @@ -2016,7 +2025,7 @@ static int ip6erspan_tap_init(struct net_device *dev) dev->priv_flags |= IFF_LIVE_ADDR_CHANGE; tunnel = netdev_priv(dev); - ip6gre_tnl_link_config(tunnel, 1); + ip6erspan_tnl_link_config(tunnel, 1); return 0; } @@ -2387,6 +2396,72 @@ static void ip6erspan_tap_setup(struct net_device *dev) netif_keep_dst(dev); } +#ifdef HAVE_IP6GRE_EXTACK +static int rpl_ip6erspan_newlink(struct net *src_net, struct net_device *dev, + struct nlattr *tb[], struct nlattr *data[], + struct netlink_ext_ack *extack) +#else +static int rpl_ip6erspan_newlink(struct net *src_net, struct net_device *dev, + struct nlattr *tb[], struct nlattr *data[]) +#endif +{ +#ifdef HAVE_IP6GRE_EXTACK + int err = ip6gre_newlink_common(src_net, dev, tb, data, extack); +#else + int err = ip6gre_newlink_common(src_net, dev, tb, data); +#endif + struct ip6_tnl *nt = netdev_priv(dev); + struct net *net = dev_net(dev); + + if (!err) { + ip6erspan_tnl_link_config(nt, !tb[IFLA_MTU]); + ip6gre_tunnel_link(net_generic(net, ip6gre_net_id), nt); + } + return err; +} +#define ip6erspan_newlink rpl_ip6erspan_newlink + +static void ip6erspan_tnl_link_config(struct ip6_tnl *t, int set_mtu) +{ + ip6gre_tnl_link_config_common(t); + ip6gre_tnl_link_config_route(t, set_mtu, ip6erspan_calc_hlen(t)); +} + +static int ip6erspan_tnl_change(struct ip6_tnl *t, + const struct __ip6_tnl_parm *p, int set_mtu) +{ + ip6gre_tnl_copy_tnl_parm(t, p); + ip6erspan_tnl_link_config(t, set_mtu); + return 0; +} + +#ifdef HAVE_IP6GRE_EXTACK +static int rpl_ip6erspan_changelink(struct net_device *dev, struct nlattr *tb[], + struct nlattr *data[], + struct netlink_ext_ack *extack) +#else +static int rpl_ip6erspan_changelink(struct net_device *dev, struct nlattr *tb[], + struct nlattr *data[]) +#endif +{ + struct ip6gre_net *ign = net_generic(dev_net(dev), ip6gre_net_id); + struct __ip6_tnl_parm p; + struct ip6_tnl *t; +#ifdef HAVE_IP6GRE_EXTACK + t = ip6gre_changelink_common(dev, tb, data, &p, extack); +#else + t = ip6gre_changelink_common(dev, tb, data, &p); +#endif + if (IS_ERR(t)) + return PTR_ERR(t); + + ip6gre_tunnel_unlink(ign, t); + ip6erspan_tnl_change(t, &p, !tb[IFLA_MTU]); + ip6gre_tunnel_link(ign, t); + return 0; +} +#define ip6erspan_changelink rpl_ip6erspan_changelink + static struct rtnl_link_ops ip6gre_link_ops __read_mostly = { .kind = "ip6gre", .maxtype = RPL_IFLA_GRE_MAX, @@ -2428,8 +2503,8 @@ static struct rtnl_link_ops ip6erspan_tap_ops __read_mostly = { .priv_size = sizeof(struct ip6_tnl), .setup = ip6erspan_tap_setup, .validate = ip6erspan_tap_validate, - .newlink = ip6gre_newlink, - .changelink = ip6gre_changelink, + .newlink = ip6erspan_newlink, + .changelink = ip6erspan_changelink, .dellink = ip6gre_dellink, .get_size = ip6gre_get_size, .fill_info = ip6gre_fill_info, From patchwork Tue May 29 12:55:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 922089 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="j/pUj2t0"; 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 40wDNd5lB0z9s1B for ; Tue, 29 May 2018 23:00:33 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 14D3CC27; Tue, 29 May 2018 12:55:43 +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 82C889CD for ; Tue, 29 May 2018 12:55:29 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E7B4B6F2 for ; Tue, 29 May 2018 12:55:28 +0000 (UTC) Received: by mail-pf0-f194.google.com with SMTP id a22-v6so7245808pfn.6 for ; Tue, 29 May 2018 05:55:28 -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:in-reply-to:references; bh=2jVlrFiLO+oqBhpQLaMi3bllivTxfvvfNvBlZ/zf+cg=; b=j/pUj2t0RxmrI977edu0/4b4HimYiHysCKCUWCF2/EMn8Vit0SEkjbzDeurvhdpdcR YuQ3xFVhQ6rVUIzgFVOH5GftKeay7GHu+2blnM4aayuTcAYDcPjH4hTdCdl3JVudRfAT TLZeCT0ePpnwRUhlt2l0RQheq1fe2Dmc3+z69JhsvBfYlMO2l7nsT7QFsBA8cuDXbRCE PebMkfDK7ZNtgmlqQfn169MLgDSTnayl/VxBg9U8kwGDPUXmIj4Q4z+l7mrzve3DmLCS QLrTEjZ7vpZvuRAFES4IdvINZwxlV6E9Jp1sC5q5yvn2zGZw77RSUHJ6nGep3eYTWVOf +qeQ== 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:in-reply-to :references; bh=2jVlrFiLO+oqBhpQLaMi3bllivTxfvvfNvBlZ/zf+cg=; b=KnJ1XGa5W6R9FdQj37PHZrqUTEmun1vbwNzzr4gPDJWhzwR4zA1GoB+ObOpThVtYBu qVtHmhFdo+fjvW7UzaaqIUhyAFJpLKMMCd/GQ2ce5bhkdNaTR4wvGg3GH2N17Gy6JfOx mjBTzmq7BqQDXZ7KCPezC7InI8DcQ0G1Y13mlObhJlfpV/qExXyWkEz1h3sHVYTwZPT8 Ff4+/PaaebiFseYl6NojFz8RMNharnpV4brWowJHzyy9ZzIly66XLjY/5UzSaTOrXzfx 2pLmlQLtPtBW9DuePqKpukCpebq/X3rwQ/VsrzjiuLL8ns8JDCwOAxGv0WZIqyhlJZE2 Zq9w== X-Gm-Message-State: ALKqPwduk2liPpjiuViHCc1jR6LOkq43OCcmhdv45y8PZmn45CrHwBC9 98H5UIkbr5VrxZy77+rXNZBqT6bI X-Google-Smtp-Source: AB8JxZoQNeu6EnbTF8UckcF6DzDujk1KS46pX78/ZBpYb5oMGXtg2/mAE1u3IS4t0fhBMt8sSoU1WA== X-Received: by 2002:a63:6185:: with SMTP id v127-v6mr13340593pgb.301.1527598528275; Tue, 29 May 2018 05:55:28 -0700 (PDT) Received: from ovs.eng.vmware.com ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id l67-v6sm17151739pfj.66.2018.05.29.05.55.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 05:55:27 -0700 (PDT) From: William Tu To: dev@openvswitch.org Date: Tue, 29 May 2018 05:55:05 -0700 Message-Id: <1527598505-22648-8-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527598505-22648-1-git-send-email-u9012063@gmail.com> References: <1527598505-22648-1-git-send-email-u9012063@gmail.com> 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 8/8] net: ip6_gre: fix tunnel metadata device sharing. 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 commit b80d0b93b991e551a32157e0d9d38fc5bc9348a7 Author: William Tu Date: Fri May 18 19:22:28 2018 -0700 net: ip6_gre: fix tunnel metadata device sharing. Currently ip6gre and ip6erspan share single metadata mode device, using 'collect_md_tun'. Thus, when doing: ip link add dev ip6gre11 type ip6gretap external ip link add dev ip6erspan12 type ip6erspan external RTNETLINK answers: File exists simply fails due to the 2nd tries to create the same collect_md_tun. The patch fixes it by adding a separate collect md tunnel device for the ip6erspan, 'collect_md_tun_erspan'. As a result, a couple of places need to refactor/split up in order to distinguish ip6gre and ip6erspan. First, move the collect_md check at ip6gre_tunnel_{unlink,link} and create separate function {ip6gre,ip6ersapn}_tunnel_{link_md,unlink_md}. Then before link/unlink, make sure the link_md/unlink_md is called. Finally, a separate ndo_uninit is created for ip6erspan. Tested it using the samples/bpf/test_tunnel_bpf.sh. Fixes: ef7baf5e083c ("ip6_gre: add ip6 erspan collect_md mode") Signed-off-by: William Tu Signed-off-by: David S. Miller Cc: Greg Rose Signed-off-by: William Tu Reviewed-by: Greg Rose Tested-by: Greg Rose --- datapath/linux/compat/ip6_gre.c | 116 +++++++++++++++++++++++++++++----------- 1 file changed, 86 insertions(+), 30 deletions(-) diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c index 3a82c3d0fc6b..24e850a22266 100644 --- a/datapath/linux/compat/ip6_gre.c +++ b/datapath/linux/compat/ip6_gre.c @@ -69,6 +69,7 @@ struct ip6gre_net { struct ip6_tnl __rcu *tunnels[4][IP6_GRE_HASH_SIZE]; struct ip6_tnl __rcu *collect_md_tun; + struct ip6_tnl __rcu *collect_md_tun_erspan; struct net_device *fb_tunnel_dev; }; @@ -245,7 +246,12 @@ static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev, if (cand) return cand; - t = rcu_dereference(ign->collect_md_tun); + if (gre_proto == htons(ETH_P_ERSPAN) || + gre_proto == htons(ETH_P_ERSPAN2)) + t = rcu_dereference(ign->collect_md_tun_erspan); + else + t = rcu_dereference(ign->collect_md_tun); + if (t && t->dev->flags & IFF_UP) return t; @@ -274,6 +280,31 @@ static struct ip6_tnl __rcu **__ip6gre_bucket(struct ip6gre_net *ign, return &ign->tunnels[prio][h]; } +static void ip6gre_tunnel_link_md(struct ip6gre_net *ign, struct ip6_tnl *t) +{ + if (t->parms.collect_md) + rcu_assign_pointer(ign->collect_md_tun, t); +} + +static void ip6erspan_tunnel_link_md(struct ip6gre_net *ign, struct ip6_tnl *t) +{ + if (t->parms.collect_md) + rcu_assign_pointer(ign->collect_md_tun_erspan, t); +} + +static void ip6gre_tunnel_unlink_md(struct ip6gre_net *ign, struct ip6_tnl *t) +{ + if (t->parms.collect_md) + rcu_assign_pointer(ign->collect_md_tun, NULL); +} + +static void ip6erspan_tunnel_unlink_md(struct ip6gre_net *ign, + struct ip6_tnl *t) +{ + if (t->parms.collect_md) + rcu_assign_pointer(ign->collect_md_tun_erspan, NULL); +} + static inline struct ip6_tnl __rcu **ip6gre_bucket(struct ip6gre_net *ign, const struct ip6_tnl *t) { @@ -284,9 +315,6 @@ static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t) { struct ip6_tnl __rcu **tp = ip6gre_bucket(ign, t); - if (t->parms.collect_md) - rcu_assign_pointer(ign->collect_md_tun, t); - rcu_assign_pointer(t->next, rtnl_dereference(*tp)); rcu_assign_pointer(*tp, t); } @@ -296,9 +324,6 @@ static void ip6gre_tunnel_unlink(struct ip6gre_net *ign, struct ip6_tnl *t) struct ip6_tnl __rcu **tp; struct ip6_tnl *iter; - if (t->parms.collect_md) - rcu_assign_pointer(ign->collect_md_tun, NULL); - for (tp = ip6gre_bucket(ign, t); (iter = rtnl_dereference(*tp)) != NULL; tp = &iter->next) { @@ -385,11 +410,23 @@ failed_free: return NULL; } +static void ip6erspan_tunnel_uninit(struct net_device *dev) +{ + struct ip6_tnl *t = netdev_priv(dev); + struct ip6gre_net *ign = net_generic(t->net, ip6gre_net_id); + + ip6erspan_tunnel_unlink_md(ign, t); + ip6gre_tunnel_unlink(ign, t); + dst_cache_reset(&t->dst_cache); + dev_put(dev); +} + static void ip6gre_tunnel_uninit(struct net_device *dev) { struct ip6_tnl *t = netdev_priv(dev); struct ip6gre_net *ign = net_generic(t->net, ip6gre_net_id); + ip6gre_tunnel_unlink_md(ign, t); ip6gre_tunnel_unlink(ign, t); dst_cache_reset(&t->dst_cache); dev_put(dev); @@ -2032,7 +2069,7 @@ static int ip6erspan_tap_init(struct net_device *dev) static const struct net_device_ops ip6erspan_netdev_ops = { .ndo_init = ip6erspan_tap_init, - .ndo_uninit = ip6gre_tunnel_uninit, + .ndo_uninit = ip6erspan_tunnel_uninit, .ndo_start_xmit = ip6erspan_tunnel_xmit, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, @@ -2107,8 +2144,6 @@ static int rpl_ip6gre_newlink_common(struct net *src_net, struct net_device *dev #endif { struct ip6_tnl *nt; - struct net *net = dev_net(dev); - struct ip6gre_net *ign = net_generic(net, ip6gre_net_id); struct ip_tunnel_encap ipencap; int err; @@ -2121,16 +2156,6 @@ static int rpl_ip6gre_newlink_common(struct net *src_net, struct net_device *dev return err; } - ip6gre_netlink_parms(data, &nt->parms); - - if (nt->parms.collect_md) { - if (rtnl_dereference(ign->collect_md_tun)) - return -EEXIST; - } else { - if (ip6gre_tunnel_find(net, &nt->parms, dev->type)) - return -EEXIST; - } - if (dev->type == ARPHRD_ETHER && !tb[IFLA_ADDRESS]) eth_hw_addr_random(dev); @@ -2160,17 +2185,30 @@ static int rpl_ip6gre_newlink(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[]) #endif { + struct ip6_tnl *nt = netdev_priv(dev); + struct net *net = dev_net(dev); + struct ip6gre_net *ign; + int err; + + ip6gre_netlink_parms(data, &nt->parms); + ign = net_generic(net, ip6gre_net_id); + + if (nt->parms.collect_md) { + if (rtnl_dereference(ign->collect_md_tun)) + return -EEXIST; + } else { + if (ip6gre_tunnel_find(net, &nt->parms, dev->type)) + return -EEXIST; + } #ifdef HAVE_IP6GRE_EXTACK - int err = ip6gre_newlink_common(src_net, dev, tb, data, extack); + err = ip6gre_newlink_common(src_net, dev, tb, data, extack); #else - int err = ip6gre_newlink_common(src_net, dev, tb, data); + err = ip6gre_newlink_common(src_net, dev, tb, data); #endif - struct ip6_tnl *nt = netdev_priv(dev); - struct net *net = dev_net(dev); - if (!err) { ip6gre_tnl_link_config(nt, !tb[IFLA_MTU]); + ip6gre_tunnel_link_md(ign, nt); ip6gre_tunnel_link(net_generic(net, ip6gre_net_id), nt); } return err; @@ -2240,8 +2278,10 @@ static int rpl_ip6gre_changelink(struct net_device *dev, struct nlattr *tb[], if (IS_ERR(t)) return PTR_ERR(t); + ip6gre_tunnel_unlink_md(ign, t); ip6gre_tunnel_unlink(ign, t); ip6gre_tnl_change(t, &p, !tb[IFLA_MTU]); + ip6gre_tunnel_link_md(ign, t); ip6gre_tunnel_link(ign, t); return 0; } @@ -2405,16 +2445,30 @@ static int rpl_ip6erspan_newlink(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[]) #endif { -#ifdef HAVE_IP6GRE_EXTACK - int err = ip6gre_newlink_common(src_net, dev, tb, data, extack); -#else - int err = ip6gre_newlink_common(src_net, dev, tb, data); -#endif struct ip6_tnl *nt = netdev_priv(dev); struct net *net = dev_net(dev); + struct ip6gre_net *ign; + int err; + ip6gre_netlink_parms(data, &nt->parms); + ign = net_generic(net, ip6gre_net_id); + + if (nt->parms.collect_md) { + if (rtnl_dereference(ign->collect_md_tun_erspan)) + return -EEXIST; + } else { + if (ip6gre_tunnel_find(net, &nt->parms, dev->type)) + return -EEXIST; + } + +#ifdef HAVE_IP6GRE_EXTACK + err = ip6gre_newlink_common(src_net, dev, tb, data, extack); +#else + err = ip6gre_newlink_common(src_net, dev, tb, data); +#endif if (!err) { ip6erspan_tnl_link_config(nt, !tb[IFLA_MTU]); + ip6erspan_tunnel_link_md(ign, nt); ip6gre_tunnel_link(net_generic(net, ip6gre_net_id), nt); } return err; @@ -2455,8 +2509,10 @@ static int rpl_ip6erspan_changelink(struct net_device *dev, struct nlattr *tb[], if (IS_ERR(t)) return PTR_ERR(t); + ip6gre_tunnel_unlink_md(ign, t); ip6gre_tunnel_unlink(ign, t); ip6erspan_tnl_change(t, &p, !tb[IFLA_MTU]); + ip6erspan_tunnel_link_md(ign, t); ip6gre_tunnel_link(ign, t); return 0; }