From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7F6C1A034E; Tue, 19 Nov 2019 17:37:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D9CC3A69; Tue, 19 Nov 2019 17:37:10 +0100 (CET) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 13362A69 for ; Tue, 19 Nov 2019 17:37:08 +0100 (CET) Received: by mail-pf1-f193.google.com with SMTP id n13so12450127pff.1 for ; Tue, 19 Nov 2019 08:37:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wN+SJReHcQekr6wz/jbzZMimnHrOATT66j2E1Jf/xaw=; b=LKr8YiMIOONtlTkZk92XjkTc+BdDIiOtMKjYZD77M+IUwaOsQAksZsaBghi5e1LVcQ AuRyazMM7F1/b0VcYXdQ7P9DdQK9VujminXYwxwSOU9DYu+CmxxW4cKCKwcz2MhOiCMS 0LRa8QUe6CnfyYR9lN/uSr8ZSQmvn+Eaf0jZFrfLp3BvSz/Ydrr9meQ22iO3xlPGTMAI uFfLCAsBHlOUjvy0QgQYyyZDvCbfehvJKM2iQkMYZlfEdxm6DvOvE326/6uUY0peREOH O54WvkgLfQPflJe9e/hsCu2n+acViDOLEFoCW+Ea0HJ2d1HORhSRLEJ84dad/5acMXKK oE8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wN+SJReHcQekr6wz/jbzZMimnHrOATT66j2E1Jf/xaw=; b=gNI7ahKmI/JSTPy/ay68sSQDkMjDBuD/buZMJo/2aFwL8accrZ17xAAMYNHTk50Vs+ GVqu19WpaGaBjWSm5S9K9LKaggJw/fbo4StyTd4CGysE5v+TXU1S72MirI9Yjans2e57 ahrE079FbIknZkEjxQDQxCaQ3Ht+VBJN2pR2pZvkOikMmtgFoxOb1jqugh7aHwLUUhlY iRHzIKeOV/2aw++EvousbKaqjOAsnS4MuBItg5vQUZxIXRs1SD05I5mveTDgsh+Q73V1 xfalK3EjTE+8tCcA4kXe6bRe3c7bG62mQbWXvaxFv+3nZ2AfIl+6KdRxYMlQgntrhjFQ eSsQ== X-Gm-Message-State: APjAAAVfRiIRB1xafhnRlxyBsgeFrFMLbdUEc3HcSL9IRvBLhzjVdaN2 hq90qbk//Kecrr7NifBI7Isbyw== X-Google-Smtp-Source: APXvYqxnwBXXfQHuhAgJqyL6ZB1oPY0YfNthue1kKsbSCA/MWgMZ3Uj9KzyQw0ewF/ZnlzaXpHINnA== X-Received: by 2002:a62:2f43:: with SMTP id v64mr6608858pfv.13.1574181428088; Tue, 19 Nov 2019 08:37:08 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id w69sm27551290pfc.164.2019.11.19.08.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2019 08:37:07 -0800 (PST) Date: Tue, 19 Nov 2019 08:36:38 -0800 From: Stephen Hemminger To: Tiwei Bie Cc: dev@dpdk.org, maxime.coquelin@redhat.com, zhihong.wang@intel.com, stable@dpdk.org Message-ID: <20191119083638.37097fa4@hermes.lan> In-Reply-To: <20191119062948.15834-1-tiwei.bie@intel.com> References: <20191119062948.15834-1-tiwei.bie@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 20.02] net/virtio-user: do not close tap when disabling queue pairs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, 19 Nov 2019 14:29:48 +0800 Tiwei Bie wrote: > -static int > +int > +vhost_kernel_tap_attach_queue(int fd) > +{ > + struct ifreq ifr; > + > + memset(&ifr, 0, sizeof(ifr)); > + ifr.ifr_flags = IFF_ATTACH_QUEUE; > + return ioctl(fd, TUNSETQUEUE, (void *)&ifr); > +} > + > +int > +vhost_kernel_tap_detach_queue(int fd) > +{ > + struct ifreq ifr; > + > + memset(&ifr, 0, sizeof(ifr)); > + ifr.ifr_flags = IFF_DETACH_QUEUE; > + return ioctl(fd, TUNSETQUEUE, (void *)&ifr); > +} > + These both could be squashed into one routine. int vhost_kernel_tap_set_queue(int fd, bool attach) { struct ifreq ifr = { .ifr_flags = attach ? IFF_ATTACH_QUEUE : IFF_DETACH_QUEUE }; return ioctl(fd, TUNSETQUEUE, &ifr); } 1. Use initializer instead of memset 2. Cast to void * is unnecessary