summaryrefslogtreecommitdiff
path: root/lib/sockunion.c
AgeCommit message (Collapse)Author
2024-10-31lib: In sockunion.c convert v6 memcmp's to IPV6_ADDR_CMPDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31lib, tests: Remove in6addr_cmp function from the systemDonald Sharp
This function should just be memcmp. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31lib: Replace usage of in6addr_cmp with memcmpDonald Sharp
memcmp will return and act exactly the same as in6addr_cmp but it does it significantly faster than how in6addr_cmp does it. Let this be a lesson for implementing something that is a duplicate of what is provided by the c library. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-08-04lib: Add errno details to the sockopt_reuseaddr apiMobashshera Rasool
Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-06-17lib: Add some extra error messages for when things go wrongDonald Sharp
In sockunion.c let's eliminate the silent and unexpected failure mode to let the end operator figure out something is terribly wrong. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-11*: Properly use memset() when zeroingDonatas Abraitis
Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-12bgpd, lib, pimd: Remove sockopt_corkDonald Sharp
sockopt_cork is a no-op function that was cleaned up in 2017. Since then it's still not being used. At this point in time there is little point in keeping a dead function that will not be used because of vagaries between platforms Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-14*: use semicolon after printfrr_ext_autoreg_{p,d}David Lamparter
Mostly to make clang-format not format these to peak ugly. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-06-23lib: use in6addr comparator in testDonald Lee
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-03-30lib: add `%dPF` & `%dSO` formatsDavid Lamparter
Just quick helpers to print `AF_*` and `SOCK_*` constants. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30lib: fix & improve `%pSU` formatDavid Lamparter
This wasn't quite formatting IPv6+port in a useful way (no brackets), and printing the scope ID (interface index) and unix addrs is useful too. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30lib: put printfrr extension args into structDavid Lamparter
... for easier extensibility. Add width, # and - flags while at it. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27lib: print `(null)` rather than `NULL`David Lamparter
... for consistency with `%s`, which also prints `(null)`. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27lib: rework printfrr extensions to output directlyDavid Lamparter
Allowing printfrr extensions to directly write to the output buffer has a few advantages: - there is no arbitrary length limit imposed (previously 64) - the output doesn't need to be copied another time - the extension can directly use bprintfrr() to put together pieces The downside is that the theoretical length (regardless of available buffer space) must be computed correctly. Extended unit tests to test these paths a bit more thoroughly. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
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>
2021-03-01lib: protect printfrr extensions from NULL inputMark Stapp
Protect the lib printfrr extension handlers from NULL inputs. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-01-12libs,nhrpd: remove exec permMark Stapp
Some source files got the exec bit set in a recent commit - undo that. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-12-17nhrpd: Clear shortcut routes properly for all protocolsGaurav Goyal
Currently when nhrp shortcuts are purged they will not be recreated. This patch fixes that by ensuring the shortcut routes get purged correctly. This situation can be reproduced by first allowing a shortcut to be created then clearing the shortcut: clear ip nhrp cache clear ip nhrp shortcuts Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2020-10-22lib: Convert inet_ntoa to %pI4Donatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-29Merge pull request #6732 from opensourcerouting/printfrr-prepQuentin Young
*: preparations for printfrr coccinelle run
2020-07-14lib: add %pSU for union sockunion *David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14*: un-split strings across linesDavid Lamparter
Remove mid-string line breaks, cf. workflow doc: .. [#tool_style_conflicts] For example, lines over 80 characters are allowed for text strings to make it possible to search the code for them: please see `Linux kernel style (breaking long lines and strings) <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_ and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_. Scripted commit, idempotent to running: ``` python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'` ``` Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-08*: Replace `sizeof something` to sizeof(something)Donatas Abraitis
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis) Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-13*: Remove break after returnDonatas Abraitis
Just a deadcode. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-05-24bgpd, lib: Remove SO_MARKDonald Sharp
The SO_MARK socket option was being used pre vrf to allow for the separation of the front panel -vs- the management port. This was facilitated by a ip rule. Since this is undocumented anywhere in our system( other than old commits see ed40466af80c9d0b88436c637a1d54b28a669b1c ). We should remove this because this will cause interference with people using rules and are not aware of this offshoot of functionality. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-17vrrpd: ipv6 supportQuentin Young
Add initial support for IPv6. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-04-18lib: ZEBRA_NUM_OF -> array_sizeDavid Lamparter
The latter is widely used, e.g. in the Linux kernel. Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-25*: spelchekDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-13*: style for EC replacementsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13*: LIB_[ERR|WARN] -> EC_LIBQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06*: style for flog_warn conversionsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06lib: Convert sockunion.c to use flog_errDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14*: use frr_elevate_privs() (2/2: manual)David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14*: rename zlog_fer -> flog_errQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14bgpd, lib, zebra: Convert LIB_ERR_PRIVILEGESDonald Sharp
For all the places we zlog_err about raising/lowering privileges, use zlog_ferr. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-21lib: null check (Coverity 1399277)paco
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-03-27*: use C99 standard fixed-width integer typesQuentin Young
The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-10-24lib: optimize sockunion_connect()Renato Westphal
This function is only called with non-blocking sockets [1], so there's no need to worry about setting O_NONBLOCK and unsetting it later if the given fd was a blocking socket. This saves us 4 syscalls per connect, which is not much but is something. Also, remove an outdated comment about the return values of this function. It returns a 'connect_result' enum now, whose values are self-explanatory (connect_error, connect_success and connect_in_progress). This also fixes a coverity scan warning where we weren't checking the return value of the fcntl() syscall. [1] bgp_connect() and pim_msdp_sock_connect(). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-01lib: Remove sockopt_cork functionalityDonald Sharp
Linux -> TCP_CORK is enabled by default *BSD -> The equivalent is TCP_NOPUSH As such sockopt_cork is effectively useless especially since the two places it is used do it right before TCP writes then disable it right after the writes are over. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08*: get rid of zlog(*, LOG_LEVEL, ...)David Lamparter
Result of running the following Coccinelle patch + fixups: <<EOF /* long-forms: zlog(NULL, <level>, ...) * => zlog_level(...) */ @@ expression list args; @@ - zlog(NULL, LOG_DEBUG, args) + zlog_debug(args) @@ expression list args; @@ - zlog(NULL, LOG_NOTICE, args) + zlog_notice(args) @@ expression list args; @@ - zlog(NULL, LOG_INFO, args) + zlog_info(args) @@ expression list args; @@ - zlog(NULL, LOG_WARNING, args) + zlog_warn(args) @@ expression list args; @@ - zlog(NULL, LOG_ERR, args) + zlog_err(args) /* long-forms: zlog(base->log, <level>, ...) * => zlog_level(...) */ @@ expression base; expression list args; @@ - zlog(base->log, LOG_DEBUG, args) + zlog_debug(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_NOTICE, args) + zlog_notice(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_INFO, args) + zlog_info(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_WARNING, args) + zlog_warn(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_ERR, args) + zlog_err(args) EOF Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-13frr: Remove HAVE_IPV6 from code baseDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-11-15lib: replace strlcpy & strlcat with glibc versionsDavid Lamparter
It seems these two were at some point copied in from rsync; replace with more recent versions that will hopefully become available in glibc as well. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-15build: massively remove needless checksDavid Lamparter
Since we have autoconf results from a wide swath of target platforms, we can go remove checks that have the same result on all systems. This also removes several "fallback" implementations of functions that, at some point in the history, weren't available on all target platforms. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-09-19*: split & distribute memtypes and stop (re|ab)using lib/ MTYPEsDavid Lamparter
This is a rather large mechanical commit that splits up the memory types defined in lib/memtypes.c and distributes them into *_memory.[ch] files in the individual daemons. The zebra change is slightly annoying because there is no nice place to put the #include "zebra_memory.h" statement. bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the library for its own use. This is bad practice and would break when the memtype are made static. Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> [CF: rebased for cmaster-next] Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-08-18*: use an ifindex_t type, defined in lib/if.h, for ifindex valuesPaul Jakma
(cherry picked from commit 9099f9b2a66e86f8a90d7fe18f61bd2bb1bc6744)
2016-06-08lib: constify sockunion apiTimo Teräs
Add const to read-only api calls. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit 81b139bdd530adda045d22a4daf0054b89703dab)
2016-06-03build: remove INRIA, NRL and MUSICA IPv6 quirksDavid Lamparter
Valar dohaeris. Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Acked-by: Greg Troxel <gdt@ir.bbn.com> Acked-by: Feng Lu <lu.feng@6wind.com> Acked-by: Paul Jakma <paul@jakma.org>