From: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
To: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
Subject: Re: [PATCH 4/4] C/R: Fix storing IPv6 addresses and handle the "ipv6only" socket flag (v2)
Date: Sun, 25 Apr 2010 17:08:07 -0400 [thread overview]
Message-ID: <4BD4AF37.10504@cs.columbia.edu> (raw)
In-Reply-To: <1270748932-26745-5-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Hi Dan,
Dan Smith wrote:
> The first item is a result of sockaddr_in6 being larger than the base
> sockaddr structure, thus not being long enough to reserve enough space in
> the checkpoint header.
>
> The second comes into play when things (like sshd) bind to INADDR6_ANY,
> set the "ipv6only" socket flag and then bind an IPv4 socket to the same
> port.
>
> Changes in v2:
> - Export the inet_* symbols used by inet6 so that CONFIG_IPV6=m
> will compile
>
> Signed-off-by: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> ---
> include/linux/checkpoint_hdr.h | 13 +++++++++++--
> net/ipv4/checkpoint.c | 37 +++++++++++++++++++++++--------------
> net/ipv6/af_inet6.c | 2 ++
> 3 files changed, 36 insertions(+), 16 deletions(-)
>
> diff --git a/include/linux/checkpoint_hdr.h b/include/linux/checkpoint_hdr.h
> index 98aa79c..7fde6b5 100644
> --- a/include/linux/checkpoint_hdr.h
> +++ b/include/linux/checkpoint_hdr.h
> @@ -758,12 +758,21 @@ struct ckpt_hdr_socket_inet {
> struct in6_addr saddr;
> struct in6_addr rcv_saddr;
> struct in6_addr daddr;
> + __u8 ipv6only;
> } inet6 __attribute__ ((aligned(8)));
>
> __u32 laddr_len;
> __u32 raddr_len;
> - struct sockaddr_in laddr;
> - struct sockaddr_in raddr;
> + union {
> + struct sockaddr laddr;
> + struct sockaddr_in laddr4;
> + struct sockaddr_in6 laddr6;
> + };
> + union {
> + struct sockaddr raddr;
> + struct sockaddr_in raddr4;
> + struct sockaddr_in6 raddr6;
> + };
> } __attribute__((aligned(8)));
>
> struct ckpt_hdr_file_socket {
> diff --git a/net/ipv4/checkpoint.c b/net/ipv4/checkpoint.c
> index b4024e7..1c43570 100644
> --- a/net/ipv4/checkpoint.c
> +++ b/net/ipv4/checkpoint.c
> @@ -190,12 +190,14 @@ static int sock_inet_restore_connection(struct sock *sk,
> struct inet_sock *inet = inet_sk(sk);
> int tcp_gso = sk->sk_family == AF_INET ? SKB_GSO_TCPV4 : SKB_GSO_TCPV6;
>
> - inet->inet_daddr = hh->raddr.sin_addr.s_addr;
> - inet->inet_saddr = hh->laddr.sin_addr.s_addr;
> - inet->inet_rcv_saddr = inet->inet_saddr;
> + if (sk->sk_family == AF_INET) {
> + inet->inet_daddr = hh->raddr4.sin_addr.s_addr;
> + inet->inet_saddr = hh->laddr4.sin_addr.s_addr;
> + inet->inet_rcv_saddr = inet->inet_saddr;
>
> - inet->inet_dport = hh->raddr.sin_port;
> - inet->inet_sport = hh->laddr.sin_port;
> + inet->inet_dport = hh->raddr4.sin_port;
> + inet->inet_sport = hh->laddr4.sin_port;
> + }
>
> if (sk->sk_protocol == IPPROTO_TCP)
> sk->sk_gso_type = tcp_gso;
> @@ -266,6 +268,7 @@ static int sock_inet_cptrst(struct ckpt_ctx *ctx,
> ipv6_addr_copy(&inet6->rcv_saddr, &hh->inet6.rcv_saddr);
> ipv6_addr_copy(&inet6->daddr, &hh->inet6.daddr);
> }
> + CKPT_COPY(op, hh->inet6.ipv6only, inet6->ipv6only);
> }
>
> return ret;
> @@ -281,8 +284,8 @@ int inet_checkpoint(struct ckpt_ctx *ctx, struct socket *sock)
> return -EINVAL;
>
> ret = ckpt_sock_getnames(ctx, sock,
> - (struct sockaddr *)&in->laddr, &in->laddr_len,
> - (struct sockaddr *)&in->raddr, &in->raddr_len);
> + &in->laddr, &in->laddr_len,
> + &in->raddr, &in->raddr_len);
> if (ret)
> goto out;
>
> @@ -296,11 +299,13 @@ int inet_checkpoint(struct ckpt_ctx *ctx, struct socket *sock)
>
> return ret;
> }
> +EXPORT_SYMBOL_GPL(inet_checkpoint);
This belongs to a separate patch ? Especially for as long as we
need to keep our patchset clean, until it makes it to -mm
>
> int inet_collect(struct ckpt_ctx *ctx, struct socket *sock)
> {
> return ckpt_obj_collect(ctx, sock->sk, CKPT_OBJ_SOCK);
> }
> +EXPORT_SYMBOL_GPL(inet_collect);
Ditto.
>
> static int inet_read_buffer(struct ckpt_ctx *ctx,
> struct sk_buff_head *queue,
> @@ -387,19 +392,19 @@ static int inet_precheck(struct socket *sock, struct ckpt_hdr_socket_inet *in)
> __u8 nonagle_mask = TCP_NAGLE_OFF | TCP_NAGLE_CORK | TCP_NAGLE_PUSH;
> __u8 ecn_mask = TCP_ECN_OK | TCP_ECN_QUEUE_CWR | TCP_ECN_DEMAND_CWR;
>
> - if ((htons(in->laddr.sin_port) < PROT_SOCK) &&
> + if ((htons(in->laddr4.sin_port) < PROT_SOCK) &&
> !capable(CAP_NET_BIND_SERVICE)) {
> ckpt_debug("unable to bind to port %hu\n",
> - htons(in->laddr.sin_port));
> + htons(in->laddr4.sin_port));
> return -EINVAL;
> }
>
> - if (in->laddr_len > sizeof(struct sockaddr_in)) {
> + if (in->laddr_len > sizeof(in->laddr6)) {
> ckpt_debug("laddr_len is too big\n");
> return -EINVAL;
> }
>
> - if (in->raddr_len > sizeof(struct sockaddr_in)) {
> + if (in->raddr_len > sizeof(in->laddr6)) {
> ckpt_debug("raddr_len is too big\n");
> return -EINVAL;
> }
> @@ -496,11 +501,14 @@ int inet_restore(struct ckpt_ctx *ctx,
> */
> if ((h->sock.state == TCP_LISTEN) ||
> ((h->sock.state == TCP_CLOSE) && (in->laddr_len > 0))) {
> + if (in->inet6.ipv6only) {
> + struct ipv6_pinfo *np = inet6_sk(sock->sk);
> + np->ipv6only = 1;
> + }
> +
> sock->sk->sk_reuse = 2;
> inet_sk(sock->sk)->freebind = 1;
> - ret = sock->ops->bind(sock,
> - (struct sockaddr *)&in->laddr,
> - in->laddr_len);
> + ret = sock->ops->bind(sock, &in->laddr, in->laddr_len);
> ckpt_debug("inet bind: %i\n", ret);
> if (ret < 0)
> goto out;
> @@ -547,3 +555,4 @@ int inet_restore(struct ckpt_ctx *ctx,
>
> return ret;
> }
> +EXPORT_SYMBOL_GPL(inet_restore);
Ditto.
> diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
> index 12e69d3..9acb55a 100644
> --- a/net/ipv6/af_inet6.c
> +++ b/net/ipv6/af_inet6.c
> @@ -523,6 +523,8 @@ const struct proto_ops inet6_stream_ops = {
> .mmap = sock_no_mmap,
> .sendpage = tcp_sendpage,
> .splice_read = tcp_splice_read,
> + .checkpoint = inet_checkpoint,
> + .restore = inet_restore,
> #ifdef CONFIG_COMPAT
> .compat_setsockopt = compat_sock_common_setsockopt,
> .compat_getsockopt = compat_sock_common_getsockopt,
Oren.
next prev parent reply other threads:[~2010-04-25 21:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-08 17:48 A modular approach to handling netdev address c/r Dan Smith
[not found] ` <1270748932-26745-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-08 17:48 ` [PATCH 1/4] Modularize the handling of " Dan Smith
[not found] ` <1270748932-26745-2-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-12 16:08 ` Serge E. Hallyn
2010-04-25 21:04 ` Oren Laadan
[not found] ` <4BD4AE6D.2070507-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-04-26 15:11 ` Dan Smith
[not found] ` <874oiyfdv1.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2010-04-26 16:05 ` Oren Laadan
2010-04-08 17:48 ` [PATCH 2/4] Fail checkpoint if IPv4 multicast addresses are configured Dan Smith
[not found] ` <1270748932-26745-3-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-12 16:09 ` Serge E. Hallyn
2010-04-08 17:48 ` [PATCH 3/4] Add IPv6 address checkpoint handler Dan Smith
[not found] ` <1270748932-26745-4-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-12 16:11 ` Serge E. Hallyn
[not found] ` <20100412161148.GC23380-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-12 17:39 ` Dan Smith
[not found] ` <871vekbmen.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2010-04-12 17:47 ` Serge E. Hallyn
2010-04-12 17:58 ` Dan Smith
[not found] ` <20100412174756.GA15269-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-25 20:49 ` Oren Laadan
2010-04-15 19:35 ` Brian Haley
[not found] ` <4BC76A65.7060909-VXdhtT5mjnY@public.gmane.org>
2010-04-15 19:46 ` Dan Smith
[not found] ` <87vdbs1oty.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2010-04-15 20:32 ` Brian Haley
[not found] ` <4BC777C8.6050102-VXdhtT5mjnY@public.gmane.org>
2010-04-16 15:02 ` Dan Smith
2010-04-08 17:48 ` [PATCH 4/4] C/R: Fix storing IPv6 addresses and handle the "ipv6only" socket flag (v2) Dan Smith
[not found] ` <1270748932-26745-5-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-25 21:08 ` Oren Laadan [this message]
[not found] ` <4BD4AF37.10504-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-04-26 13:41 ` Dan Smith
[not found] ` <87d3xmfhzx.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2010-04-26 14:35 ` Oren Laadan
[not found] ` <4BD5A49B.9030605-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-04-26 14:43 ` Dan Smith
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=4BD4AF37.10504@cs.columbia.edu \
--to=orenl-eqauephvms7envbuuze7ea@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.