All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oren Laadan <orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
To: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
Subject: Re: [PATCH 1/2] Add socket list helper functions
Date: Mon, 12 Oct 2009 17:27:19 -0400	[thread overview]
Message-ID: <4AD39F37.2000007@librato.com> (raw)
In-Reply-To: <1254932945-12578-2-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>



Dan Smith wrote:
> The INET patch needs to maintain a list of listening sockets in order to
> support post-restart socket hashing.  The ckpt_ctx_free() function thus
> needs to clean up that list after processing the deferqueue, and needs to
> know something about what is on that list.  Instead of calling into a
> single cleanup function in the checkpoint code, I decided to just make
> the list itself a little more abstract and separate it here.

IMHO this is over-engineered. This way, you place net-related knowledge
in ckpt_ctx_free(), instead of isolating that sort of smarts under net/
subdir. I'd rather see the clean-up logic near the "litter" logic, so
to speak.

Or, make it entirely generic, use container_of etc and put in, for
instance, in include/linux/list2.h. Anyway, I don't think it belongs
in checkpoint.h.

Thanks,

Oren.

> 
> Signed-off-by: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> ---
>  include/linux/checkpoint.h |    5 +++++
>  net/checkpoint.c           |   42 ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 47 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/checkpoint.h b/include/linux/checkpoint.h
> index dd75bc2..89e41c2 100644
> --- a/include/linux/checkpoint.h
> +++ b/include/linux/checkpoint.h
> @@ -100,6 +100,11 @@ extern int ckpt_sock_getnames(struct ckpt_ctx *ctx,
>  			      struct socket *socket,
>  			      struct sockaddr *loc, unsigned *loc_len,
>  			      struct sockaddr *rem, unsigned *rem_len);
> +int sock_list_add(struct list_head *list, struct sock *sk);
> +typedef int (*sock_compare_fn)(struct sock *, struct sock *);
> +struct sock *sock_list_find(struct list_head *list, struct sock *sk,
> +			    sock_compare_fn cmp);
> +void sock_list_free(struct list_head *list);
>  
>  /* ckpt kflags */
>  #define ckpt_set_ctx_kflag(__ctx, __kflag)  \
> diff --git a/net/checkpoint.c b/net/checkpoint.c
> index 9a72aae..e7e8e75 100644
> --- a/net/checkpoint.c
> +++ b/net/checkpoint.c
> @@ -758,3 +758,45 @@ struct file *sock_file_restore(struct ckpt_ctx *ctx, struct ckpt_hdr_file *ptr)
>  
>  	return file;
>  }
> +
> +struct ckpt_sock_list_item {
> +       struct sock *sk;
> +       struct list_head list;
> +};
> +
> +int sock_list_add(struct list_head *list, struct sock *sk)
> +{
> +	struct ckpt_sock_list_item *item;
> +
> +	item = kmalloc(sizeof(*item), GFP_KERNEL);
> +	if (!item)
> +		return -ENOMEM;
> +
> +	item->sk = sk;
> +	list_add(&item->list, list);
> +
> +	return 0;
> +}
> +
> +void sock_list_free(struct list_head *list)
> +{
> +	struct ckpt_sock_list_item *item, *tmp;
> +
> +	list_for_each_entry_safe(item, tmp, list, list) {
> +		list_del(&item->list);
> +		kfree(item);
> +	}
> +}
> +
> +struct sock *sock_list_find(struct list_head *list, struct sock *sk,
> +			    sock_compare_fn cmp)
> +{
> +	struct ckpt_sock_list_item *item;
> +
> +	list_for_each_entry(item, list, list) {
> +		if (cmp(sk, item->sk))
> +			return item->sk;
> +	}
> +
> +	return NULL;
> +}

  parent reply	other threads:[~2009-10-12 21:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-07 16:29 c/r: Support open INET connections Dan Smith
     [not found] ` <1254932945-12578-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-07 16:29   ` [PATCH 1/2] Add socket list helper functions Dan Smith
     [not found]     ` <1254932945-12578-2-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-12 21:27       ` Oren Laadan [this message]
     [not found]         ` <4AD39F37.2000007-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-10-13 15:14           ` Dan Smith
     [not found]             ` <87d44re36u.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-10-13 15:34               ` Serge E. Hallyn
2009-10-07 16:29   ` [PATCH 2/2] [RFC] Add c/r support for connected INET sockets Dan Smith
     [not found]     ` <1254932945-12578-3-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-07 17:19       ` Serge E. Hallyn
     [not found]         ` <20091007171907.GA20572-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-07 17:22           ` Dan Smith
2009-10-08 14:47     ` John Dykstra
2009-10-08 15:41       ` Dan Smith
     [not found]         ` <87ab01gag7.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-10-08 17:31           ` John Dykstra
2009-10-08 17:34             ` Dan Smith
     [not found]               ` <8763apg57w.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-10-08 18:10                 ` John Dykstra
2009-10-08 18:11                   ` Dan Smith
2009-10-12 21:52     ` Oren Laadan
2009-10-13 17:05       ` Dan Smith
     [not found]         ` <87ws2zcjhe.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-10-13 19:00           ` Oren Laadan
     [not found]             ` <4AD4CE61.30503-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-10-13 19:12               ` Dan Smith
2009-10-13 19:35                 ` Oren Laadan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AD39F37.2000007@librato.com \
    --to=orenl-rdfvbdnroixbdgjk7y7tuq@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.