[CRIU] [crtools-bot for Pavel Emelyanov ] sock: Add dst creds to
socket structs
Cyrill Gorcunov
gorcunov at openvz.org
Fri Mar 2 06:54:42 EST 2012
The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit bad126e7a542b32ce56d6f1dbcb43effa939db90
Author: Pavel Emelyanov <xemul at parallels.com>
Date: Fri Mar 2 15:50:09 2012 +0400
sock: Add dst creds to socket structs
These are required for inet sockets, but were not added since listen
sockets do not have them.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
include/image.h | 3 ++-
sockets.c | 22 ++++++++++++++++++----
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/include/image.h b/include/image.h
index 45f55eb..5d9752a 100644
--- a/include/image.h
+++ b/include/image.h
@@ -97,9 +97,10 @@ struct inet_sk_entry {
u8 proto;
u8 state;
u16 src_port;
- u8 pad[2];
+ u16 dst_port;
u32 backlog;
u32 src_addr[4];
+ u32 dst_addr[4];
} __packed;
struct sk_packet_entry {
diff --git a/sockets.c b/sockets.c
index c4a847c..60f60e6 100644
--- a/sockets.c
+++ b/sockets.c
@@ -77,10 +77,12 @@ struct inet_sk_desc {
unsigned int type;
unsigned int proto;
unsigned int src_port;
+ unsigned int dst_port;
unsigned int state;
unsigned int rqlen;
unsigned int wqlen;
unsigned int src_addr[4];
+ unsigned int dst_addr[4];
};
static int unix_sk_queue_add(int fd, const struct unix_sk_desc *sd,
@@ -254,8 +256,10 @@ static int dump_one_inet(const struct socket_desc *_sk, int fd,
ie.proto = sk->proto;
ie.state = sk->state;
ie.src_port = sk->src_port;
+ ie.dst_port = sk->dst_port;
ie.backlog = sk->wqlen;
memcpy(ie.src_addr, sk->src_addr, sizeof(u32) * 4);
+ memcpy(ie.dst_addr, sk->dst_addr, sizeof(u32) * 4);
if (write_img(cr_fdset->fds[CR_FD_INETSK], &ie))
goto err;
@@ -426,10 +430,12 @@ static int inet_collect_one(struct nlmsghdr *h, int type, int proto)
d->type = type;
d->proto = proto;
d->src_port = ntohs(m->id.idiag_sport);
+ d->dst_port = ntohs(m->id.idiag_dport);
d->state = m->idiag_state;
d->rqlen = m->idiag_rqueue;
d->wqlen = m->idiag_wqueue;
memcpy(d->src_addr, m->id.idiag_src, sizeof(u32) * 4);
+ memcpy(d->dst_addr, m->id.idiag_dst, sizeof(u32) * 4);
return sk_collect_one(m->idiag_inode, AF_INET, &d->sd);
}
@@ -1266,6 +1272,7 @@ void show_inetsk(int fd)
while (1) {
char src_addr[INET_ADDR_LEN] = "<unknown>";
+ char dst_addr[INET_ADDR_LEN] = "<unknown>";
ret = read_img_eof(fd, &ie);
if (ret <= 0)
@@ -1273,12 +1280,19 @@ void show_inetsk(int fd)
if (inet_ntop(AF_INET, (void *)ie.src_addr, src_addr,
INET_ADDR_LEN) == NULL) {
- pr_perror("Failed to translate address");
+ pr_perror("Failed to translate src address");
}
- pr_msg("fd %d family %d type %d proto %d port %d state %d "
- "--> %s\n", ie.fd, ie.family, ie.type, ie.proto,
- ie.src_port, ie.state, src_addr);
+ if (ie.state == TCP_ESTABLISHED) {
+ if (inet_ntop(AF_INET, (void *)ie.dst_addr, dst_addr,
+ INET_ADDR_LEN) == NULL) {
+ pr_perror("Failed to translate dst address");
+ }
+ }
+
+ pr_msg("fd %d family %d type %d proto %d state %d %s:%d <-> %s:%d\n",
+ ie.fd, ie.family, ie.type, ie.proto, ie.state,
+ src_addr, ie.src_port, dst_addr, ie.dst_port);
}
out:
More information about the CRIU
mailing list