From patchwork Mon Dec 8 14:58:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 42017 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 06201244AC for ; Mon, 8 Dec 2014 14:59:32 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id u10sf2831784lbd.6 for ; Mon, 08 Dec 2014 06:59:31 -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=ZELsesW/pzHeENkJWKdYnVm1LLv/KBH6GbCPoveC8V0=; b=lskMCY3UMw5QY9U1BrdZ/3f3GOhTUC/RKH7Pu7+XeGo/BZ64ZjBWrvd1I43DlflwUq bWkYAR4XOFKDc+04pBu/oxPt34B+k0bkQ6+BtAWrGsuosQ8lKEFITTXJKtYpnG3e4K5O iPmqVvab847AtPfkN/zx3/+8KEdEK1awV9n7PBQuha3uzTxVJoDYV5SECmgxUnKrcPVm Kvs1SnNTChyEd/9macN6MbssFKE4Pk6nC9A01M7LwJrJtIGfv+Vfznx2qCZJSMu9idKy B7cD0go3f51SWDQbNdTa3x65qq/NmlbS3Oz74vXDbMvalAE9NJk857jbXMgVIYusFye/ DP5Q== X-Gm-Message-State: ALoCoQlJruUSFpXCz4Ep+LHgdW1RrDEDln3z7q308ML7wBURIBCjqnHgoHzRyZsElGal+q9BFyNI X-Received: by 10.112.169.101 with SMTP id ad5mr6308160lbc.1.1418050770956; Mon, 08 Dec 2014 06:59:30 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.98 with SMTP id j2ls362655lah.103.gmail; Mon, 08 Dec 2014 06:59:30 -0800 (PST) X-Received: by 10.112.166.101 with SMTP id zf5mr17388138lbb.42.1418050770807; Mon, 08 Dec 2014 06:59: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 f6si37260508lbc.11.2014.12.08.06.59.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Dec 2014 06:59: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 gq15so4091320lab.32 for ; Mon, 08 Dec 2014 06:59:30 -0800 (PST) X-Received: by 10.112.38.4 with SMTP id c4mr16874670lbk.46.1418050770714; Mon, 08 Dec 2014 06:59: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 ew9csp617427lbc; Mon, 8 Dec 2014 06:59:29 -0800 (PST) X-Received: by 10.224.55.145 with SMTP id u17mr53913925qag.12.1418050768918; Mon, 08 Dec 2014 06:59: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 v7si43508801qaf.108.2014.12.08.06.59.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 08 Dec 2014 06:59: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 1XxzmW-0006OQ-Rg; Mon, 08 Dec 2014 14:59:24 +0000 Received: from mail-lb0-f181.google.com ([209.85.217.181]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xxzm4-0006HE-0g for lng-odp@lists.linaro.org; Mon, 08 Dec 2014 14:58:56 +0000 Received: by mail-lb0-f181.google.com with SMTP id l4so3784720lbv.40 for ; Mon, 08 Dec 2014 06:58:50 -0800 (PST) X-Received: by 10.152.170.131 with SMTP id am3mr16528667lac.15.1418050730500; Mon, 08 Dec 2014 06:58:50 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id xs6sm10869631lbb.13.2014.12.08.06.58.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Dec 2014 06:58:49 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 8 Dec 2014 17:58:32 +0300 Message-Id: <1418050713-29694-7-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] [PATCHv7 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 8a86421..4399ef9 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -546,20 +546,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; } @@ -576,19 +577,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; }