]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
libifconfig: fix carp key configuration
authorKristof Provost <kp@FreeBSD.org>
Fri, 28 Apr 2023 16:18:55 +0000 (18:18 +0200)
committerKristof Provost <kp@FreeBSD.org>
Sun, 30 Apr 2023 18:11:54 +0000 (20:11 +0200)
commit6a23843a4a6f2dae95a2029358468b697072b8d2
tree0f272498d57b3ca9c785dea8718f9b9eac2c4a21
parenta50ef47c0a22ca87cdbe669acbcbf999c72b8439
libifconfig: fix carp key configuration

There were two issues with the carp key configuration in the new netlink
code.

The first is that userspace failed to actually pass the CARP_NL_KEY
attribute to the kernel, so a key was never set.

The second issue is that snl_attr_get_string() returns a pointer to the
string inside the netlink message. It does not copy the string to the
target buffer. That's somewhat inconvenient to work with in libifconfig
where we have a static buffer for the key.
Introduce snl_attr_copy_string() which can copy a string to a target
buffer and uses the 'arg' parameter to pass the buffer size, so it
doesn't accidentally exceed the available space.

Reviewed by: melifaro
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D39874
lib/libifconfig/libifconfig_carp.c
sys/netlink/netlink_snl.h