Issue 10201: Fix building of socket module under Solaris (original) (raw)
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);
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.
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 ...).