[CRIU] [PATCH 10/15] inet: raw -- Split lookup_socket helper
Cyrill Gorcunov
gorcunov at gmail.com
Thu Sep 13 22:57:53 MSK 2018
Raw sockets may have arbitrary protocol so we
need different helper to lookup socket.
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
criu/include/sockets.h | 3 ++-
criu/sockets.c | 24 ++++++++++++++++--------
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/criu/include/sockets.h b/criu/include/sockets.h
index 371d1a5095b7..99e5762f76f6 100644
--- a/criu/include/sockets.h
+++ b/criu/include/sockets.h
@@ -44,7 +44,8 @@ extern int unix_note_scm_rights(int id_for, uint32_t *file_ids, int *fds, int n_
extern struct collect_image_info netlink_sk_cinfo;
-extern struct socket_desc *lookup_socket(unsigned ino, int family, int proto);
+extern struct socket_desc *lookup_socket_ino(unsigned int ino, int family);
+extern struct socket_desc *lookup_socket(unsigned int ino, int family, int proto);
extern const struct fdtype_ops unix_dump_ops;
extern const struct fdtype_ops inet_dump_ops;
diff --git a/criu/sockets.c b/criu/sockets.c
index e5b31175264b..fecca1a2f96c 100644
--- a/criu/sockets.c
+++ b/criu/sockets.c
@@ -390,26 +390,34 @@ static int restore_socket_filter(int sk, SkOptsEntry *soe)
static struct socket_desc *sockets[SK_HASH_SIZE];
-struct socket_desc *lookup_socket(unsigned ino, int family, int proto)
+struct socket_desc *lookup_socket_ino(unsigned int ino, int family)
{
struct socket_desc *sd;
- if (!socket_test_collect_bit(family, proto)) {
- pr_err("Sockets (family %d, proto %d) are not collected\n",
- family, proto);
- return ERR_PTR(-EINVAL);
- }
+ pr_debug("Searching for socket %#x family %d\n", ino, family);
- pr_debug("\tSearching for socket %x (family %d.%d)\n", ino, family, proto);
- for (sd = sockets[ino % SK_HASH_SIZE]; sd; sd = sd->next)
+ for (sd = sockets[ino % SK_HASH_SIZE]; sd; sd = sd->next) {
if (sd->ino == ino) {
BUG_ON(sd->family != family);
return sd;
}
+ }
return NULL;
}
+
+struct socket_desc *lookup_socket(unsigned int ino, int family, int proto)
+{
+ if (!socket_test_collect_bit(family, proto)) {
+ pr_err("Sockets (family %d proto %d) are not collected\n",
+ family, proto);
+ return ERR_PTR(-EINVAL);
+ }
+
+ return lookup_socket_ino(ino, family);
+}
+
int sk_collect_one(unsigned ino, int family, struct socket_desc *d, struct ns_id *ns)
{
struct socket_desc **chain;
--
2.17.1
More information about the CRIU
mailing list