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)

💬 Communitydiscussie & reacties

🌐 Naar de hoofdchat

Start de discussie in de Social Chat broadcaststream of dien hierboven een vakbijdrage in via het aanvulformulier.

Security Briefing Gratis · 1-klik uitschrijven

Intelligence Digest gratis

Dagelijks het belangrijkste beveiligingsnieuws · kan op elk moment worden opgehaald

Community Rating & Social Proof
⭐ Lezersbeoordeling
–
Ø / 5.0
Nog geen recensies van lezers
Was dit artikel nuttig?
0
Geef uw beoordeling
Detailbeoordeling (optioneel)
Inhoud & Kwaliteit
Bron & Geloofwaardigheid
Actualiteit

Verwant Story Cluster & Sources (vector AI)

6 Cluster
26 Bronnen
Black Friday Oura Ring deals: The best of the deals so far, picked by a wearable-tech expert
Latest from TechRadar 45 min. geleden
25 andere bronnen
CNET6 jaar geledenOur Favorite Blenders of 2026 Are on Sale Ahead of Black Friday CNET49 min. geledenBrighten Up Your Day by Saving 20% Off Flashlights With Olight’s Black Friday Sale CNET41 min. geledenLive: Black Friday Deals Are Here. Shop Expert Picks Across Tech, Everyday Essentials and More at Up to 60% Off Golem.de55 min. geledenAnzeige: Logitech-Tastatur MX Keys S am Black Friday zum Sensationspreis auf Amazon PC-WELT1 uur geledenLuminar zum Black Friday: KI-Bildbearbeitung für nur 79,20 Euro Latest from TechRadar1 uur geledenThis is the pair of open earbuds to hunt down over Black Friday Latest from TechRadar1 uur geledenBest AirPods Black Friday deals: all live savings on AirPods Pro 3 and more Computer Bild1 uur geledenPhilips Sonicare DiamondClean 9000 zum Black Friday günstiger netzwelt.de2 uur geledenESR startet mit Black-Friday-Rabatten: Diese AirPods-Hüllen lohnen sich jetzt netzwelt.de2 uur geledenPlayStation 5 geschenkt: Diese Black-Friday-Aktion legt die Konsole gratis obendrauf netzwelt.de2 uur geleden6 Dyson-Staubsauger im Vergleich: Dieser Sauger wird am Black Friday überraschend zum Preis/Leistungssieger netzwelt.de1 uur geledenMonitore im Angebot zum Black Friday: Gutes Bild für Office, Gaming und mehr Golem.de1 uur geledenAnzeige: Akkuschrauber mit 20 Bits zum Black Friday erstmals unter 50 Euro bei Amazon PC-WELT1 uur geledenDie günstigsten Handytarife an Black Friday von 10 GB bis Unlimited: Hier lohnt sich ein Wechsel PC-WELT1 uur geledenBlack Friday 2026 bei LiberNovo: Ergonomische Bürostühle mit bis zu 44 Prozent Rabatt Latest from TechRadar2 uur geledenThe best Black Friday robot vacuum deals: Dreame, Shark, Dyson, and Roborock Golem.de1 uur geledenAnzeige: Topdon-Starthilfe-Powerbank für Kfz zum Black-Friday-Bestpreis nur rund 85 Euro heise online News2 uur geledenBlack Friday: Die besten Kopfhörer zum Tiefstpreis – Sonos Ace, Nothing & Shokz Latest from Windows Central2 uur geledenDell's Black Friday deals drop major savings on Alienware OLED monitors CNET2 jaar geledenMake Every Night Game Night and Save $90 on the Nex Playground With This Black Friday Deal DEV Community1 uur geledenThe app is part of the gadget: 14,000 App Store reviews of 28 device apps before Black Friday Latest from TechRadar2 uur geledenBlack Friday tech deals under $100 / £100: Fire TV Sticks, earbuds, coffee machines and more Caschys Blog3 uur geledenGoogle One: Black-Friday-Angebot mit bis zu 50 Prozent Rabatt netzwelt.de3 uur geledenDem Testsieger ebenbürtig: Zum Black Friday stürzt Xiaomis stärkster E-Scooter im Preis ab Macerkopf.de3 uur geledenFotos verbessern mit Aiarty: 52 % Rabatt + Gratisgeschenke zum Black Friday
Soortgelijke bijdragen
🔍 Verwandte News

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

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

Laden...

Video's zijn geladen...

Laden...

Bijdragen zijn geladen ...

Laden...

Video's zijn geladen...

Laden...

Bijdragen zijn geladen ...

Laden...

Video's zijn geladen...

Laden...

Bijdragen zijn geladen ...

Laden...

Video's zijn geladen...

Laden...

Bijdragen zijn geladen ...

Laden...

Video's zijn geladen...

💬 Reacties worden geladen…
Trek om te vernieuwen
Widgets & Topics
Loading widgets…
Nächster Beitrag