From patchwork Mon Dec 8 14:58:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 42012 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7810E244AC for ; Mon, 8 Dec 2014 14:59:04 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id l18sf2843464wgh.2 for ; Mon, 08 Dec 2014 06:59:03 -0800 (PST) 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:in-reply-to :references: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=be2Lax/TBgXV5yYCG8QTJgLxeG2cV0RMbYq8oHQ0bxo=; b=UcZyPFx0/ivkJU7nE7Kxj5Tzbj7ppLvtyX/ou5lGHz3ARxD3ih4K8kg76V4OqDkrkY tzSW6mg4EXE74IXCq95vMKGjo5EZlLPGtXmCoZtNqYHXOhpNPPg6MiTzFzDzo4ZfD8pw LPOM/sjYNZp1yl5PRLqg6rqPdpg2QK0cUZW9SKCZJhDC6gF+UoSTD+zXeCJ+a97Pk0Dl 57xMfgXSQkT9CCUQU/XwhO6zPu6hhTao70r3HR7VGZgon+C6dTUuZC6PRupDkidnwVQT cZ3ZtYkQMtgojMXmzaroJ8ps7emWEPPMZgIkevAZXQJHjz6lrwkfH1f8tpMU6YPRugk/ YaSw== X-Gm-Message-State: ALoCoQloWgGBBCnjaHM/8mPX/vK6LXxaqytAwwgQIWPbNFq7RktxwKJ0YJjWVh8hnhYFec2fV6bI X-Received: by 10.152.43.50 with SMTP id t18mr30877lal.8.1418050743775; Mon, 08 Dec 2014 06:59:03 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.202 with SMTP id e10ls551762lae.86.gmail; Mon, 08 Dec 2014 06:59:03 -0800 (PST) X-Received: by 10.152.5.6 with SMTP id o6mr16973681lao.8.1418050743628; Mon, 08 Dec 2014 06:59:03 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id b1si17348848lab.72.2014.12.08.06.59.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Dec 2014 06:59:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id pv20so3970912lab.41 for ; Mon, 08 Dec 2014 06:59:03 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr16502805lbo.32.1418050743545; Mon, 08 Dec 2014 06:59:03 -0800 (PST) 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.184.201 with SMTP id ew9csp617335lbc; Mon, 8 Dec 2014 06:59:02 -0800 (PST) X-Received: by 10.140.102.248 with SMTP id w111mr51648461qge.33.1418050742030; Mon, 08 Dec 2014 06:59:02 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id b52si43533714qgb.93.2014.12.08.06.59.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 08 Dec 2014 06:59:02 -0800 (PST) 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 1Xxzm7-0006Hu-R5; Mon, 08 Dec 2014 14:58:59 +0000 Received: from mail-lb0-f175.google.com ([209.85.217.175]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xxzlw-0006Gx-NS for lng-odp@lists.linaro.org; Mon, 08 Dec 2014 14:58:48 +0000 Received: by mail-lb0-f175.google.com with SMTP id u10so3939134lbd.34 for ; Mon, 08 Dec 2014 06:58:42 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr16770429lal.29.1418050722862; Mon, 08 Dec 2014 06:58:42 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id xs6sm10869631lbb.13.2014.12.08.06.58.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Dec 2014 06:58:42 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 8 Dec 2014 17:58:27 +0300 Message-Id: <1418050713-29694-2-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1418050713-29694-1-git-send-email-maxim.uvarov@linaro.org> References: <1418050713-29694-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH] fix loop 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: maxim.uvarov@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.215.54 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 Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_packet_io.c | 58 ++++++++-------------------------- 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 833725e..4399ef9 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -155,33 +155,6 @@ static int free_pktio_entry(odp_pktio_t id) return 0; } -static int find_loop_dev(char loop[IFNAMSIZ]) -{ - struct ifaddrs *ifap, *ifa; - - getifaddrs(&ifap); - - for (ifa = ifap; ifa; ifa = ifa->ifa_next) { - if (ifa->ifa_addr && - ifa->ifa_addr->sa_family == AF_INET) { - if ((ifa->ifa_flags & (IFF_LOOPBACK | - IFF_POINTOPOINT | - IFF_NOARP)) || - (!memcmp(ifa->ifa_name, "lxcbr", 5)) || - (!memcmp(ifa->ifa_name, "wlan", 4)) || - (!memcmp(ifa->ifa_name, "veth", 4)) || - (!memcmp(ifa->ifa_name, "virbr", 5))) - continue; - memcpy(loop, ifa->ifa_name, IFNAMSIZ); - freeifaddrs(ifap); - return 0; - } - } - - freeifaddrs(ifap); - return -1; -} - odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool) { odp_pktio_t id; @@ -203,26 +176,21 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool) */ loop_hint = getenv("ODP_PKTIO_LOOPDEV"); if (!strcmp(dev, "loop")) { - if (loop_hint && (strlen(loop_hint) > 0)) { - if (strlen(loop_hint) >= IFNAMSIZ) { - ODP_ERR("pktio name %s is too big, limit is %d bytes\n", - loop_hint, IFNAMSIZ); - return ODP_PKTIO_INVALID; - } + if (!loop_hint || (strlen(loop_hint) == 0)) { + ODP_ERR("Set loop with ODP_PKTIO_LOOPDEV=ethX\n"); + return ODP_PKTIO_INVALID; + } - memset(loop, 0, IFNAMSIZ); - memcpy(loop, loop_hint, strlen(loop_hint)); - dev = loop; - ODP_DBG("pktio using %s as loopback device\n", loop_hint); - } else { - if (!find_loop_dev(loop)) { - ODP_DBG("pktio rename loop to %s\n", loop); - dev = loop; - } else { - ODP_DBG("pktio: No suitable netdev.\n"); - return ODP_PKTIO_INVALID; - } + if (strlen(loop_hint) >= IFNAMSIZ) { + ODP_ERR("pktio name %s is too big, limit is %d bytes\n", + loop_hint, IFNAMSIZ); + return ODP_PKTIO_INVALID; } + + memset(loop, 0, IFNAMSIZ); + memcpy(loop, loop_hint, strlen(loop_hint)); + dev = loop; + ODP_DBG("pktio using %s as loopback device\n", loop_hint); } id = alloc_lock_pktio_entry();