Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syslog-format: cannot parse ipv6 into hostname #1617

Merged
merged 1 commit into from Aug 9, 2017

Conversation

furiel
Copy link
Collaborator

@furiel furiel commented Jul 24, 2017

Fixes:
#1616

@kira-syslogng
Copy link
Contributor

Build FAILURE, the tests were executed on test branch: master and test suite: functions

Copy link
Collaborator

@bazsi bazsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. I would be very reluctant to change the rfc3164 parser. the colon is there to make sure that if there's no hostname, just the program name, we don't overflow into into the MSG part of the message.

PID is not always present, so '[' is not a good indicator either.

@kira-syslogng
Copy link
Contributor

Build FAILURE, the tests were executed on test branch: master and test suite: functions

@furiel
Copy link
Collaborator Author

furiel commented Jul 24, 2017

Not nice but maybe works:

We could use inet_pton to check if we see a valid ipv6 address. If yes, we set the hostname. If not, we go with the original heuristic.

Of course we need to prepare the candidate string for inet pton, so first I need to create nullterminated substring until the first space or '[' character, which then can be passed to inet_pton.

@furiel
Copy link
Collaborator Author

furiel commented Jul 24, 2017

Or this is maybe better: g_hostname_is_ip_address (), from glib 2.22

@bazsi
Copy link
Collaborator

bazsi commented Jul 24, 2017 via email

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

@furiel
Copy link
Collaborator Author

furiel commented Jul 25, 2017

Instead of explicitely validating for ipv6 address, I added a new version which relaxes the condition for colon being delimiter. The new heuristics just check a few extra characters around the colon, so probably have lower effect on performance than calling a glib function or inet_pton.

@presidento
Copy link
Contributor

We should check a bit more strictly that it seems like an ipv6 address. (Hexa numbers, colons...)

@furiel furiel force-pushed the hostname_ipv6 branch 2 times, most recently from cad7577 to a6524a4 Compare August 4, 2017 12:39
@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

1 similar comment
@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

@furiel
Copy link
Collaborator Author

furiel commented Aug 4, 2017

@bazsi I replaced the previous heuristics with a more strict one. In the end, an ipv6-heuristics class added just checks if the candidate is max 8 blocks of max 4-wide hexa characters. I felt the class useful, because the state of the ipv6 part became more complex than the previous one.

The good news is I could still avoid memory allocation, so I am very hopeful that we do not lose too much performance. Anyway, we will run a performance test for this version next week.

if (c == ':')
{
self->digits_in_segment = 0;
if (self->current_segment > 8)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current_segment is not incremented.

typedef struct _IPv6Heuristics
{
gchar current_segment;
gchar digits_in_segment;
Copy link
Collaborator

@MrAnno MrAnno Aug 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use guint8/gint8 for 8 bit integers.

gchar current_segment;
gchar digits_in_segment;
gboolean heuristic_failed;
gboolean (*feed_gchar)(struct _IPv6Heuristics *, gchar);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why you made this virtual?

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

Hostname parser expected colon to separate msg part from host-program
part. But colon is valid character for host in case of ipv6. So some
heuristics are added to allow colon during parsing hostname: looking
for at maximum 8 blocks of at maximum 4-hexa values, separated by
:. This heuristic automatically allows usage of double colons as well.

Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
Copy link
Collaborator

@MrAnno MrAnno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perftest is in progress

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

@pzoleex
Copy link
Collaborator

pzoleex commented Aug 8, 2017

the perftest passed, there was no regression

@lbudai lbudai merged commit 710316e into syslog-ng:master Aug 9, 2017
@lbudai lbudai removed the in progress label Aug 9, 2017
@furiel furiel deleted the hostname_ipv6 branch May 8, 2018 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants