[klibc] [PATCH] possible bug in bindresvport

Olaf Hering olh at suse.de
Tue Jan 6 21:14:42 PST 2004


nfsmount doesnt work anymore for me. This patch fixes at least udp nfs
mounts. tcp does still hang. client and server is 2.6.


--- /dev/shm/bindresvport.c     2003-12-08 02:33:24.000000000 +0100
+++ klibc/inet/bindresvport.c   2004-01-06 21:05:02.283779072 +0100
@@ -23,7 +23,7 @@ int bindresvport(int sd, struct sockaddr
        if (sin == NULL) {
                sin = &me;
                memset(sin, 0, sizeof(me));
-               sin->sin_port = AF_INET;
+               sin->sin_family = AF_INET;
        }
        else if (sin->sin_family != AF_INET) {
                errno = EPFNOSUPPORT;
@@ -37,7 +37,7 @@ int bindresvport(int sd, struct sockaddr

        for (i = 0; i < NUM_PORTS; i++, port++) {
                sin->sin_port = htons(port);
-               if ((ret = bind(sd, (struct sockaddr *)&sin, sizeof(*sin))) != -1)
+               if ((ret = bind(sd, (struct sockaddr *)sin, sizeof(*sin))) != -1)
                        break;
                if (port == END_PORT)
                        port = START_PORT;

mango:~ # strace -f /lib/klibc/bin/nfsmount -o udp,rsize=8192,wsize=8192 192.168.1.2:/nfsroot/mango /mnt
execve("/lib/klibc/bin/nfsmount", ["/lib/klibc/bin/nfsmount", "-o", "udp,rsize=8192,wsize=8192", "192.168.1.2:/nfsroot/mango", "/mnt"], [/* 46 vars */]) = 0
gettimeofday({1073419650, 154920}, NULL) = 0
mmap2(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0) = 0x30000000
stat("/mnt", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(111), sin_addr=inet_addr("192.168.1.2")}, 16) = 0
write(3, "\200\0\0<\33\247~r\0\0\0\0\0\0\0\2\0\1\206\240\0\0\0\2"..., 60) = 60
read(3, "\200\0\0\34\33\247~r\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 32) = 32
close(3)                                = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(111), sin_addr=inet_addr("192.168.1.2")}, 16) = 0
write(3, "\200\0\0<\34\312\254t\0\0\0\0\0\0\0\2\0\1\206\240\0\0\0"..., 60) = 60
read(3, "\200\0\0\34\34\312\254t\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0"..., 32) = 32
close(3)                                = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 3
getpid()                                = 2050
bind(3, {sa_family=AF_INET, sin_port=htons(958), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(32916), sin_addr=inet_addr("192.168.1.2")}, 16) = 0
write(3, "\377\235&\256\0\0\0\0\0\0\0\2\0\1\206\245\0\0\0\1\0\0\0"..., 58) = 58
poll([{fd=3, events=POLLRDNORM, revents=POLLRDNORM}], 1, 2077) = 1
read(3, "\377\235&\256\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 96) = 60
socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 4
bind(4, {sa_family=AF_INET, sin_port=htons(958), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
bind(4, {sa_family=AF_INET, sin_port=htons(959), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
mount("192.168.1.2:/nfsroot/mango", "/mnt", "nfs", , 0x10014100) = 805306384
mount("192.168.1.2:/nfsroot/mango", "/mnt", "nfs", , 0x10014100) = 0
close(3)                                = 0
close(4)                                = 0
exit(0)                                 = ?
mango:~ # umount /mnt
mango:~ # strace -f /lib/klibc/bin/nfsmount -o tcp,rsize=8192,wsize=8192 192.168.1.2:/nfsroot/mango /mnt
execve("/lib/klibc/bin/nfsmount", ["/lib/klibc/bin/nfsmount", "-o", "tcp,rsize=8192,wsize=8192", "192.168.1.2:/nfsroot/mango", "/mnt"], [/* 46 vars */]) = 0
gettimeofday({1073419684, 685341}, NULL) = 0
mmap2(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0) = 0x30000000
stat("/mnt", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(111), sin_addr=inet_addr("192.168.1.2")}, 16) = 0
write(3, "\200\0\0<\303\21\247\32\0\0\0\0\0\0\0\2\0\1\206\240\0\0"..., 60) = 60
read(3, "\200\0\0\34\303\21\247\32\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 32) = 32
close(3)                                = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(111), sin_addr=inet_addr("192.168.1.2")}, 16) = 0
write(3, "\200\0\0<\337\333_3\0\0\0\0\0\0\0\2\0\1\206\240\0\0\0\2"..., 60) = 60
read(3, "\200\0\0\34\337\333_3\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 32) = 32
close(3)                                = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
getpid()                                = 2054
bind(3, {sa_family=AF_INET, sin_port=htons(962), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(33052), sin_addr=inet_addr("192.168.1.2")}, 16) = 0
write(3, "\200\0\0>\10\356h\313\0\0\0\0\0\0\0\2\0\1\206\245\0\0\0"..., 62) = 62
read(3, "\200\0\0\30\10\356h\313\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0"..., 100) = 28
write(2, "rpc failed: 4\n", 14rpc failed: 4
)         = 14
close(3)                                = 0
exit(1)                                 = ?
mango:~ #
mango:~ # mount -o tcp 192.168.1.2:/nfsroot/mango /mnt
mango:~ # cat /proc/mounts 
rootfs / rootfs rw 0 0
/dev/hda11 / ext2 rw,noatime 0 0
sysfs /sys sysfs rw 0 0
shmfs /dev/shm tmpfs rw 0 0
proc /proc proc rw 0 0
devpts /dev/pts devpts rw 0 0
shmfs /dev/shm tmpfs rw 0 0
usbdevfs /proc/bus/usb usbdevfs rw 0 0
192.168.1.2:/nfsroot/mango /mnt nfs rw,v3,rsize=32768,wsize=32768,hard,tcp,lock,addr=192.168.1.2 0 0


-- 
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG



More information about the klibc mailing list