DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC] net/memif: allow for full key size in socket name
@ 2019-07-08 16:06 Stephen Hemminger
  2019-07-16 17:18 ` [dpdk-dev] [RFC v2] " Stephen Hemminger
  2019-07-16 17:20 ` [dpdk-dev] [RFC v3] " Stephen Hemminger
  0 siblings, 2 replies; 8+ messages in thread
From: Stephen Hemminger @ 2019-07-08 16:06 UTC (permalink / raw)
  To: jgrajcia; +Cc: dev, Stephen Hemminger

The key size for memif is 256 but the unix domain socket structure has
space for 100 bytes. Change it to use a larger buffer and not hard
code the keysize everywhere.

Not sure what purpose of socket is anyway since there is no code
which connects to it in the current tree anyway?

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
Patch is RFC since not tested and I don't use memif so not
going to go further.

 drivers/net/memif/memif_socket.c | 30 +++++++++++++++++++-----------
 drivers/net/memif/memif_socket.h |  4 +++-
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c
index 01a935f87c9f..fb69015694ba 100644
--- a/drivers/net/memif/memif_socket.c
+++ b/drivers/net/memif/memif_socket.c
@@ -860,11 +860,16 @@ 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, char *key, uint8_t listener)
+memif_socket_create(struct pmd_internals *pmd,
+		    const char *key, uint8_t listener)
 {
 	struct memif_socket *sock;
-	struct sockaddr_un un;
+	struct sockaddr_un *un;
+	char un_buf[MEMIF_SOCKET_UN_SIZE];
 	int sockfd;
 	int ret;
 	int on = 1;
@@ -876,23 +881,25 @@ memif_socket_create(struct pmd_internals *pmd, char *key, uint8_t listener)
 	}
 
 	sock->listener = listener;
-	rte_memcpy(sock->filename, key, 256);
+	strlcpy(sock->filename, key, MEMIF_SOCKET_KEY_LEN);
 	TAILQ_INIT(&sock->dev_queue);
 
 	if (listener != 0) {
+
 		sockfd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
 		if (sockfd < 0)
 			goto error;
 
-		un.sun_family = AF_UNIX;
-		memcpy(un.sun_path, sock->filename,
-			sizeof(un.sun_path) - 1);
+		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);
 
 		ret = setsockopt(sockfd, SOL_SOCKET, SO_PASSCRED, &on,
 				 sizeof(on));
 		if (ret < 0)
 			goto error;
-		ret = bind(sockfd, (struct sockaddr *)&un, sizeof(un));
+		ret = bind(sockfd, (struct sockaddr *)un, MEMIF_SOCKET_UN_SIZE);
 		if (ret < 0)
 			goto error;
 		ret = listen(sockfd, 1);
@@ -928,9 +935,10 @@ static struct rte_hash *
 memif_create_socket_hash(void)
 {
 	struct rte_hash_parameters params = { 0 };
+
 	params.name = MEMIF_SOCKET_HASH_NAME;
 	params.entries = 256;
-	params.key_len = 256;
+	params.key_len = MEMIF_SOCKET_KEY_LEN;;
 	params.hash_func = rte_jhash;
 	params.hash_func_init_val = 0;
 	return rte_hash_create(&params);
@@ -945,7 +953,7 @@ memif_socket_init(struct rte_eth_dev *dev, const char *socket_filename)
 	struct pmd_internals *tmp_pmd;
 	struct rte_hash *hash;
 	int ret;
-	char key[256];
+	char key[MEMIF_SOCKET_KEY_LEN];
 
 	hash = rte_hash_find_existing(MEMIF_SOCKET_HASH_NAME);
 	if (hash == NULL) {
@@ -956,8 +964,8 @@ memif_socket_init(struct rte_eth_dev *dev, const char *socket_filename)
 		}
 	}
 
