{"id":833719,"url":"http://patchwork.ozlabs.org/api/1.2/patches/833719/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20171103090344.19444-10-jiri@resnulli.us/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20171103090344.19444-10-jiri@resnulli.us>","list_archive_url":null,"date":"2017-11-03T09:03:37","name":"[net-next,09/16] mlxsw: spectrum_router: Extract __mlxsw_sp_ipip_entry_update_tunnel()","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"bb9ff06f5d8f45ec10ff661f2a61d410b821c6c5","submitter":{"id":15321,"url":"http://patchwork.ozlabs.org/api/1.2/people/15321/?format=json","name":"Jiri Pirko","email":"jiri@resnulli.us"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20171103090344.19444-10-jiri@resnulli.us/mbox/","series":[{"id":11677,"url":"http://patchwork.ozlabs.org/api/1.2/series/11677/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=11677","date":"2017-11-03T09:03:28","name":"mlxsw: Handle changes in GRE configuration","version":1,"mbox":"http://patchwork.ozlabs.org/series/11677/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/833719/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/833719/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=resnulli-us.20150623.gappssmtp.com\n\theader.i=@resnulli-us.20150623.gappssmtp.com\n\theader.b=\"ZGYMA37x\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3ySwxG2bzlz9sNV\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri,  3 Nov 2017 20:04:02 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S932833AbdKCJEA (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 3 Nov 2017 05:04:00 -0400","from mail-wr0-f196.google.com ([209.85.128.196]:52499 \"EHLO\n\tmail-wr0-f196.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S932569AbdKCJDx (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 3 Nov 2017 05:03:53 -0400","by mail-wr0-f196.google.com with SMTP id k62so1863823wrc.9\n\tfor <netdev@vger.kernel.org>; Fri, 03 Nov 2017 02:03:53 -0700 (PDT)","from localhost (ip-94-113-127-32.net.upcbroadband.cz.\n\t[94.113.127.32]) by smtp.gmail.com with ESMTPSA id\n\ta34sm5435948wra.64.2017.11.03.02.03.51\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tFri, 03 Nov 2017 02:03:52 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=resnulli-us.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=xVlLLg7aubhyaOx1QMaTx4HLEFxxJvW2ikMq6tWZlRc=;\n\tb=ZGYMA37xZs4iDCfLMw8t7LQ1D0qRK+ia/rHNwcYHksUiPwWd+FMc7c/A0arBkRgbCQ\n\tPOkS6kbVIXXfl2rEM+76Xr8A8Cz/hNOqLUdRYF5wvqovl9UvI3nuifnCJVO0YFDQWMoj\n\tFL+pXfIu9I5DT0ubwohhKpt4UeOAvRDGkghG/Knf5nGnVoxRx+/e3s6uQde7qM/w61RP\n\tff7BaKf3mJU1H/WVlfQTbx4a9FmCrdUR933r8x3rDaDBrr+clbpg04jx4EqZBlY36QAo\n\tXlhKwcGc+qhK+FiUuRwe+qMC5GfoMqvA78vTxoSXbkT0uMKIfzkW2OZTSpsGSfaViG6v\n\tm2jw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=xVlLLg7aubhyaOx1QMaTx4HLEFxxJvW2ikMq6tWZlRc=;\n\tb=MQnGH/LZLMSXXgOJwSIv5bU2HqjueEs13DOhNVGQPuOLyzKuf8EbPXEhohiWZWjjhq\n\tfx8OIm7iHNeH0u/9qJUX5A1pWsp/HNqNjs5IL4z+XkmTRY/R0xBjAH61/WRX0bnfG0PQ\n\toF5duT4FkW5BgO5pfPMEpBMtjNOVlB+sPGVfnueUSHWzfRaa8KRENfYY/r7Qr94gVUy/\n\t0f5Pd1pSzj3Nc11pRTxpve2/3E4BD+ahbmr32iuzgwsQQHY3owGiDl/pZ/Cn8QNhmpnf\n\tLB6CMoVqcsWC5Gjt4v9kRhEvgXz/CjWiJhmp0qnCHzfe5UlIJ6i/55toUbRBdxlMfcmp\n\t1wpQ==","X-Gm-Message-State":"AMCzsaULVSUizdTqcIgSnDAb9l+xyjVcNcgu+HzHDDRREbViN0qFXWM2\n\tr+cuSnGyb8vfpvhRfmwQJA2DReeW","X-Google-Smtp-Source":"ABhQp+QXilb4V62v0ovjgHjc5UejfpqT3asjfNozv3n08++gJ+uq9FoLu9osFI9LEQeUxSVOQcJgoQ==","X-Received":"by 10.223.179.1 with SMTP id j1mr5483827wrd.105.1509699832541;\n\tFri, 03 Nov 2017 02:03:52 -0700 (PDT)","From":"Jiri Pirko <jiri@resnulli.us>","To":"netdev@vger.kernel.org","Cc":"davem@davemloft.net, petrm@mellanox.com, idosch@mellanox.com,\n\tmlxsw@mellanox.com","Subject":"[patch net-next 09/16] mlxsw: spectrum_router: Extract\n\t__mlxsw_sp_ipip_entry_update_tunnel()","Date":"Fri,  3 Nov 2017 10:03:37 +0100","Message-Id":"<20171103090344.19444-10-jiri@resnulli.us>","X-Mailer":"git-send-email 2.9.5","In-Reply-To":"<20171103090344.19444-1-jiri@resnulli.us>","References":"<20171103090344.19444-1-jiri@resnulli.us>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: Petr Machata <petrm@mellanox.com>\n\nThe work that's done by mlxsw_sp_netdevice_ipip_ol_vrf_event() is a good\nbasis for a more versatile function that would take care of all sorts of\ntunnel updates requests: __mlxsw_sp_ipip_entry_update_tunnel(). Extract\nthat function. Factor out a helper mlxsw_sp_ipip_entry_ol_lb_update() as\nwell.\n\nSigned-off-by: Petr Machata <petrm@mellanox.com>\nReviewed-by: Ido Schimmel <idosch@mellanox.com>\nSigned-off-by: Jiri Pirko <jiri@mellanox.com>\n---\n .../net/ethernet/mellanox/mlxsw/spectrum_router.c  | 74 ++++++++++++++--------\n 1 file changed, 46 insertions(+), 28 deletions(-)","diff":"diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c\nindex c4f1881..e2795b8 100644\n--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c\n+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c\n@@ -1355,46 +1355,64 @@ static void mlxsw_sp_netdevice_ipip_ol_down_event(struct mlxsw_sp *mlxsw_sp,\n \t\tmlxsw_sp_ipip_entry_ol_down_event(mlxsw_sp, ipip_entry);\n }\n \n-static int mlxsw_sp_netdevice_ipip_ol_vrf_event(struct mlxsw_sp *mlxsw_sp,\n-\t\t\t\t\t\tstruct net_device *ol_dev,\n-\t\t\t\t\t\tstruct netlink_ext_ack *extack)\n-{\n-\tstruct mlxsw_sp_fib_entry *decap_fib_entry;\n-\tstruct mlxsw_sp_ipip_entry *ipip_entry;\n-\tstruct mlxsw_sp_rif_ipip_lb *lb_rif;\n+static int\n+mlxsw_sp_ipip_entry_ol_lb_update(struct mlxsw_sp *mlxsw_sp,\n+\t\t\t\t struct mlxsw_sp_ipip_entry *ipip_entry,\n+\t\t\t\t struct netlink_ext_ack *extack)\n+{\n+\tstruct mlxsw_sp_rif_ipip_lb *old_lb_rif = ipip_entry->ol_lb;\n+\tstruct mlxsw_sp_rif_ipip_lb *new_lb_rif;\n+\n+\tnew_lb_rif = mlxsw_sp_ipip_ol_ipip_lb_create(mlxsw_sp,\n+\t\t\t\t\t\t     ipip_entry->ipipt,\n+\t\t\t\t\t\t     ipip_entry->ol_dev,\n+\t\t\t\t\t\t     extack);\n+\tif (IS_ERR(new_lb_rif))\n+\t\treturn PTR_ERR(new_lb_rif);\n+\tipip_entry->ol_lb = new_lb_rif;\n+\tmlxsw_sp_rif_destroy(&old_lb_rif->common);\n \n-\tipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev);\n-\tif (!ipip_entry)\n-\t\treturn 0;\n+\treturn 0;\n+}\n+\n+int __mlxsw_sp_ipip_entry_update_tunnel(struct mlxsw_sp *mlxsw_sp,\n+\t\t\t\t\tstruct mlxsw_sp_ipip_entry *ipip_entry,\n+\t\t\t\t\tstruct netlink_ext_ack *extack)\n+{\n+\tint err;\n \n-\t/* When a tunneling device is moved to a different VRF, we need to\n-\t * update the backing loopback. Since RIFs can't be edited, we need to\n-\t * destroy and recreate it. That might create a window of opportunity\n-\t * where RALUE and RATR registers end up referencing a RIF that's\n-\t * already gone. RATRs are handled by the RIF destroy, and to take care\n+\t/* RIFs can't be edited, so to update loopback, we need to destroy and\n+\t * recreate it. That creates a window of opportunity where RALUE and\n+\t * RATR registers end up referencing a RIF that's already gone. RATRs\n+\t * are handled in mlxsw_sp_ipip_entry_ol_lb_update(), and to take care\n \t * of RALUE, demote the decap route back.\n \t */\n \tif (ipip_entry->decap_fib_entry)\n \t\tmlxsw_sp_ipip_entry_demote_decap(mlxsw_sp, ipip_entry);\n \n-\tlb_rif = mlxsw_sp_ipip_ol_ipip_lb_create(mlxsw_sp, ipip_entry->ipipt,\n-\t\t\t\t\t\t ol_dev, extack);\n-\tif (IS_ERR(lb_rif))\n-\t\treturn PTR_ERR(lb_rif);\n-\tmlxsw_sp_rif_destroy(&ipip_entry->ol_lb->common);\n-\tipip_entry->ol_lb = lb_rif;\n+\terr = mlxsw_sp_ipip_entry_ol_lb_update(mlxsw_sp, ipip_entry, extack);\n+\tif (err)\n+\t\treturn err;\n \n-\tif (ol_dev->flags & IFF_UP) {\n-\t\tdecap_fib_entry = mlxsw_sp_ipip_entry_find_decap(mlxsw_sp,\n-\t\t\t\t\t\t\t\t ipip_entry);\n-\t\tif (decap_fib_entry)\n-\t\t\tmlxsw_sp_ipip_entry_promote_decap(mlxsw_sp, ipip_entry,\n-\t\t\t\t\t\t\t  decap_fib_entry);\n-\t}\n+\tif (ipip_entry->ol_dev->flags & IFF_UP)\n+\t\tmlxsw_sp_ipip_entry_ol_up_event(mlxsw_sp, ipip_entry);\n \n \treturn 0;\n }\n \n+static int mlxsw_sp_netdevice_ipip_ol_vrf_event(struct mlxsw_sp *mlxsw_sp,\n+\t\t\t\t\t\tstruct net_device *ol_dev,\n+\t\t\t\t\t\tstruct netlink_ext_ack *extack)\n+{\n+\tstruct mlxsw_sp_ipip_entry *ipip_entry =\n+\t\tmlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev);\n+\n+\tif (!ipip_entry)\n+\t\treturn 0;\n+\treturn __mlxsw_sp_ipip_entry_update_tunnel(mlxsw_sp, ipip_entry,\n+\t\t\t\t\t\t   extack);\n+}\n+\n int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp,\n \t\t\t\t     struct net_device *ol_dev,\n \t\t\t\t     unsigned long event,\n","prefixes":["net-next","09/16"]}