^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * proc_llc.c - proc interface for LLC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2001 by Jay Schulist <jschlst@samba.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * 2002-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * This program can be redistributed or modified under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * GNU General Public License as published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is distributed without any warranty or implied warranty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * of merchantability or fitness for a particular purpose.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * See the GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <net/net_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <net/llc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <net/llc_c_ac.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <net/llc_c_ev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <net/llc_c_st.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <net/llc_conn.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static void llc_ui_format_mac(struct seq_file *seq, u8 *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) seq_printf(seq, "%pM", addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static struct sock *llc_get_sk_idx(loff_t pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct llc_sap *sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct sock *sk = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) list_for_each_entry_rcu(sap, &llc_sap_list, node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) spin_lock_bh(&sap->sk_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) for (i = 0; i < LLC_SK_LADDR_HASH_ENTRIES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct hlist_nulls_head *head = &sap->sk_laddr_hash[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct hlist_nulls_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) sk_nulls_for_each(sk, node, head) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) if (!pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) goto found; /* keep the lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) --pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) spin_unlock_bh(&sap->sk_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) sk = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) found:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static void *llc_seq_start(struct seq_file *seq, loff_t *pos) __acquires(RCU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) loff_t l = *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) rcu_read_lock_bh();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) return l ? llc_get_sk_idx(--l) : SEQ_START_TOKEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static struct sock *laddr_hash_next(struct llc_sap *sap, int bucket)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct hlist_nulls_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct sock *sk = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) while (++bucket < LLC_SK_LADDR_HASH_ENTRIES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) sk_nulls_for_each(sk, node, &sap->sk_laddr_hash[bucket])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) return sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) static void *llc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct sock* sk, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct llc_sock *llc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct llc_sap *sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) ++*pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) if (v == SEQ_START_TOKEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) sk = llc_get_sk_idx(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) sk = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) next = sk_nulls_next(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) if (next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) sk = next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) sk = laddr_hash_next(sap, llc_sk_laddr_hashfn(sap, &llc->laddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) if (sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) spin_unlock_bh(&sap->sk_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) list_for_each_entry_continue_rcu(sap, &llc_sap_list, node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) spin_lock_bh(&sap->sk_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) sk = laddr_hash_next(sap, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) break; /* keep the lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) spin_unlock_bh(&sap->sk_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static void llc_seq_stop(struct seq_file *seq, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) if (v && v != SEQ_START_TOKEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct sock *sk = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) spin_unlock_bh(&sap->sk_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) rcu_read_unlock_bh();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static int llc_seq_socket_show(struct seq_file *seq, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) struct sock* sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct llc_sock *llc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (v == SEQ_START_TOKEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) seq_puts(seq, "SKt Mc local_mac_sap remote_mac_sap "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) " tx_queue rx_queue st uid link\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) sk = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* FIXME: check if the address is multicast */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) seq_printf(seq, "%2X %2X ", sk->sk_type, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (llc->dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) llc_ui_format_mac(seq, llc->dev->dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) u8 addr[6] = {0,0,0,0,0,0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) llc_ui_format_mac(seq, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) seq_printf(seq, "@%02X ", llc->sap->laddr.lsap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) llc_ui_format_mac(seq, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) seq_printf(seq, "@%02X %8d %8d %2d %3u %4d\n", llc->daddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) sk_wmem_alloc_get(sk),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) sk_rmem_alloc_get(sk) - llc->copied_seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) sk->sk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) llc->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static const char *const llc_conn_state_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) [LLC_CONN_STATE_ADM] = "adm",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) [LLC_CONN_STATE_SETUP] = "setup",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) [LLC_CONN_STATE_NORMAL] = "normal",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) [LLC_CONN_STATE_BUSY] = "busy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) [LLC_CONN_STATE_REJ] = "rej",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) [LLC_CONN_STATE_AWAIT] = "await",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) [LLC_CONN_STATE_AWAIT_BUSY] = "await_busy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) [LLC_CONN_STATE_AWAIT_REJ] = "await_rej",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) [LLC_CONN_STATE_D_CONN] = "d_conn",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) [LLC_CONN_STATE_RESET] = "reset",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) [LLC_CONN_STATE_ERROR] = "error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) [LLC_CONN_STATE_TEMP] = "temp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) static int llc_seq_core_show(struct seq_file *seq, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) struct sock* sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct llc_sock *llc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) if (v == SEQ_START_TOKEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) seq_puts(seq, "Connection list:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) "dsap state retr txw rxw pf ff sf df rs cs "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) "tack tpfc trs tbs blog busr\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) sk = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) seq_printf(seq, " %02X %-10s %3d %3d %3d %2d %2d %2d %2d %2d %2d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) "%4d %4d %3d %3d %4d %4d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) llc->daddr.lsap, llc_conn_state_names[llc->state],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) llc->retry_count, llc->k, llc->rw, llc->p_flag, llc->f_flag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) llc->s_flag, llc->data_flag, llc->remote_busy_flag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) llc->cause_flag, timer_pending(&llc->ack_timer.timer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) timer_pending(&llc->pf_cycle_timer.timer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) timer_pending(&llc->rej_sent_timer.timer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) timer_pending(&llc->busy_state_timer.timer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) !!sk->sk_backlog.tail, !!sk->sk_lock.owned);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) static const struct seq_operations llc_seq_socket_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) .start = llc_seq_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) .next = llc_seq_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) .stop = llc_seq_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) .show = llc_seq_socket_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static const struct seq_operations llc_seq_core_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) .start = llc_seq_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) .next = llc_seq_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) .stop = llc_seq_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) .show = llc_seq_core_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static struct proc_dir_entry *llc_proc_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int __init llc_proc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct proc_dir_entry *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) llc_proc_dir = proc_mkdir("llc", init_net.proc_net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (!llc_proc_dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) p = proc_create_seq("socket", 0444, llc_proc_dir, &llc_seq_socket_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) goto out_socket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) p = proc_create_seq("core", 0444, llc_proc_dir, &llc_seq_core_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) goto out_core;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) out_core:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) remove_proc_entry("socket", llc_proc_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) out_socket:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) remove_proc_entry("llc", init_net.proc_net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) void llc_proc_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) remove_proc_entry("socket", llc_proc_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) remove_proc_entry("core", llc_proc_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) remove_proc_entry("llc", init_net.proc_net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }