pppoe: fix stale device name shown in procfs
RFC 1/1 pppoe: fix stale device name shown in procfs
In pppoe_seq_show(), the device name is currently read from po->pppoe_pa.dev, which contains the name at the time the socket was connected. If the lower network device is renamed afterwards, reading /proc/net/pppoe will still print the old name.
Fix this by reading the name directly from the bound net_device via the po->pppoe_dev pointer. Note that the pointer can be cleared when the socket is being released, so a NULL check is required.
Signed-off-by Qingfang Deng <[email protected]>
--- drivers/net/ppp/pppoe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ppp/pppoe.c +5 -1
@@ -960,6 +960,7 @@ static int pppoe_recvmsg(struct socket *sock, struct msghdr *m,#ifdef CONFIG_PROC_FS static int pppoe_seq_show (struct seq_file *seq,void *v) { +struct net_device *dev;struct pppox_sock *po;char *dev_name;
@@ -969,7 +970,10 @@ static int pppoe_seq_show(struct seq_file *seq, void *v) } po = v; - dev_name = po->pppoe_pa.dev; + dev =READ_ONCE (po->pppoe_dev); +if (!dev) + goto out; + dev_name = dev->name;seq_printf (seq,"%08X %pM %8s\n" , po->pppoe_pa.sid, po->pppoe_pa.remote, dev_name);
Signature · 1 line
2.43.0