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 9C97AA328D for ; Tue, 22 Oct 2019 18:37:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 71ADB1BF22; Tue, 22 Oct 2019 18:37:34 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 164481BF0F for ; Tue, 22 Oct 2019 18:37:33 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id 15so4925400pgt.7 for ; Tue, 22 Oct 2019 09:37:33 -0700 (PDT) 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=9AOaXo8dv+A13hd//f9yxasKKaKcff45PnhaUlnMv00=; b=IXCU1YnH8fmj6ktjv7x8dljMxcmcfY/+bRWus5hY4EbHLjPeNjp+4DTqAWtINqCjb1 mk6LLkcCwGfGY+xBdNhrI99LrIcR3SJQ7tUvhfwJjdV8m2qFuVk374xR2gL3XCYPCfjG DVpRdZTrvNPu2rSlgjfYe7cZnbhzkbqkYJu8ipMOkCNBo7I+6HW2IOQxxBpqpSZL0TqX rm/6RFftWnsWP3F8EX20g3T2b0o+ZiU5FZBgmGDl5z7rdbQ2cboSicS11Z+eFusU322w ljk2yXU33BRN1BrH5HK93S3pNlbB4CMmB3Q0HTilhMcLhHLrEE4coN0AltvIhgRA1ZlW 1vdg== 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=9AOaXo8dv+A13hd//f9yxasKKaKcff45PnhaUlnMv00=; b=XZV1MSsi47L0E1Hw9uZ1htVH+tIsHn4VAyH3IM5/2XxxD8qvHYisgF3m2V5GDVJuWl Lh5AgnzMXJw3SAllunZ3VRTrHltjd/P0N3WnKpui/4Lw9KD0nZCWP29fIr2BI7c0xOY4 Y7pXda5P9IGnQ80qKGD8sUqHra1ZlJ3QNNFyPKKqnuHwQsIgpcjhGqs5CUuGV6+XusEG A/3XZNSnP7VZmT88CzMYFNcd+FvC5D/J70ns0v+H5JAvY9Tm+hDX50R4ahEvC1uxQtmg 95qn3YkuaxWZnIEE/V05wJeiUB8oMiPR9Twmc6pybspFblJr0p1jiQlG3BSZ+T5Kb4PD vjFQ== X-Gm-Message-State: APjAAAXy5TG4HBIrwYtt1pzh383e9A2F411jGi/5Y2lK9ljJ1ZRaUr8C fiRK80R+7nvLLnJKvX6Jn3DkdifZpgBndA== X-Google-Smtp-Source: APXvYqyZ4SBWiUx12vrfBZwRyORXOQNEJryRTzg4TIhWpa2+7s+FNMpeA6v9tu/keCJgk0yrNX7kpw== X-Received: by 2002:a63:5a03:: with SMTP id o3mr4687580pgb.381.1571762252093; Tue, 22 Oct 2019 09:37:32 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id o20sm3471136pfp.16.2019.10.22.09.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 09:37:32 -0700 (PDT) Date: Tue, 22 Oct 2019 09:37:30 -0700 From: Stephen Hemminger To: Jakub Grajciar Cc: Message-ID: <20191022093730.36cc5075@hermes.lan> In-Reply-To: <20191022160829.21664-1-jgrajcia@cisco.com> References: <20191022160829.21664-1-jgrajcia@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] net/memif: fix invalid unix domain address length 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, 22 Oct 2019 18:08:29 +0200 Jakub Grajciar wrote: > Cc: stephen@networkplumber.org > > Signed-off-by: Jakub Grajciar > --- > doc/guides/nics/memif.rst | 2 +- > drivers/net/memif/memif_socket.c | 27 +++++++++++---------------- > drivers/net/memif/memif_socket.h | 6 ++++-- > drivers/net/memif/rte_eth_memif.c | 5 +++++ > 4 files changed, 21 insertions(+), 19 deletions(-) > > diff --git a/doc/guides/nics/memif.rst b/doc/guides/nics/memif.rst > index de2d481eb..9a568455e 100644 > --- a/doc/guides/nics/memif.rst > +++ b/doc/guides/nics/memif.rst > @@ -42,7 +42,7 @@ client. > "role=master", "Set memif role", "slave", "master|slave" > "bsize=1024", "Size of single packet buffer", "2048", "uint16_t" > "rsize=11", "Log2 of ring size. If rsize is 10, actual ring size is 1024", "10", "1-14" > - "socket=/tmp/memif.sock", "Socket filename", "/tmp/memif.sock", "string len 256" > + "socket=/tmp/memif.sock", "Socket filename", "/tmp/memif.sock", "string len 108" > "mac=01:23:45:ab:cd:ef", "Mac address", "01:ab:23:cd:45:ef", "" > "secret=abc123", "Secret is an optional security option, which if specified, must be matched by peer", "", "string len 24" > "zero-copy=yes", "Enable/disable zero-copy slave mode", "no", "yes|no" > diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c > index 0c71f6c45..4efa68e1a 100644 > --- a/drivers/net/memif/memif_socket.c > +++ b/drivers/net/memif/memif_socket.c > @@ -7,7 +7,6 @@ > #include > #include > #include > -#include > #include > #include > > @@ -860,16 +859,12 @@ memif_listener_handler(void *arg) > rte_free(cc); > } > > -#define MEMIF_SOCKET_UN_SIZE \ > - (offsetof(struct sockaddr_un, sun_path) + MEMIF_SOCKET_KEY_LEN) > - > static struct memif_socket * > memif_socket_create(struct pmd_internals *pmd, > const char *key, uint8_t listener) > { > struct memif_socket *sock; > - struct sockaddr_un *un; > - char un_buf[MEMIF_SOCKET_UN_SIZE]; > + struct sockaddr_un un; > int sockfd; > int ret; > int on = 1; > @@ -881,7 +876,7 @@ memif_socket_create(struct pmd_internals *pmd, > } > > sock->listener = listener; > - strlcpy(sock->filename, key, MEMIF_SOCKET_KEY_LEN); > + strlcpy(sock->filename, key, MEMIF_SOCKET_UN_SIZE); > TAILQ_INIT(&sock->dev_queue); > > if (listener != 0) { > @@ -889,18 +884,18 @@ memif_socket_create(struct pmd_internals *pmd, > if (sockfd < 0) > goto error; > > - memset(un_buf, 0, sizeof(un_buf)); > - un = (struct sockaddr_un *)un_buf; > - un->sun_family = AF_UNIX; > - strlcpy(un->sun_path, sock->filename, MEMIF_SOCKET_KEY_LEN); > + un.sun_family = AF_UNIX; > + strlcpy(un.sun_path, sock->filename, MEMIF_SOCKET_UN_SIZE); Why does this not use abstract unix domain socket naming? That would be much less error prone, because then the socket would disappear when all applications using it are closed.