1 #include <linux/kernel.h>
2 #include <linux/module.h>
3 #include <linux/device.h>
4 #include <linux/netdevice.h>
11 #include <linux/debugfs.h>
12 #include <linux/seq_file.h>
14 static struct dentry
*bonding_debug_root
;
19 static int bond_debug_rlb_hash_show(struct seq_file
*m
, void *v
)
21 struct bonding
*bond
= m
->private;
22 struct alb_bond_info
*bond_info
= &(BOND_ALB_INFO(bond
));
23 struct rlb_client_info
*client_info
;
26 if (bond
->params
.mode
!= BOND_MODE_ALB
)
29 seq_printf(m
, "SourceIP DestinationIP "
30 "Destination MAC DEV\n");
32 spin_lock_bh(&(BOND_ALB_INFO(bond
).rx_hashtbl_lock
));
34 hash_index
= bond_info
->rx_hashtbl_head
;
35 for (; hash_index
!= RLB_NULL_INDEX
; hash_index
= client_info
->next
) {
36 client_info
= &(bond_info
->rx_hashtbl
[hash_index
]);
37 seq_printf(m
, "%-15pI4 %-15pI4 %-17pM %s\n",
40 &client_info
->mac_dst
,
41 client_info
->slave
->dev
->name
);
44 spin_unlock_bh(&(BOND_ALB_INFO(bond
).rx_hashtbl_lock
));
49 static int bond_debug_rlb_hash_open(struct inode
*inode
, struct file
*file
)
51 return single_open(file
, bond_debug_rlb_hash_show
, inode
->i_private
);
54 static const struct file_operations bond_debug_rlb_hash_fops
= {
56 .open
= bond_debug_rlb_hash_open
,
59 .release
= single_release
,
62 void bond_debug_register(struct bonding
*bond
)
64 if (!bonding_debug_root
)
68 debugfs_create_dir(bond
->dev
->name
, bonding_debug_root
);
70 if (!bond
->debug_dir
) {
71 pr_warning("%s: Warning: failed to register to debugfs\n",
76 debugfs_create_file("rlb_hash_table", 0400, bond
->debug_dir
,
77 bond
, &bond_debug_rlb_hash_fops
);
80 void bond_debug_unregister(struct bonding
*bond
)
82 if (!bonding_debug_root
)
85 debugfs_remove_recursive(bond
->debug_dir
);
88 void bond_debug_reregister(struct bonding
*bond
)
92 if (!bonding_debug_root
)
95 d
= debugfs_rename(bonding_debug_root
, bond
->debug_dir
,
96 bonding_debug_root
, bond
->dev
->name
);
100 pr_warning("%s: Warning: failed to reregister, "
101 "so just unregister old one\n",
103 bond_debug_unregister(bond
);
107 void bond_create_debugfs(void)
109 bonding_debug_root
= debugfs_create_dir("bonding", NULL
);
111 if (!bonding_debug_root
) {
112 pr_warning("Warning: Cannot create bonding directory"
117 void bond_destroy_debugfs(void)
119 debugfs_remove_recursive(bonding_debug_root
);
120 bonding_debug_root
= NULL
;
124 #else /* !CONFIG_DEBUG_FS */
126 void bond_debug_register(struct bonding
*bond
)
130 void bond_debug_unregister(struct bonding
*bond
)
134 void bond_debug_reregister(struct bonding
*bond
)
138 void bond_create_debugfs(void)
142 void bond_destroy_debugfs(void)
146 #endif /* CONFIG_DEBUG_FS */