Skip to content

Commit 18e80ce

Browse files
committed
confd: extend syslogd support with hostname-based filtering
Signed-off-by: Joachim Wiberg <[email protected]>
1 parent f71755d commit 18e80ce

File tree

5 files changed

+30
-3
lines changed

5 files changed

+30
-3
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# -l :: Keep kernel looging to console
1+
# -H :: Log remote messages using hostname from the message
2+
# -l :: Keep kernel logging to console
23
# -m0 :: Disable periodic syslog MARK entries
4+
# -n :: Disable DNS query for every request, trust hostname in message
35
# -s :: Enable secure mode, don't listen to remote logs
46
# -r 1M:5 :: Log rotation every 1 MiB and keep 5 rotated ones
5-
SYSLOGD_ARGS="-l -m0"
7+
SYSLOGD_ARGS="-H -l -m0"

src/confd/src/ietf-syslog.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,20 @@ static size_t selector(sr_session_ctx_t *session, struct action *act)
104104
char *pattern;
105105
int rc;
106106

107+
/* Check for hostname-filter (infix-syslog augment) */
108+
snprintf(xpath, sizeof(xpath), "%s/infix-syslog:hostname-filter", act->xpath);
109+
rc = sr_get_items(session, xpath, 0, 0, &list, &count);
110+
if (rc == SR_ERR_OK && count > 0) {
111+
fprintf(act->fp, "+");
112+
for (size_t i = 0; i < count; i++)
113+
fprintf(act->fp, "%s%s", i ? "," : "", list[i].data.string_val);
114+
fprintf(act->fp, "\n");
115+
116+
sr_free_values(list, count);
117+
list = NULL;
118+
count = 0;
119+
}
120+
107121
/* Check for pattern-match (select-match feature) */
108122
pattern = srx_get_str(session, "%s/pattern-match", act->xpath);
109123
if (pattern) {

src/confd/yang/confd.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ MODULES=(
1919
# NOTE: ietf-tls-client must be version matched with ietf-tls-server, used by netopeer2!
2020
2121
"[email protected] -e file-action -e file-limit-size -e remote-action -e select-adv-compare -e select-match"
22-
"infix-syslog@2024-07-19.yang"
22+
"infix-syslog@2025-11-17.yang"
2323
2424
"[email protected] -e hardware-state -e hardware-sensor"
2525

src/confd/yang/confd/infix-syslog.yang

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ module infix-syslog {
1616
contact "[email protected]";
1717
description "Infix augments and deviations to ietf-syslog, draft 32.";
1818

19+
revision 2025-11-17 {
20+
description "Add hostname-filter support.";
21+
reference "internal";
22+
}
23+
1924
revision 2024-07-19 {
2025
description "Initial revision, based on IETF syslog YANG draft 32.
2126
The following changes have been made in this model:
@@ -164,6 +169,12 @@ module infix-syslog {
164169
}
165170
}
166171
}
172+
173+
leaf-list hostname-filter {
174+
type inet:domain-name;
175+
description "Filter messages by hostname. Messages from the listed
176+
hostnames will be logged to this file.";
177+
}
167178
}
168179

169180
augment "/syslog:syslog/syslog:actions/syslog:remote/syslog:destination" {

0 commit comments

Comments
 (0)