From patchwork Thu Dec 4 12:00:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 41935 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 024982486D for ; Thu, 4 Dec 2014 12:01:32 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id u10sf10784831lbd.6 for ; Thu, 04 Dec 2014 04:01:30 -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=GOzEb2Z7HeY9SRRzjn8WmYY0G7E4RV6wfZ9UoNCCT0c=; b=GvZuqp20zmVpMxp8Jh9UmOXbU9NhDn34Adz6iAfwSJptANQ7EgufW9wAz0egzGBRUY hJVAwIHwWvFZf4zJEl7b6IF6gUnbYyKKoylM7HkO8jm0rgDAGiqCN4zoa51ketMckQzU oybqS+EjR0vtrVk9ja+KeOogbrv88QaCvqXWzQ6PYvDlEegS9RNUvu2XDtsfZixBzCxq 4bIpp/qXmPogGP3HTB0lzVldgPSL7lqTXjK9JervoxJusul5K5or3cQ0zssXP7IS7O1x B1XPkrwvkbGXm2xLOrRwMicYBOQUjYFf6H7w1EB26wQSw6tD6hxVww5MPUMXbEMadd23 VMqQ== X-Gm-Message-State: ALoCoQms5Rof+MkjPAQGdpy72zH2GcUYr8tFCw1NG2GLp+qt5+zo1d4SAN0rXTUQTxgnN/s6KgDC X-Received: by 10.152.6.133 with SMTP id b5mr224laa.10.1417694490942; Thu, 04 Dec 2014 04:01:30 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.42 with SMTP id g10ls243309laa.56.gmail; Thu, 04 Dec 2014 04:01:30 -0800 (PST) X-Received: by 10.152.7.99 with SMTP id i3mr9137991laa.80.1417694490481; Thu, 04 Dec 2014 04:01:30 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id ao10si25658190lac.113.2014.12.04.04.01.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Dec 2014 04:01:30 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id gq15so14382106lab.18 for ; Thu, 04 Dec 2014 04:01:30 -0800 (PST) X-Received: by 10.152.21.66 with SMTP id t2mr8898218lae.27.1417694490414; Thu, 04 Dec 2014 04:01:30 -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 ew9csp21584lbc; Thu, 4 Dec 2014 04:01:29 -0800 (PST) X-Received: by 10.140.90.47 with SMTP id w44mr10659500qgd.4.1417694488879; Thu, 04 Dec 2014 04:01:28 -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 l108si31099357qgf.94.2014.12.04.04.01.27 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 04 Dec 2014 04:01:28 -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 1XwV66-0007AP-I4; Thu, 04 Dec 2014 12:01:26 +0000 Received: from mail-lb0-f174.google.com ([209.85.217.174]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XwV5h-00075m-Ke for lng-odp@lists.linaro.org; Thu, 04 Dec 2014 12:01:01 +0000 Received: by mail-lb0-f174.google.com with SMTP id w7so13879023lbi.19 for ; Thu, 04 Dec 2014 04:00:56 -0800 (PST) X-Received: by 10.112.173.39 with SMTP id bh7mr9213631lbc.53.1417694456129; Thu, 04 Dec 2014 04:00:56 -0800 (PST) Received: from localhost.localdomain (ppp91-76-163-205.pppoe.mtu-net.ru. [91.76.163.205]) by mx.google.com with ESMTPSA id f7sm7172882lam.26.2014.12.04.04.00.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Dec 2014 04:00:55 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 4 Dec 2014 15:00:38 +0300 Message-Id: <1417694439-13861-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1417694439-13861-1-git-send-email-maxim.uvarov@linaro.org> References: <1417694439-13861-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv5 5/6] linux-generic: correct socket get for mtu functions 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.45 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 Use helper function to get socket fd and add locks. Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_packet_io.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 796c625..728c465 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -578,20 +578,21 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu) return -1; } - if (entry->s.pkt_sock_mmap.sockfd) - sockfd = entry->s.pkt_sock_mmap.sockfd; - else - sockfd = entry->s.pkt_sock.sockfd; + lock_entry(entry); - strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ); + sockfd = sockfd_from_pktio_entry(entry); + strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = 0; ifr.ifr_mtu = mtu; ret = ioctl(sockfd, SIOCSIFMTU, (caddr_t)&ifr); if (ret < 0) { ODP_DBG("ioctl SIOCSIFMTU error\n"); + unlock_entry(entry); return -1; } + unlock_entry(entry); return 0; } @@ -608,19 +609,20 @@ int odp_pktio_mtu(odp_pktio_t id) return -1; } - if (entry->s.pkt_sock_mmap.sockfd) - sockfd = entry->s.pkt_sock_mmap.sockfd; - else - sockfd = entry->s.pkt_sock.sockfd; + lock_entry(entry); - strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ); + sockfd = sockfd_from_pktio_entry(entry); + strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = 0; ret = ioctl(sockfd, SIOCGIFMTU, &ifr); if (ret < 0) { ODP_DBG("ioctl SIOCGIFMTU error\n"); + unlock_entry(entry); return -1; } + unlock_entry(entry); return ifr.ifr_mtu; }