Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  net/dccp/diag.c
0004  *
0005  *  An implementation of the DCCP protocol
0006  *  Arnaldo Carvalho de Melo <acme@mandriva.com>
0007  */
0008 
0009 
0010 #include <linux/module.h>
0011 #include <linux/inet_diag.h>
0012 
0013 #include "ccid.h"
0014 #include "dccp.h"
0015 
0016 static void dccp_get_info(struct sock *sk, struct tcp_info *info)
0017 {
0018     struct dccp_sock *dp = dccp_sk(sk);
0019     const struct inet_connection_sock *icsk = inet_csk(sk);
0020 
0021     memset(info, 0, sizeof(*info));
0022 
0023     info->tcpi_state    = sk->sk_state;
0024     info->tcpi_retransmits  = icsk->icsk_retransmits;
0025     info->tcpi_probes   = icsk->icsk_probes_out;
0026     info->tcpi_backoff  = icsk->icsk_backoff;
0027     info->tcpi_pmtu     = icsk->icsk_pmtu_cookie;
0028 
0029     if (dp->dccps_hc_rx_ackvec != NULL)
0030         info->tcpi_options |= TCPI_OPT_SACK;
0031 
0032     if (dp->dccps_hc_rx_ccid != NULL)
0033         ccid_hc_rx_get_info(dp->dccps_hc_rx_ccid, sk, info);
0034 
0035     if (dp->dccps_hc_tx_ccid != NULL)
0036         ccid_hc_tx_get_info(dp->dccps_hc_tx_ccid, sk, info);
0037 }
0038 
0039 static void dccp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
0040                    void *_info)
0041 {
0042     r->idiag_rqueue = r->idiag_wqueue = 0;
0043 
0044     if (_info != NULL)
0045         dccp_get_info(sk, _info);
0046 }
0047 
0048 static void dccp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
0049                const struct inet_diag_req_v2 *r)
0050 {
0051     inet_diag_dump_icsk(&dccp_hashinfo, skb, cb, r);
0052 }
0053 
0054 static int dccp_diag_dump_one(struct netlink_callback *cb,
0055                   const struct inet_diag_req_v2 *req)
0056 {
0057     return inet_diag_dump_one_icsk(&dccp_hashinfo, cb, req);
0058 }
0059 
0060 static const struct inet_diag_handler dccp_diag_handler = {
0061     .dump        = dccp_diag_dump,
0062     .dump_one    = dccp_diag_dump_one,
0063     .idiag_get_info  = dccp_diag_get_info,
0064     .idiag_type  = IPPROTO_DCCP,
0065     .idiag_info_size = sizeof(struct tcp_info),
0066 };
0067 
0068 static int __init dccp_diag_init(void)
0069 {
0070     return inet_diag_register(&dccp_diag_handler);
0071 }
0072 
0073 static void __exit dccp_diag_fini(void)
0074 {
0075     inet_diag_unregister(&dccp_diag_handler);
0076 }
0077 
0078 module_init(dccp_diag_init);
0079 module_exit(dccp_diag_fini);
0080 
0081 MODULE_LICENSE("GPL");
0082 MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@mandriva.com>");
0083 MODULE_DESCRIPTION("DCCP inet_diag handler");
0084 MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 2-33 /* AF_INET - IPPROTO_DCCP */);