2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-08-12 12:51:49 -03:00
|
|
|
#ifndef _INET_DIAG_H_
|
|
|
|
|
#define _INET_DIAG_H_ 1
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2020-03-05 15:33:12 +03:00
|
|
|
#include <net/netlink.h>
|
2012-10-13 10:46:48 +01:00
|
|
|
#include <uapi/linux/inet_diag.h>
|
2009-01-30 21:42:47 +05:30
|
|
|
|
2005-08-12 09:27:49 -03:00
|
|
|
struct inet_hashinfo;
|
|
|
|
|
|
|
|
|
|
struct inet_diag_handler {
|
2015-03-10 07:15:54 -07:00
|
|
|
void (*dump)(struct sk_buff *skb,
|
|
|
|
|
struct netlink_callback *cb,
|
2020-02-25 15:04:15 -08:00
|
|
|
const struct inet_diag_req_v2 *r);
|
2011-12-09 06:23:18 +00:00
|
|
|
|
2020-02-25 15:04:09 -08:00
|
|
|
int (*dump_one)(struct netlink_callback *cb,
|
2015-03-10 07:15:54 -07:00
|
|
|
const struct inet_diag_req_v2 *req);
|
2011-12-09 06:23:18 +00:00
|
|
|
|
2015-03-10 07:15:54 -07:00
|
|
|
void (*idiag_get_info)(struct sock *sk,
|
|
|
|
|
struct inet_diag_msg *r,
|
|
|
|
|
void *info);
|
2015-12-16 12:30:04 +09:00
|
|
|
|
2017-08-31 09:59:38 -07:00
|
|
|
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);
|
|
|
|
|
|
2015-12-16 12:30:04 +09:00
|
|
|
int (*destroy)(struct sk_buff *in_skb,
|
|
|
|
|
const struct inet_diag_req_v2 *req);
|
|
|
|
|
|
2015-03-10 07:15:54 -07:00
|
|
|
__u16 idiag_type;
|
2015-06-15 11:26:19 -04:00
|
|
|
__u16 idiag_info_size;
|
2005-08-12 09:27:49 -03:00
|
|
|
};
|
|
|
|
|
|
2020-02-25 15:04:27 -08:00
|
|
|
struct bpf_sk_storage_diag;
|
2020-02-25 15:04:15 -08:00
|
|
|
struct inet_diag_dump_data {
|
|
|
|
|
struct nlattr *req_nlas[__INET_DIAG_REQ_MAX];
|
|
|
|
|
#define inet_diag_nla_bc req_nlas[INET_DIAG_REQ_BYTECODE]
|
2020-02-25 15:04:27 -08:00
|
|
|
#define inet_diag_nla_bpf_stgs req_nlas[INET_DIAG_REQ_SK_BPF_STORAGES]
|
|
|
|
|
|
|
|
|
|
struct bpf_sk_storage_diag *bpf_stg_diag;
|
2020-02-25 15:04:15 -08:00
|
|
|
};
|
|
|
|
|
|
2011-12-09 06:23:00 +00:00
|
|
|
struct inet_connection_sock;
|
|
|
|
|
int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
|
2020-02-25 15:04:09 -08:00
|
|
|
struct sk_buff *skb, struct netlink_callback *cb,
|
|
|
|
|
const struct inet_diag_req_v2 *req,
|
|
|
|
|
u16 nlmsg_flags, bool net_admin);
|
2011-12-09 06:23:18 +00:00
|
|
|
void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
|
2015-03-10 07:15:54 -07:00
|
|
|
struct netlink_callback *cb,
|
2020-02-25 15:04:15 -08:00
|
|
|
const struct inet_diag_req_v2 *r);
|
2011-12-09 06:23:18 +00:00
|
|
|
int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
|
2020-02-25 15:04:09 -08:00
|
|
|
struct netlink_callback *cb,
|
2015-03-10 07:15:54 -07:00
|
|
|
const struct inet_diag_req_v2 *req);
|
2011-12-09 06:23:18 +00:00
|
|
|
|
2015-12-16 12:30:02 +09:00
|
|
|
struct sock *inet_diag_find_one_icsk(struct net *net,
|
|
|
|
|
struct inet_hashinfo *hashinfo,
|
|
|
|
|
const struct inet_diag_req_v2 *req);
|
|
|
|
|
|
2011-12-09 06:22:44 +00:00
|
|
|
int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
|
2011-12-09 06:21:53 +00:00
|
|
|
|
2016-06-09 18:05:09 +01:00
|
|
|
void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
|
|
|
|
|
|
2020-03-05 15:33:12 +03:00
|
|
|
static inline size_t inet_diag_msg_attrs_size(void)
|
|
|
|
|
{
|
|
|
|
|
return nla_total_size(1) /* INET_DIAG_SHUTDOWN */
|
|
|
|
|
+ nla_total_size(1) /* INET_DIAG_TOS */
|
|
|
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
|
|
|
+ nla_total_size(1) /* INET_DIAG_TCLASS */
|
|
|
|
|
+ nla_total_size(1) /* INET_DIAG_SKV6ONLY */
|
|
|
|
|
#endif
|
|
|
|
|
+ nla_total_size(4) /* INET_DIAG_MARK */
|
2020-04-30 18:51:14 +03:00
|
|
|
+ nla_total_size(4) /* INET_DIAG_CLASS_ID */
|
|
|
|
|
#ifdef CONFIG_SOCK_CGROUP_DATA
|
|
|
|
|
+ nla_total_size_64bit(sizeof(u64)) /* INET_DIAG_CGROUP_ID */
|
|
|
|
|
#endif
|
2020-09-01 15:10:08 -07:00
|
|
|
+ nla_total_size(sizeof(struct inet_diag_sockopt))
|
|
|
|
|
/* INET_DIAG_SOCKOPT */
|
2020-04-30 18:51:14 +03:00
|
|
|
;
|
2020-03-05 15:33:12 +03:00
|
|
|
}
|
2016-06-09 18:05:09 +01:00
|
|
|
int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
|
|
|
|
|
struct inet_diag_msg *r, int ext,
|
2016-09-08 00:42:25 +09:00
|
|
|
struct user_namespace *user_ns, bool net_admin);
|
2016-06-09 18:05:09 +01:00
|
|
|
|
2005-08-12 09:27:49 -03:00
|
|
|
extern int inet_diag_register(const struct inet_diag_handler *handler);
|
|
|
|
|
extern void inet_diag_unregister(const struct inet_diag_handler *handler);
|
2005-08-12 12:51:49 -03:00
|
|
|
#endif /* _INET_DIAG_H_ */
|