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