inliniac/suricata — pull request #824 by ken-tilera (2014-02-06 14:50:22+00:00)
Title: Add ability to log Alerts over PCIe from TILEncore card to Host

These changes enable sending fastlog alerts from Suricata running on a TILEncore-Gx PCIe card, over PCIe to an application running on the host x86 systems that writes the alerts to a file on the host system. This is faster than the default method where Suricata on the TILEncore-Gx PCIe writes the alerts to a file in the TILEncore-Gx's Linux file system, which is cross mounted using FUSE back to the host's file system. It is faster because PCIe logging is done directly from User Space on Tile Linux to User Space on the host Linux, thus avoiding system calls.

To cause PCIe logging to be done from Suricata, the filetype of fast log in suricata.yaml is set to "pcie". This then requires running tile_pci_logd on the host to receive the alerts. building tile_pcie_logd is enabled by the configure when TILERA_ROOT is defined, which is required to point to the Tilera Multicore Development Environement (MDE) that contains the PCIe Packet Queue header files and libraries.

The changes also reduce the amount of time the file mutex is held for fast log alerts by moving the printf() call to generate the alert out of the critical section by using snprintf() to generate the alert string before acquiring the file lock and then calling fwrite().

Passes regression tests:
https://buildbot.suricata-ids.org/builders/ken-tilera-pcap/builds/40
https://buildbot.suricata-ids.org/builders/ken-tilera/builds/106

Replaces PR 819 #819 and addresses review comments from Victor.
Same as PR 822, but rebased to master.