From patchwork Wed Jun 13 13:47:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 10462251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 17F4360234 for ; Wed, 13 Jun 2018 13:49:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0422628914 for ; Wed, 13 Jun 2018 13:49:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7FEF28A0B; Wed, 13 Jun 2018 13:49:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D768728914 for ; Wed, 13 Jun 2018 13:48:50 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 415SlL2gx1zF09h for ; Wed, 13 Jun 2018 23:48:46 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="P2ZClcb5"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=resnulli.us (client-ip=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=jiri@resnulli.us; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="P2ZClcb5"; dkim-atps=neutral Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 415SlC2xZVzDrcd for ; Wed, 13 Jun 2018 23:48:39 +1000 (AEST) Received: by mail-wm0-x243.google.com with SMTP id j15-v6so5615902wme.0 for ; Wed, 13 Jun 2018 06:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B6/BHFNZUdWEcBDaB1DrHpQXDe4/1wgOZGcAXcAr4ZU=; b=P2ZClcb5UjNb/jgeVbzGg7I4PYwQsbyxlxy3aAIRbaRGGfbzHXY2TlK8C/QuNtOf6n 0kOV6H+zd2dKewwQqfpCSlNCZVEyAx9/Zoxv1ohkWHhqDjW/mnVq3LRdBMN5L1Bp5cZ4 OOygt3pqXfQeuFuS8FAG00c6FZ/w8oD2RPH8SHfjArugrSn37RHSJScNT/kkq7Lf1APq K+mFHsJO38ubWfnRShHwoHDMGN1eGnVpLwkGqCTrPIdt5CbbVr5UbIV+Y42nNPr0lgjS ikEOqpf7vTPC0/ihuBvriSvLnYgNugrjnltcK6hTDFtHvwBGIKEz1p6V2zxzj4Ecv9rz hbzQ== 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=B6/BHFNZUdWEcBDaB1DrHpQXDe4/1wgOZGcAXcAr4ZU=; b=cHJNgUteDZBE7ho4Qb1+PmR0LyP2ZtL43B0G2KoLQ+fQCXT54FFJir5bnuSNxUyMl5 T6tL5/LtWcGi56En9SIoq8HqzUYclCezFx90dcduXgXWyxqpL5IJBwU7+D99nS6Wl2De p0ZLOa0XwatZNYX2VyRCPFKBkJmbQhEN/EnWwnsZLi2VnyA3AE8+1muXBGtGecw8+yiq +q1ADvTwJxfOoLUSKVSZtpx6iX4XoeOVEdD9HNSUHYuxVXBY0OKYdAyme7JtG98mu6LW FilVlrm27PhbkbatPMvoaWXyXxdhD4620V8hJ+WXCqlCND3j2RR4p2nDllpf8kXjYe2Z U2gw== X-Gm-Message-State: APt69E0h7h5cZxnxYidpI1tYN1GTwfR70/noDqYra4Nz+lu+RAnqCdPp cC3Hk77/A6P8ZP+IV6NZYj1UCg== X-Google-Smtp-Source: ADUXVKLNpJwOctBx0jVBZteHSBfhBbXphTwUItxoV4nh6fIefROmORTCzHWQXuBapjqy9yXGq/14BA== X-Received: by 2002:a1c:78b:: with SMTP id 133-v6mr3839295wmh.59.1528897714149; Wed, 13 Jun 2018 06:48:34 -0700 (PDT) Received: from localhost (ip-89-177-135-115.net.upcbroadband.cz. [89.177.135.115]) by smtp.gmail.com with ESMTPSA id b124-v6sm4817012wmf.11.2018.06.13.06.48.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 06:48:33 -0700 (PDT) From: Jiri Pirko To: linux-internal@mellanox.com Subject: [patch net-next mlxsw/noapply 1/7] net: sched: push ops lookup bits into tcf_proto_lookup_ops() Date: Wed, 13 Jun 2018 15:47:27 +0200 Message-Id: <20180613134733.2766-2-jiri@resnulli.us> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180613134733.2766-1-jiri@resnulli.us> References: <20180613134733.2766-1-jiri@resnulli.us> X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jiri Pirko Push all bits that take care of ops lookup, including module loading outside tcf_proto_create() function, into tcf_proto_lookup_ops() Signed-off-by: Jiri Pirko --- net/sched/cls_api.c | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index c06585fb2dc6..327c89c8e3f7 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -39,7 +39,7 @@ static DEFINE_RWLOCK(cls_mod_lock); /* Find classifier type by string name */ -static const struct tcf_proto_ops *tcf_proto_lookup_ops(const char *kind) +static const struct tcf_proto_ops *__tcf_proto_lookup_ops(const char *kind) { const struct tcf_proto_ops *t, *res = NULL; @@ -57,6 +57,33 @@ static const struct tcf_proto_ops *tcf_proto_lookup_ops(const char *kind) return res; } +static const struct tcf_proto_ops * +tcf_proto_lookup_ops(const char *kind, struct netlink_ext_ack *extack) +{ + const struct tcf_proto_ops *ops; + + ops = __tcf_proto_lookup_ops(kind); + if (ops) + return ops; +#ifdef CONFIG_MODULES + rtnl_unlock(); + request_module("cls_%s", kind); + rtnl_lock(); + ops = __tcf_proto_lookup_ops(kind); + /* We dropped the RTNL semaphore in order to perform + * the module load. So, even if we succeeded in loading + * the module we have to replay the request. We indicate + * this using -EAGAIN. + */ + if (ops) { + module_put(ops->owner); + return ERR_PTR(-EAGAIN); + } +#endif + NL_SET_ERR_MSG(extack, "TC classifier not found"); + return ERR_PTR(-ENOENT); +} + /* Register(unregister) new classifier type */ int register_tcf_proto_ops(struct tcf_proto_ops *ops) @@ -133,27 +160,9 @@ static struct tcf_proto *tcf_proto_create(const char *kind, u32 protocol, if (!tp) return ERR_PTR(-ENOBUFS); - err = -ENOENT; - tp->ops = tcf_proto_lookup_ops(kind); - if (!tp->ops) { -#ifdef CONFIG_MODULES - rtnl_unlock(); - request_module("cls_%s", kind); - rtnl_lock(); - tp->ops = tcf_proto_lookup_ops(kind); - /* We dropped the RTNL semaphore in order to perform - * the module load. So, even if we succeeded in loading - * the module we have to replay the request. We indicate - * this using -EAGAIN. - */ - if (tp->ops) { - module_put(tp->ops->owner); - err = -EAGAIN; - } else { - NL_SET_ERR_MSG(extack, "TC classifier not found"); - err = -ENOENT; - } -#endif + tp->ops = tcf_proto_lookup_ops(kind, extack); + if (IS_ERR(tp->ops)) { + err = PTR_ERR(tp->ops); goto errout; } tp->classify = tp->ops->classify;