Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <net/net_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <net/netns/generic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <net/bonding.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include "bonding_priv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 	__acquires(RCU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	struct bonding *bond = PDE_DATA(file_inode(seq->file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	struct list_head *iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	struct slave *slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	loff_t off = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	if (*pos == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 		return SEQ_START_TOKEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	bond_for_each_slave_rcu(bond, slave, iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		if (++off == *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 			return slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) static void *bond_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct bonding *bond = PDE_DATA(file_inode(seq->file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	struct list_head *iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct slave *slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	bool found = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	++*pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	if (v == SEQ_START_TOKEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		return bond_first_slave_rcu(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	bond_for_each_slave_rcu(bond, slave, iter) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		if (found)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 			return slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		if (slave == v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			found = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) static void bond_info_seq_stop(struct seq_file *seq, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	__releases(RCU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static void bond_info_show_master(struct seq_file *seq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct bonding *bond = PDE_DATA(file_inode(seq->file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	const struct bond_opt_value *optval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct slave *curr, *primary;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	curr = rcu_dereference(bond->curr_active_slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	seq_printf(seq, "Bonding Mode: %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		   bond_mode_name(BOND_MODE(bond)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	    bond->params.fail_over_mac) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		optval = bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 					  bond->params.fail_over_mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		seq_printf(seq, " (fail_over_mac %s)", optval->string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	seq_printf(seq, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	if (bond_mode_uses_xmit_hash(bond)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		optval = bond_opt_get_val(BOND_OPT_XMIT_HASH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 					  bond->params.xmit_policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		seq_printf(seq, "Transmit Hash Policy: %s (%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			   optval->string, bond->params.xmit_policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	if (bond_uses_primary(bond)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		primary = rcu_dereference(bond->primary_slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		seq_printf(seq, "Primary Slave: %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			   primary ? primary->dev->name : "None");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		if (primary) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			optval = bond_opt_get_val(BOND_OPT_PRIMARY_RESELECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 						  bond->params.primary_reselect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			seq_printf(seq, " (primary_reselect %s)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 				   optval->string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		seq_printf(seq, "\nCurrently Active Slave: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			   (curr) ? curr->dev->name : "None");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	seq_printf(seq, "MII Status: %s\n", netif_carrier_ok(bond->dev) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		   "up" : "down");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	seq_printf(seq, "MII Polling Interval (ms): %d\n", bond->params.miimon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	seq_printf(seq, "Up Delay (ms): %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		   bond->params.updelay * bond->params.miimon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	seq_printf(seq, "Down Delay (ms): %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		   bond->params.downdelay * bond->params.miimon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	seq_printf(seq, "Peer Notification Delay (ms): %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		   bond->params.peer_notif_delay * bond->params.miimon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	/* ARP information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	if (bond->params.arp_interval > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		int printed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		seq_printf(seq, "ARP Polling Interval (ms): %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 				bond->params.arp_interval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		seq_printf(seq, "ARP IP target/s (n.n.n.n form):");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			if (!bond->params.arp_targets[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			if (printed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 				seq_printf(seq, ",");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			seq_printf(seq, " %pI4", &bond->params.arp_targets[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			printed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		seq_printf(seq, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	if (BOND_MODE(bond) == BOND_MODE_8023AD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		struct ad_info ad_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		seq_puts(seq, "\n802.3ad info\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		seq_printf(seq, "LACP rate: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			   (bond->params.lacp_fast) ? "fast" : "slow");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		seq_printf(seq, "Min links: %d\n", bond->params.min_links);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		optval = bond_opt_get_val(BOND_OPT_AD_SELECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 					  bond->params.ad_select);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		seq_printf(seq, "Aggregator selection policy (ad_select): %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			   optval->string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		if (capable(CAP_NET_ADMIN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			seq_printf(seq, "System priority: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 				   BOND_AD_INFO(bond).system.sys_priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			seq_printf(seq, "System MAC address: %pM\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 				   &BOND_AD_INFO(bond).system.sys_mac_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			if (__bond_3ad_get_active_agg_info(bond, &ad_info)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 				seq_printf(seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 					   "bond %s has no active aggregator\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 					   bond->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 				seq_printf(seq, "Active Aggregator Info:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 				seq_printf(seq, "\tAggregator ID: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 					   ad_info.aggregator_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 				seq_printf(seq, "\tNumber of ports: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 					   ad_info.ports);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 				seq_printf(seq, "\tActor Key: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 					   ad_info.actor_key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 				seq_printf(seq, "\tPartner Key: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 					   ad_info.partner_key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 				seq_printf(seq, "\tPartner Mac Address: %pM\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 					   ad_info.partner_system);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static void bond_info_show_slave(struct seq_file *seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 				 const struct slave *slave)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	struct bonding *bond = PDE_DATA(file_inode(seq->file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	seq_printf(seq, "MII Status: %s\n", bond_slave_link_status(slave->link));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	if (slave->speed == SPEED_UNKNOWN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		seq_printf(seq, "Speed: %s\n", "Unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		seq_printf(seq, "Speed: %d Mbps\n", slave->speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	if (slave->duplex == DUPLEX_UNKNOWN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		seq_printf(seq, "Duplex: %s\n", "Unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		seq_printf(seq, "Duplex: %s\n", slave->duplex ? "full" : "half");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	seq_printf(seq, "Link Failure Count: %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		   slave->link_failure_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	seq_printf(seq, "Permanent HW addr: %*phC\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		   slave->dev->addr_len, slave->perm_hwaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	seq_printf(seq, "Slave queue ID: %d\n", slave->queue_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	if (BOND_MODE(bond) == BOND_MODE_8023AD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		const struct port *port = &SLAVE_AD_INFO(slave)->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		const struct aggregator *agg = port->aggregator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		if (agg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			seq_printf(seq, "Aggregator ID: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 				   agg->aggregator_identifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 			seq_printf(seq, "Actor Churn State: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 				   bond_3ad_churn_desc(port->sm_churn_actor_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 			seq_printf(seq, "Partner Churn State: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 				   bond_3ad_churn_desc(port->sm_churn_partner_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			seq_printf(seq, "Actor Churned Count: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 				   port->churn_actor_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 			seq_printf(seq, "Partner Churned Count: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 				   port->churn_partner_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			if (capable(CAP_NET_ADMIN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 				seq_puts(seq, "details actor lacp pdu:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 				seq_printf(seq, "    system priority: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 					   port->actor_system_priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 				seq_printf(seq, "    system mac address: %pM\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 					   &port->actor_system);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 				seq_printf(seq, "    port key: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 					   port->actor_oper_port_key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 				seq_printf(seq, "    port priority: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 					   port->actor_port_priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 				seq_printf(seq, "    port number: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 					   port->actor_port_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 				seq_printf(seq, "    port state: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 					   port->actor_oper_port_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 				seq_puts(seq, "details partner lacp pdu:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 				seq_printf(seq, "    system priority: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 					   port->partner_oper.system_priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 				seq_printf(seq, "    system mac address: %pM\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 					   &port->partner_oper.system);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 				seq_printf(seq, "    oper key: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 					   port->partner_oper.key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 				seq_printf(seq, "    port priority: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 					   port->partner_oper.port_priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 				seq_printf(seq, "    port number: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 					   port->partner_oper.port_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 				seq_printf(seq, "    port state: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 					   port->partner_oper.port_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			seq_puts(seq, "Aggregator ID: N/A\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) static int bond_info_seq_show(struct seq_file *seq, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	if (v == SEQ_START_TOKEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		seq_printf(seq, "%s\n", bond_version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		bond_info_show_master(seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		bond_info_show_slave(seq, v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static const struct seq_operations bond_info_seq_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	.start = bond_info_seq_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	.next  = bond_info_seq_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	.stop  = bond_info_seq_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	.show  = bond_info_seq_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) void bond_create_proc_entry(struct bonding *bond)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	struct net_device *bond_dev = bond->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	struct bond_net *bn = net_generic(dev_net(bond_dev), bond_net_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	if (bn->proc_dir) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		bond->proc_entry = proc_create_seq_data(bond_dev->name, 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 				bn->proc_dir, &bond_info_seq_ops, bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		if (bond->proc_entry == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 			netdev_warn(bond_dev, "Cannot create /proc/net/%s/%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 				    DRV_NAME, bond_dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) void bond_remove_proc_entry(struct bonding *bond)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	struct net_device *bond_dev = bond->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	struct bond_net *bn = net_generic(dev_net(bond_dev), bond_net_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	if (bn->proc_dir && bond->proc_entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		remove_proc_entry(bond->proc_file_name, bn->proc_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		memset(bond->proc_file_name, 0, IFNAMSIZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		bond->proc_entry = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) /* Create the bonding directory under /proc/net, if doesn't exist yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)  * Caller must hold rtnl_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) void __net_init bond_create_proc_dir(struct bond_net *bn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	if (!bn->proc_dir) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		bn->proc_dir = proc_mkdir(DRV_NAME, bn->net->proc_net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		if (!bn->proc_dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 			pr_warn("Warning: Cannot create /proc/net/%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 				DRV_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) /* Destroy the bonding directory under /proc/net, if empty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)  * Caller must hold rtnl_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) void __net_exit bond_destroy_proc_dir(struct bond_net *bn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	if (bn->proc_dir) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		remove_proc_entry(DRV_NAME, bn->net->proc_net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		bn->proc_dir = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }