Commit b0cf603b authored by Pavel Emelyanov's avatar Pavel Emelyanov

netlink: Pass argument through do_rtnl_req engine

Will need it int netns dumping callbacks later.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent cffe1ea1
......@@ -5,6 +5,6 @@
extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
extern int do_rtnl_req(int nl, void *req, int size,
int (*receive_callback)(struct nlmsghdr *h));
int (*receive_callback)(struct nlmsghdr *h, void *), void *);
#endif /* LIBNETLINK_H__ */
......@@ -53,7 +53,7 @@ extern int dump_one_inet(struct fd_parms *p, int lfd, const struct cr_fdset *set
extern int dump_one_unix(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int inet_collect_one(struct nlmsghdr *h, int family, int type, int proto);
extern int unix_receive_one(struct nlmsghdr *h);
extern int unix_receive_one(struct nlmsghdr *h, void *);
extern int do_dump_opt(int sk, int name, void *val, int len);
......
......@@ -21,7 +21,7 @@ int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
return 0;
}
static int nlmsg_receive(char *buf, int len, int (*cb)(struct nlmsghdr *))
static int nlmsg_receive(char *buf, int len, int (*cb)(struct nlmsghdr *, void *), void *arg)
{
struct nlmsghdr *hdr;
......@@ -34,7 +34,7 @@ static int nlmsg_receive(char *buf, int len, int (*cb)(struct nlmsghdr *))
pr_err("Error getting sockets list\n");
return -1;
}
if (cb(hdr))
if (cb(hdr, arg))
return -1;
}
......@@ -42,7 +42,7 @@ static int nlmsg_receive(char *buf, int len, int (*cb)(struct nlmsghdr *))
}
int do_rtnl_req(int nl, void *req, int size,
int (*receive_callback)(struct nlmsghdr *h))
int (*receive_callback)(struct nlmsghdr *h, void *), void *arg)
{
struct msghdr msg;
struct sockaddr_nl nladdr;
......@@ -90,7 +90,7 @@ int do_rtnl_req(int nl, void *req, int size,
if (err == 0)
break;
err = nlmsg_receive(buf, err, receive_callback);
err = nlmsg_receive(buf, err, receive_callback, arg);
if (err < 0)
goto err;
if (err == 0)
......
......@@ -367,7 +367,7 @@ skip:
return ret;
}
int unix_receive_one(struct nlmsghdr *h)
int unix_receive_one(struct nlmsghdr *h, void *arg)
{
struct unix_diag_msg *m = NLMSG_DATA(h);
struct rtattr *tb[UNIX_DIAG_MAX+1];
......
......@@ -141,32 +141,32 @@ int dump_socket(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset)
return -1;
}
static int inet_tcp_receive_one(struct nlmsghdr *h)
static int inet_tcp_receive_one(struct nlmsghdr *h, void *arg)
{
return inet_collect_one(h, AF_INET, SOCK_STREAM, IPPROTO_TCP);
}
static int inet_udp_receive_one(struct nlmsghdr *h)
static int inet_udp_receive_one(struct nlmsghdr *h, void *arg)
{
return inet_collect_one(h, AF_INET, SOCK_DGRAM, IPPROTO_UDP);
}
static int inet_udplite_receive_one(struct nlmsghdr *h)
static int inet_udplite_receive_one(struct nlmsghdr *h, void *arg)
{
return inet_collect_one(h, AF_INET, SOCK_DGRAM, IPPROTO_UDPLITE);
}
static int inet6_tcp_receive_one(struct nlmsghdr *h)
static int inet6_tcp_receive_one(struct nlmsghdr *h, void *arg)
{
return inet_collect_one(h, AF_INET6, SOCK_STREAM, IPPROTO_TCP);
}
static int inet6_udp_receive_one(struct nlmsghdr *h)
static int inet6_udp_receive_one(struct nlmsghdr *h, void *arg)
{
return inet_collect_one(h, AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
}
static int inet6_udplite_receive_one(struct nlmsghdr *h)
static int inet6_udplite_receive_one(struct nlmsghdr *h, void *arg)
{
return inet_collect_one(h, AF_INET6, SOCK_DGRAM, IPPROTO_UDPLITE);
}
......@@ -201,7 +201,7 @@ int collect_sockets(void)
req.r.u.udiag_show = UDIAG_SHOW_NAME | UDIAG_SHOW_VFS |
UDIAG_SHOW_PEER | UDIAG_SHOW_ICONS |
UDIAG_SHOW_RQLEN;
tmp = do_rtnl_req(nl, &req, sizeof(req), unix_receive_one);
tmp = do_rtnl_req(nl, &req, sizeof(req), unix_receive_one, NULL);
if (tmp)
err = tmp;
......@@ -211,7 +211,7 @@ int collect_sockets(void)
req.r.i.idiag_ext = 0;
/* Only listening and established sockets supported yet */
req.r.i.idiag_states = (1 << TCP_LISTEN) | (1 << TCP_ESTABLISHED);
tmp = do_rtnl_req(nl, &req, sizeof(req), inet_tcp_receive_one);
tmp = do_rtnl_req(nl, &req, sizeof(req), inet_tcp_receive_one, NULL);
if (tmp)
err = tmp;
......@@ -220,7 +220,7 @@ int collect_sockets(void)
req.r.i.sdiag_protocol = IPPROTO_UDP;
req.r.i.idiag_ext = 0;
req.r.i.idiag_states = -1; /* All */
tmp = do_rtnl_req(nl, &req, sizeof(req), inet_udp_receive_one);
tmp = do_rtnl_req(nl, &req, sizeof(req), inet_udp_receive_one, NULL);
if (tmp)
err = tmp;
......@@ -229,7 +229,7 @@ int collect_sockets(void)
req.r.i.sdiag_protocol = IPPROTO_UDPLITE;
req.r.i.idiag_ext = 0;
req.r.i.idiag_states = -1; /* All */
tmp = do_rtnl_req(nl, &req, sizeof(req), inet_udplite_receive_one);
tmp = do_rtnl_req(nl, &req, sizeof(req), inet_udplite_receive_one, NULL);
if (tmp)
err = tmp;
......@@ -239,7 +239,7 @@ int collect_sockets(void)
req.r.i.idiag_ext = 0;
/* Only listening sockets supported yet */
req.r.i.idiag_states = 1 << TCP_LISTEN;
tmp = do_rtnl_req(nl, &req, sizeof(req), inet6_tcp_receive_one);
tmp = do_rtnl_req(nl, &req, sizeof(req), inet6_tcp_receive_one, NULL);
if (tmp)
err = tmp;
......@@ -248,7 +248,7 @@ int collect_sockets(void)
req.r.i.sdiag_protocol = IPPROTO_UDP;
req.r.i.idiag_ext = 0;
req.r.i.idiag_states = -1; /* All */
tmp = do_rtnl_req(nl, &req, sizeof(req), inet6_udp_receive_one);
tmp = do_rtnl_req(nl, &req, sizeof(req), inet6_udp_receive_one, NULL);
if (tmp)
err = tmp;
......@@ -257,7 +257,7 @@ int collect_sockets(void)
req.r.i.sdiag_protocol = IPPROTO_UDPLITE;
req.r.i.idiag_ext = 0;
req.r.i.idiag_states = -1; /* All */
tmp = do_rtnl_req(nl, &req, sizeof(req), inet6_udplite_receive_one);
tmp = do_rtnl_req(nl, &req, sizeof(req), inet6_udplite_receive_one, NULL);
if (tmp)
err = tmp;
......
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