cregit-Linux how code gets into the kernel

Release 4.11 net/llc/llc_proc.c

Directory: net/llc
/*
 * proc_llc.c - proc interface for LLC
 *
 * Copyright (c) 2001 by Jay Schulist <jschlst@samba.org>
 *               2002-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
 *
 * This program can be redistributed or modified under the terms of the
 * GNU General Public License as published by the Free Software Foundation.
 * This program is distributed without any warranty or implied warranty
 * of merchantability or fitness for a particular purpose.
 *
 * See the GNU General Public License for more details.
 */

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/errno.h>
#include <linux/seq_file.h>
#include <linux/export.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/llc.h>
#include <net/llc_c_ac.h>
#include <net/llc_c_ev.h>
#include <net/llc_c_st.h>
#include <net/llc_conn.h>


static void llc_ui_format_mac(struct seq_file *seq, u8 *addr) { seq_printf(seq, "%pM", addr); }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo1979.17%133.33%
Joe Perches416.67%133.33%
Johannes Berg14.17%133.33%
Total24100.00%3100.00%


static struct sock *llc_get_sk_idx(loff_t pos) { struct llc_sap *sap; struct sock *sk = NULL; int i; list_for_each_entry_rcu(sap, &llc_sap_list, node) { spin_lock_bh(&sap->sk_lock); for (i = 0; i < LLC_SK_LADDR_HASH_ENTRIES; i++) { struct hlist_nulls_head *head = &sap->sk_laddr_hash[i]; struct hlist_nulls_node *node; sk_nulls_for_each(sk, node, head) { if (!pos) goto found; /* keep the lock */ --pos; } } spin_unlock_bh(&sap->sk_lock); } sk = NULL; found: return sk; }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo6959.48%562.50%
Octavian Purdila4740.52%337.50%
Total116100.00%8100.00%


static void *llc_seq_start(struct seq_file *seq, loff_t *pos) { loff_t l = *pos; rcu_read_lock_bh(); return l ? llc_get_sk_idx(--l) : SEQ_START_TOKEN; }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo3391.67%360.00%
Octavian Purdila25.56%120.00%
Joe Perches12.78%120.00%
Total36100.00%5100.00%


static struct sock *laddr_hash_next(struct llc_sap *sap, int bucket) { struct hlist_nulls_node *node; struct sock *sk = NULL; while (++bucket < LLC_SK_LADDR_HASH_ENTRIES) sk_nulls_for_each(sk, node, &sap->sk_laddr_hash[bucket]) goto out; out: return sk; }

Contributors

PersonTokensPropCommitsCommitProp
Octavian Purdila51100.00%1100.00%
Total51100.00%1100.00%


static void *llc_seq_next(struct seq_file *seq, void *v, loff_t *pos) { struct sock* sk, *next; struct llc_sock *llc; struct llc_sap *sap; ++*pos; if (v == SEQ_START_TOKEN) { sk = llc_get_sk_idx(0); goto out; } sk = v; next = sk_nulls_next(sk); if (next) { sk = next; goto out; } llc = llc_sk(sk); sap = llc->sap; sk = laddr_hash_next(sap, llc_sk_laddr_hashfn(sap, &llc->laddr)); if (sk) goto out; spin_unlock_bh(&sap->sk_lock); list_for_each_entry_continue_rcu(sap, &llc_sap_list, node) { spin_lock_bh(&sap->sk_lock); sk = laddr_hash_next(sap, -1); if (sk) break; /* keep the lock */ spin_unlock_bh(&sap->sk_lock); } out: return sk; }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo13476.14%450.00%
Octavian Purdila4123.30%337.50%
Joe Perches10.57%112.50%
Total176100.00%8100.00%


static void llc_seq_stop(struct seq_file *seq, void *v) { if (v && v != SEQ_START_TOKEN) { struct sock *sk = v; struct llc_sock *llc = llc_sk(sk); struct llc_sap *sap = llc->sap; spin_unlock_bh(&sap->sk_lock); } rcu_read_unlock_bh(); }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo5893.55%466.67%
Octavian Purdila46.45%233.33%
Total62100.00%6100.00%


static int llc_seq_socket_show(struct seq_file *seq, void *v) { struct sock* sk; struct llc_sock *llc; if (v == SEQ_START_TOKEN) { seq_puts(seq, "SKt Mc local_mac_sap remote_mac_sap " " tx_queue rx_queue st uid link\n"); goto out; } sk = v; llc = llc_sk(sk); /* FIXME: check if the address is multicast */ seq_printf(seq, "%2X %2X ", sk->sk_type, 0); if (llc->dev) llc_ui_format_mac(seq, llc->dev->dev_addr); else { u8 addr[6] = {0,0,0,0,0,0}; llc_ui_format_mac(seq, addr); } seq_printf(seq, "@%02X ", llc->sap->laddr.lsap); llc_ui_format_mac(seq, llc->daddr.mac); seq_printf(seq, "@%02X %8d %8d %2d %3u %4d\n", llc->daddr.lsap, sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk) - llc->copied_seq, sk->sk_state, from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)), llc->link); out: return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo15881.03%654.55%
Joe Perches2512.82%218.18%
Eric W. Biedermann94.62%19.09%
Eric Dumazet21.03%19.09%
Francesco Fusco10.51%19.09%
Total195100.00%11100.00%

