Zum Hauptinhalt springen
Intelligence View
⚡ tsecurity.de Intelligence

net-snmp ip-forward table performance problems

Some performance problems are hard and complex, but others seem to bedue to just plain stupidity. This is the saga of SNMP daemon and afull BGP route table.…

Beitrag
0
Seite
0
↗ Quelle (linux-network-plumber.blogspot.com)
Cloud & Tech-Stack · 4 Min. Lesezeit
Quelle: linux-network-plumber.blogspot.com
Rubrik: Unix & Linux Server
Some performance problems are hard and complex, but others seem to be
due to just plain stupidity. This is the saga of SNMP daemon and a
full BGP route table. Way back in 2006, Vyatta discovered that if an
SNMP walk was done on a server with a full BGP route table, it would
peg the CPU and never complete. A full BGP route table is 500K entries
or more so it does a good job of exposing scalability nightmares. The
initial fix was to disable the caching of the route table in SNMP
which made it return no entries. Hardly a good fix, but returning
nothing is better than crashing.

I began investigating with the simple tools of packet capture with wireshark
and syscall capturing with strace. The first discovery was that each
request caused the TCP wrappers library to open and read
/etc/hosts.allow and /etc/hosts.deny. Bogus on two counts:

  1. Debian is shipping the 2 files with no real entries only comments.
    Each packet caused file to be read but there was really no data.
    It would have been better to have the file not exist and have the open fail.
  2. But for our distribution, there was no point in enabling
    TCP wrappers anyway.

The fix was simple to disable tcp-wrappers.

The net-snmp daemon retrieves the ipv4 and ipv6 routing table the old
school way through /proc. This isn't a total disaster but since the
route entries in /proc start with an interface name and net-snmp wants
an ifindex it looks up each entry. That is 300K extra ioctl
calls. Short term hack was to just cache last ifname -> ifindex
translation
; later I replaced it with a netlink route dump
which gives ifindex (surprisingly netlink route dump is already used
in another MIB).

Next observation was that it is stupid to use snmpwalk to walk
the whole system and instead use snmpbulk. This helps but still
the walk would not complete.

The real discovery was when looking at the net-snmp container
code. Internally, net-snmp uses an objectish abstraction to store
data, and the main ones are a flat table and a linked list. The table
is stored in sorted order for fast lookup and sequential access. New
entries are placed at the end of the table and a dirty bit is set for
next lookup. The problem is that each insert also does a lookup for
duplicates which causes a sort
. This makes inserts do quicksort for
each entry -- there is the scalability problem.

To make it more interesting net-snmp creates the route table
twice. First it reads table from /proc and puts entries in one table,
then walks that table to create the cache table used for lookup.

Loading the cache with non-scalable insertion takes several minutes on
a really fast machine, and the cache timeout is 30 seconds. This
ends up causing the CPU load because each request finds a dirty cache
and does a full reload.

Now for the good news, fixing the insert wasn't the hard. The first
step was realizing that the temporary table doesn't have to a table
container, instead it can be changed to a FIFO (linked list). The FIFO
container is O(1) on insert. The actual cache container requires a
different approach. The table container has an unused flag to allow
duplicates in the table. Turning the ALLOW_DUPLICATES flag makes
inserts much faster because the table is not sorted until the first
request. These get the table load down to less than a 5 seconds
on fast machine.

Lastly a couple of other improvements help as well. When the
binary_table is expanded, the code would calloc a new area, copy the
old data and then free the original. This is much worse than just
using realloc which can usually in place expansion when table is
getting large. The sort function can be optimized to avoid calling the
comparison function, and using a faster insertion sort for small sub
sections. These get the load down to less than a second.

Extra credit to the first developer who implements a new net-snmp
container using something better for big tables like AVL or B-tree.
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:
✏️ Information ergänzen
🛡️ Versioniert via CMS-Revisions-Engine (Freigabe-Queue für Gäste)

💬 Community-Diskussion & Kommentare

🌐 Zum Hauptchat

Starte die Diskussion im Social-Chat Broadcast Stream oder reiche oben über „Information ergänzen“ einen Fachbeitrag ein.

