mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
![Martin KaFai Lau](/assets/img/avatar_default.png)
In a latter patch, there is a need to update "cb->min_dump_alloc" in inet_sk_diag_fill() as it learns the diffierent bpf_sk_storages stored in a sk while dumping all sk(s) (e.g. tcp_hashinfo). The inet_sk_diag_fill() currently does not take the "cb" as an argument. One of the reason is inet_sk_diag_fill() is used by both dump_one() and dump() (which belong to the "struct inet_diag_handler". The dump_one() interface does not pass the "cb" along. This patch is to make dump_one() pass a "cb". The "cb" is created in inet_diag_cmd_exact(). The "nlh" and "in_skb" are stored in "cb" as the dump() interface does. The total number of args in inet_sk_diag_fill() is also cut from 10 to 7 and that helps many callers to pass fewer args. In particular, "struct user_namespace *user_ns", "u32 pid", and "u32 seq" can be replaced by accessing "cb->nlh" and "cb->skb". A similar argument reduction is also made to inet_twsk_diag_fill() and inet_req_diag_fill(). inet_csk_diag_dump() and inet_csk_diag_fill() are also removed. They are mostly equivalent to inet_sk_diag_fill(). Their repeated usages are very limited. Thus, inet_sk_diag_fill() is directly used in those occasions. Signed-off-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Song Liu <songliubraving@fb.com> Link: https://lore.kernel.org/bpf/20200225230409.1975173-1-kafai@fb.com
69 lines
2 KiB
C
69 lines
2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _INET_DIAG_H_
|
|
#define _INET_DIAG_H_ 1
|
|
|
|
#include <uapi/linux/inet_diag.h>
|
|
|
|
struct net;
|
|
struct sock;
|
|
struct inet_hashinfo;
|
|
struct nlattr;
|
|
struct nlmsghdr;
|
|
struct sk_buff;
|
|
struct netlink_callback;
|
|
|
|
struct inet_diag_handler {
|
|
void (*dump)(struct sk_buff *skb,
|
|
struct netlink_callback *cb,
|
|
const struct inet_diag_req_v2 *r,
|
|
struct nlattr *bc);
|
|
|
|
int (*dump_one)(struct netlink_callback *cb,
|
|
const struct inet_diag_req_v2 *req);
|
|
|
|
void (*idiag_get_info)(struct sock *sk,
|
|
struct inet_diag_msg *r,
|
|
void *info);
|
|
|
|
int (*idiag_get_aux)(struct sock *sk,
|
|
bool net_admin,
|
|
struct sk_buff *skb);
|
|
|
|
size_t (*idiag_get_aux_size)(struct sock *sk,
|
|
bool net_admin);
|
|
|
|
int (*destroy)(struct sk_buff *in_skb,
|
|
const struct inet_diag_req_v2 *req);
|
|
|
|
__u16 idiag_type;
|
|
__u16 idiag_info_size;
|
|
};
|
|
|
|
struct inet_connection_sock;
|
|
int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
|
|
struct sk_buff *skb, struct netlink_callback *cb,
|
|
const struct inet_diag_req_v2 *req,
|
|
u16 nlmsg_flags, bool net_admin);
|
|
void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
|
|
struct netlink_callback *cb,
|
|
const struct inet_diag_req_v2 *r,
|
|
struct nlattr *bc);
|
|
int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
|
|
struct netlink_callback *cb,
|
|
const struct inet_diag_req_v2 *req);
|
|
|
|
struct sock *inet_diag_find_one_icsk(struct net *net,
|
|
struct inet_hashinfo *hashinfo,
|
|
const struct inet_diag_req_v2 *req);
|
|
|
|
int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
|
|
|
|
void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
|
|
|
|
int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
|
|
struct inet_diag_msg *r, int ext,
|
|
struct user_namespace *user_ns, bool net_admin);
|
|
|
|
extern int inet_diag_register(const struct inet_diag_handler *handler);
|
|
extern void inet_diag_unregister(const struct inet_diag_handler *handler);
|
|
#endif /* _INET_DIAG_H_ */
|