All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch 3/3] tabled: drop addr_af
@ 2009-12-16  5:10 Pete Zaitcev
  2009-12-16  5:48 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Pete Zaitcev @ 2009-12-16  5:10 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Project Hail List

This flag was is a useless duplication and a fiction prompted by
getaddrinfo(). In reality it's not useful even if we decide to run
CLD over DCCP.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>

---
 server/storage.c |    8 ++++----
 server/tabled.h  |    3 +--
 2 files changed, 5 insertions(+), 6 deletions(-)

commit 7b1efec72048557b1b51d07a95073dbe25cf08d1
Author: Master <zaitcev@lembas.zaitcev.lan>
Date:   Tue Dec 15 21:47:48 2009 -0700

    Drop af flag, not needed.

diff --git a/server/storage.c b/server/storage.c
index cc7066f..8298e60 100644
--- a/server/storage.c
+++ b/server/storage.c
@@ -44,10 +44,10 @@ static int stor_new_stc(struct storage_node *stn, struct st_client **stcp)
 	struct sockaddr_in6 *a6;
 	unsigned short port;
 
-	if (stn->addr_af == AF_INET) {
+	if (stn->addr.sin6_family == AF_INET) {
 		a4 = (struct sockaddr_in *) &stn->addr;
 		port = ntohs(a4->sin_port);
-	} else if (stn->addr_af == AF_INET6) {
+	} else if (stn->addr.sin6_family == AF_INET6) {
 		a6 = &stn->addr;
 		port = ntohs(a6->sin6_port);
 	} else {
@@ -419,9 +419,9 @@ static int stor_add_node_addr(struct storage_node *sn,
 		if (res->ai_addrlen > ADDRSIZE)		/* should not happen */
 			continue;
 
-		memcpy(&sn->addr, res->ai_addr, res->ai_addrlen);
-		sn->addr_af = res->ai_family;
 		sn->alen = res->ai_addrlen;
+		memcpy(&sn->addr, res->ai_addr, sn->alen);
+		sn->addr.sin6_family = res->ai_family;
 
 		/* Use just the first address for now. */
 		freeaddrinfo(res0);
diff --git a/server/tabled.h b/server/tabled.h
index 51bfd44..290edaf 100644
--- a/server/tabled.h
+++ b/server/tabled.h
@@ -36,7 +36,7 @@
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 #endif
 
-#define ADDRSIZE	24	/* Enough for IPv6, including port. */
+#define ADDRSIZE	(sizeof(struct sockaddr_in6))	/* enough for v4 & v6 */
 
 enum {
 	TABLED_PGSZ_INODE	= 4096,
@@ -96,7 +96,6 @@ struct storage_node {
 	time_t			last_up;
 
 	unsigned		alen;
-	int			addr_af;
 	struct sockaddr_in6	addr;
 	char *hostname;		/* Only used because stc_new is overly smart. */
 

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

* Re: [Patch 3/3] tabled: drop addr_af
  2009-12-16  5:10 [Patch 3/3] tabled: drop addr_af Pete Zaitcev
@ 2009-12-16  5:48 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2009-12-16  5:48 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: Project Hail List

On 12/16/2009 12:10 AM, Pete Zaitcev wrote:
> This flag was is a useless duplication and a fiction prompted by
> getaddrinfo(). In reality it's not useful even if we decide to run
> CLD over DCCP.
>
> Signed-off-by: Pete Zaitcev<zaitcev@redhat.com>
>
> ---
>   server/storage.c |    8 ++++----
>   server/tabled.h  |    3 +--
>   2 files changed, 5 insertions(+), 6 deletions(-)
>
> commit 7b1efec72048557b1b51d07a95073dbe25cf08d1
> Author: Master<zaitcev@lembas.zaitcev.lan>
> Date:   Tue Dec 15 21:47:48 2009 -0700
>
>      Drop af flag, not needed.
>
> diff --git a/server/storage.c b/server/storage.c
> index cc7066f..8298e60 100644
> --- a/server/storage.c
> +++ b/server/storage.c
> @@ -44,10 +44,10 @@ static int stor_new_stc(struct storage_node *stn, struct st_client **stcp)
>   	struct sockaddr_in6 *a6;
>   	unsigned short port;
>
> -	if (stn->addr_af == AF_INET) {
> +	if (stn->addr.sin6_family == AF_INET) {
>   		a4 = (struct sockaddr_in *)&stn->addr;
>   		port = ntohs(a4->sin_port);
> -	} else if (stn->addr_af == AF_INET6) {
> +	} else if (stn->addr.sin6_family == AF_INET6) {
>   		a6 =&stn->addr;
>   		port = ntohs(a6->sin6_port);
>   	} else {
> @@ -419,9 +419,9 @@ static int stor_add_node_addr(struct storage_node *sn,
>   		if (res->ai_addrlen>  ADDRSIZE)		/* should not happen */
>   			continue;
>
> -		memcpy(&sn->addr, res->ai_addr, res->ai_addrlen);
> -		sn->addr_af = res->ai_family;
>   		sn->alen = res->ai_addrlen;
> +		memcpy(&sn->addr, res->ai_addr, sn->alen);
> +		sn->addr.sin6_family = res->ai_family;

applied 1-3, though I have a mild worry about how well this change works 
on non-Linux platforms.

We'll see when I next boot my FreeBSD virtual machine...

	Jeff



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

end of thread, other threads:[~2009-12-16  5:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-16  5:10 [Patch 3/3] tabled: drop addr_af Pete Zaitcev
2009-12-16  5:48 ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.