Back when I put this together in 2015, ISO C11 was still reasonably new
and we couldn't require it just yet. Without ISO C11, there is no
"good" way (only bad hacks) to require a semicolon after a macro that
ends with a function definition. And if you added one anyway, you'd get
"spurious semicolon" warnings on some compilers...
With C11, `_Static_assert()` at the end of a macro will make it so that
the semicolon is properly required, consumed, and not warned about.
Consistently requiring semicolons after "file-level" macros matches
Linux kernel coding style and helps some editors against mis-syntax'ing
these macros.
Signed-off-by: David Lamparter <equinox@diac24.net>
Recent changes to remove PRIu... in commit:
6cde4b4552
causes clang 11 to be unhappy, with length of field warnings.
Modify the offending code to compile properly using that compiler.
I've tested against clang 11 and gcc 9.3
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Based on looking at other vendors, seems I misinterpreted the RFC - type
0 auth (no authentication) still requires the authentication fields to
be present, just set to all zero.
This should fix VRRPv2 interop with other vendors.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
They used a %u where they should have used a PRIu16, and a %lu where
they wanted a %zu. Shame!
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Fix null dereference when retrieving IPv6 source address
* Change IPv4 code path to use system-specified source address instead
of the one delivered in the IPv4 raw header
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Gate all debugging messages with the debugging system
* Simplify a bit of debugging where it was easy to do inline
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Fuzz testing revealed a crash in which VRRPD tries to create an
advertisement packet with no IP addresses. Should never occur under
normal use but might as well patch.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Use proper format specifiers for some data
* Print the correct sizes when reporting IP size errors
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Prefix all packet functions with 'vrrp_pkt'
* Break out checksum computation into separate function
* Accept version field when building advertisements
* Update doc comments
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Add include guards where missing
* Add include guard comments where missing
* Fix copyright notices
* Sort includes
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Search for macvlan interfaces with the appropriate name and MAC
address when starting up a new VRRP instance
* Split VRRP socket into two; one for Tx, one for Rx
* Bind Tx socket to the macvlan subinterface so our VRRP advertisements
go out with the correct MAC address
* Send ARP requests from this macvlan subinterface
* Improve error messaging
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Validate IPvX headers and packet contents
* Remove filter of non-255 TTL IPv4 packets; better to receive, log and
drop them ourselves
* Set outgoing packet TTL / hop limit to 255
* Use existing sockopt functions
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Properly encode VRRP packets
* Calculate checksum appropriately
* Update signature to provide caller both packet and result length
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>