Skip to content

Commit 4c2d5e3

Browse files
TaeheeYoodavem330
authored andcommitted
hsr: rename debugfs file when interface name is changed
hsr interface has own debugfs file, which name is same with interface name. So, interface name is changed, debugfs file name should be changed too. Fixes: fc4ecae ("net: hsr: add debugfs support for display node list") Signed-off-by: Taehee Yoo <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c6c4ccd commit 4c2d5e3

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

net/hsr/hsr_debugfs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ hsr_node_table_open(struct inode *inode, struct file *filp)
6565
return single_open(filp, hsr_node_table_show, inode->i_private);
6666
}
6767

68+
void hsr_debugfs_rename(struct net_device *dev)
69+
{
70+
struct hsr_priv *priv = netdev_priv(dev);
71+
struct dentry *d;
72+
73+
d = debugfs_rename(hsr_debugfs_root_dir, priv->node_tbl_root,
74+
hsr_debugfs_root_dir, dev->name);
75+
if (IS_ERR(d))
76+
netdev_warn(dev, "failed to rename\n");
77+
else
78+
priv->node_tbl_root = d;
79+
}
80+
6881
static const struct file_operations hsr_fops = {
6982
.open = hsr_node_table_open,
7083
.read = seq_read,

net/hsr/hsr_main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
4545
case NETDEV_CHANGE: /* Link (carrier) state changes */
4646
hsr_check_carrier_and_operstate(hsr);
4747
break;
48+
case NETDEV_CHANGENAME:
49+
hsr_debugfs_rename(dev);
50+
break;
4851
case NETDEV_CHANGEADDR:
4952
if (port->type == HSR_PT_MASTER) {
5053
/* This should not happen since there's no

net/hsr/hsr_main.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,15 @@ static inline u16 hsr_get_skb_sequence_nr(struct sk_buff *skb)
184184
}
185185

186186
#if IS_ENABLED(CONFIG_DEBUG_FS)
187+
void hsr_debugfs_rename(struct net_device *dev);
187188
void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev);
188189
void hsr_debugfs_term(struct hsr_priv *priv);
189190
void hsr_debugfs_create_root(void);
190191
void hsr_debugfs_remove_root(void);
191192
#else
193+
static inline void void hsr_debugfs_rename(struct net_device *dev)
194+
{
195+
}
192196
static inline void hsr_debugfs_init(struct hsr_priv *priv,
193197
struct net_device *hsr_dev)
194198
{}

0 commit comments

Comments
 (0)