Bug 1665

Summary: prefix_pton is inefficient
Product: py-radix Reporter: Göran Weinholt <weinholt>
Component: DefaultAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED MOVED    
Severity: enhancement CC: djm
Priority: P2    
Version: -current   
Hardware: ix86   
OS: Linux   
Attachments: change prefix_pton to use inet_pton()

Description Göran Weinholt 2009-10-26 22:07:29 AEDT
Created attachment 1710 [details]
change prefix_pton to use inet_pton()

py-radix 0.5 uses getaddrinfo() to parse IPv4/IPv6 addresses. On
GNU/Linux this procedure creates a socket and performs a few syscalls
on it. It would be better to parse addresses without performing
syscalls.

I noticed this when writing a program that generates DHCP configuration
for ~15k hosts. When running the program on the server running the DHCP
daemon it ran out of some sort of kernel memory (NFS stopped working,
neighbor table filled, new TCP connections failed). For some reason the
development machine didn't have the same problem. I traced it down to
the getaddrinfo() call.

To solve this problem I patched py-radix to use inet_pton instead.
Please review the attached patch. Also, the testbed runs in 3.1 seconds
when it previously took 4.3s.

The patch also fixes the error messages. Previously invalid prefix
lengths would result in a garbage error message, and a failed call to
getaddrinfo() would return a pointer to inside the function's stack.
Comment 1 Damien Miller 2019-01-23 20:04:44 AEDT
py-radix is not longer in this bugtracker
Comment 2 Damien Miller 2022-02-25 13:55:21 AEDT
closing bugs resolved before the openssh-8.9 release