Remove struct timeval from socket header
PATCH 1/1 Remove struct timeval from socket header
This patch removes the 'struct timeval' from the socket header and replaces it with a fixed-size type as suggested by Oren.
--- include/linux/checkpoint_hdr.h | 5 +++-- net/checkpoint.c | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-)
include/linux/checkpoint_hdr.h +3 -2
@@ -385,6 +385,9 @@ struct ckpt_hdr_socket {__s64 rcvlowat;__u64 flags; +__s64 rcvtimeo; +__s64 sndtimeo; +__u32 err;__u32 err_soft;__u32 priority;
@@ -400,8 +403,6 @@ struct ckpt_hdr_socket {__u8 no_check;struct linger linger; -struct timeval rcvtimeo; -struct timeval sndtimeo; } sock __attribute__ ((aligned(8))); } __attribute__ ((aligned(8)));
net/checkpoint.c +20 -2
@@ -349,6 +349,24 @@ static int sock_restore_flags(struct socket *sock,return 0 ; } +static int sock_copy_timeval (int op,struct sock *sk, +int sockopt,__s64 *saved) +{ +struct timeval tv; + +if (op ==CKPT_CPT ) { +if (CKPT_COPY_SOPT (op, sk, sockopt, &tv)) +return -EINVAL ; + *saved =timeval_to_ns (&tv); + }else { + tv =ns_to_timeval (*saved); +if (CKPT_COPY_SOPT (op, sk, sockopt, &tv)) +return -EINVAL ; + } + +return 0 ; +} +static int sock_cptrst (struct ckpt_ctx *ctx,struct sock *sk,struct ckpt_hdr_socket *h,int op) {
@@ -392,12 +410,12 @@ static int sock_cptrst(struct ckpt_ctx *ctx, struct sock *sk,return -EINVAL ; } -if (CKPT_COPY_SOPT (op, sk,SO_SNDTIMEO , &h->sock.sndtimeo)) { +if (sock_copy_timeval (op, sk,SO_SNDTIMEO , &h->sock.sndtimeo)) {ckpt_debug ("Failed to set SO_SNDTIMEO" );return -EINVAL ; } -if (CKPT_COPY_SOPT (op, sk,SO_RCVTIMEO , &h->sock.rcvtimeo)) { +if (sock_copy_timeval (op, sk,SO_RCVTIMEO , &h->sock.rcvtimeo)) {ckpt_debug ("Failed to set SO_RCVTIMEO" );return -EINVAL ; }
Signature · 1 line
1.6.2.5
A message that is not in the archive (sent off-list or not yet received): 1251137994-17972-1-git-send-email-danms-r/[email protected]
Serge E. Hallyn
Acked-byQuoted 4 lines · Dan Smith
This patch removes the 'struct timeval' from the socket header and replaces it with a fixed-size type as suggested by Oren.
Signed-off-by Dan Smith <danms-r/[email protected]>
Quoted 79 lines
--- include/linux/checkpoint_hdr.h | 5 +++-- net/checkpoint.c | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-)include/linux/checkpoint_hdr.h +3
-2@@ -385,6 +385,9 @@ struct ckpt_hdr_socket {__s64 rcvlowat;__u64 flags; +__s64 rcvtimeo; +__s64 sndtimeo; +__u32 err;__u32 err_soft;__u32 priority;@@ -400,8 +403,6 @@ struct ckpt_hdr_socket {__u8 no_check;struct linger linger; -struct timeval rcvtimeo; -struct timeval sndtimeo; } sock __attribute__ ((aligned(8))); } __attribute__ ((aligned(8)));net/checkpoint.c +20
-2@@ -349,6 +349,24 @@ static int sock_restore_flags(struct socket *sock,return 0 ; } +static int sock_copy_timeval (int op,struct sock *sk, +int sockopt,__s64 *saved) +{ +struct timeval tv; + +if (op ==CKPT_CPT ) { +if (CKPT_COPY_SOPT (op, sk, sockopt, &tv)) +return -EINVAL ; + *saved =timeval_to_ns (&tv); + }else { + tv =ns_to_timeval (*saved); +if (CKPT_COPY_SOPT (op, sk, sockopt, &tv)) +return -EINVAL ; + } + +return 0 ; +} +static int sock_cptrst (struct ckpt_ctx *ctx,struct sock *sk,struct ckpt_hdr_socket *h,int op) {@@ -392,12 +410,12 @@ static int sock_cptrst(struct ckpt_ctx *ctx, struct sock *sk,return -EINVAL ; } -if (CKPT_COPY_SOPT (op, sk,SO_SNDTIMEO , &h->sock.sndtimeo)) { +if (sock_copy_timeval (op, sk,SO_SNDTIMEO , &h->sock.sndtimeo)) {ckpt_debug ("Failed to set SO_SNDTIMEO" );return -EINVAL ; } -if (CKPT_COPY_SOPT (op, sk,SO_RCVTIMEO , &h->sock.rcvtimeo)) { +if (sock_copy_timeval (op, sk,SO_RCVTIMEO , &h->sock.rcvtimeo)) {ckpt_debug ("Failed to set SO_RCVTIMEO" );return -EINVAL ; }Signature · 6 lines
1.6.2.5 _______________________________________________ Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org https://lists.linux-foundation.org/mailman/listinfo/containers
Added, thanks.
Quoted 76 lines · Dan Smith
This patch removes the 'struct timeval' from the socket header and replaces it with a fixed-size type as suggested by Oren.
Signed-off-by Dan Smith <danms-r/[email protected]>--- include/linux/checkpoint_hdr.h | 5 +++-- net/checkpoint.c | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-)include/linux/checkpoint_hdr.h +3
-2@@ -385,6 +385,9 @@ struct ckpt_hdr_socket {__s64 rcvlowat;__u64 flags; +__s64 rcvtimeo; +__s64 sndtimeo; +__u32 err;__u32 err_soft;__u32 priority;@@ -400,8 +403,6 @@ struct ckpt_hdr_socket {__u8 no_check;struct linger linger; -struct timeval rcvtimeo; -struct timeval sndtimeo; } sock __attribute__ ((aligned(8))); } __attribute__ ((aligned(8)));net/checkpoint.c +20
-2@@ -349,6 +349,24 @@ static int sock_restore_flags(struct socket *sock,return 0 ; } +static int sock_copy_timeval (int op,struct sock *sk, +int sockopt,__s64 *saved) +{ +struct timeval tv; + +if (op ==CKPT_CPT ) { +if (CKPT_COPY_SOPT (op, sk, sockopt, &tv)) +return -EINVAL ; + *saved =timeval_to_ns (&tv); + }else { + tv =ns_to_timeval (*saved); +if (CKPT_COPY_SOPT (op, sk, sockopt, &tv)) +return -EINVAL ; + } + +return 0 ; +} +static int sock_cptrst (struct ckpt_ctx *ctx,struct sock *sk,struct ckpt_hdr_socket *h,int op) {@@ -392,12 +410,12 @@ static int sock_cptrst(struct ckpt_ctx *ctx, struct sock *sk,return -EINVAL ; } -if (CKPT_COPY_SOPT (op, sk,SO_SNDTIMEO , &h->sock.sndtimeo)) { +if (sock_copy_timeval (op, sk,SO_SNDTIMEO , &h->sock.sndtimeo)) {ckpt_debug ("Failed to set SO_SNDTIMEO" );return -EINVAL ; } -if (CKPT_COPY_SOPT (op, sk,SO_RCVTIMEO , &h->sock.rcvtimeo)) { +if (sock_copy_timeval (op, sk,SO_RCVTIMEO , &h->sock.rcvtimeo)) {ckpt_debug ("Failed to set SO_RCVTIMEO" );return -EINVAL ; }
Quoted 2 lines · Dan Smith
This patch removes the 'struct timeval' from the socket header and replaces it with a fixed-size type as suggested by Oren.
nit:
I think I can guess the reason Oren suggested this but I shouldn't have to -- it should be in the changelog instead of simply saying oren suggested it.
Cheers,
-Matt Helsley
A message that is not in the archive (sent off-list or not yet received): 20090825074902.GE8078-52DBMbEzqgQ/wnmkkaCWp/[email protected]
MH> I think I can guess the reason Oren suggested this but I shouldn't MH> have to -- it should be in the changelog instead of simply saying MH> oren suggested it.
Okay, I thought "fixed-size type" was clear enough, but noted.
Thanks!
Signature · 3 lines
Dan Smith IBM Linux Technology Center email: danms-r/[email protected]