diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 317c8704e5..6112cb9d88 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -492,7 +492,6 @@ static TmEcode AFPPeersListAdd(AFPThreadVars *ptv) SCEnter(); AFPPeer *peer = SCMalloc(sizeof(AFPPeer)); AFPPeer *pitem; - int mtu, out_mtu; if (unlikely(peer == NULL)) { SCReturnInt(TM_ECODE_FAILED); @@ -527,12 +526,18 @@ static 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) { - SCLogWarning("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, MIN(out_mtu, mtu)); + + LiveDevice *iface = ptv->livedev; + DEBUG_VALIDATE_BUG_ON(iface == NULL); + DEBUG_VALIDATE_BUG_ON(strcmp(iface->dev, ptv->iface) != 0); + LiveDevice *out_iface = LiveGetDevice(ptv->out_iface); + if (out_iface == NULL) + FatalError("AF_PACKET device %s not found. Aborting..", ptv->out_iface); + if (iface->mtu != out_iface->mtu) { + SCLogWarning("MTU on %s (%d) and %s (%d) are not equal, transmission of packets " + "bigger than %d will fail.", + iface->dev, iface->mtu, out_iface->dev, out_iface->mtu, + MIN(out_iface->mtu, iface->mtu)); } peerslist.peered += 2; break; diff --git a/src/util-device.h b/src/util-device.h index 51ddf7d525..0f756b78ca 100644 --- a/src/util-device.h +++ b/src/util-device.h @@ -49,6 +49,7 @@ typedef struct { typedef struct LiveDevice_ { char *dev; /**< the device (e.g. "eth0") */ char dev_short[MAX_DEVNAME + 1]; + int mtu; /* MTU of the device */ bool tenant_id_set; uint16_t id; diff --git a/src/util-ioctl.c b/src/util-ioctl.c index 399751b056..f39662bd4d 100644 --- a/src/util-ioctl.c +++ b/src/util-ioctl.c @@ -132,6 +132,7 @@ int GetIfaceMaxPacketSize(LiveDevice *ld) case -1: return 0; } + ld->mtu = mtu; int ll_header = GetIfaceMaxHWHeaderLength(dev); return ll_header + mtu; }