From patchwork Thu Aug 6 10:18:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51997 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 5AE2B20539 for ; Thu, 6 Aug 2015 10:19:02 +0000 (UTC) Received: by wilj18 with SMTP id j18sf4260119wil.0 for ; Thu, 06 Aug 2015 03:19:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=P3Oy2uuxYqVBONSypkj2UgNRShOvqhXedEhd6AqmGNE=; b=Tp85+2tKheSFhPvA2/zN8BXxhKpdPvYZsTlWXSkYeR6ToqPavP37eKYrW5QWbdZWfr ygUWrkmiPZf5ytnP3zHl3ZRfVIg2YmJZtPZ0wBtqM8XQVT9qca9JXXsCUn9pljZ2WG3z FD0O4ZZyKtg3KB6hf3zG6GXIAhm4k9CcQGOCjDfSC0IkXSnfsKLV/WnWq6igMe+SzKTh Qufc5uf+y7IKCsplFOaNXKagsH7oFj3mm1bEuoluNLVme3x+5/w2mkwk3Hlpyf0hqca0 w1CW+ZZ+T6s7y9jZsV45iVngJ2l7+E64KoJh9plMu5E4EiIC6mNrmdt2BcVYNYKw3Yvr 3MPQ== X-Gm-Message-State: ALoCoQmcHfzQ1CJwLa8BVX/YuW2CRzp4eSKPAGXYqSzmc4MmjxGCzLnJg+FnpsjwlgwC1MXu3Snt X-Received: by 10.180.87.201 with SMTP id ba9mr731959wib.3.1438856341620; Thu, 06 Aug 2015 03:19:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.40 with SMTP id kv8ls287732lac.94.gmail; Thu, 06 Aug 2015 03:19:01 -0700 (PDT) X-Received: by 10.152.206.41 with SMTP id ll9mr772077lac.103.1438856341383; Thu, 06 Aug 2015 03:19:01 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id lk12si4343480lac.139.2015.08.06.03.19.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Aug 2015 03:19:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbpo9 with SMTP id po9so40194859lbb.2 for ; Thu, 06 Aug 2015 03:19:01 -0700 (PDT) X-Received: by 10.152.120.135 with SMTP id lc7mr780727lab.41.1438856341285; Thu, 06 Aug 2015 03:19:01 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp856112lba; Thu, 6 Aug 2015 03:19:00 -0700 (PDT) X-Received: by 10.140.97.72 with SMTP id l66mr1532305qge.11.1438856339999; Thu, 06 Aug 2015 03:18:59 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f188si10953015qhe.92.2015.08.06.03.18.59; Thu, 06 Aug 2015 03:18:59 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 4B0E862068; Thu, 6 Aug 2015 10:18:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 6204B61836; Thu, 6 Aug 2015 10:18:55 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 13A3961B14; Thu, 6 Aug 2015 10:18:53 +0000 (UTC) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by lists.linaro.org (Postfix) with ESMTPS id 167E561833 for ; Thu, 6 Aug 2015 10:18:52 +0000 (UTC) Received: by wijp15 with SMTP id p15so16349917wij.0 for ; Thu, 06 Aug 2015 03:18:51 -0700 (PDT) X-Received: by 10.180.184.168 with SMTP id ev8mr5027361wic.28.1438856331347; Thu, 06 Aug 2015 03:18:51 -0700 (PDT) Received: from e106441.cambridge.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id ev2sm2477836wib.21.2015.08.06.03.18.50 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Aug 2015 03:18:50 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Thu, 6 Aug 2015 11:18:44 +0100 Message-Id: <1438856324-24231-1-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: pktio: store errno correctly in setup X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stuart.haslam@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 errno must be stored immediately after the failure to avoid it being overwritten by the ODP_ERR() call. Signed-off-by: Stuart Haslam --- platform/linux-generic/pktio/socket.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 202608a..55c3594 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -207,6 +207,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sockfd == -1) { + __odp_errno = errno; ODP_ERR("socket(): %s\n", strerror(errno)); goto error; } @@ -217,6 +218,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, snprintf(ethreq.ifr_name, IF_NAMESIZE, "%s", netdev); err = ioctl(sockfd, SIOCGIFINDEX, ðreq); if (err != 0) { + __odp_errno = errno; ODP_ERR("ioctl(SIOCGIFINDEX): %s: \"%s\".\n", strerror(errno), ethreq.ifr_name); goto error; @@ -228,6 +230,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, snprintf(ethreq.ifr_name, IF_NAMESIZE, "%s", netdev); err = ioctl(sockfd, SIOCGIFHWADDR, ðreq); if (err != 0) { + __odp_errno = errno; ODP_ERR("ioctl(SIOCGIFHWADDR): %s\n", strerror(errno)); goto error; } @@ -240,6 +243,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, sa_ll.sll_ifindex = if_idx; sa_ll.sll_protocol = htons(ETH_P_ALL); if (bind(sockfd, (struct sockaddr *)&sa_ll, sizeof(sa_ll)) < 0) { + __odp_errno = errno; ODP_ERR("bind(to IF): %s\n", strerror(errno)); goto error; } @@ -247,7 +251,6 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, return 0; error: - __odp_errno = errno; sock_close(pktio_entry); return -1;