NetBSD Problem Report #9256
Received: (qmail 17075 invoked from network); 20 Jan 2000 07:17:35 -0000
Message-Id: <200001200717.QAA15644@itojun.org>
Date: Thu, 20 Jan 2000 16:17:27 +0900 (JST)
From: itojun@itojun.org
Reply-To: itojun@itojun.org
To: gnats-bugs@gnats.netbsd.org
Cc: tsarna@netbsd.org
Subject: lang/python6: python with IPv6 support
X-Send-Pr-Version: 3.95
>Number: 9256
>Category: pkg
>Synopsis: lang/python6: python with IPv6 support
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: pkg-manager
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Jan 19 23:18:00 +0000 2000
>Closed-Date: Thu Mar 15 12:17:03 +0000 2001
>Last-Modified: Thu Mar 15 12:18:00 +0000 2001
>Originator: Jun-ichiro itojun Hagino
>Release: current
>Organization:
itojun.org
>Environment:
System: NetBSD lychee.itojun.org 1.4.1 NetBSD 1.4.1 (LYCHEE.v6) #530: Tue Jan 18 21:10:07 JST 2000 itojun@lychee.itojun.org:/export/home/itojun/k/kame/netbsd/sys/arch/i386/compile/LYCHEE.v6 i386
>Description:
python language with IPv6 patch. I submit this here before I go on,
to solicit review, or comments.
Issues to be discussed:
- The pkgsrc will pull in IPv6 support. Due to IPv6 changes,
there are certain changes in socket support, and network related
libraries. This may break existing python script, so I made a
"parasite" pkgsrc for safety. Is it the right way to go, or should
we try bring it into lang/python to see what happens?
- Is it a right way to make a parasite port (it certainly decreases
- of course, need to submit IPv6 support patch to original author
(did in the past but he looked busy)
>How-To-Repeat:
>Fix:
apply the following patch to lang/python.
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/lang/python/Makefile,v
retrieving revision 1.18
diff -c -r1.18 Makefile
*** Makefile 2000/01/09 01:19:11 1.18
--- Makefile 2000/01/20 07:09:55
***************
*** 2,8 ****
#
DISTNAME= py152
! PKGNAME= python-1.5.2
CATEGORIES= lang
MASTER_SITES= ftp://ftp.python.org/pub/python/src/
EXTRACT_SUFX= .tgz
--- 2,8 ----
#
DISTNAME= py152
! PKGNAME?= python-1.5.2
CATEGORIES= lang
MASTER_SITES= ftp://ftp.python.org/pub/python/src/
EXTRACT_SUFX= .tgz
***************
*** 16,21 ****
--- 16,23 ----
WRKSRC= ${WRKDIR}/Python-1.5.2
GNU_CONFIGURE= yes
+
+ CONFLICTS+= python6-*
# Make sure having environment variable OPT doesn't affect the
# installed module-building Makefile
next, create lang/python6 with this.
diff -r -u -N /tmp/Makefile ./Makefile
--- /tmp/Makefile Wed Dec 31 16:00:00 1969
+++ ./Makefile Wed Jan 19 23:02:47 2000
@@ -0,0 +1,20 @@
+# $NetBSD: Makefile,v 1.17 1999/08/02 10:59:34 agc Exp $
+#
+
+PKGDIR= ${.CURDIR}/../../lang/python/pkg
+FILESDIR= ${.CURDIR}/../../lang/python/files
+PATCHDIR= ${.CURDIR}/../../lang/python/patches
+MD5_FILE= ${.CURDIR}/files/md5
+
+PATCH_SITES= ftp://ftp.kame.net/pub/kame/misc/
+PATCHFILES= python-152-v6-20000120.diff.gz
+PATCH_DIST_STRIP= -p1
+
+# overrides - should be set with "=?" in ../python/Makefile
+PKGNAME= python6-1.5.2
+
+CONFLICTS+= python-*
+
+.include "${.CURDIR}/../../lang/python/Makefile"
+
+COMMENT= ${.CURDIR}/pkg/COMMENT
diff -r -u -N /tmp/files/md5 ./files/md5
--- /tmp/files/md5 Wed Dec 31 16:00:00 1969
+++ ./files/md5 Wed Jan 19 23:05:04 2000
@@ -0,0 +1,4 @@
+$NetBSD$
+
+MD5 (python/py152.tgz) = e9d677ae6d5a3efc6937627ed8a3e752
+MD5 (python/python-152-v6-20000120.diff.gz) = bbbd8296a8f651a76ea60a9ff0a5feb1
diff -r -u -N /tmp/pkg/COMMENT ./pkg/COMMENT
--- /tmp/pkg/COMMENT Wed Dec 31 16:00:00 1969
+++ ./pkg/COMMENT Wed Jan 19 20:50:39 2000
@@ -0,0 +1 @@
+Python language with IPv6 support.
>Release-Note:
>Audit-Trail:
Date: Thu, 20 Jan 100 09:27:50 -0600 (CST)
From: Ty Sarna <tsarna@endicor.com>
Subject: Re: lang/python6: python with IPv6 support
Thanks for doing this work!
itojun@itojun.org wrote:
| Issues to be discussed:
| - The pkgsrc will pull in IPv6 support. Due to IPv6 changes,
| there are certain changes in socket support, and network related
| libraries. This may break existing python script, so I made a
| "parasite" pkgsrc for safety. Is it the right way to go, or should
| we try bring it into lang/python to see what happens?
Correct me if I'm wrong, but if python6 were installed on an IPv4-only
NetBSD box, none of the behavior changes should be visible, right? If
this is the case, I think it could be integrated safely into the main
package. Only IPv6 users would have problems, and I think for them the
benefit outweighs the problems. Plus, IPv6 early adopters probably
expect some amount of trouble and are willing to find and fix it.
The downside of a parasite port is that other python-using packages have
to have alternate dependancies. However, if integration could break
IPv4-only systems too, then that's probably the best way.
| - Is it a right way to make a parasite port (it certainly decreases
decreases what? :) ^
| - of course, need to submit IPv6 support patch to original author
| (did in the past but he looked busy)
It would be good to have at least an official reaction to the patches. I
will be at IPC8 next week, so maybe I can get one :^)
I suggest holding off until then.
Date: Fri, 21 Jan 2000 01:51:12 +0900
From: itojun@iijlab.net
Subject: Re: lang/python6: python with IPv6 support
|> Issues to be discussed:
|> - The pkgsrc will pull in IPv6 support. Due to IPv6 changes,
|> there are certain changes in socket support, and network related
|> libraries. This may break existing python script, so I made a
|> "parasite" pkgsrc for safety. Is it the right way to go, or should
|> we try bring it into lang/python to see what happens?
|Correct me if I'm wrong, but if python6 were installed on an IPv4-only
|NetBSD box, none of the behavior changes should be visible, right?
If we use patched tree on IPv4-only box, I cannot be 100% sure because
socket class now uses different underlying name resolution function.
The only safest way is to use unpatched tree, IMHO.
I'll attach README.v6 which I attached to the patch. Please let me
know your opinion.
|> - of course, need to submit IPv6 support patch to original author
|> (did in the past but he looked busy)
|It would be good to have at least an official reaction to the patches. I
|will be at IPC8 next week, so maybe I can get one :^)
|I suggest holding off until then.
If you see the author please mention it.
itojun
---
IPv6-ready python 1.5.x
KAME Project
$Id: README.v6,v 1.8 2000/01/19 15:56:37 itojun Exp $
This patchkit enables python 1.5.x to perform AF_INET6 socket operations.
The only affected module is Modules/socketmodule.c.
Modules/socketmodule.c
In most cases, IPv6 address can be placed where IPv4 address fits.
sockaddr
sockaddr tuple is formatted as follows:
IPv4: (host, port)
IPv6: socket class methods always generate
(host, port, flowinfo, scopeid).
socket class methods will accept 2, 3, or 4 tuple
(for backward compatibility).
Compatibility warning: Some of the scripts assume that the sockaddr
structure is 2 tuple, like:
host, port = sock.getpeername()
this will fail if you are connected to IPv6 node.
socket.getaddrinfo(host, port [, family, socktype, proto, flags])
host: String or None
port: String, Int or None
family, socktype, proto, flags: Int, can be omitted
Perform getaddrinfo(3). Returns List of the following 5 tuple:
(family, socktype, proto, canonname, sockaddr)
family: Int
socktype: Int
proto: Int
canonname: String
sockaddr: sockaddr (see above)
See Lib/httplib.py for typical usage on the client side.
socket.getnameinfo(sockaddr, flags)
sockaddr: sockaddr
flags: Int
Perform getnameinfo(3). Returns the following 2 tuple:
host: String, numeric or hostname depending on flgags
port: String, numeric or portname depending on flgags
socket.gethostbyname(host) (behavior change if IPv6 support is compiled in)
host: String
Performs gethostbyname(3). Returns numeric address representation
for "host".
Unlike gethostbyname(3) (which returns IPv4 addresses only),
socket.gethostbyname() can return IPv6 address in numeric form.
This is because original Python soket.gethostbyname() can return
addresses other than IPv4. We just followed the existing practice
in Python.
However, this may cause trouble with existing scripts, if:
- the given "host" resolves to IPv6 address
- and the script assumes to get IPv4 address
For example, while the following code always success with normal
Python distribution, this can fail with IPv6-ready Python because
'localhost' can resolve to IPv6 address ('::1').
a = socket.gethostbyname('localhost')
# "a" can be '::1'
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# if "a" is '::1', s.bind() fails
s.bind(a, port)
socket.gethostbyaddr(addr) (behavior change if IPv6 support is compiled in)
addr: String
Performs gethostbyaddr(3). Returns string address representation for
"addr".
The function can take IPv6 numeric address as well. This behavior
is not problematical, because
- if you pass numeric "addr" parameter, we can always identify address
family for it
- return value is string address reprsentation, where IPv6 and IPv4
are not distinguishable.
socket.bind(addr, port), socket.connect(addr, port) and others.
(No behavior change, but be careful)
With Python "addr" can be string hostname. When the string hostname
resolved to numeric address, it will obey address family of the socket
(which was specified when socket.socket() was called).
If you give some string that does not give matching address family,
you will get some error.
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# this is okay, if 'localhost' resolves to both IPv4/v6
s.connect('localhost', 80)
# this is not okay, of course
s.connect('::1', 80)
# this is not okay, as v6only.kame.net will not resolve to IPv4
s.connect('v6only.kame.net', 80)
Lib/httplib.py
IPv6 ready. "host" in HTTP(host) will accept the following 3 forms:
[host]:port
host:port there must be only single colon
host
This is to allow IPv6 numeric URL (http://[host]:port/) in documents.
IMHO "host:port" parsing should be implemented in urllib.py, not here.
Lib/ftplib.py
IPv6 ready. This uses EPSV/EPRT on IPv6 ftp. See RFC2428 for
protocol details.
Lib/SocketServer.py
IPv6 ready. Wildcard bind on TCPServer, i.e. TCPServer(('', port)),
will bind to wildcard socket on TCPServer.address_family.
TCPServer.addresss_family is set to AF_INET by default, so ('', port)
will usually bind AF_INET.
Lib/smtplib.py, Lib/telnetlib.py, Lib/poplib.py
IPv6 ready. Not much to say about protocol details - they just use
TCP over IPv6.
configure
Configure has extra option, --enable-ipv6 and --disable-ipv6.
The option controls IPv6 support feature.
dynamic link issues in Modules/socketmodule.c
Modules/socketmodule.c can be dynamically loaded only in the following
situations:
- getaddrinfo(3) and getnameinfo(3) are supplied by OS vendor in
libc, and libc is dynamic link library.
- OS vendor is NOT supplying getaddrinfo(3) nor getnameinfo(3), and
You are configuring this package with --disable-ipv6. In this case,
you'll be using missing/get{addr,name}info.c and they will refer to
gethostby{name,addr}. gethostnameby{name,addr} can usually be found
in dynamic-linking libc.
In other situations, such as the following, please link
Modules/socketmodule.c into python itself.
- getaddrinfo(3) and getnameinfo(3) are supplied by OS vendor, but
they are in statically linked library like libinet6.a.
(KAME falls into this category)
python usually links Modules/socketmodule.c into python itself
(due to its popularity) so there should be no problem.
restrictions
- The patched tree will not use gethostbyname_r and other
thread-ready libraries. Instead, it will use getaddrinfo() and
getnameinfo() throughout the operation.
todo
- Patch bunch of library files in Lib/*.py.
compatibility issues with existing scripts
If you disable IPv6 support (./configure --disable-ipv6), the
patched code is mostly compatible with original Python
(except files in "Lib" directory modified for dual stack support).
User script may choke if:
- IPv4/v6 dualstack libc is supplied, python is compiled for dual
stack, and script assumes some of IPv4-only behavior (especially
sockaddr)
- IPv4/v6 dualstack libc is supplied, python is compiled for IPv4 only,
and script assumes some of IPv4-only behavior.
In this case, Python socket class itself does not support IPv6,
however, name resolution functions can return IPv6 names since
they use IPv6-ready libc functions! I do not recommend this
configuration.
- script assumes certain IPv4-only version behavior in Lib/*.py.
compilation
If you use IPv6 features, it is assumed that you have working
getaddrinfo() and getnameinfo() library functions. We have noticed
that some of IPv6 stack is shipped with broken getaddrinfo(). In
such cases, use missing/get{addr,name}info.c instead (but then, you
need to have working getipnodeby{name,addr}).
If you compile this on IPv4-only machine without get{addr,name}info,
missing/get{addr,name}info.c will be used. They are from KAME IPv6
distribution and is #ifdef'ed for IPv4 only support. They are
fairly complete implementation and you don't need to bother with
bind 8.2 (bind 8.2 get{addr,name}info() has bugs).
When compiling this kit on IPv6 node, you may need to specify some
additional library paths or cpp defs. (like -linet6 or -DINET6)
--enable-ipv6 will give you some warning, if the IPv6 stack is unknown
to the "configure" script. Currently, the following IPv6 stacks
are officially supported (i.e. we've checked that the package works
well):
- KAME IPv6 stack, http://www.kame.net/
References
RFC2553, for getaddrinfo(3) and getnameinfo(3).
Author contacts
http://www.kame.net/
mailto:core@kame.net
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
To: gnats-bugs@gnats.netbsd.org
Cc: tsarna@endicor.com
Subject: Re: pkg/9256
Date: Tue, 15 Aug 2000 17:59:44 +0900
(about pkgsrc/lang/python6)
I have an IPv6 patch for python 1.6b1. it is in
ftp://ftp.kame.net/pub/kame/misc. also I've submitted
the patch to python sourceforget bug tracking system.
hope it to be picked up by the author this time...
i'm still not 100% sure about backward compatibility. there are
too many issues to look at.
itojun
State-Changed-From-To: open->suspended
State-Changed-By: wiz
State-Changed-When: Tue Mar 13 11:13:08 PST 2001
State-Changed-Why:
The python package is at 2.0 now -- do you think you'll provide a patch
for that too? Or is it already IPv6-enabled?
From: itojun@iijlab.net
To: wiz@netbsd.org
Cc: pkg-manager@netbsd.org
Subject: Re: pkg/9256
Date: Wed, 14 Mar 2001 09:58:49 +0900
>Synopsis: lang/python6: python with IPv6 support
>State-Changed-From-To: open->suspended
>State-Changed-By: wiz
>State-Changed-When: Tue Mar 13 11:13:08 PST 2001
>State-Changed-Why:
>The python package is at 2.0 now -- do you think you'll provide a patch
>for that too?
i believe i can ship a new patch.
>Or is it already IPv6-enabled?
no. i have sent the patch to python developers but it is yet to get merged.
itojun
From: Thomas Klausner <wiz@netbsd.org>
To: itojun@iijlab.net
Cc: pkg-manager@netbsd.org, gnats-bugs@netbsd.org
Subject: Re: pkg/9256
Date: Wed, 14 Mar 2001 11:49:43 +0100
Mutt made me believe that itojun@iijlab.net wrote:
> >The python package is at 2.0 now -- do you think you'll provide a patch
> >for that too?
>
> i believe i can ship a new patch.
Do you want this PR to remain open in the meantime, or will you just
open a new one once you got new patches? (Or just import a package
right away?)
Thanks,
Thomas
--
Thomas Klausner - wiz@danbala.tuwien.ac.at
To live for some future goal is shallow. It's the sides of the mountain
that sustain life, not the top. -- Robert M. Pirsig
State-Changed-From-To: suspended->closed
State-Changed-By: itojun
State-Changed-When: Thu Mar 15 04:16:51 PST 2001
State-Changed-Why:
python 2.0 is out
From: itojun@iijlab.net
To: Thomas Klausner <wiz@netbsd.org>
Cc: pkg-manager@netbsd.org, gnats-bugs@netbsd.org
Subject: Re: pkg/9256
Date: Thu, 15 Mar 2001 21:16:42 +0900
>Do you want this PR to remain open in the meantime, or will you just
>open a new one once you got new patches? (Or just import a package
>right away?)
i'll close it once. thanks.
itojun
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.