IPL(4)
π¦ IPL(4) β IP packet log device π¦
okay bestie, welcome to IPL(4) from the Kernel Interfaces Manual. this page is the IP packet log device, and it is lowkey iconic kernel lore π
.
β¨ NAME β¨
ipl β IP packet log device. periodt.
πΈ DESCRIPTION πΈ
okay so the ipl pseudo device's purpose is to provide an easy way to gather packet headers of packets you wish to log. slay. If a packet header is to be logged, the entire header is logged β including any IP options, and TCP/UDP options are not included when it calculates header size β or it isn't logged at all. no half-logging, bestie. The packet contents are also logged after the header. If the log reader is busy or otherwise unable to read log records, up to IPLLOGSIZE bytes of data are stored; 8192 is the default. noted and filed π.
Prepending every packet header that gets logged is a structure containing information relevant to the packet following it and why it was logged. The structure's format is as follows:
/*
* Log structure. Each packet header logged is prepended by one of these.
* Following this in the log records read from the device will be an ipflog
* structure which is then followed by any packet data.
*/
typedef struct iplog {
u_long ipl_sec;
u_long ipl_usec;
u_int ipl_len;
u_int ipl_count;
size_t ipl_dsize;
struct iplog *ipl_next;
} iplog_t;
typedef struct ipflog {
#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603))
u_char fl_ifname[IFNAMSIZ];
#else
u_int fl_unit;
u_char fl_ifname[4];
#endif
u_char fl_plen; /* extra data after hlen */
u_char fl_hlen; /* length of IP headers saved */
u_short fl_rule; /* assume never more than 64k rules, total */
u_32_t fl_flags;
} ipflog_t;
When reading from the ipl device, it is necessary to call read(2) with a buffer big enough to hold at least 1 complete log record. reading of partial log records is not supported. the way that is a hard boundary π«Ά.
If the packet contents are more than 128 bytes when log body is used, then only 128 bytes of the packet contents are logged. small but mighty.
Although it is only possible to read from the ipl device, opening it for writing is required when using an ioctl which changes any kernel data. yes, that's the rule π
.
The ioctls which are loaded with this device can be found under ipf(4). The ioctls which are for use with logging and don't affect the filter are:
SIOCIPFFBβioctl(fd, SIOCIPFFB, int *)flushes the log buffer and returns the number of bytes flushed.FIONREADβioctl(fd, FIONREAD, int *)returns the number of bytes currently used for storing log data.
If IPFILTER_LOG is not defined when compiling, SIOCIPFFB is not available and FIONREAD will return but not do anything. compile-time tea β.
There is currently no support for non-blocking IO with this device, meaning all read operations should be considered blocking in nature β if there is no data to read, it will sleep until some is made available. it's giving patient main character energy π΄π.
π SEE ALSO π
ipf(4) β yes bestie, that's the one π«Ά.
π BUGS π
Packet headers are dropped when the internal buffer (static size) fills. sad but true.
π FILES π
/dev/ipl0
That's the whole IPL(4) page, bestie β the footer's just IPL(4), with no extra source/version/date stamp on this copy. stay logged π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms