FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
Syslog protocol support

VPP provides RFC5424 syslog protocol logging, which is used to transport event messages across network. VPP currently suports UDP transport based on RFC5426.

The syslog message has the following format:

  • header
  • structured data
  • free-form message

The header contains, priority, version, timestamp, hostname, application, process id and message id. It is followed by structured data, which provides a mechanism to express event data in easily parsable format. Structured data can contain zero, one or multiple structured data elements. Structured data element contains name-value pairs. Structured data can by followed by free-form message.

Following example explains how to use the internal APIs to genrate syslog message:

...
syslog_msg_t syslog_msg;
/* Check if syslog logging is enabled */
return;
/* Severity filer test */
return;
/* Initialize syslog message header */
syslog_msg_init (&syslog_msg, facility, severity, "NAT", "SADD");
/* Create structured data element */
/* Add structured data element parameters (name-value pairs) */
syslog_msg_add_sd_param (&syslog_msg, "SSUBIX", "%d", ssubix);
syslog_msg_add_sd_param (&syslog_msg, "SVLAN", "%d", svlan);
syslog_msg_add_sd_param (&syslog_msg, "IATYP", "IPv4");
syslog_msg_add_sd_param (&syslog_msg, "ISPORT", "%d", isport);
syslog_msg_add_sd_param (&syslog_msg, "XATYP", "IPv4");
syslog_msg_add_sd_param (&syslog_msg, "XSPORT", "%d", xsport);
/* Send syslog message */

Example above produces following syslog message: <134>1 2018-11-12T11:25:30.252715Z 172.16.4.1 NAT 5901 SADD [nsess SSUBIX="0" SVLAN="0" IATYP="IPv4" ISADDR="172.16.1.2" ISPORT="6303" XATYP="IPv4" XSADDR="10.0.0.3" XSPORT="16253" PROTO="6"]

To add free-form message use:

syslog_msg_add_msg (&syslog_msg, "event log entry");
format_ip4_address
format_function_t format_ip4_address
Definition: format.h:73
syslog_msg
static u8 * syslog_msg
Definition: main.c:95
syslog_msg_init
void syslog_msg_init(syslog_msg_t *syslog_msg, syslog_facility_t facility, syslog_severity_t severity, char *app_name, char *msgid)
Initialize syslog message header.
Definition: syslog.c:143
syslog_severity_filter_block
static int syslog_severity_filter_block(syslog_severity_t s)
Severity filter test.
Definition: syslog.h:212
syslog.h
syslog_msg_add_msg
void syslog_msg_add_msg(syslog_msg_t *syslog_msg, char *fmt,...)
Add free-form message RFC5424 6.4.
Definition: syslog.c:129
syslog_msg_add_sd_param
void syslog_msg_add_sd_param(syslog_msg_t *syslog_msg, char *name, char *fmt,...)
Add structured data elemnt parameter name-value pair RFC5424 6.3.3.
Definition: syslog.c:111
syslog_is_enabled
static int syslog_is_enabled(void)
Check if syslog logging is enabled.
Definition: syslog.h:199
syslog_msg_sd_init
void syslog_msg_sd_init(syslog_msg_t *syslog_msg, char *sd_id)
Initialize structured data element.
Definition: syslog.c:101
syslog_msg_send
int syslog_msg_send(syslog_msg_t *syslog_msg)
Send syslog message.
Definition: syslog.c:159
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51