Commit 072778c4 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

inet: raw -- Split lookup_socket helper

Raw sockets may have arbitrary protocol so we
need different helper to lookup socket.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@gmail.com>
parent 2da21b11
...@@ -45,7 +45,8 @@ extern int unix_note_scm_rights(int id_for, uint32_t *file_ids, int *fds, int n_ ...@@ -45,7 +45,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 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 unix_dump_ops;
extern const struct fdtype_ops inet_dump_ops; extern const struct fdtype_ops inet_dump_ops;
......
...@@ -426,26 +426,34 @@ static int restore_socket_filter(int sk, SkOptsEntry *soe) ...@@ -426,26 +426,34 @@ static int restore_socket_filter(int sk, SkOptsEntry *soe)
static struct socket_desc *sockets[SK_HASH_SIZE]; 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; struct socket_desc *sd;
if (!socket_test_collect_bit(family, proto)) { pr_debug("Searching for socket %#x family %d\n", ino, family);
pr_err("Sockets (family %d, proto %d) are not collected\n",
family, proto);
return ERR_PTR(-EINVAL);
}
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) { if (sd->ino == ino) {
BUG_ON(sd->family != family); BUG_ON(sd->family != family);
return sd; return sd;
} }
}
return NULL; 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) int sk_collect_one(unsigned ino, int family, struct socket_desc *d, struct ns_id *ns)
{ {
struct socket_desc **chain; struct socket_desc **chain;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment