From patchwork Wed Mar 11 13:13:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 45655 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A0407214C6 for ; Wed, 11 Mar 2015 13:14:11 +0000 (UTC) Received: by lbiz11 with SMTP id z11sf6640432lbi.2 for ; Wed, 11 Mar 2015 06:14:10 -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: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=thrWZqrgbYQhAqDPA0HV2y2dD8EjJTBiysysaN0f5do=; b=iufa20zohcoNYDMmlmPIPF21yyXrIUeBKB4M1qT0/nr/NIfxbwPclp4vd/7iFw66hF CjObBRsYysWWruvJOyGGCvCtiYdhJwLedzgzffhk6X6p6fzcAXmK8OEF9G+hxlM0siB6 mUPFj6x3B3FbrNRvCMrjq4jQL/04wSbr+qNY2n6NxHuMiedRxXKxdRGi6t8wxviDQoPj mW0geOp2+/tOUzV5L69rwI3QRD+1+ADNXj2BMd+lCIP6xccz/Smv0MGSUzmd5ftw06O9 B6vzlyxsWgjf0/uFHPOCZDaynK/QTv9euW2z8PH6Nu+Q8LNBM5cvU1j+kyKJZ+pj0tL/ gJ2g== X-Gm-Message-State: ALoCoQmX2nULwyo59+vMm7DmmShdR3OWJjcs1rWyGzVfiR/BCVj63UxpQ8yQJteuYf4jnTOgpwzz X-Received: by 10.180.13.195 with SMTP id j3mr8649323wic.2.1426079650597; Wed, 11 Mar 2015 06:14:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.169 with SMTP id s9ls161699laa.8.gmail; Wed, 11 Mar 2015 06:14:10 -0700 (PDT) X-Received: by 10.152.178.164 with SMTP id cz4mr34211417lac.39.1426079650224; Wed, 11 Mar 2015 06:14:10 -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 v5si2261141lbj.169.2015.03.11.06.14.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2015 06:14:10 -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 lbiz11 with SMTP id z11so8749748lbi.3 for ; Wed, 11 Mar 2015 06:14:10 -0700 (PDT) X-Received: by 10.152.43.51 with SMTP id t19mr34148018lal.73.1426079650053; Wed, 11 Mar 2015 06:14:10 -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.35.133 with SMTP id h5csp2770700lbj; Wed, 11 Mar 2015 06:14:09 -0700 (PDT) X-Received: by 10.141.18.146 with SMTP id u140mr47504741qhd.48.1426079648761; Wed, 11 Mar 2015 06:14:08 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id y74si3303793qky.123.2015.03.11.06.14.07 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 11 Mar 2015 06:14:08 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YVgSa-0000SV-Jj; Wed, 11 Mar 2015 13:14:04 +0000 Received: from mail-lb0-f172.google.com ([209.85.217.172]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YVgSV-0000SQ-Dm for lng-odp@lists.linaro.org; Wed, 11 Mar 2015 13:13:59 +0000 Received: by lbvn10 with SMTP id n10so8775785lbv.1 for ; Wed, 11 Mar 2015 06:13:53 -0700 (PDT) X-Received: by 10.152.6.2 with SMTP id w2mr34452424law.6.1426079633629; Wed, 11 Mar 2015 06:13:53 -0700 (PDT) Received: from robucws331.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id ba13sm710111lab.45.2015.03.11.06.13.52 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Mar 2015 06:13:52 -0700 (PDT) From: Ciprian Barbu To: lng-odp@lists.linaro.org Date: Wed, 11 Mar 2015 15:13:43 +0200 Message-Id: <1426079623-17395-1-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-Topics: patch Subject: [lng-odp] [PATCH] example: odp_ipsec: remove USE_MAC_ADDR_HACK X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ciprian.barbu@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 Remove the old hack and switch to using the provided API This also fixes https://bugs.linaro.org/show_bug.cgi?id=1330 Signed-off-by: Ciprian Barbu --- example/ipsec/odp_ipsec.c | 58 ++--------------------------------------------- 1 file changed, 2 insertions(+), 56 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 98160ba..82ed0cb 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -211,56 +211,6 @@ void free_pkt_ctx(pkt_ctx_t *ctx) } /** - * Use socket I/O workaround to query interface MAC address - * - * @todo Remove all references to USE_MAC_ADDR_HACK once - * https://bugs.linaro.org/show_bug.cgi?id=627 is resolved - */ -#define USE_MAC_ADDR_HACK 1 - -#if USE_MAC_ADDR_HACK - -/** - * Query MAC address associated with an interface (temporary workaround - * till API is created) - * - * @param intf String name of the interface - * @param src_mac MAC address used by the interface - * - * @return 0 if successful else -1 - */ -static -int query_mac_address(char *intf, uint8_t *src_mac) -{ - int sd; - struct ifreq ifr; - - /* Get a socket descriptor */ - sd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); - if (sd < 0) { - EXAMPLE_ERR("Error: socket() failed for %s\n", intf); - return -1; - } - - /* Use ioctl() to look up interface name and get its MAC address */ - memset(&ifr, 0, sizeof(ifr)); - snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", intf); - if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0) { - close(sd); - EXAMPLE_ERR("Error: ioctl() failed for %s\n", intf); - return -1; - } - memcpy(src_mac, ifr.ifr_hwaddr.sa_data, ODPH_ETHADDR_LEN); - - /* Fini */ - close(sd); - - return 0; -} - -#endif - -/** * Example supports either polling queues or using odp_schedule * * Specify "CFLAGS=-DIPSEC_POLL_QUEUES" during configure to enable polling @@ -590,12 +540,8 @@ void initialize_intf(char *intf) } /* Read the source MAC address for this interface */ -#if USE_MAC_ADDR_HACK - ret = query_mac_address(intf, src_mac); -#else - ret = odp_pktio_get_mac_addr(pktio, src_mac); -#endif - if (ret) { + ret = odp_pktio_mac_addr(pktio, src_mac, sizeof(src_mac)); + if (ret <= 0) { EXAMPLE_ERR("Error: failed during MAC address get for %s\n", intf); exit(EXIT_FAILURE);