-	memset(key, 0, 256);
-	rte_memcpy(key, socket_filename, strlen(socket_filename));
+	memset(key, 0, MEMIF_SOCKET_KEY_LEN);
+	strlcpy(key, socket_filename, MEMIF_SOCKET_KEY_LEN);
 	ret = rte_hash_lookup_data(hash, key, (void **)&socket);
 	if (ret < 0) {
 		socket = memif_socket_create(pmd, key,
diff --git a/drivers/net/memif/memif_socket.h b/drivers/net/memif/memif_socket.h
index db293e200961..9f40f8d138bb 100644
--- a/drivers/net/memif/memif_socket.h
+++ b/drivers/net/memif/memif_socket.h
@@ -79,9 +79,11 @@ struct memif_socket_dev_list_elt {
 };
 
 #define MEMIF_SOCKET_HASH_NAME			"memif-sh"
+#define MEMIF_SOCKET_KEY_LEN		256
+
 struct memif_socket {
 	struct rte_intr_handle intr_handle;	/**< interrupt handle */
-	char filename[256];			/**< socket filename */
+	char filename[MEMIF_SOCKET_KEY_LEN];	/**< socket filename */
 
 	TAILQ_HEAD(, memif_socket_dev_list_elt) dev_queue;
 	/**< Queue of devices using this socket */
-- 
2.20.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-dev] [RFC v2] net/memif: allow for full key size in socket name
  2019-07-08 16:06 [dpdk-dev] [RFC] net/memif: allow for full key size in socket name Stephen Hemminger
@ 2019-07-16 17:18 ` Stephen Hemminger
  2019-07-16 17:20 ` [dpdk-dev] [RFC v3] " Stephen Hemminger
  1 sibling, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2019-07-16 17:18 UTC (permalink / raw)
  To: dev, jgrajcia; +Cc: Stephen Hemminger

The key size for memif is 256 but the unix domain socket structure has
space for 100 bytes. Change it to use a larger buffer and not hard
code the keysize everywhere.

Not sure what purpose of socket is anyway since there is no code
which connects to it in the current tree anyway?

Still and RFC since I have no way to test this.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - fix checkpatch warnings

 drivers/net/memif/memif_socket.c | 30 +++++++++++++++++++-----------
 drivers/net/memif/memif_socket.h |  4 +++-
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c
index 01a935f87c9f..fb69015694ba 100644
--- a/drivers/net/memif/memif_socket.c
+++ b/drivers/net/memif/memif_socket.c
@@ -860,11 +860,16 @@ 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, char *key, uint8_t listener)
+memif_socket_create(struct pmd_internals *pmd,
+		    const char *key, uint8_t listener)
 {
 	struct memif_socket *sock;
-	struct sockaddr_un un;
+	struct sockaddr_un *un;
+	char un_buf[MEMIF_SOCKET_UN_SIZE];
 	int sockfd;
 	int ret;
 	int on = 1;
@@ -876,23 +881,25 @@ memif_socket_create(struct pmd_internals *pmd, char *key, uint8_t listener)
 	}
 
 	sock->listener = listener;
-	rte_memcpy(sock->filename, key, 256);
+	strlcpy(sock->filename, key, MEMIF_SOCKET_KEY_LEN);
 	TAILQ_INIT(&sock->dev_queue);
 
 	if (listener != 0) {
+
 		sockfd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
 		if (sockfd < 0)
 			goto error;
 
-		un.sun_family = AF_UNIX;
-		memcpy(un.sun_path, sock->filename,
-			sizeof(un.sun_path) - 1);
+		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);
 
 		ret = setsockopt(sockfd, SOL_SOCKET, SO_PASSCRED, &on,
 				 sizeof(on));
 		if (ret < 0)
 			goto error;
-		ret = bind(sockfd, (struct sockaddr *)&un, sizeof(un));
+		ret = bind(sockfd, (struct sockaddr *)un, MEMIF_SOCKET_UN_SIZE);
 		if (ret < 0)
 			goto error;
 		ret = listen(sockfd, 1);
@@ -928,9 +935,10 @@ static struct rte_hash *
 memif_create_socket_hash(void)
 {
 	struct rte_hash_parameters params = { 0 };
+
 	params.name = MEMIF_SOCKET_HASH_NAME;
 	params.entries = 256;
-	params.key_len = 256;
+	params.key_len = MEMIF_SOCKET_KEY_LEN;;
 	params.hash_func = rte_jhash;
 	params.hash_func_init_val = 0;
 	return rte_hash_create(&params);
@@ -945,7 +953,7 @@ memif_socket_init(struct rte_eth_dev *dev, const char *socket_filename)
 	struct pmd_internals *tmp_pmd;
 	struct rte_hash *hash;
 	int ret;
-	char key[256];
+	char key[MEMIF_SOCKET_KEY_LEN];
 
 	hash = rte_hash_find_existing(MEMIF_SOCKET_HASH_NAME);
 	if (hash == NULL) {
@@ -956,8 +964,8 @@ memif_socket_init(struct rte_eth_dev *dev, const char *socket_filename)
 		}
 	}
 
-	memset(key, 0, 256);
-	rte_memcpy(key, socket_filename, strlen(socket_filename));
+	memset(key, 0, MEMIF_SOCKET_KEY_LEN);
+	strlcpy(key, socket_filename, MEMIF_SOCKET_KEY_LEN);
 	ret = rte_hash_lookup_data(hash, key, (void **)&socket);
 	if (ret < 0) {
 		socket = memif_socket_create(pmd, key,
diff --git a/drivers/net/memif/memif_socket.h b/drivers/net/memif/memif_socket.h
index db293e200961..9f40f8d138bb 100644
--- a/drivers/net/memif/memif_socket.h
+++ b/drivers/net/memif/memif_socket.h
@@ -79,9 +79,11 @@ struct memif_socket_dev_list_elt {
 };
 
 #define MEMIF_SOCKET_HASH_NAME			"memif-sh"
+#define MEMIF_SOCKET_KEY_LEN		256
+
 struct memif_socket {
 	struct rte_intr_handle intr_handle;	/**< interrupt handle */
-	char filename[256];			/**< socket filename */
+	char filename[MEMIF_SOCKET_KEY_LEN];	/**< socket filename */
 
 	TAILQ_HEAD(, memif_socket_dev_list_elt) dev_queue;
 	/**< Queue of devices using this socket */
-- 
2.20.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-dev] [RFC v3] net/memif: allow for full key size in socket name
  2019-07-08 16:06 [dpdk-dev] [RFC] net/memif: allow for full key size in socket name Stephen Hemminger
  2019-07-16 17:18 ` [dpdk-dev] [RFC v2] " Stephen Hemminger
@ 2019-07-16 17:20 ` Stephen Hemminger
  2019-08-30  7:17   ` Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco)
  2019-10-04 12:41   ` Yigit, Ferruh
  1 sibling, 2 replies; 8+ messages in thread
From: Stephen Hemminger @ 2019-07-16 17:20 UTC (permalink / raw)
  To: dev, jgrajcia; +Cc: Stephen Hemminger

The key size for memif is 256 but the unix domain socket structure has
space for 100 bytes. Change it to use a larger buffer and not hard
code the keysize everywhere.

Not sure what purpose of socket is anyway since there is no code
which connects to it in the current tree anyway?

Still an RFC, have no way to test.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v3 - fix checkpatch issues

 drivers/net/memif/memif_socket.c | 29 ++++++++++++++++++-----------
 drivers/net/memif/memif_socket.h |  4 +++-
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c
index 01a935f87c9f..5eecbdc98040 100644
--- a/drivers/net/memif/memif_socket.c
+++ b/drivers/net/memif/memif_socket.c
@@ -860,11 +860,16 @@ 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, char *key, uint8_t listener)
+memif_socket_create(struct pmd_internals *pmd,
+		    const char *key, uint8_t listener)
 {
 	struct memif_socket *sock;
-	struct sockaddr_un un;
+	struct sockaddr_un *un;
+	char un_buf[MEMIF_SOCKET_UN_SIZE];
 	int sockfd;
 	int ret;
 	int on = 1;
@@ -876,7 +881,7 @@ memif_socket_create(struct pmd_internals *pmd, char *key, uint8_t listener)
 	}
 
 	sock->listener = listener;
-	rte_memcpy(sock->filename, key, 256);
+	strlcpy(sock->filename, key, MEMIF_SOCKET_KEY_LEN);
 	TAILQ_INIT(&sock->dev_queue);
 
 	if (listener != 0) {
@@ -884,15 +889,16 @@ memif_socket_create(struct pmd_internals *pmd, char *key, uint8_t listener)
 		if (sockfd < 0)
 			goto error;
 
-		un.sun_family = AF_UNIX;
-		memcpy(un.sun_path, sock->filename,
-			sizeof(un.sun_path) - 1);
+		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);
 
 		ret = setsockopt(sockfd, SOL_SOCKET, SO_PASSCRED, &on,
 				 sizeof(on));
 		if (ret < 0)
 			goto error;
-		ret = bind(sockfd, (struct sockaddr *)&un, sizeof(un));
+		ret = bind(sockfd, (struct sockaddr *)un, MEMIF_SOCKET_UN_SIZE);
 		if (ret < 0)
 			goto error;
 		ret = listen(sockfd, 1);
@@ -928,9 +934,10 @@ static struct rte_hash *
 memif_create_socket_hash(void)
 {
 	struct rte_hash_parameters params = { 0 };
+
 	params.name = MEMIF_SOCKET_HASH_NAME;
 	params.entries = 256;
-	params.key_len = 256;
+	params.key_len = MEMIF_SOCKET_KEY_LEN;
 	params.hash_func = rte_jhash;
 	params.hash_func_init_val = 0;
 	return rte_hash_create(&params);
@@ -945,7 +952,7 @@ memif_socket_init(struct rte_eth_dev *dev, const char *socket_filename)
 	struct pmd_internals *tmp_pmd;
 	struct rte_hash *hash;
 	int ret;
-	char key[256];
+	char key[MEMIF_SOCKET_KEY_LEN];
 
 	hash = rte_hash_find_existing(MEMIF_SOCKET_HASH_NAME);
 	if (hash == NULL) {
@@ -956,8 +963,8 @@ memif_socket_init(struct rte_eth_dev *dev, const char *socket_filename)
 		}
 	}
 
-	memset(key, 0, 256);
-	rte_memcpy(key, socket_filename, strlen(socket_filename));
+	memset(key, 0, MEMIF_SOCKET_KEY_LEN);
+	strlcpy(key, socket_filename, MEMIF_SOCKET_KEY_LEN);
 	ret = rte_hash_lookup_data(hash, key, (void **)&socket);
 	if (ret < 0) {
 		socket = memif_socket_create(pmd, key,
diff --git a/drivers/net/memif/memif_socket.h b/drivers/net/memif/memif_socket.h
index db293e200961..9f40f8d138bb 100644
--- a/drivers/net/memif/memif_socket.h
+++ b/drivers/net/memif/memif_socket.h
@@ -79,9 +79,11 @@ struct memif_socket_dev_list_elt {
 };
 
 #define MEMIF_SOCKET_HASH_NAME			"memif-sh"
+#define MEMIF_SOCKET_KEY_LEN		256
+
 struct memif_socket {
 	struct rte_intr_handle intr_handle;	/**< interrupt handle */
-	char filename[256];			/**< socket filename */
+	char filename[MEMIF_SOCKET_KEY_LEN];	/**< socket filename */
 
 	TAILQ_HEAD(, memif_socket_dev_list_elt) dev_queue;
 	/**< Queue of devices using this socket */
-- 
2.20.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [RFC v3] net/memif: allow for full key size in socket name
  2019-07-16 17:20 ` [dpdk-dev] [RFC v3] " Stephen Hemminger
@ 2019-08-30  7:17   ` Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco)
  2019-09-13 18:47     ` Ferruh Yigit
  2019-10-04 12:41   ` Yigit, Ferruh
  1 sibling, 1 reply; 8+ messages in thread
From: Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco) @ 2019-08-30  7:17 UTC (permalink / raw)
  To: Stephen Hemminger, dev



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, July 16, 2019 7:21 PM
> To: dev@dpdk.org; Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at
> Cisco) <jgrajcia@cisco.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Subject: [RFC v3] net/memif: allow for full key size in socket name
> 
> The key size for memif is 256 but the unix domain socket structure has
> space for 100 bytes. Change it to use a larger buffer and not hard
> code the keysize everywhere.
> 
> Not sure what purpose of socket is anyway since there is no code
> which connects to it in the current tree anyway?

	See memif_connect_slave in memif_socket.c

> 
> Still an RFC, have no way to test.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Tested-by: Jakub Grajciar <jgrajcia@cisco.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [RFC v3] net/memif: allow for full key size in socket name
  2019-08-30  7:17   ` Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco)
@ 2019-09-13 18:47     ` Ferruh Yigit
  0 siblings, 0 replies; 8+ messages in thread
From: Ferruh Yigit @ 2019-09-13 18:47 UTC (permalink / raw)
  To: Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco),
	Stephen Hemminger, dev

On 8/30/2019 8:17 AM, Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at
Cisco) wrote:
> 
> 
>> -----Original Message-----
>> From: Stephen Hemminger <stephen@networkplumber.org>
>> Sent: Tuesday, July 16, 2019 7:21 PM
>> To: dev@dpdk.org; Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at
>> Cisco) <jgrajcia@cisco.com>
>> Cc: Stephen Hemminger <stephen@networkplumber.org>
>> Subject: [RFC v3] net/memif: allow for full key size in socket name
>>
>> The key size for memif is 256 but the unix domain socket structure has
>> space for 100 bytes. Change it to use a larger buffer and not hard
>> code the keysize everywhere.
>>
>> Not sure what purpose of socket is anyway since there is no code
>> which connects to it in the current tree anyway?
> 
> 	See memif_connect_slave in memif_socket.c
> 
>>
>> Still an RFC, have no way to test.
>>
>> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> 
> Tested-by: Jakub Grajciar <jgrajcia@cisco.com>
> 

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [RFC v3] net/memif: allow for full key size in socket name
  2019-07-16 17:20 ` [dpdk-dev] [RFC v3] " Stephen Hemminger
  2019-08-30  7:17   ` Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco)
