From patchwork Sat Oct 28 08:40:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhongbaisong X-Patchwork-Id: 831593 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 3yPDjs1Ky3z9t2Z for ; Sat, 28 Oct 2017 19:41:17 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 104B6486; Sat, 28 Oct 2017 08:41:14 +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 8DA9A40C for ; Sat, 28 Oct 2017 08:41:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C1FFA14B for ; Sat, 28 Oct 2017 08:41:11 +0000 (UTC) Received: from 172.30.72.60 (EHLO DGGEMS406-HUB.china.huawei.com) ([172.30.72.60]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DJX93679; Sat, 28 Oct 2017 16:41:09 +0800 (CST) Received: from localhost (10.177.238.156) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.361.1; Sat, 28 Oct 2017 16:40:59 +0800 From: zhongbaisong To: Date: Sat, 28 Oct 2017 16:40:37 +0800 Message-ID: <1509180037-13812-1-git-send-email-zhongbaisong@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.238.156] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.59F442A5.0046, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d69edabda443d17e57113d14804a1785 X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, 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] netdev-linux: dev_stats should be initialized before used 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: zhongbasiong struct netdev_stats dev_stats was used without initialized. As result, the output of 'ovs-vsctl list interface' has some random values. Signed-off-by: zhongbasiong --- lib/netdev-linux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 2ff3e2b..09f174b 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -1726,6 +1726,7 @@ netdev_linux_get_stats(const struct netdev *netdev_, int error; ovs_mutex_lock(&netdev->mutex); + memset(&dev_stats, 0, sizeof(struct netdev_stats)); get_stats_via_vport(netdev_, stats); error = get_stats_via_netlink(netdev_, &dev_stats); if (error) { @@ -1777,6 +1778,7 @@ netdev_tap_get_stats(const struct netdev *netdev_, struct netdev_stats *stats) int error; ovs_mutex_lock(&netdev->mutex); + memset(&dev_stats, 0, sizeof(struct netdev_stats)); get_stats_via_vport(netdev_, stats); error = get_stats_via_netlink(netdev_, &dev_stats); if (error) {