From patchwork Thu Mar 6 13:08:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 327426 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 883182C0324 for ; Fri, 7 Mar 2014 00:09:58 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751012AbaCFNJy (ORCPT ); Thu, 6 Mar 2014 08:09:54 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:50760 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750760AbaCFNJx (ORCPT ); Thu, 6 Mar 2014 08:09:53 -0500 Received: from 172.24.2.119 (EHLO szxeml207-edg.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id ALM55908; Thu, 06 Mar 2014 21:09:51 +0800 (CST) Received: from SZXEML413-HUB.china.huawei.com (10.82.67.152) by szxeml207-edg.china.huawei.com (172.24.2.56) with Microsoft SMTP Server (TLS) id 14.3.158.1; Thu, 6 Mar 2014 21:08:46 +0800 Received: from localhost (10.177.18.231) by szxeml413-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.158.1; Thu, 6 Mar 2014 21:08:43 +0800 From: Yang Yingliang To: , CC: , Subject: [PATCH net-next 2/5] net_sched: add replace func in struct Qdisc_ops Date: Thu, 6 Mar 2014 21:08:38 +0800 Message-ID: <1394111321-11192-3-git-send-email-yangyingliang@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 In-Reply-To: <1394111321-11192-1-git-send-email-yangyingliang@huawei.com> References: <1394111321-11192-1-git-send-email-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.18.231] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add replace func, if NLM_F_REPLACE is set, use replace func. Otherwise, use change func. Signed-off-by: Yang Yingliang --- include/net/sch_generic.h | 1 + net/sched/sch_api.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index d062f81c692f..ef8a41bcb9a7 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -170,6 +170,7 @@ struct Qdisc_ops { void (*reset)(struct Qdisc *); void (*destroy)(struct Qdisc *); int (*change)(struct Qdisc *, struct nlattr *arg); + int (*replace)(struct Qdisc *, struct nlattr *arg); void (*attach)(struct Qdisc *); int (*dump)(struct Qdisc *, struct sk_buff *); diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 961cb0f1bd0c..8f0f8e9d5475 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -999,9 +999,15 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca, u16 flags) int err = 0; if (tca[TCA_OPTIONS]) { - if (sch->ops->change == NULL) - return -EINVAL; - err = sch->ops->change(sch, tca[TCA_OPTIONS]); + if (flags & NLM_F_REPLACE) { + if (sch->ops->replace == NULL) + return -EINVAL; + err = sch->ops->replace(sch, tca[TCA_OPTIONS]); + } else { + if (sch->ops->change == NULL) + return -EINVAL; + err = sch->ops->change(sch, tca[TCA_OPTIONS]); + } if (err) return err; }