summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* zebra, lib/memtypes.c: the netlink sockets work per VRFFeng Lu2015-06-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch lets the netlink sockets work per VRF. * The definition of "struct nlsock" is moved into zebra/rib.h. * The previous global variables "netlink" and "netlink_cmd" now become the members of "struct zebra_vrf", and are initialized in zebra_vrf_alloc(). * All relative functions now work for a specific VRF, by adding a new parameter which specifies the working VRF, except those functions in which the VRF ID can be obtained from the interface. * kernel_init(), interface_list() and route_read() are now also working per VRF, and moved from main() to zebra_vrf_enable(). * A new function kernel_terminate() is added to release the netlink sockets. It is called from zebra_vrf_disable(). * Correct VRF ID, instead of the previous VRF_DEFAULT, are now passed to the functions of processing interfaces or route entries. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
* lib/vrf: enable / disable a VRFFeng Lu2015-06-022-1/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new API vrf_is_enabled() is defined to check whether a VRF is ready to use, that is, to allocate resources in that VRF. Currently there's only one type of resource: socket. Two new hooks VRF_ENABLE_HOOK/VRF_DISABLE_HOOK are introduced to tell the user when a VRF gets ready or to be unavailable. The VRF_ENABLE_HOOK callback is called in the new function vrf_enable(), which is used to let the VRF be ready to use. Till now, only the default VRF can be enabled, and we need do nothing to enable the default, except calling the hook. The VRF_DISABLE_HOOK callback is called in the new function vrf_disable(), which is used to let the VRF be unusable. Till now, it is called only when the VRF is to be deleted. A new utility vrf_socket() is defined to provide a socket in a given VRF to the user. Till now before introducing a way of VRF realization, only the default VRF is enabled since its birth, and vrf_socket() creates socket for only the default VRF. This patch defines the framework of the VRF APIs. The way they serve the users is: - vrf_is_enabled() is used to tell the user whether a VRF is usable; - users are informed by the VRF_ENABLE_HOOK that a VRF gets usable; they can allocate resources after that; - users are informed by the VRF_DISABLE_HOOK that a VRF is to be unavailable, and they must release the resources instantly; - vrf_socket() is used to provide a socket in a given VRF. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib, zebra, vtysh: configure an interface in non-default VRFFeng Lu2015-06-022-0/+23
| | | | | | | | | | | | | | Introduce a new command "interface IFNAME vrf N" to configure an interface in the non-default VRF. Till now, only zebra uses this command. Other daemons will install the command when they support multiple VRFs. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: move the interface list into "struct vrf"Feng Lu2015-06-024-58/+259
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An interface belongs to a specific VRF. So move the interface list into the "struct vrf". * vrf.c/vrf.h: - add a new member "struct list *iflist" to the the "struct vrf"; - call if_init() in vrf_new(); - call if_terminate() in vrf_delete(); - add utilities to access the interface list and VRF ID in the specified VRF. * if.c/if.h: - the global "iflist" now only exists for the default VRF; - the global "if_master" is initialized on the definition; - in if_create(), the interface is added into the list in the specified VRF; if the VRF does not exist, create one; - add parameters to if_init()/if_terminate() so that the interface list in the VRF can be initialized/destroyed; - in if_dump_all() scan the interfaces in all the VRFs; - add a command "show address vrf N" to show addresses in a specified VRF; - add a command "show address vrf all" to show addresses in all VRFs; - new APIs ifxxx_vrf() are added to access an interface in a specified VRF. The old interface APIs (the global variable "iflist" and the API functions) are not changed to keep the backward compatibility. The new APIs are used in the daemons which support multiple VRFs (till now only zebra). Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: call if_init()/if_terminate() from vrf_init()/vrf_terminate()Feng Lu2015-06-021-0/+5
| | | | | | | | | | | | | | | | | | Later, an interface will belong to a specific VRF, and the interface initialization will be a part of the VRF initialization. So now call if_init() from vrf_init(), and if_terminate() from vrf_terminate(). Daemons have the according changes: - if if_init() was called or "iflist" was initialized, now call vrf_init() instead; - if if_terminate() was called or "iflist" was destroyed, now call vrf_terminate() instead. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib, zebra: add "vrf_id" into the "struct interface"Feng Lu2015-06-022-4/+6
| | | | | | | | | | | | | | | | | | Later, an interface will belong to a specific VRF. Now we add a property "vrf_id" to the "struct interface", and keep it as the default value 0. This property is shown when displaying interfaces information. It is also added in some logs. This is just the preparation to move the interace list into the "struct vrf". The main logic is not changed. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib, zebra: move "struct vrf" to be a lib moduleFeng Lu2015-06-025-4/+372
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously "struct vrf" is defined locally in zebra. Now it is moved to be a lib module. This is the first step to support multi-VRF in quagga. The implementation is splitted into small patches for the purpose of easy review. * lib: "struct vrf" with basic members is defined in vrf.c. The member "void *info" is for user data. Some basic functions are defined in vrf.c for adding/deleting/ looking up a VRF, scanning the VRF table and initializing the VRF module. The type "vrf_id_t" is defined specificly for VRF ID. * zebra: The previous "struct vrf" is re-defined as "struct zebra_vrf"; and previous "vrf" variables are renamed to "zvrf". The previous "struct vrf" related functions are removed from zbera_rib.c. New functions are defined to maintain the new "struct zebra_vrf". The names vrf_xxx are reserved for the functions in VRF module. So: - the previous vrf_table() are renamed to zebra_vrf_table(); - the previous vrf_static_table() are renamed to zebra_vrf_static_table(). The main logic is not changed. BTW: Add a statement to zebra_snmp.c telling that the SNMP is running only for the MIBs in the default VRF. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: make prefix2str simpler to use, and use it in zclientTimo Teräs2015-06-013-7/+11
| | | | | | | | | | | Returning the buffer allows using it in the logging functions in easier way. This also makes the API consistent with sockunion. Add also PREFIX_STRLEN to be the generic buffer length required for any prefix string representation. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: make sockunion2str safer to useTimo Teräs2015-06-011-5/+12
| | | | | | | | It's mostly used for logging, and the return value is never checked, so try to make it valid. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* route table: constify some APIsTimo Teräs2015-05-292-8/+8
| | | | | Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* sockunion: add accessors for sockunion addressTimo Teräs2015-05-292-0/+61
| | | | | | | | Upcoming nhrp code will use this, and it can be used to remove the sockunion2ip(X) macro. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: allow caller to provide prefix storage in sockunion2hostprefixTimo Teräs2015-05-293-16/+10
| | | | | | | Avoids a dynamic allocation which is usually freed immediate afterwards. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* privs: fix privilege dropping to use system defined groupsTimo Teräs2015-05-291-19/+47
| | | | | | | | | | It may be requred for quagga process to belong to additional groups. E.g. nhrp module will need to talk to strongSwan using vici and may require additional permissions. Initialize groups from the system group database. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Revert "lib: wrong #define used for IPV6_MINHOPCOUNT"David Lamparter2015-05-271-7/+3
| | | | | | | | | | This reverts commit 54b88cac24f335414caa875b390d2d78ff4bf9e0. Unfortunately, this breaks the build on systems where linux/in6.h and netinet/in.h can't both be included, such as Ubuntu 14.04 and Debian Jessie. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: wrong #define used for IPV6_MINHOPCOUNTDonald Sharp2015-05-271-3/+7
| | | | | | | | | | | The #define IPV6_MINHOPCNT define is never defined on any unix platform. >From what I can tell the original implementation on the linux platform was IPV6_MINHOPCNT, when it got accepted into the mainstream kernel it was transformed into IPV6_MINHOPCOUNT. Since we test for the define before attempting to use the code it was silently doing nothing for a long time. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib/privs: Don't use CAP_NET_BROADCASTChristian Franke2015-05-271-2/+1
| | | | | | | | | | | | From what I can tell, CAP_NET_BROADCAST has never been required for any functionality in the Linux kernel, so we do not really need it. However, it causes breakage in contexts where Quagga is started with a limited set of capabilities, e.g. in Docker, because these may not include CAP_NET_BROADCAST and in the case of Docker do not even support adding CAP_NET_BROADCAST. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib/privs: display more info if cap_set_proc fails.Christian Franke2015-05-271-1/+15
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib/vty: don't clear output buffer on input EOFDavid Lamparter2015-05-271-1/+1
| | | | | | | | | | | A VTY's input can be closed without the output becoming unavailable. This happens both on stdio when stdin ends, as well as over TCP when an unidirectional input shutdown() happens. In such a case, resetting the output buffer is not appropriate since there might still be data to be successfully written. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib/vty: add vty_stdio at-close hookDavid Lamparter2015-05-272-2/+8
| | | | | | | | | This is intended to be used for either "exit on close", "fork on close" or "reopen vty on close" functionality for the stdio vty. Which of these options to take depends on the context, the use case right now is test programs exiting on EOF. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib/vty: put stdin in raw mode for vtyDavid Lamparter2015-05-271-1/+36
| | | | | | | The interactive CLI actually works just fine, if we just put the terminal in raw mode to get keystrokes as they come. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib/vty: add vty_stdio()David Lamparter2015-05-272-21/+57
| | | | | | | | this introduces a new public/API function to the vty code for opening a VTY on stdin/stdout. Intended for unrestricted use by the individual daemons, i.e. "offical API". Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib/vty: add separate output fd support to VTYsDavid Lamparter2015-05-273-13/+19
| | | | | | | | | to be used with stdin/stdout terminals, this adds support for writing to a different FD than we're reading from. Also fixes error messages from config load being written to stdin. [v2: fixed config write] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: fix "sockunion: add hash function" for BSD (9196caf)David Lamparter2015-05-201-0/+10
| | | | | | | | | | | | | The sockunion_hash() function uses s6_addr32, which is not defined on BSD systems. (It only works on glibc because we set _GNU_SOURCE) ripngd/ripng_nexthop.h already contains a workaround for this. Bump workaround to prefix.h so it's available everywhere. Reported-by: NetDEF CI System <mwinter@netdef.org> Fixes: 9196caf ("sockunion: add hash function") Cc: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* sockunion: add hash functionTimo Teräs2015-05-202-0/+17
| | | | | Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* sockopt: add support for querying tcp round-trip-timeTimo Teräs2015-05-202-0/+17
| | | | | Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: assert(0) still needs a returnDavid Lamparter2015-05-141-0/+1
| | | | | | | | assert(0) is not guaranteed to not return since assert() in general can be optimised out when building without debug / with optimisation. This breaks the build in clang, which warns/errors about the missing return. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: fix "reduce strcmp in CLI" fallout (10bac801)David Lamparter2015-05-142-33/+19
| | | | | | | | | | | | | | | In "lib/cli: reduce strcmp in CLI hot paths", I failed to notice that CMD_VARIABLE as a boolean test covers a superset of the other types of variables. Thus, the patch broke processing of IP/IPv6/Integer range parameters in the CLI. Fix by some reordering and introducing TERMINAL_RECORD macro (which marks whether a given terminal type is a parameter) to be used in places where the check is really for all kinds of variables. Reported-by: Timo Teräs <timo.teras@iki.fi> Tested-by: Martin Winter <mwinter@netdef.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: straighten out ORF prefix list supportDavid Lamparter2015-05-052-102/+54
| | | | | | | | | BGP ORF prefix lists are in a separate namespace; this was previously hooked up with a special-purpose AFI value. This is a little kludgy for extension, hence this splits it off. Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Acked-by: Paul Jakma <paul@jakma.org>
* lib: hide internal prefix list structuresDavid Lamparter2015-05-054-43/+82
| | | | | | | These are about to be touched and there's no point in other code touching into prefix list's internas. Add some isolation. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib/cli: reduce strcmp in CLI hot pathsDavid Lamparter2015-05-052-136/+174
| | | | | | | | | | | | Er, no idea how anyone could ever have thought that it would be a good idea to have a zillion of strcmp() calls in the CLI's active paths, just to compare against things like "A.B.C.D". Reduces 40k prefix list load time from 1.65s to 1.23s (1.34:1). Acked-by: Paul Jakma <paul@jakma.org> [v2: killed CMDS_* macros] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: constify sockunion apiTimo Teräs2015-05-052-18/+18
| | | | | | | 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>
* build: add --enable-werrorDavid Lamparter2015-04-211-0/+1
| | | | | | | | | | | | | | | This allows enabling -Werror in a consistent way. Note that this is different from just specifiying it in CFLAGS, since that would either break configure tests (if done on ./configure), or would override configure's CFLAGS (if done on make). Using --enable-werror instead provides a new WERROR variable that is additionally used during make with a consistent set of warning flags. The tests/ directory is exempt. (Rationale being, better to have more tests than pedantically complain about them.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* snmp: fix warningsDavid Lamparter2015-04-212-4/+4
| | | | | | batch-fix all warnings that come up when enabling AgentX SNMP support. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* vtysh: don't use '\0' as NULLDavid Lamparter2015-04-211-3/+3
| | | | | | for some reason, the vty code was using '\0' in place of NULL. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib, vtysh: reduce unneccessary C extension usageDavid Lamparter2015-04-211-1/+1
| | | | | | | We're only supporting GCC, Clang and ICC; but there's no reason to use nonstandard C constructs if they don't actually provide any benefit. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: use const consistently for zserv pathDavid Lamparter2015-04-212-3/+3
| | | | | | | The global variable is missing its const, but the accessor function has a meaningless extra const in exchange... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: silence type range warning in macroDavid Lamparter2015-04-211-6/+10
| | | | | | | | While splitting up the CLI input macro is a bit annoying, this seems to be the least annoying way to get rid of the "< 0" comparison warning for unsigned long. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: add/cleanup initialisersDavid Lamparter2015-04-211-1/+1
| | | | | | | | There were some (inconsequential) warnings about uninitialised use of variables. Also, in one case, sub-structs were mixed in initialisation, which doesn't quite work as intended. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: add missing includesDavid Lamparter2015-04-212-0/+3
| | | | | | | Some places, particularly headers, were spewing warnings since they don't include neccessary other headers to get struct/enum definitions. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: remove stray extra semicolonsDavid Lamparter2015-04-211-1/+1
| | | | | | Some places had extra semicolons where none belong. Remove them. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: use void * for printing pointersDavid Lamparter2015-04-213-3/+4
| | | | | | | | | On higher warning levels, compilers expect %p printf arguments to be void *. Since format string / argument warnings can be useful otherwise, let's get rid of this noise by sprinkling casts to void * over printf calls. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: Fix POSIX capabilities on SunOS platformsBrian Bennett2015-03-041-27/+49
| | | | | | | | | | | | | | When using POSIX capabilities on SunOS the capabilities are too restricitve resulting in quagga processes not being able to read their own config files. Credit goes to Oracle where this patch was originally authored and included in OpenSolaris. lib/privs.c: Include additional capabilities, better checking of missing capabilities. Fixes: #820 Acked-by: Greg Troxel <gdt@ir.bbn.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* build: track config argsDavid Lamparter2015-02-142-0/+5
| | | | | | | Record the ./configure arguments used and make them user-visible. Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Acked-by: Paul Jakma <paul@jakma.org>
* build: get rid of INCLUDES, use AM_CPPFLAGSDavid Lamparter2015-02-141-1/+1
| | | | | | | | | | | | INCLUDES in configure.ac was not used at all, and INCLUDES in Makefile.am is supposed to be AM_CPPFLAGS these days. Reduces warnings spewed during bootstrap/autoreconf. 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>
* build: remove INRIA, NRL and MUSICA IPv6 quirksDavid Lamparter2015-02-142-14/+4
| | | | | | | | | 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>
* build: remove AIX, NEC EWS and IRIXDavid Lamparter2015-02-141-14/+0
| | | | | | | | | Valar morghulis. 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>
* pimd: Remove non-standard copyright line.Everton Marques2015-02-046-7/+0
|
* zebra: mrib: Remove non-standard copyright line.Everton Marques2015-02-041-1/+0
|
* pimd: Revert accidental removal of show_memory_isis_cmd().Everton Marques2015-02-041-0/+1
|
* zclient: Revert lib export of zclient_socket()/zclient_socket_un().Everton Marques2015-02-042-4/+2
|