Merge branch 'topic/tasklet-convert' into for-linus
[linux-block.git] / include / linux / inet_diag.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
73c1f4a0
ACM
2#ifndef _INET_DIAG_H_
3#define _INET_DIAG_H_ 1
1da177e4 4
83f73c5b 5#include <net/netlink.h>
607ca46e 6#include <uapi/linux/inet_diag.h>
2df005b7 7
4f5736c4
ACM
8struct inet_hashinfo;
9
10struct inet_diag_handler {
34160ea3
ED
11 void (*dump)(struct sk_buff *skb,
12 struct netlink_callback *cb,
0df6d328 13 const struct inet_diag_req_v2 *r);
34160ea3 14
5682d393 15 int (*dump_one)(struct netlink_callback *cb,
34160ea3
ED
16 const struct inet_diag_req_v2 *req);
17
18 void (*idiag_get_info)(struct sock *sk,
19 struct inet_diag_msg *r,
20 void *info);
6eb5d2e0 21
b37e8840
ID
22 int (*idiag_get_aux)(struct sock *sk,
23 bool net_admin,
24 struct sk_buff *skb);
25
26 size_t (*idiag_get_aux_size)(struct sock *sk,
27 bool net_admin);
28
6eb5d2e0
LC
29 int (*destroy)(struct sk_buff *in_skb,
30 const struct inet_diag_req_v2 *req);
31
34160ea3 32 __u16 idiag_type;
3fd22af8 33 __u16 idiag_info_size;
4f5736c4
ACM
34};
35
085c20ca 36struct bpf_sk_storage_diag;
0df6d328
MKL
37struct inet_diag_dump_data {
38 struct nlattr *req_nlas[__INET_DIAG_REQ_MAX];
39#define inet_diag_nla_bc req_nlas[INET_DIAG_REQ_BYTECODE]
085c20ca
MKL
40#define inet_diag_nla_bpf_stgs req_nlas[INET_DIAG_REQ_SK_BPF_STORAGES]
41
42 struct bpf_sk_storage_diag *bpf_stg_diag;
0df6d328
MKL
43};
44
3c4d05c8
PE
45struct inet_connection_sock;
46int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
5682d393
MKL
47 struct sk_buff *skb, struct netlink_callback *cb,
48 const struct inet_diag_req_v2 *req,
49 u16 nlmsg_flags, bool net_admin);
1942c518 50void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
34160ea3 51 struct netlink_callback *cb,
0df6d328 52 const struct inet_diag_req_v2 *r);
1942c518 53int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
5682d393 54 struct netlink_callback *cb,
34160ea3 55 const struct inet_diag_req_v2 *req);
1942c518 56
b613f56e
LC
57struct sock *inet_diag_find_one_icsk(struct net *net,
58 struct inet_hashinfo *hashinfo,
59 const struct inet_diag_req_v2 *req);
60
8d07d151 61int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
b005ab4e 62
c3ec5e5c
BD
63void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
64
83f73c5b
DY
65static inline size_t inet_diag_msg_attrs_size(void)
66{
67 return nla_total_size(1) /* INET_DIAG_SHUTDOWN */
68 + nla_total_size(1) /* INET_DIAG_TOS */
69#if IS_ENABLED(CONFIG_IPV6)
70 + nla_total_size(1) /* INET_DIAG_TCLASS */
71 + nla_total_size(1) /* INET_DIAG_SKV6ONLY */
72#endif
73 + nla_total_size(4) /* INET_DIAG_MARK */
6e3a401f
DY
74 + nla_total_size(4) /* INET_DIAG_CLASS_ID */
75#ifdef CONFIG_SOCK_CGROUP_DATA
76 + nla_total_size_64bit(sizeof(u64)) /* INET_DIAG_CGROUP_ID */
77#endif
78 ;
83f73c5b 79}
c3ec5e5c
BD
80int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
81 struct inet_diag_msg *r, int ext,
d545caca 82 struct user_namespace *user_ns, bool net_admin);
c3ec5e5c 83
4f5736c4
ACM
84extern int inet_diag_register(const struct inet_diag_handler *handler);
85extern void inet_diag_unregister(const struct inet_diag_handler *handler);
73c1f4a0 86#endif /* _INET_DIAG_H_ */