Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to call nfs_mount using the qt program (compilation kit qt5.15.2 msvc2019 64 bit) on window #511

Open
JieBinCao opened this issue Dec 26, 2024 · 17 comments

Comments

@JieBinCao
Copy link

I failed to call nfs_mount using the qt program (compilation kit qt5.15.2 msvc2019 64 bit) on window, with a status code of -5 and error message: nfs_service failed, How to solve the problem that both ends of the network can be pinged? The RPC information of my Linux server is as follows:
program vers proto port service
100000 4 tcp 111
100000 3 tcp 111
100000 2 tcp 111
100000 4 udp 111
100000 3 udp 111
100000 2 udp 111
100024 1 udp 42449
100024 1 tcp 50421
100003 3 tcp 2049
100021 1 udp 36680
100021 3 udp 36680
100021 4 udp 36680
100021 1 tcp 33051
100021 3 tcp 33051
100021 4 tcp 33051
100005 1 udp 35199
100005 1 tcp 58483
100005 2 udp 50381
100005 2 tcp 35065
100005 3 udp 56087
100005 3 tcp 42365
My code snippet is as follows:
WSADATA wsaData;
#ifdef WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
printf("Failed to start Winsock2\n");
return;
}
#endif
struct nfs_context *nfs = NULL;
struct nfsfh *nfsfh = NULL;
struct nfs_url *url = NULL;
struct nfsdir *nfsdir;
nfs = nfs_init_context();
if (nfs == NULL) {
printf("failed to init context\n");
return;
}
nfs_set_version(nfs, 3);
QString fp = "nfs://192.168.xxx.xxx/home/user/";
url = nfs_parse_url_full(nfs, fp.toStdString().c_str());
if (url == NULL) {
fprintf(stderr, "%s\n", nfs_get_error(nfs));
return;
}
int ret = nfs_mount(nfs, url->server, url->path);
if ( ret != 0) {
fprintf(stderr,"return ret: %d \n\r",ret);
fprintf(stderr, "Failed to mount nfs share : %s\n", nfs_get_error(nfs));
return;
}

@JieBinCao
Copy link
Author

The error message for tracking RPC is: Read from socket(1120) failed, errno:10057 (Unknown error). Closing socket.

@JieBinCao
Copy link
Author

I added this sentence to the above code snippet: nfs_set_mountport(nfs, 2049); After returning a -14 status code, the breakpoint was traced and entered into the rpc_process_deply interface implemented in pdu. c at the following location: case PROG_UNAVAIL:
status = RPC_STATUS_ERROR;
data = "Server responded: Program not available";

@sahlberg
Copy link
Owner

Collect a network trace with wireshark.

Generally, PROG_UNAVAIL means that either NFS or Portmapper is not configured/running on the server.

Run "rpcinfo" on the server. It should list a whole bunch of program such as:
100003 3 tcp 0.0.0.0.8.1 nfs superuser
100003 4 tcp 0.0.0.0.8.1 nfs superuser
and other stuff.

@JieBinCao
Copy link
Author

Collect a network trace with wireshark.

Generally, PROG_UNAVAIL means that either NFS or Portmapper is not configured/running on the server.

Run "rpcinfo" on the server. It should list a whole bunch of program such as: 100003 3 tcp 0.0.0.0.8.1 nfs superuser 100003 4 tcp 0.0.0.0.8.1 nfs superuser and other stuff.

