/proc/fs/nfsd/clients/*/info TCP port not updating after reconnect

Tyler Mitchell
2024-10-22T03:42:24Z

Hi,

I have an NFS server running on Alpine Linux:

# uname -a
Linux charm 6.6.54-0-lts #1-Alpine SMP PREEMPT_DYNAMIC 2024-10-04 16:47:58 x86_64 Linux

I wrote some very simple shell scripts to track & report NFS client
usage. But I noticed that after some time, the TCP port reported in
the "address" field of /proc/fs/nfsd/clients/*/info doesn't match
the actual TCP port in use by the client.

An example from the server side:

# cat /proc/fs/nfsd/clients/4/info
clientid: 0xdf43354e670522ab
address: "192.168.93.218:752"
status: confirmed
seconds from last renew: 60
name: "Linux NFSv4.2 raspberrypi"
minor version: 2
Implementation domain: "kernel.org"
Implementation name: "Linux 6.1.21-v7+ #1642 SMP Mon Apr 3 17:20:52 BST 2023 armv7l"
Implementation time: [0, 0]
callback state: UP
callback address: 192.168.93.218:0
# netstat -n | egrep '(Foreign|:2049)'
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.93.82:2049 192.168.93.218:776 ESTABLISHED
tcp 0 0 192.168.93.82:2049 192.168.93.218:752 ESTABLISHED

And on the client:

% netstat -4n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.93.218:776 192.168.93.82:2049 ESTABLISHED

When the NFS connection was first established, it was using 752 (I
had checked), but it seems that it got disconnected at some point
and reconnected from port 776. (In this case I was actually doing
some rewiring and the NFS server was temporarily disconnected from
the network.)

The client_info_show() function seems to be just reading the state
data from a struct nfs4_client. And I see this gets populated in
create_client() but I don't see it being updated anywhere. In this
case, it would have to happen after the client reconnects following
a transient error.

Anyhow, I don't have an immediate solution, but wanted to mention
this in case it wasn't already a known issue. Ideally the port
could be updated when it changes so that it's possible to better
track active clients.

Many thanks,
Tyler