This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix building of socket module under Solaris
Type: behavior Stage: patch review
Components: Build Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6, Python 2.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: _socket fails to build on OpenSolaris x64
View: 8852
Assigned To: Nosy List: jcea, laca, loewis, movement, pitrou
Priority: normal Keywords: patch

Created on 2010-10-26 16:22 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
buildsocket.patch pitrou, 2010-10-26 16:46
Messages (8)
msg119615 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-26 16:22
Sun/Oracle uses the following patch to fix building of the socket module, since on Solaris "netpacket/packet.h" is incompatible with its Linux counterpart. Otherwise, it fails with the following messages:

/home/antoine/py3k/gcc/Modules/socketmodule.c: In function ‘makesockaddr’:
/home/antoine/py3k/gcc/Modules/socketmodule.c:1150: error: ‘struct ifreq’ has no member named ‘ifr_ifindex’
/home/antoine/py3k/gcc/Modules/socketmodule.c:1151: error: ‘SIOCGIFNAME’ undeclared (first use in this function)
/home/antoine/py3k/gcc/Modules/socketmodule.c:1151: error: (Each undeclared identifier is reported only once
/home/antoine/py3k/gcc/Modules/socketmodule.c:1151: error: for each function it appears in.)
/home/antoine/py3k/gcc/Modules/socketmodule.c: In function ‘getsockaddrarg’:
/home/antoine/py3k/gcc/Modules/socketmodule.c:1484: error: ‘SIOCGIFINDEX’ undeclared (first use in this function)
/home/antoine/py3k/gcc/Modules/socketmodule.c:1502: error: ‘struct ifreq’ has no member named ‘ifr_ifindex’
/home/antoine/py3k/gcc/Modules/socketmodule.c: In function ‘PyInit__socket’:
/home/antoine/py3k/gcc/Modules/socketmodule.c:4580: error: ‘PACKET_LOOPBACK’ undeclared (first use in this function)
/home/antoine/py3k/gcc/Modules/socketmodule.c:4581: error: ‘PACKET_FASTROUTE’ undeclared (first use in this function)



$ cat ~/spec-files/patches/Python26-17-netpacket-packet-h.diff 
--- Python-2.6.2/Modules/socketmodule.c.packet	2009-04-01 07:20:48.000000000 +1300
+++ Python-2.6.2/Modules/socketmodule.c	2009-12-01 21:25:04.133257645 +1300
@@ -81,6 +81,14 @@
 
 */
 
+#ifdef HAVE_NETPACKET_PACKET_H
+#ifdef sun
+#define USE_NETPACKET_PACKET_H 0
+#else
+#define USE_NETPACKET_PACKET_H 1
+#endif
+#endif
+
 #ifdef __APPLE__
   /*
    * inet_aton is not available on OSX 10.3, yet we want to use a binary
@@ -1092,7 +1100,7 @@
 		}
 #endif
 
-#ifdef HAVE_NETPACKET_PACKET_H
+#if USE_NETPACKET_PACKET_H
 	case AF_PACKET:
 	{
 		struct sockaddr_ll *a = (struct sockaddr_ll *)addr;
@@ -1382,7 +1390,7 @@
 	}
 #endif
 
-#ifdef HAVE_NETPACKET_PACKET_H
+#if USE_NETPACKET_PACKET_H
 	case AF_PACKET:
 	{
 		struct sockaddr_ll* addr;
@@ -1559,7 +1567,7 @@
 	}
 #endif
 
-#ifdef HAVE_NETPACKET_PACKET_H
+#if USE_NETPACKET_PACKET_H
 	case AF_PACKET:
 	{
 		*len_ret = sizeof (struct sockaddr_ll);
@@ -4575,7 +4583,7 @@
 	PyModule_AddStringConstant(m, "BDADDR_LOCAL", "00:00:00:FF:FF:FF");
 #endif
 
-#ifdef HAVE_NETPACKET_PACKET_H
+#if USE_NETPACKET_PACKET_H
 	PyModule_AddIntConstant(m, "AF_PACKET", AF_PACKET);
 	PyModule_AddIntConstant(m, "PF_PACKET", PF_PACKET);
 	PyModule_AddIntConstant(m, "PACKET_HOST", PACKET_HOST);
msg119618 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-26 16:46
Here is a working patch for py3k. Tested under OpenSolaris with both gcc and Sun C.
msg119656 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2010-10-26 22:48
This is not a problem under Solaris 10. I guess it is a problem with OpenSolaris/OpenIndiana/Illumos.

Can you confirm?.
msg119657 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-26 23:05
> This is not a problem under Solaris 10. I guess it is a problem with
> OpenSolaris/OpenIndiana/Illumos.
> 
> Can you confirm?.

It's with the most recent OpenSolaris development build (build 134).
msg119664 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2010-10-27 00:39
Could this to be considered a bug in OpenSolaris?.

If not, I think this fix should be backported to 2.5/2.6/2.7/3.1.

Just for the record, I am asking for help to get a buildbot under OpenIndiana: http://openindiana.org/pipermail/openindiana-discuss/2010-October/000974.html . Hope somebody can help out. We need it.
msg119684 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-27 10:09
> Jesús Cea Avión <jcea@jcea.es> added the comment:
> 
> Could this to be considered a bug in OpenSolaris?.

That's a good question. Perhaps Laca (who wrote the original patch) can
chime in.

> If not, I think this fix should be backported to 2.5/2.6/2.7/3.1.

It's not a security fix, so I think 2.5 and 2.6 are not applicable.
msg119688 - (view) Author: John Levon (movement) Date: 2010-10-27 10:42
This is not a bug in Solaris - the interfaces Python is trying to use are not standardized.

(It's a reasonable RFE for Solaris to fully support these, though - I'll follow up on that.)

WRT the patch, at least the PACKET_* defined would be better done via a specific guard (#ifdef PACKET_LOOPBACK ...).
msg119694 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-27 11:46
Actually, there's a better patch in #8852.
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54410
2010-10-27 11:46:17pitrousetstatus: open -> closed
resolution: duplicate
superseder: _socket fails to build on OpenSolaris x64
messages: + msg119694
2010-10-27 10:42:31movementsetmessages: + msg119688
2010-10-27 10:09:26pitrousetmessages: + msg119684
2010-10-27 00:39:05jceasetmessages: + msg119664
versions: + Python 2.6, Python 2.5
2010-10-26 23:05:37pitrousetmessages: + msg119657
2010-10-26 22:48:37jceasetmessages: + msg119656
2010-10-26 16:46:56pitrousetfiles: + buildsocket.patch

nosy: + laca
messages: + msg119618

keywords: + patch
2010-10-26 16:22:48pitroucreate