Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _INET_DIAG_H_
0003 #define _INET_DIAG_H_ 1
0004 
0005 #include <net/netlink.h>
0006 #include <uapi/linux/inet_diag.h>
0007 
0008 struct inet_hashinfo;
0009 
0010 struct inet_diag_handler {
0011     void        (*dump)(struct sk_buff *skb,
0012                 struct netlink_callback *cb,
0013                 const struct inet_diag_req_v2 *r);
0014 
0015     int     (*dump_one)(struct netlink_callback *cb,
0016                     const struct inet_diag_req_v2 *req);
0017 
0018     void        (*idiag_get_info)(struct sock *sk,
0019                       struct inet_diag_msg *r,
0020                       void *info);
0021 
0022     int     (*idiag_get_aux)(struct sock *sk,
0023                      bool net_admin,
0024                      struct sk_buff *skb);
0025 
0026     size_t      (*idiag_get_aux_size)(struct sock *sk,
0027                           bool net_admin);
0028 
0029     int     (*destroy)(struct sk_buff *in_skb,
0030                    const struct inet_diag_req_v2 *req);
0031 
0032     __u16       idiag_type;
0033     __u16       idiag_info_size;
0034 };
0035 
0036 struct bpf_sk_storage_diag;
0037 struct inet_diag_dump_data {
0038     struct nlattr *req_nlas[__INET_DIAG_REQ_MAX];
0039 #define inet_diag_nla_bc req_nlas[INET_DIAG_REQ_BYTECODE]
0040 #define inet_diag_nla_bpf_stgs req_nlas[INET_DIAG_REQ_SK_BPF_STORAGES]
0041 
0042     struct bpf_sk_storage_diag *bpf_stg_diag;
0043 };
0044 
0045 struct inet_connection_sock;
0046 int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
0047               struct sk_buff *skb, struct netlink_callback *cb,
0048               const struct inet_diag_req_v2 *req,
0049               u16 nlmsg_flags, bool net_admin);
0050 void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
0051              struct netlink_callback *cb,
0052              const struct inet_diag_req_v2 *r);
0053 int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
0054                 struct netlink_callback *cb,
0055                 const struct inet_diag_req_v2 *req);
0056 
0057 struct sock *inet_diag_find_one_icsk(struct net *net,
0058                      struct inet_hashinfo *hashinfo,
0059                      const struct inet_diag_req_v2 *req);
0060 
0061 int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
0062 
0063 void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
0064 
0065 static inline size_t inet_diag_msg_attrs_size(void)
0066 {
0067     return    nla_total_size(1)  /* INET_DIAG_SHUTDOWN */
0068         + nla_total_size(1)  /* INET_DIAG_TOS */
0069 #if IS_ENABLED(CONFIG_IPV6)
0070         + nla_total_size(1)  /* INET_DIAG_TCLASS */
0071         + nla_total_size(1)  /* INET_DIAG_SKV6ONLY */
0072 #endif
0073         + nla_total_size(4)  /* INET_DIAG_MARK */
0074         + nla_total_size(4)  /* INET_DIAG_CLASS_ID */
0075 #ifdef CONFIG_SOCK_CGROUP_DATA
0076         + nla_total_size_64bit(sizeof(u64))  /* INET_DIAG_CGROUP_ID */
0077 #endif
0078         + nla_total_size(sizeof(struct inet_diag_sockopt))
0079                              /* INET_DIAG_SOCKOPT */
0080         ;
0081 }
0082 int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
0083                  struct inet_diag_msg *r, int ext,
0084                  struct user_namespace *user_ns, bool net_admin);
0085 
0086 extern int  inet_diag_register(const struct inet_diag_handler *handler);
0087 extern void inet_diag_unregister(const struct inet_diag_handler *handler);
0088 #endif /* _INET_DIAG_H_ */