From patchwork Thu Nov 30 16:31:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Sun X-Patchwork-Id: 843191 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=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="a7e+k+07"; dkim-atps=neutral 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 3ynrLL5krSz9s7B for ; Fri, 1 Dec 2017 08:35:54 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 561E1BBF; Thu, 30 Nov 2017 21:35:53 +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 06D44941 for ; Thu, 30 Nov 2017 21:35:52 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B6B513FB for ; Thu, 30 Nov 2017 21:35:51 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id w7so3544929pgv.6 for ; Thu, 30 Nov 2017 13:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=gzWv9ZBw0YOvYjtO9ga3eTDunia+zTdSI8h/I74kQo4=; b=a7e+k+07e1sWH1jJ+PygkEzxkkJuBGzmdpDgg/BFLE2Efe8e2dU9IbL31zAmVOjPiv lrqM97Ckg4qwrGWK07Oy9Reotdk2g43JaVcKiJlfVCF+sqwa2T6MJHLHn4txli+dwMsy S+vKu5CRWEVios9/qS4jc5JFbTqVjWWs8UZrSlmHsfdqYLTBXm3CgCvtO9SgLH7fGdd/ D+DZnA6nMywMOPa8hgI1jbVmup3/NzKlt7CSqLQVhFfD3FMC0IGGtYyCSmGvUv4BVB6H YZZADXnoxxBT0DwmoToyhkilnF+/nGtaYXtYV97LD5sgWdWxIhafzqnquVOlueDt9gfq 9hgA== 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; bh=gzWv9ZBw0YOvYjtO9ga3eTDunia+zTdSI8h/I74kQo4=; b=bFUTAlLefbkD695Wq66w33I9uIlo8wD7kl99z6JYkQPaE7r7Y1SJ3R99paG8z+oIul A/aFJiQmbR4mWJf8d8UtVyYvMEXQI6fzsr78Hg+HYZM7YG00klXJcT2dCn7RK5LsY/22 aBXQR4R5Bmzpwao8+iKL4NgjhP6y3Skdqh4+efTr8L/n+373SMTZYwz0Hdcr7IjmR5RD pJl1KOo7k7UyUiziiEmsNduHlZfzZE74ZnUgHH6saojoL5FwfEvbB9Mcw/KlAzRdW4Cf ilMzkgGcCuxP0SBEA/dZqrHR7PI4Fo0Zp9CK5TyDMjJhA1ZMRC9QfODbOhOyBw7DZ1q3 ++eg== X-Gm-Message-State: AJaThX5WNS1kzm24QaAMgmzGmmAqz4O2Rf9sJ5d8pOHc6hgUQr5zeMMm GNCG2t/6hXczUqOUIWA4pW8VWA== X-Google-Smtp-Source: AGs4zMaF+Vf5YAm6VXjX4KMeJB9FisltlMkIIsh7arMt+Nc2kP8kyLqWTLWJBRqPRXe4dOR9li/Vbw== X-Received: by 10.98.48.3 with SMTP id w3mr7531206pfw.219.1512077750934; Thu, 30 Nov 2017 13:35:50 -0800 (PST) Received: from yfsovs.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id n19sm8248091pgf.65.2017.11.30.13.35.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Nov 2017 13:35:50 -0800 (PST) From: Yifeng Sun To: dev@openvswitch.org, blp@ovn.org Date: Thu, 30 Nov 2017 08:31:24 -0800 Message-Id: <1512059484-2849-1-git-send-email-pkusunyifeng@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCHv2] netdev: netdev_get_etheraddr is not functioning as advertised. 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: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org netdev_get_etheraddr claims to clear 'mac' on error, but it fails to do so. When looking further into both netdev_windows_get_etheraddr() and netdev_linux_get_etheraddr(), 'mac' is also not cleared. This will lead to usage of uninitialised ofputil_phy_port.hw_addr. v1 -> v2: fixed a bug in v1 found by Ben, thanks Ben. Signed-off-by: Yifeng Sun --- lib/netdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/netdev.c b/lib/netdev.c index c52680659e3f..2d69fe5dac68 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -897,7 +897,13 @@ netdev_set_etheraddr(struct netdev *netdev, const struct eth_addr mac) int netdev_get_etheraddr(const struct netdev *netdev, struct eth_addr *mac) { - return netdev->netdev_class->get_etheraddr(netdev, mac); + int error; + + error = netdev->netdev_class->get_etheraddr(netdev, mac); + if (error) { + memset(mac, 0, sizeof *mac); + } + return error; } /* Returns the name of the network device that 'netdev' represents,