static const char *const llc_conn_state_names[] = { [LLC_CONN_STATE_ADM] = "adm", [LLC_CONN_STATE_SETUP] = "setup", [LLC_CONN_STATE_NORMAL] = "normal", [LLC_CONN_STATE_BUSY] = "busy", [LLC_CONN_STATE_REJ] = "rej", [LLC_CONN_STATE_AWAIT] = "await", [LLC_CONN_STATE_AWAIT_BUSY] = "await_busy", [LLC_CONN_STATE_AWAIT_REJ] = "await_rej", [LLC_CONN_STATE_D_CONN] = "d_conn", [LLC_CONN_STATE_RESET] = "reset", [LLC_CONN_STATE_ERROR] = "error", [LLC_CONN_STATE_TEMP] = "temp", };
static int llc_seq_core_show(struct seq_file *seq, void *v) { struct sock* sk; struct llc_sock *llc; if (v == SEQ_START_TOKEN) { seq_puts(seq, "Connection list:\n" "dsap state retr txw rxw pf ff sf df rs cs " "tack tpfc trs tbs blog busr\n"); goto out; } sk = v; llc = llc_sk(sk); seq_printf(seq, " %02X %-10s %3d %3d %3d %2d %2d %2d %2d %2d %2d " "%4d %4d %3d %3d %4d %4d\n", llc->daddr.lsap, llc_conn_state_names[llc->state], llc->retry_count, llc->k, llc->rw, llc->p_flag, llc->f_flag, llc->s_flag, llc->data_flag, llc->remote_busy_flag, llc->cause_flag, timer_pending(&llc->ack_timer.timer), timer_pending(&llc->pf_cycle_timer.timer), timer_pending(&llc->rej_sent_timer.timer), timer_pending(&llc->busy_state_timer.timer), !!sk->sk_backlog.tail, !!sk->sk_lock.owned); out: return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo16795.98%350.00%
Hannes Frederic Sowa42.30%116.67%
David S. Miller21.15%116.67%
Joe Perches10.57%116.67%
Total174100.00%6100.00%

static const struct seq_operations llc_seq_socket_ops = { .start = llc_seq_start, .next = llc_seq_next, .stop = llc_seq_stop, .show = llc_seq_socket_show, }; static const struct seq_operations llc_seq_core_ops = { .start = llc_seq_start, .next = llc_seq_next, .stop = llc_seq_stop, .show = llc_seq_core_show, };
static int llc_seq_socket_open(struct inode *inode, struct file *file) { return seq_open(file, &llc_seq_socket_ops); }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo25100.00%2100.00%
Total25100.00%2100.00%


static int llc_seq_core_open(struct inode *inode, struct file *file) { return seq_open(file, &llc_seq_core_ops); }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo25100.00%2100.00%
Total25100.00%2100.00%

static const struct file_operations llc_seq_socket_fops = { .owner = THIS_MODULE, .open = llc_seq_socket_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; static const struct file_operations llc_seq_core_fops = { .owner = THIS_MODULE, .open = llc_seq_core_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; static struct proc_dir_entry *llc_proc_dir;
int __init llc_proc_init(void) { int rc = -ENOMEM; struct proc_dir_entry *p; llc_proc_dir = proc_mkdir("llc", init_net.proc_net); if (!llc_proc_dir) goto out; p = proc_create("socket", S_IRUGO, llc_proc_dir, &llc_seq_socket_fops); if (!p) goto out_socket; p = proc_create("core", S_IRUGO, llc_proc_dir, &llc_seq_core_fops); if (!p) goto out_core; rc = 0; out: return rc; out_core: remove_proc_entry("socket", llc_proc_dir); out_socket: remove_proc_entry("llc", init_net.proc_net); goto out; }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo10289.47%360.00%
Wang Chen87.02%120.00%
Eric W. Biedermann43.51%120.00%
Total114100.00%5100.00%


void llc_proc_exit(void) { remove_proc_entry("socket", llc_proc_dir); remove_proc_entry("core", llc_proc_dir); remove_proc_entry("llc", init_net.proc_net); }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo2893.33%266.67%
Eric W. Biedermann26.67%133.33%
Total30100.00%3100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo104381.61%1339.39%
Octavian Purdila14511.35%39.09%
Joe Perches322.50%26.06%
Eric W. Biedermann181.41%26.06%
Hideaki Yoshifuji / 吉藤英明110.86%26.06%
Wang Chen80.63%13.03%
Hannes Frederic Sowa40.31%13.03%
Paul Gortmaker30.23%13.03%
Arjan van de Ven20.16%13.03%
Philippe De Muyter20.16%13.03%
Jan Engelhardt20.16%13.03%
Adrian Bunk20.16%13.03%
David S. Miller20.16%13.03%
Eric Dumazet20.16%13.03%
Francesco Fusco10.08%13.03%
Johannes Berg10.08%13.03%
Total1278100.00%33100.00%
Directory: net/llc
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.