@ 2019-10-04 12:41   ` Yigit, Ferruh
  2019-10-07  9:01     ` Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco)
  1 sibling, 1 reply; 8+ messages in thread
From: Yigit, Ferruh @ 2019-10-04 12:41 UTC (permalink / raw)
  To: Stephen Hemminger, jgrajcia; +Cc: dev, Konstantin Ananyev

On 7/16/2019 6:20 PM, Stephen Hemminger wrote:
> The key size for memif is 256 but the unix domain socket structure has
> space for 100 bytes. Change it to use a larger buffer and not hard
> code the keysize everywhere.
> 
> Not sure what purpose of socket is anyway since there is no code
> which connects to it in the current tree anyway?
> 
> Still an RFC, have no way to test.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> v3 - fix checkpatch issues
> 
>  drivers/net/memif/memif_socket.c | 29 ++++++++++++++++++-----------
>  drivers/net/memif/memif_socket.h |  4 +++-
>  2 files changed, 21 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c
> index 01a935f87c9f..5eecbdc98040 100644
> --- a/drivers/net/memif/memif_socket.c
> +++ b/drivers/net/memif/memif_socket.c
> @@ -860,11 +860,16 @@ 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, char *key, uint8_t listener)
> +memif_socket_create(struct pmd_internals *pmd,
> +		    const char *key, uint8_t listener)
>  {
>  	struct memif_socket *sock;
> -	struct sockaddr_un un;
> +	struct sockaddr_un *un;
> +	char un_buf[MEMIF_SOCKET_UN_SIZE];
>  	int sockfd;
>  	int ret;
>  	int on = 1;
> @@ -876,7 +881,7 @@ memif_socket_create(struct pmd_internals *pmd, char *key, uint8_t listener)
>  	}
>  
>  	sock->listener = listener;
> -	rte_memcpy(sock->filename, key, 256);
> +	strlcpy(sock->filename, key, MEMIF_SOCKET_KEY_LEN);
>  	TAILQ_INIT(&sock->dev_queue);
>  
>  	if (listener != 0) {
> @@ -884,15 +889,16 @@ memif_socket_create(struct pmd_internals *pmd, char *key, uint8_t listener)
>  		if (sockfd < 0)
>  			goto error;
>  
> -		un.sun_family = AF_UNIX;
> -		memcpy(un.sun_path, sock->filename,
> -			sizeof(un.sun_path) - 1);
> +		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);
>  
>  		ret = setsockopt(sockfd, SOL_SOCKET, SO_PASSCRED, &on,
>  				 sizeof(on));
>  		if (ret < 0)
>  			goto error;
> -		ret = bind(sockfd, (struct sockaddr *)&un, sizeof(un));
> +		ret = bind(sockfd, (struct sockaddr *)un, MEMIF_SOCKET_UN_SIZE);

