From ac56b1bf24e5003806c85fe549fc7fcd24e1d627 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Tue, 14 Aug 2012 09:49:07 +0200 Subject: [PATCH] af-packet: detect MTU mismatch and warn user 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/source-af-packet.c b/src/source-af-packet.c index ec838cbe2e..8ceac4a3d7 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -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; }