^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * tcp_diag.c Module for monitoring TCP transport protocols sockets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/sock_diag.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/inet_diag.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/tcp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <net/netlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <net/tcp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) void *_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct tcp_info *info = _info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) if (inet_sk_state_load(sk) == TCP_LISTEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) r->idiag_rqueue = READ_ONCE(sk->sk_ack_backlog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) r->idiag_wqueue = READ_ONCE(sk->sk_max_ack_backlog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) } else if (sk->sk_type == SOCK_STREAM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) const struct tcp_sock *tp = tcp_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) r->idiag_rqueue = max_t(int, READ_ONCE(tp->rcv_nxt) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) READ_ONCE(tp->copied_seq), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) r->idiag_wqueue = READ_ONCE(tp->write_seq) - tp->snd_una;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) if (info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) tcp_get_info(sk, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #ifdef CONFIG_TCP_MD5SIG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static void tcp_diag_md5sig_fill(struct tcp_diag_md5sig *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) const struct tcp_md5sig_key *key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) info->tcpm_family = key->family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) info->tcpm_prefixlen = key->prefixlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) info->tcpm_keylen = key->keylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) memcpy(info->tcpm_key, key->key, key->keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) if (key->family == AF_INET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) info->tcpm_addr[0] = key->addr.a4.s_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) else if (key->family == AF_INET6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) memcpy(&info->tcpm_addr, &key->addr.a6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) sizeof(info->tcpm_addr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static int tcp_diag_put_md5sig(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) const struct tcp_md5sig_info *md5sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) const struct tcp_md5sig_key *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct tcp_diag_md5sig *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct nlattr *attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int md5sig_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) hlist_for_each_entry_rcu(key, &md5sig->head, node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) md5sig_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) if (md5sig_count == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) attr = nla_reserve(skb, INET_DIAG_MD5SIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) md5sig_count * sizeof(struct tcp_diag_md5sig));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) if (!attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) info = nla_data(attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) memset(info, 0, md5sig_count * sizeof(struct tcp_diag_md5sig));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) hlist_for_each_entry_rcu(key, &md5sig->head, node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) tcp_diag_md5sig_fill(info++, key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (--md5sig_count == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static int tcp_diag_put_ulp(struct sk_buff *skb, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) const struct tcp_ulp_ops *ulp_ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct nlattr *nest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) nest = nla_nest_start_noflag(skb, INET_DIAG_ULP_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) if (!nest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) err = nla_put_string(skb, INET_ULP_INFO_NAME, ulp_ops->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) goto nla_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (ulp_ops->get_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) err = ulp_ops->get_info(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) goto nla_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) nla_nest_end(skb, nest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) nla_failure:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) nla_nest_cancel(skb, nest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static int tcp_diag_get_aux(struct sock *sk, bool net_admin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct inet_connection_sock *icsk = inet_csk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #ifdef CONFIG_TCP_MD5SIG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) if (net_admin) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct tcp_md5sig_info *md5sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) md5sig = rcu_dereference(tcp_sk(sk)->md5sig_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (md5sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) err = tcp_diag_put_md5sig(skb, md5sig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) if (net_admin) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) const struct tcp_ulp_ops *ulp_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) ulp_ops = icsk->icsk_ulp_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (ulp_ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) err = tcp_diag_put_ulp(skb, sk, ulp_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static size_t tcp_diag_get_aux_size(struct sock *sk, bool net_admin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct inet_connection_sock *icsk = inet_csk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) size_t size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #ifdef CONFIG_TCP_MD5SIG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (net_admin && sk_fullsock(sk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) const struct tcp_md5sig_info *md5sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) const struct tcp_md5sig_key *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) size_t md5sig_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) md5sig = rcu_dereference(tcp_sk(sk)->md5sig_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (md5sig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) hlist_for_each_entry_rcu(key, &md5sig->head, node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) md5sig_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) size += nla_total_size(md5sig_count *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) sizeof(struct tcp_diag_md5sig));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (net_admin && sk_fullsock(sk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) const struct tcp_ulp_ops *ulp_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) ulp_ops = icsk->icsk_ulp_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (ulp_ops) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) size += nla_total_size(0) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) nla_total_size(TCP_ULP_NAME_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (ulp_ops->get_info_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) size += ulp_ops->get_info_size(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static void tcp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) const struct inet_diag_req_v2 *r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) inet_diag_dump_icsk(&tcp_hashinfo, skb, cb, r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static int tcp_diag_dump_one(struct netlink_callback *cb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) const struct inet_diag_req_v2 *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) return inet_diag_dump_one_icsk(&tcp_hashinfo, cb, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) #ifdef CONFIG_INET_DIAG_DESTROY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static int tcp_diag_destroy(struct sk_buff *in_skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) const struct inet_diag_req_v2 *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct net *net = sock_net(in_skb->sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct sock *sk = inet_diag_find_one_icsk(net, &tcp_hashinfo, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) if (IS_ERR(sk))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) return PTR_ERR(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) err = sock_diag_destroy(sk, ECONNABORTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) sock_gen_put(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) static const struct inet_diag_handler tcp_diag_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) .dump = tcp_diag_dump,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) .dump_one = tcp_diag_dump_one,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) .idiag_get_info = tcp_diag_get_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) .idiag_get_aux = tcp_diag_get_aux,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) .idiag_get_aux_size = tcp_diag_get_aux_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) .idiag_type = IPPROTO_TCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) .idiag_info_size = sizeof(struct tcp_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) #ifdef CONFIG_INET_DIAG_DESTROY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) .destroy = tcp_diag_destroy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) static int __init tcp_diag_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) return inet_diag_register(&tcp_diag_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static void __exit tcp_diag_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) inet_diag_unregister(&tcp_diag_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) module_init(tcp_diag_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) module_exit(tcp_diag_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 2-6 /* AF_INET - IPPROTO_TCP */);