Hi Jakub,

While testing your zero-copy patch [1], I stuck to a bind() error [2].
When provided a socket length bigger than "sizeof(struct sockaddr)", bind()
fails. I am testing this on a Fedora system.
I wonder if there is a check in glibc related to the length.

What was your test platform for the change?



[1]
https://patches.dpdk.org/patch/57817/

[2]
memif_socket_create(): NULL: Failed to setup socket /run/memif.sock: Invalid
argument

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [RFC v3] net/memif: allow for full key size in socket name
  2019-10-04 12:41   ` Yigit, Ferruh
@ 2019-10-07  9:01     ` Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco)
  2019-10-07 15:21       ` Ferruh Yigit
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco) @ 2019-10-07  9:01 UTC (permalink / raw)
  To: Yigit, Ferruh, Stephen Hemminger; +Cc: dev, Konstantin Ananyev


Hi Ferruh,

> Hi Jakub,
> 
> While testing your zero-copy patch [1], I stuck to a bind() error [2].
> When provided a socket length bigger than "sizeof(struct sockaddr)", bind()
> fails. I am testing this on a Fedora system.
> I wonder if there is a check in glibc related to the length.

	Zero-copy patch does not contain this fix, in fact, I can't find this patch in the commit log.
	It was supposed to be applied on 2019-09-13.
	http://git.dpdk.org/next/dpdk-next-net/log/?ofs=400
	Was there any problem with apply? Maybe because the patch is RFC?

> 
> What was your test platform for the change?

	Ubuntu 18.04

> 
> 
> 
> [1]
> https://patches.dpdk.org/patch/57817/
> 
> [2]
> memif_socket_create(): NULL: Failed to setup socket /run/memif.sock: Invalid
> argument

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [RFC v3] net/memif: allow for full key size in socket name
  2019-10-07  9:01     ` Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco)
