From patchwork Wed Sep 27 16:23:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ali Volkan Atli X-Patchwork-Id: 819226 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=) 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 3y2NRw1vkXz9t5l for ; Thu, 28 Sep 2017 02:23:56 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7446A94B; Wed, 27 Sep 2017 16:23:52 +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 C6A5F412 for ; Wed, 27 Sep 2017 16:23:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from MX1.argela.com.tr (mail.argela.com.tr [95.0.156.7]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CBDE8367 for ; Wed, 27 Sep 2017 16:23:49 +0000 (UTC) Received: from MX2.argela.com.tr (192.168.0.26) by MX1.argela.com.tr (192.168.0.25) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Wed, 27 Sep 2017 19:23:49 +0300 Received: from MX2.argela.com.tr ([fe80::e817:b333:ea71:7f88]) by MX2.argela.com.tr ([fe80::e817:b333:ea71:7f88%12]) with mapi id 15.00.1178.000; Wed, 27 Sep 2017 19:23:49 +0300 From: Ali Volkan Atli To: "dev@openvswitch.org" Thread-Topic: [PATCH] dpif-netdev: Fix a zero-rate bug for meter Thread-Index: AQHTN6zNaGCK+JpmLUy4dk7q+ftAmg== Date: Wed, 27 Sep 2017 16:23:49 +0000 Message-ID: <7ca4f1c0c058403789d1f16ed1f40695@MX2.argela.com.tr> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [192.168.28.52] MIME-Version: 1.0 X-Spam-Status: No, score=-0.0 required=5.0 tests=RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] dpif-netdev: Fix a zero-rate bug for meter 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From 23bc166eecd6e4db7b55720cdd780012df62a0cc Mon Sep 17 00:00:00 2001 From: Ali Volkan ATLI Date: Wed, 27 Sep 2017 18:33:57 +0300 Subject: [PATCH] dpif-netdev: Fix a zero-rate bug for meter Open vSwitch daemon crashes (by receiving signal SIGFPE, Arithmetic exception) when a controller tries to send a meter-mod message with zero rate. Signed-off-by: Ali Volkan ATLI --- lib/dpif-netdev.c | 8 ++++++++ ofproto/ofproto-dpif.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index cb6cf06..ab52809 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -4276,10 +4276,18 @@ dpif_netdev_meter_set(struct dpif *dpif, ofproto_meter_id *meter_id, !(config->flags & (OFPMF13_KBPS | OFPMF13_PKTPS))) { return EBADF; /* Unsupported flags set */ } + /* Validate bands */ if (config->n_bands == 0 || config->n_bands > MAX_BANDS) { return EINVAL; /* Too many bands */ } + + /* Validate rates */ + for (i = 0; i < config->n_bands; ++i) { + if (config->bands[i].rate == 0) + return EBADRQC; /* rate must be non-zero */ + } + for (i = 0; i < config->n_bands; ++i) { switch (config->bands[i].type) { case OFPMBT13_DROP: diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 1a8e829..d99dc9d 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -5695,6 +5695,8 @@ meter_set(struct ofproto *ofproto_, ofproto_meter_id *meter_id, return OFPERR_OFPMMFC_OUT_OF_BANDS; case ENODEV: /* Unsupported band type */ return OFPERR_OFPMMFC_BAD_BAND; + case EBADRQC: /* Rate must be non-zero */ + return OFPERR_OFPMMFC_BAD_RATE; default: return OFPERR_OFPMMFC_UNKNOWN; }