The result of running the 'rpcinfo' command is as follows:
program version netid address service owner
100000 4 tcp6 ::.0.111 - superuser
100000 3 tcp6 ::.0.111 - superuser
100000 4 udp6 ::.0.111 - superuser
100000 3 udp6 ::.0.111 - superuser
100000 4 tcp 0.0.0.0.0.111 - superuser
100000 3 tcp 0.0.0.0.0.111 - superuser
100000 2 tcp 0.0.0.0.0.111 - superuser
100000 4 udp 0.0.0.0.0.111 - superuser
100000 3 udp 0.0.0.0.0.111 - superuser
100000 2 udp 0.0.0.0.0.111 - superuser
100000 4 local /var/run/rpcbind.sock - superuser
100000 3 local /var/run/rpcbind.sock - superuser
100024 1 udp 0.0.0.0.165.209 - superuser
100024 1 tcp 0.0.0.0.196.245 - superuser
100024 1 udp6 ::.209.41 - superuser
100024 1 tcp6 ::.207.181 - superuser
100003 3 tcp 0.0.0.0.8.1 - superuser
100003 3 tcp6 ::.8.1 - superuser
100021 1 udp 0.0.0.0.143.72 - superuser
100021 3 udp 0.0.0.0.143.72 - superuser
100021 4 udp 0.0.0.0.143.72 - superuser
100021 1 tcp 0.0.0.0.129.27 - superuser
100021 3 tcp 0.0.0.0.129.27 - superuser
100021 4 tcp 0.0.0.0.129.27 - superuser
100021 1 udp6 ::.233.242 - superuser
100021 3 udp6 ::.233.242 - superuser
100021 4 udp6 ::.233.242 - superuser
100021 1 tcp6 ::.141.243 - superuser
100021 3 tcp6 ::.141.243 - superuser
100021 4 tcp6 ::.141.243 - superuser
100005 1 udp 0.0.0.0.137.127 - superuser
100005 1 tcp 0.0.0.0.228.115 - superuser
100005 1 udp6 ::.180.247 - superuser
100005 1 tcp6 ::.179.103 - superuser
100005 2 udp 0.0.0.0.196.205 - superuser
100005 2 tcp 0.0.0.0.136.249 - superuser
100005 2 udp6 ::.196.221 - superuser
100005 2 tcp6 ::.142.223 - superuser
100005 3 udp 0.0.0.0.219.23 - superuser
100005 3 tcp 0.0.0.0.165.125 - superuser
100005 3 udp6 ::.151.137 - superuser
100005 3 tcp6 ::.227.71 - superuser

It seems to have NFS or Portmapper configured/running.
Strangely enough, I can mount it normally using the NFS client that comes with my Windows computer.This is a bit confusing.

@sahlberg
Copy link
Owner

Ok. Collect a network trace with wireshark when you try to mount the share and I can have a look.

@JieBinCao
Copy link
Author

Ok. Collect a network trace with wireshark when you try to mount the share and I can have a look.
I've collected the network trace with Wireshark. Here it is for your review.
20250102133032
Could you please help me analyze what caused it? Thank you!

@kambala-decapitator
Copy link

kambala-decapitator commented Jan 10, 2025

seeing the same issue with v6, but only on Windows. Android and macOS were confirmed to work correctly. Issue observed in Kodi, see the link just above this comment. To be precise: with v5.0.2 all's fine, with v6.0.2 the issue is reproducible,

@sahlberg
Copy link
Owner

Ok. Collect a network trace with wireshark when you try to mount the share and I can have a look.
I've collected the network trace with Wireshark. Here it is for your review.
20250102133032
Could you please help me analyze what caused it? Thank you!

Can you send me the actual network trace. Not a screenshot of it but the pcap file that wireshark created.

@kambala-decapitator
Copy link

@sahlberg here you go. NFS server is at 192.168.1.100
nfs.pcapng.gz

@JieBinCao
Copy link
Author

Ok. Collect a network trace with wireshark when you try to mount the share and I can have a look.
I've collected the network trace with Wireshark. Here it is for your review.
20250102133032
Could you please help me analyze what caused it? Thank you!

Can you send me the actual network trace. Not a screenshot of it but the pcap file that wireshark created.

OK.This is the collected network tracking file:
tracking.zip

@sahlberg
Copy link
Owner

sahlberg commented Jan 13, 2025 via email

@JieBinCao
Copy link
Author

Looks like a configuration error in your environment. Look at packet 133. The server responds to the MOUNT NULL procedure. Open the "Remote Procedure Call" expansion and look at the last line : "Accept state: remote hasn't exported program"

