From: Jeff Lucovsky Date: Mon, 16 Jun 2025 14:04:48 +0000 (-0400) Subject: util/mtu: Avoid excessive ioctls for MTU X-Git-Tag: suricata-8.0.0~63 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e8753b9ba78cf54b1b8db65b646f09d71bc10f8d;p=thirdparty%2Fsuricata.git util/mtu: Avoid excessive ioctls for MTU Issue: 7643 Use the cached livedev MTU value, when available. --- diff --git a/src/util-ioctl.c b/src/util-ioctl.c index 813a5590cd..d335ecce19 100644 --- a/src/util-ioctl.c +++ b/src/util-ioctl.c @@ -127,13 +127,16 @@ int GetIfaceMaxPacketSize(LiveDevice *ld) if ((dev == NULL) || strlen(dev) == 0) return 0; - int mtu = GetIfaceMTU(dev); - switch (mtu) { - case 0: - case -1: - return 0; + int mtu = ld->mtu; + if (ld->mtu == 0) { + mtu = GetIfaceMTU(dev); + switch (mtu) { + case 0: + case -1: + return 0; + } + ld->mtu = mtu; } - ld->mtu = mtu; int ll_header = GetIfaceMaxHWHeaderLength(dev); return ll_header + mtu; }