Package: klibc-utils
Version: 1.5.12-2
Followup-For: Bug #444087

The 32 bits version of socket-related syscalls for sparc/sparc64 does 
not seem to conform to the interface provided by the kernel. As a 
result, klibc-utils commands such as ipconfig ends with a "ipconfig: 
eth0: socket(AF_INET): Function not implemented".

See bug #444087 for the log with an older version. See for the following 
session for another evidence of the problem with a newer version:
jer...@sunny:~$ /usr/lib/klibc/bin/ipconfig lo
ipconfig: lo: socket(AF_INET): Function not implemented
/usr/lib/klibc/bin/ipconfig: no devices to configure

Looking at the source code, it seems there is 2 call mechanisms:
- if the kernel header files (asm/unistd.h) defines __NR_socket (and so 
on), the makefiles uses the syscall interface ;
- otherwise, the makefiles uses the socketcall interface, which wraps 
the call into a common syscall (named socketcall).
See the <src>/usr/klibc/syscalls.pl and <src>/usr/klibc/socketcalls.pl 
for details.

Looking at the kernel source code for the 32 bits syscall table for the 
sparc64 architecture <src-2.6.26>/arch/sparc64/kernel/systbls.S, we see 
at index __NR_socket (97 according to asm-sparc/unistd.h and to 
asm-sparc64/unistd.h) that the entry points to sys_nis_syscall. Looking 
in <src-2.6.26>/arch/sparc64/kernel/syscalls.S, it branches to 
c_sys_nis_syscall, which (<src-2.6.26>/arch/sparc64/kernel/sys_sparc.c) 
returns ENOSYS, the error code for non-implemented syscalls.

According to my quick tests, there are 2 workarounds:
1) compile klibc to sparc64, as the 64 bits syscall table of the kernel 
provides the direct socket (and related) syscalls
2) patch klibc such that it uses socketcall when targeting sparc(32).

Here is a sample patch for the 2nd option:
diff -urN a/usr/klibc/socketcalls.pl b/usr/klibc/socketcalls.pl
--- a/usr/klibc/socketcalls.pl  2008-07-08 01:05:17.000000000 +0200
+++ b/usr/klibc/socketcalls.pl  2009-05-26 14:32:03.000000000 +0200
@@ -63,7 +63,7 @@

            print OUT "#include \"socketcommon.h\"\n";
            print OUT "\n";
-           print OUT "#ifndef __NR_${name}\n\n";
+           print OUT "#if (defined(__sparc__) && !defined(__arch64__)) || 
!defined(__NR_${name})\n\n";

            print OUT "extern long __socketcall(int, const unsigned long 
*);\n\n";

diff -urN a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def
--- a/usr/klibc/SYSCALLS.def    2008-07-08 01:05:17.000000000 +0200
+++ b/usr/klibc/SYSCALLS.def    2009-05-26 14:30:16.000000000 +0200
@@ -259,4 +259,9 @@
  * system calls.
  */
 <?!i386> long socketcall::__socketcall(int, const unsigned long *);
+#if !defined(__sparc__) && !defined(__arch64__)
+/*
+ * SPARC does not have direct syscalls for socket
+ */
 #include "SOCKETCALLS.def"
+#endif

-- System Information:
Debian Release: 5.0.1
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: sparc (sparc64)

Kernel: Linux 2.6.26-2-sparc64
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages klibc-utils depends on:
ii  libklibc                      1.5.12-2   minimal libc subset for use with i

klibc-utils recommends no packages.

klibc-utils suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to