On Mon, 13 Jan 2025 at 13:20, JieBinCao @.> wrote: Ok. Collect a network trace with wireshark when you try to mount the share and I can have a look. I've collected the network trace with Wireshark. Here it is for your review. [image: 20250102133032] https://private-user-images.githubusercontent.com/42132793/399620105-b04b536f-518f-490f-a30a-a661bf2ef314.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzY0OTcyOTIsIm5iZiI6MTczNjQ5Njk5MiwicGF0aCI6Ii80MjEzMjc5My8zOTk2MjAxMDUtYjA0YjUzNmYtNTE4Zi00OTBmLWEzMGEtYTY2MWJmMmVmMzE0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTEwVDA4MTYzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYyMDNlY2YzZTJmYzkxOWEzMGE1NzQwMzE3ZWZlN2EzZTRjMzMzMmNlYmE1MzY1NzE2OGRiNjI2OTU4YzA4Y2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.TiBCODq5p_0zUzAO0ul7ttPjwW5cjNueLnXVfR4hGWo Could you please help me analyze what caused it? Thank you! Can you send me the actual network trace. Not a screenshot of it but the pcap file that wireshark created. OK.This is the collected network tracking file: tracking.zip https://github.com/user-attachments/files/18392394/tracking.zip — Reply to this email directly, view it on GitHub <#511 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADY3EALXOSAXFUXVBREQR32KMWGPAVCNFSM6AAAAABUG22V2OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOBWGEYDGNJYHA . You are receiving this because you were mentioned.Message ID: @.>

OK.My code is written like this, can you help me analyze where the problem occurred?
`void MainWindow::doReadFile(){
WSADATA wsaData;
#ifdef WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
printf("Failed to start Winsock2\n");
return;
}
#endif

struct nfs_context *nfs = NULL;
struct nfs_url *url = NULL;

nfs = nfs_init_context();
if (nfs == NULL) {
    printf("failed to init context\n");
    return;
}
nfs_set_version(nfs, 3);

nfs_set_autoreconnect(nfs, -1);
nfs_set_mountport(nfs, 2049);

QString fp = "nfs://192.168.100.12/home/user/";

url = nfs_parse_url_full(nfs, fp.toStdString().c_str());
if (url == NULL) {
    fprintf(stderr, "%s\n", nfs_get_error(nfs));
    return;
}
int ret = nfs_mount(nfs, url->server, url->path);
if ( ret != 0) {
    fprintf(stderr,"return ret: %d \n\r",ret);
    fprintf(stderr, "Failed to mount nfs share : %s\n", nfs_get_error(nfs));
    return;
}

}`

@sahlberg
Copy link
Owner

sahlberg commented Jan 13, 2025 via email

@JieBinCao
Copy link
Author

Get rid of this : nfs_set_mountport(nfs, 2049); The mount program is very likely not running on 2049 but on an ephemeral port.

Get rid of this :
nfs_set_countport (nfs, 2049);
Report this issue: nfs_service failed

@kambala-decapitator
Copy link

Looks like a configuration error in your environment. Look at packet 133. The server responds to the MOUNT NULL procedure. Open the "Remote Procedure Call" expansion and look at the last line : "Accept state: remote hasn't exported program"

why does the issue manifest only on Windows but not on macOS / Android?

@kambala-decapitator
Copy link

kambala-decapitator commented Jan 13, 2025

as far as I can see, in Kodi the only windows-specific code is a few defines that are used here: https://github.com/xbmc/xbmc/blob/e7e6ee63bf222e4a5896598d5520dd509dbaef1d/xbmc/filesystem/NFSFile.cpp#L947

ret = nfs_creat(m_pNfsContext, filename.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, &m_pFileHandle);

the defines are: https://github.com/xbmc/xbmc/blob/e7e6ee63bf222e4a5896598d5520dd509dbaef1d/xbmc/filesystem/NFSFile.cpp#L35-L40

#define S_IRGRP 0
#define S_IROTH 0
#define S_IWUSR _S_IWRITE
#define S_IRUSR _S_IREAD

and there's no nfs_set_mountport call

@JieBinCao
Copy link
Author

seeing the same issue with v6, but only on Windows. Android and macOS were confirmed to work correctly. Issue observed in Kodi, see the link just above this comment. To be precise: with v5.0.2 all's fine, with v6.0.2 the issue is reproducible,

Indeed, everything was normal in v5.0.2, but in v6.0.2, this issue is reproducible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants