]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: detect MTU mismatch and warn user
authorEric Leblond <eric@regit.org>
Tue, 14 Aug 2012 07:49:07 +0000 (09:49 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 3 Sep 2012 13:27:38 +0000 (15:27 +0200)
If the MTU on the reception interface and the one on the transmission
interface are different, this will result in an error at transmission
when sending packet to the wire.

src/source-af-packet.c

index ec838cbe2eec5fbbda68f9ab28d058da38e2c455..8ceac4a3d700b74bc3d0c8beb89b69727a5e3c00 100644 (file)
@@ -50,6 +50,7 @@
 #include "util-privs.h"
 #include "util-optimize.h"
 #include "util-checksum.h"
+#include "util-ioctl.h"
 #include "tmqh-packetpool.h"
 #include "source-af-packet.h"
 #include "runmodes.h"
@@ -322,6 +323,7 @@ TmEcode AFPPeersListAdd(AFPThreadVars *ptv)
     SCEnter();
     AFPPeer *peer = SCMalloc(sizeof(AFPPeer));
     AFPPeer *pitem;
+    int mtu, out_mtu;
 
     if (peer == NULL) {
         SCReturnInt(TM_ECODE_FAILED);
@@ -351,6 +353,16 @@ TmEcode AFPPeersListAdd(AFPThreadVars *ptv)
             continue;
         peer->peer = pitem;
         pitem->peer = peer;
+        mtu = GetIfaceMTU(ptv->iface);
+        out_mtu = GetIfaceMTU(ptv->out_iface);
+        if (mtu != out_mtu) {
+            SCLogError(SC_ERR_AFP_CREATE,
+                      "MTU on %s (%d) and %s (%d) are not equal, "
+                      "transmission of packets bigger than %d will fail.",
+                      ptv->iface, mtu,
+                      ptv->out_iface, out_mtu,
+                      (out_mtu > mtu) ? mtu : out_mtu);
+        }
         peerslist.peered += 2;
         break;
     }