Bug 1665 - prefix_pton is inefficient
Summary: prefix_pton is inefficient
Status: CLOSED MOVED
Alias: None
Product: py-radix
Classification: Unclassified
Component: Default (show other bugs)
Version: -current
Hardware: ix86 Linux
: P2 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-26 22:07 AEDT by Göran Weinholt
Modified: 2022-02-25 13:55 AEDT (History)
1 user (show)

See Also:


Attachments
change prefix_pton to use inet_pton() (1.94 KB, patch)
2009-10-26 22:07 AEDT, Göran Weinholt
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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