From patchwork Fri Dec 5 16:20:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 41982 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 98DF4240F7 for ; Fri, 5 Dec 2014 16:21:22 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id c13sf718760eek.10 for ; Fri, 05 Dec 2014 08:21:21 -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=S+g3EkE5TM+M/FF/JikBKX4zGihgwpEm3Sc5jlJJx9M=; b=WCgaTr8VOuI6llNA8PoVGctV1jbVuvb0Jw/D85MzNQKuCpkxSFbZXxEhWaIoixYDJF zWsIh83U1+seuITFaUR3gXOI9uW/LPn5bQWrW4D6aOGyp0dPe//ho+zxo64BHjOr4gTS NfuJ8m09AgXaYt2F3vV7GjW9FL+c/kGYX+QFmnqLhmio0SOss71AkKyYCZhE2jpEEFzB iw/5d/GcWnWWPLtSPiRT66yqVarv903Vla7aZU6F3cCX3v6rwArqkQmhR7c68OHxg11c LNwY7tkeV0tH6Dv5rRLl3MY+qTiiLM+A02IQTNUxHTlh0DE/wHWkvvxSybSJTXLnqDly dHgA== X-Gm-Message-State: ALoCoQmsgadS+70OhNAZmtY9Ou9SZU3CFvL2kJRVoRaXNngM3Tp5fnmijIazAF7tsk0+bifeawCt X-Received: by 10.180.98.39 with SMTP id ef7mr812461wib.6.1417796481791; Fri, 05 Dec 2014 08:21:21 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.166 with SMTP id t6ls446221lat.20.gmail; Fri, 05 Dec 2014 08:21:21 -0800 (PST) X-Received: by 10.152.42.198 with SMTP id q6mr3655947lal.48.1417796481263; Fri, 05 Dec 2014 08:21:21 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id lf4si20029721lab.95.2014.12.05.08.21.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Dec 2014 08:21:21 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id pn19so929766lab.37 for ; Fri, 05 Dec 2014 08:21:21 -0800 (PST) X-Received: by 10.112.38.4 with SMTP id c4mr3736603lbk.46.1417796481155; Fri, 05 Dec 2014 08:21:21 -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 ew9csp239458lbc; Fri, 5 Dec 2014 08:21:20 -0800 (PST) X-Received: by 10.140.29.9 with SMTP id a9mr26707480qga.41.1417796478426; Fri, 05 Dec 2014 08:21:18 -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 l6si35290162qao.37.2014.12.05.08.21.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 05 Dec 2014 08:21:18 -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 1Xwvd5-0001zV-UM; Fri, 05 Dec 2014 16:21:15 +0000 Received: from mail-la0-f49.google.com ([209.85.215.49]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xwvcb-0001uJ-Pr for lng-odp@lists.linaro.org; Fri, 05 Dec 2014 16:20:45 +0000 Received: by mail-la0-f49.google.com with SMTP id hs14so906738lab.8 for ; Fri, 05 Dec 2014 08:20:40 -0800 (PST) X-Received: by 10.153.6.33 with SMTP id cr1mr3702739lad.63.1417796440212; Fri, 05 Dec 2014 08:20:40 -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 pr9sm8455263lbc.12.2014.12.05.08.20.38 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Dec 2014 08:20:39 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 5 Dec 2014 19:20:23 +0300 Message-Id: <1417796424-9909-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1417796424-9909-1-git-send-email-maxim.uvarov@linaro.org> References: <1417796424-9909-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv6 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.50 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 993f2ab..833725e 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; }