summaryrefslogtreecommitdiff
path: root/lib/sockopt.c
AgeCommit message (Collapse)Author
2024-12-04lib: Allow setsockopt functions to return size setDonald Sharp
When finding a send/receive buffer size that is usable let's report how big we were able to set it. Signed-off-by: Donald Sharp <sharpd@nvidia.com> (cherry picked from commit d5615fd6f84e643f194be8c3e91343b35585eb9c)
2024-02-07bgpd: Do not show TCP MSS if the socket is brokenDonatas Abraitis
Just avoid calling for TCP MSS socket option if it's not in use. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-11-14lib: Prevent infinite loop in ospfDonald Sharp
For some series of calls in FREEBSD setting the SO_RCVBUF size will always fail under freebsd. This is no bueno since the setsockopt_so_recvbuf call goes into an infinite loop. (gdb) bt 0 setsockopt () at setsockopt.S:4 1 0x0000000083065870 in setsockopt_so_recvbuf (sock=15, size=0) at lib/sockopt.c:26 2 0x00000000002bd200 in ospf_ifp_sock_init (ifp=<optimized out>, ifp@entry=0x8d1dd500) at ospfd/ospf_network.c:290 3 0x00000000002ad1e0 in ospf_if_new (ospf=0x8eefc000, ifp=0x8d1dd500, p=0x8eecf1c0) at ospfd/ospf_interface.c:276 4 0x0000000000304ee0 in add_ospf_interface (co=0x8eecbe10, area=0x8d192100) at ospfd/ospfd.c:1115 5 0x00000000003050fc in ospf_network_run_interface (ospf=0x8eefc000, ifp=0x8d1dd500, p=0x80ff63f8, given_area=0x8d192100) at ospfd/ospfd.c:1460 6 ospf_network_run (p=0x80ff63f8, area=0x8d192100) at ospfd/ospfd.c:1474 7 ospf_network_set (ospf=ospf@entry=0x8eefc000, p=p@entry=0x80ff63f8, area_id=..., df=<optimized out>) at ospfd/ospfd.c:1247 8 0x00000000002e876c in ospf_network_area (self=<optimized out>, vty=0x8eef3180, argc=<optimized out>, argv=<optimized out>) at ospfd/ospf_vty.c:560 9 0x0000000083006f24 in cmd_execute_command_real (vline=vline@entry=0x8eee9100, vty=vty@entry=0x8eef3180, cmd=<optimized out>, cmd@entry=0x0, up_level=<optimized out>) at lib/command.c:978 10 0x0000000083006b30 in cmd_execute_command (vline=0x8eee9100, vty=vty@entry=0x8eef3180, cmd=cmd@entry=0x0, vtysh=vtysh@entry=0) at lib/command.c:1037 11 0x0000000083007044 in cmd_execute (vty=vty@entry=0x8eef3180, cmd=cmd@entry=0x8eefb000 "network 192.168.64.0/24 area 0.0.0.0", matched=0x0, vtysh=0) at lib/command.c:1203 12 0x000000008307e9cc in vty_command (vty=0x8eef3180, buf=0x8eefb000 "network 192.168.64.0/24 area 0.0.0.0") at lib/vty.c:594 13 vty_execute (vty=vty@entry=0x8eef3180) at lib/vty.c:1357 14 0x000000008307ce40 in vtysh_read (thread=<optimized out>) at lib/vty.c:2365 15 0x0000000083073db0 in event_call (thread=thread@entry=0x80ff88a0) at lib/event.c:1965 16 0x000000008302c604 in frr_run (master=0x8d188140) at lib/libfrr.c:1214 17 0x000000000029c330 in main (argc=6, argv=<optimized out>) at ospfd/ospf_main.c:252 (gdb) Force the setsockopt function to quit when the value we are passing no longer makes any sense. Fixes: #14790 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-07*: Remove APPLE #defines from buildDonald Sharp
We cannot build on apple machines at all due to our usage of some gcc extensions that will probably never see the light of day again. 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-10-10Merge pull request #9998 from pguibert6WIND/bgp_tcp_keepaliveDonatas Abraitis
Bgp tcp keepalive
2022-08-02lib: Remove usage of inet_ntop in lib/sockopt.cDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-29lib: Use pI4 instead of inet_ntop in sockopt.cDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-28lib: add a function to configure tcp keepalive parametersXiaofeng Liu
New function setsockopt_tcp_keepalive() is added to enable TCP keepalive mechanism for specified socket. Also TCP keepalive idle time, interval and maximum probes are configured. Signed-off-by: Xiaofeng Liu <xiaofeng.liu@6wind.com> Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-10-22lib: finish fixing spelling in lib filesewlumpkin
Signed-off-by: ewlumpkin <ewlumpkin@gmail.com>
2021-06-29lib: Avoid using assignments within checksDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-05-04bgpd: Support tcp-mss for bgp neighborsAbhinay Ramesh
Problem Statement: ================= In scale setup BGP sessions start flapping. RCA: ==== In virtualized environment there are multiple places where MTU need to be set. If there are some places were MTU is not set properly then there is chances that BGP packets get fragmented, in scale setup this will lead to BGP session flap. Fix: ==== A new tcp option is provided as part of this implementation, which can be configured per neighbor and helps to set the TCP max segment size. User need to derive the path MTU between the BGP neighbors and set that value as part of tcp-mss setting. 1. CLI Configuration: [no] neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535) 2. Running config frr# show running-config router bgp 100 neighbor 198.51.100.2 tcp-mss 150 => new entry neighbor 2001:DB8::2 tcp-mss 400 => new entry 3. Show command frr# show bgp neighbors 198.51.100.2 BGP neighbor is 198.51.100.2, remote AS 100, local AS 100, internal link Hostname: frr Configured tcp-mss is 150, synced tcp-mss is 138 => new display 4. Show command json output frr# show bgp neighbors 2001:DB8::2 json { "2001:DB8::2":{ "remoteAs":100, "bgpTimerKeepAliveIntervalMsecs":60000, "bgpTcpMssConfigured":400, => new entry "bgpTcpMssSynced":388, => new entry Risk: ===== Low - This is a config driven feature and it sets the max segment size for the TCP session between BGP peers. Tests Executed: =============== Have done manual testing with three router topology. 1. Executed basic config and un config scenarios 2. Verified if the config is updated in running config during config and no config operation 3. Verified the show command output in both CLI format and JSON format. 4. Verified if TCP SYN messages carry the max segment size in their initial packets. 5. Verified the behaviour during clear bgp session. 6. done packet capture to see if the new segment size takes effect. Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2021-04-21build: run autoupdateDavid Lamparter
AC_TRY_COMPILE is deprecated too. Also configure.ac isn't executable. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-09-21*: Remove solaris from FRRDonald Sharp
The Solaris code has gone through a deprecation cycle. No-one has said anything to us and worse of all we don't have any test systems running Solaris to know if we are making changes that are breaking on Solaris. Remove it from the system so we can clean up a bit. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
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-27lib: Cleanup set but unused variablesDonald Sharp
There existed some variables set but never used. Clean this up. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-13*: Remove break after returnDonatas Abraitis
Just a deadcode. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-12-14lib: random unused bits cleanupDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-10-16lib: Add getsockopt_so_recvbufDonald Sharp
Add a new function getsockopt_so_recvbuf which tells you the operating systems receive buffer size. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-07lib: On some platforms function did not return anythingDonald Sharp
On some compiler platforms the md5 setup function was not returning anything. Place failure case on the bottom to properly handle this situation. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-16lib: add support for extended TCP MD5 authQuentin Young
MD5 auth on TCP is supported for prefixes in recent versions of Linux; add complementary support for FRR. This is a reworked version of Donald's commit to keep library compatibility and obviate the need for changes in daemons that don't need to support this themselves. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
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-06lib: Convert sockopt.c to flog_errDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-25lib: remove Linux 2.4 TCP-MD5 supportDavid Lamparter
Linux 2.6.0 was released in December of 2003... I'm pretty sure we don't need this Linux 2.4 support anymore. Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-16Merge pull request #2448 from qlyoung/error-reference-cardsDavid Lamparter
Error Reference Cards
2018-08-15lib, ripngd, zebra: Remove pre-solaris 9 special cased codeDonald Sharp
The CMSG_FIRSTHDR was broken on solaris pre version 9. Version 9 was released in May of 2002 and EOL'ed in 2014. Version 8 EOL'ed in 2012. Remove special case code for a little used platform that has not seen the light of day in a very long time. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14*: rename ferr_zlog -> flog_err_sysQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14*: rename zlog_fer -> flog_errQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14lib: Add LIB_ERR_SYSTEM_CALL and convert VRF_SOCKET to SOCKETDonald Sharp
Add a new error code LIB_ERR_SYSTEM_CALL to the ferr subsystem. Additionally convert LIB_ERR_VRF_SOCKET to a more generic LIB_ERR_SOCKET. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-01lib: fix getsockopt_cmsg_data retrievalRafael Zalamena
The `type` parameter was not being compared with `cmsg_type`, so the result of this function was always a pointer to the first header matching the level. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-06-20bgpd isisd ldpd lib ospfd pimd: redundancy (infer)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-07-22Revert "*: reindent pt. 2"David Lamparter
This reverts commit c14777c6bfd0a446c85243d3a9835054a259c276. clang 5 is not widely available enough for people to indent with. This is particularly problematic when rebasing/adjusting branches. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17*: reindent pt. 2whitespace / reindent
w/ clang 5 * reflow comments * struct members go 1 per line * binpack algo was adjusted
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-07*: add frr_init() infrastructureDavid Lamparter
Start centralising startup & option parsing into the library. FRR_DAEMON_INFO is a bit weird, but it will become useful later (e.g. for killing the ZLOG_* enum, and having the daemon name available) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-02Merge remote-tracking branch 'origin/stable/2.0'Donald Sharp
2017-02-01*: fix warning fallout from set_socket_pathDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-26lib: Add set_socket_path() to sockopt.c to override the path element of a ↵Martin Winter
(vty) socket (but keep filename) Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2017-01-13frr: Remove HAVE_IPV6 from code baseDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-08*: always set SO_SNDBUF and SO_RCVBUF using a best effort approachRenato Westphal
If we fail to set any socket's buffer size, try again with a smaller value and keep going until it succeeds. This is better than just giving up or, even worse, abort the creation of a socket (ospf6d and ripd). Fix broken ospf6d on FreeBSD. Signed-off-by: Renato Westphal <renato@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-25*: create a helper function to set the IP_MULTICAST_LOOP sockoptionRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-09-23lib: update Solaris multicast API (BZ#725)Christian Franke
On OpenIndiana/Solaris the build fails with "unsupported multicast API". It's only in the IPv4 part where setsockopt IP_MULTICAST_IF needs a local address and not the index (IPv6 wants the index). The following code walks the list of interfaces until it finds the matching index and uses the interface's local address for the setsockopt call. I don't know if it works on Solaris < 10 (I guess yes, but I don't have any machine to verify it). [NB: this breaks unnumbered setups that use the same IPv4 address on multiple interfaces. -- equinox@opensourcerouting.org] Reported-by: Brian Utterback <brian.utterback@oracle.com> Signed-off-by: Christian Franke <chris@opensourcerouting.org> Patchwork #762
2016-08-18*: use an ifindex_t type, defined in lib/if.h, for ifindex valuesPaul Jakma
(cherry picked from commit 9099f9b2a66e86f8a90d7fe18f61bd2bb1bc6744)
2016-08-07lib: fix setting of IPv4 multicast sockopts on OpenBSDRenato Westphal
OpenBSD doesn't support the "ifindex hack" derived from RFC 1724 which allows an ifindex to be encoded in the imr_interface field (in_addr) of the ip_mreq structure. OpenBSD also doesn't support the RFC3678 Protocol-Independent socket API extensions, which allows an interface to be specified by its ifindex. With that said, in OpenBSD we still need to specify an interface by its IP address. This patch adds an exception in the multicast sockopt functions to handle this case. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-05-26sockopt: add support for querying tcp round-trip-timeTimo Teräs
Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit 6b2672f3c9493aef3495192e113f95a7db4b65bc)
2011-10-17lib: compile even without IPV6_TCLASSDenis Ovsienko