@ 2019-10-07 15:21       ` Ferruh Yigit
  0 siblings, 0 replies; 8+ messages in thread
From: Ferruh Yigit @ 2019-10-07 15:21 UTC (permalink / raw)
  To: Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco),
	Yigit, Ferruh, Stephen Hemminger
  Cc: dev, Konstantin Ananyev

On 10/7/2019 10:01 AM, Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at
Cisco) wrote:
> 
> Hi Ferruh,
> 
>> Hi Jakub,
>>
>> While testing your zero-copy patch [1], I stuck to a bind() error [2].
>> When provided a socket length bigger than "sizeof(struct sockaddr)", bind()
>> fails. I am testing this on a Fedora system.
>> I wonder if there is a check in glibc related to the length.
> 
> 	Zero-copy patch does not contain this fix, in fact, I can't find this patch in the commit log.
> 	It was supposed to be applied on 2019-09-13.
> 	http://git.dpdk.org/next/dpdk-next-net/log/?ofs=400
> 	Was there any problem with apply? Maybe because the patch is RFC?

No zero-copy patch doesn't contain it. It is already in the repo. I hit the
issue while testing zero-copy, other than that there is no relation to zero-copy
feature J

The commit is in next-net tree, it is not released yet:
f018cfa797eb ("net/memif: allow for full key size in socket name")

Briefly, I am having issues with that commit, bind() fails, but it has your
Tested-by tag. Can you please confirm it again?

> 
>>
>> What was your test platform for the change?
> 
> 	Ubuntu 18.04

So you are on Linux as well, I wonder what is the difference.

> 
>>
>>
>>
>> [1]
>> https://patches.dpdk.org/patch/57817/
>>
>> [2]
>> memif_socket_create(): NULL: Failed to setup socket /run/memif.sock: Invalid
>> argument


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-10-07 15:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 16:06 [dpdk-dev] [RFC] net/memif: allow for full key size in socket name Stephen Hemminger
2019-07-16 17:18 ` [dpdk-dev] [RFC v2] " Stephen Hemminger
2019-07-16 17:20 ` [dpdk-dev] [RFC v3] " Stephen Hemminger
2019-08-30  7:17   ` Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco)
2019-09-13 18:47     ` Ferruh Yigit
2019-10-04 12:41   ` Yigit, Ferruh
2019-10-07  9:01     ` Jakub Grajciar -X (jgrajcia - PANTHEON TECHNOLOGIES at Cisco)
2019-10-07 15:21       ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).