Commit graph

24 commits

Author SHA1 Message Date
Quentin Young 772270f3b6 *: sprintf -> snprintf
Replace sprintf with snprintf where straightforward to do so.

- sprintf's into local scope buffers of known size are replaced with the
  equivalent snprintf call
- snprintf's into local scope buffers of known size that use the buffer
  size expression now use sizeof(buffer)
- sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp
  buffer followed by strlcat

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
Donatas Abraitis 5ee080f00a zebra, lib: Remove return from void functions
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-04 20:05:21 +02:00
David Lamparter 1b3e9a21dd lib: make some variables static
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-13 06:22:34 +01:00
Quentin Young 0a22ddfbb1 *: remove null check before XFREE
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:46 +00:00
Quentin Young 1c50c1c0d6 *: style for EC replacements
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:38:57 +00:00
Quentin Young 450971aa99 *: LIB_[ERR|WARN] -> EC_LIB
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:34:28 +00:00
Donald Sharp 8b895cd32f lib: Convert netns_linux.c to new error-code work
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-06 20:50:58 +00:00
Philippe Guibert 2ed3953ccc lib: remove spurious message when netns is not available
remove spurious message when netns is not available.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-29 09:27:17 +02:00
Quentin Young 09c866e34d *: rename ferr_zlog -> flog_err_sys
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Quentin Young af4c27286d *: rename zlog_fer -> flog_err
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Donald Sharp 674c3ca8a8 lib: Add LIB_ERR_NS to error subsystem
Add additional information about NameSpace errors that
may happen.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Donald Sharp 481bc15ffc lib: Add LIB_ERR_SYSTEM_CALL and convert VRF_SOCKET to SOCKET
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-14 20:02:05 +00:00
Philippe Guibert 0faeba264e lib: add the pathname to get the realpath in case of failure
Sometimes, the file under /var/run/netns may not be authorised to be
read ( because it is not read permission for frr user, for instance).
so it is good to know what happened.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-06 08:51:54 +02:00
Philippe Guibert f0295a548a lib: rename parameter for netns function
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-13 16:40:32 +02:00
Philippe Guibert 1ea16e0937 lib: Update netns_linux.c
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-13 16:40:32 +02:00
Philippe Guibert 03aff2d848 zebra: add an indirection table for ns_id
This list "table" is created in the case the netns backend for VRF is
used. This contains the mapping between the NSID value read from the
'ip netns list' and the ns id external used to create the VRF
value from vrf context. This mapping is
necessary in order to reserve default 0 value for vrf_default.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-13 16:40:32 +02:00
Donald Sharp 290d80a720 lib: Namespaces should only complain about failure if we have it
Do not complain about failure to create a namespace if we
do not have any such thing going on.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-31 15:08:14 -04:00
Donald Sharp 54085eafeb
Merge pull request #1428 from LabNConsulting/working/master/indent
frr: conform with COMMUNITY.md formatting rules
2018-03-07 10:44:37 -05:00
Lou Berger 996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00
Philippe Guibert c214a6e928 lib: NS_DEFAULT wrong value
The NS_DEFAULT value returns UNKNOWN in the case the vrf lite backend is
used, whereas this is wrong. This commit fixes the default value.
Also, it fixes the default value in the case NETNS support from system
is not ok, or some error can occur when reading default NS at startup.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-06 18:18:32 +01:00
Philippe Guibert 281da0a94d lib: do not use ENOSYS errno when returning from ns
ENOSYS should not be used for other goals.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert c485b14bdc lib: netns checkstyle fix
A space is appended between RB_FOREACH and ' ', to comply with style
practiced in frr.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert a2c999f21f lib: add debug guard for ns informational traces
Informational traces are being added.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert e26aedbe0b lib: split logicalrouter and vrf netns feature
This split is introducing logicalrouter.[ch] as the file that contains
the vty commands to configure logical router feature. The split has as
consequence that the backend of logical router is linux_netns.c formerly
called ns.c. The same relationship exists between VRF and its backend
which may be linux_netns.c file.
The split is adapting ns and vrf fiels so as to :
- clarify header
- ensure that the daemon persepctive, the feature VRF or logical router
  is called instead of calling directly ns.
- this implies that VRF will call NS apis, as logical router does.

Also, like it is done for default NS and default VRF, the associated VRF
is enabled first, before NETNS is enabled, so that zvrf->zns pointer is
valid when NETNS discovery applies.

Also, other_netns.c file is a stub handler that will be used for non
linux systems. As NETNS feature is only used by Linux, some BSD systems
may want to use the same backend API to benefit from NETNS. This is what
that file has been done.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Renamed from lib/ns.c (Browse further)