Security Briefing Kostenlos · 1-Klick-Abmeldung

Intelligence Digest — kostenlos

Täglich die wichtigsten Security-News · jederzeit abbestellbar

Community Rating & Social Proof
⭐ Leser-Wertung
–
Ø / 5.0
Noch keine Leser-Bewertungen
War dieser Artikel hilfreich?
0
Jetzt Bewertung abgeben
Detail-Bewertung (optional)
Inhalt & Qualität
Quelle & Glaubwürdigkeit
Aktualität

Verwandte Story-Cluster & Quellen (Vektor-KI)

6 Cluster
23 Quellen
Newegg knocks $200 off the 4TB KingSpec P3 SATA SSD for Black Friday
Latest from TechRadar vor 38 Min.
22 weitere Quellen
CNETvor 19 TagenGTA 6 May Not Be on Sale, but These Black Friday PlayStation Deals Are Still Worth Shopping The Vergevor 20 Min.Dreame and Eufy are offering nearly 60 percent off robovacs for Black Friday Latest from TechRadarvor 59 Min.Black Friday Roku deals: save on Roku Streaming Sticks, Roku TVs, and more Computer Bildvor 50 Min.Bigbank erhöht Festgeldzinsen: Bis zu 3,60 Prozent zum Black Friday Golem.devor 49 Min.Anzeige: 65 Zoll großer OLED-TV von Samsung günstig wie nie am Black Friday Latest from TechRadarvor 2 Std.Black Friday Pixel deals: save big on Pixel 10, Pixel 10a, Pixel 11 Pro, and more Latest from TechRadarvor 2 Std.Samsung's Black Friday sale is here — I've found 11 excellent deals, including up to $1,800 off OLED TVs, Galaxy S26 Ultra, tablets, and more Latest from TechRadarvor 2 Std.Pick your favourite shade: every AeroPress colour is on sale for Black Friday Latest from TechRadarvor 1 Std.PureVPN has launched 5-year plans just in time for Black Friday — $1.49 per month for half a decade of protection Latest from TechRadarvor 1 Std.DDR5 RAM Black Friday deals: 6 32GB kits under $500 — because sadly that’s where memory prices are right now Latest from TechRadarvor 1 Std.25 hand-picked deals in the Amazon UK Black Friday sale — Lego, Bose earbuds, Switch 2, Ninja Crispi, Kindles, and more WIREDvor 1 Std.The 24 Very Best Amazon Black Friday Deals to Get Now (2026) heise online Newsvor 1 TagBlack Friday 2026: Die besten Deals für Smartphones, Tablets und Smartwatches WIREDvor 1 Std.Best Black Friday Nintendo Switch 2 Deals (2026): Bundles, Games Latest from Windows Centralvor 2 Std.Dell's budget-friendly XPS 13 Windows laptop drops below $550 ahead of Black Friday PC-WELTvor 1 Std.575 Euro günstiger: Solakon onPower Balkonkraftwerk mit ONE-Speicher im Black-Friday-Deal PC-WELTvor 1 Std.Black Friday bei PC-WELT: Norton 360 Premium-Security nur 19,99 Euro PC-WELTvor 1 Std.575 Euro günstiger: Solakon onPower Balkonkraftwerk mit ONE-Speicher im Black-Friday-Deal PC-WELTvor 1 Std.Black Friday bei PC-WELT: Norton 360 Premium-Security nur 19,99 Euro PC-WELTvor 1 Std.Black Friday: Diese Handytarife sind jetzt besonders günstig – von 10 GB bis Unlimited PC-WELTvor 1 Std.Black Friday: Diese Handytarife sind jetzt besonders günstig – von 10 GB bis Unlimited Macerkopf.devor 3 Std.Zendure Black Friday: bis zu 45 Prozent Rabatt auf Balkonkraftwerke mit Speicher, Solarmodule und mehr
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten net-snmp ip-forward table performance problems

Thematisch verwandte Begriffe: netsnmp, ipforward, table, performance · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
Widgets & Themen
Widgets werden geladen…
Nächster Beitrag