Commit Graph

293 Commits

Author SHA1 Message Date
Philippe Guibert
921a85ba8c zebra, ifp: on netlink discovery, anticipate the vrf creation
there may be cases where the vrf is yet allocated from the vty, and the
discovery process did not make the relationship between the vrf_id and
the name of the vrf. For instance, by parsing an interface belonging to
vrf-id X, it is not sure that vrf-id X and vrfname XX are talking about
the same vrf. For that, lets allocate the vrf, and lets try to detect
there is a duplicate case in vrf, so that the merge can be done without
any impact for the user.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
8205b1b455 zebra, lib: upon entering interface, create vrf context
the interface search is based on vrfs. As at startup, some interfaces
may be configured, there is need to have vrfs contexts present. A macro
is being appended with an extra parameter that permits create a vrf and
return the context. This macro is also used by some show routines, but
will not create vrfs, because that extra parameter will be set to false,
on that case.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
ac6c2a11a6 lib: create interface upon accessing interface NB API.
Upon accessing interface NB API, the interface is created, if the vrf
is available. the commit does not change the behaviour, since at this
commit, this is not yet possible to have vrf contexts, while zebra did
not connect to daemons. However, that commit adds some work, so that it
will be possible to work on a vrf context, without having the vrf_id
completely resolved. for instance, if we suppose a vrf is created by
command 'vrf TOTO' in the starting configuration of a daemon, then 'interface
TITI vrf TOTO' will permit to create interface TITI within vrf TOTO.

the macro VRF_GET_INSTANCE will return the vrf context, if available or
not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
f11e98eca3 *: change if_lookup_by_name() api with vrf
the vrf_id parameter is replaced by struct vrf * parameter.
this impacts most of the daemons that look for an interface based on the
name and the vrf identifier.
Also, it fixes 2 lookup calls in zebra and sharpd, where the vrf_id was
ignored until now.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:54 +02:00
Philippe Guibert
e9c199a6c1 lib, ospfd, pimd, zebra: change if_create() api with vrf
if_create() takes as input a vrf poiter instead of the vrf_id parameter.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11 17:10:47 +02:00
Philippe Guibert
4c634658a6 ospf, ospf6d, zebra, lib: change if_get_by_name prototype with vrf
vrf pointer is used as reference when calling if_get_by_name() function.
this will permit to create interfaces with an unknown vrf_id, since it
is only necessary to get the vrf structure to store the interfaces.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11 17:10:47 +02:00
Quentin Young
667179cae4 lib: add function to get iface link-local
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
dad18a2fd7 vrrpd: add initial macvlan support
* 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>
2019-05-17 00:27:08 +00:00
Renato Westphal
83981138fe lib: introduce a read-write lock for northbound configurations
The upcoming gRPC-based northbound plugin will run on a separate
pthread, and it will need to have access to the running configuration
global variable.  Introduce a rw-lock to control concurrent access
to the running configuration. Add the lock inside the "nb_config"
structure so that it can be used to protect candidate configurations
as well (this might be necessary depending on the threading scheme
of future northbound plugins).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-26 18:04:22 -03:00
Donald Sharp
8f19bc1c69
Merge pull request #3786 from mjstapp/dplane_intf
zebra: async interface address programming
2019-04-22 15:29:02 -04:00
Mark Stapp
6339042cb9 libs: use const in some interface flag accessors
Use const in several interface struct flag accessors (that just
test flags.)

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-22 13:49:27 -04:00
Renato Westphal
ccd43ada17 lib: rework management of user pointers in the northbound layer
Introduce a hash table to keep track of user pointers associated
to configuration entries. The previous strategy was to embed
the user pointers inside libyang data nodes, but this solution
incurred a substantial performance overhead. The user pointers
embedded in candidate configurations could be lost while the
configuration was being edited, so they needed to be regenerated
before the candidate could be committed.  This was done by the
nb_candidate_restore_priv_pointers() function, which was extremely
expensive for large configurations. The new hash table solves this
performance problem.

The yang_dnode_[gs]et_entry() functions were renamed and moved from
yang.[ch] to northbound.[ch], which is a more appropriate place
for them. This patch also introduces the nb_running_unset_entry()
function, the counterpart of nb_running_set_entry() (unsetting
user pointers was done automatically before, now it needs to be
done manually).

As a consequence of these changes, we shouldn't need support for
libyang private pointers anymore (-DENABLE_LYD_PRIV=ON). But it's
probably a good idea to keep requiring this feature as we might
need it in the future for other things (e.g. disable configuration
settings without removing them).

Fixes #4136.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-18 11:56:45 -03:00
Donald Sharp
3393df5cf1 lib: Fixup IFF_OUT_LOG macro to make SA happy
The IFF_OUT_LOG macro is using BUFSIZE, which is the sizeof(logbuf)
but for some reason 8.0 clang SA is not happy with it.  Just
make it happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-06 20:10:52 -04:00
Donald Sharp
f61f266a0e
Merge pull request #3548 from opensourcerouting/rip-vrf
rip(ng)d: add VRF support
2019-04-04 19:24:14 -04:00
Quentin Young
c17faa4b10 lib: reduce exported var symbols
Don't need these in our DSO tables

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-04-03 20:34:18 +00:00
Renato Westphal
6a3fdeecf1 lib, ripd, ripngd: rename remaining delete northbound callbacks
PR #3622 renamed the "delete" northbound callback to "destroy" in
order to make the libfrr headers compatible with C++. This commit
renames a few functions that still use "delete" instead of "destroy"
in their names.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-03-29 11:32:33 -03:00
Donald Sharp
c9146c85a0
Merge pull request #3772 from pguibert6WIND/vrf_backend_unknown
Vrf backend unknown
2019-03-25 08:13:16 -04: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
Mark Stapp
95ce849b58 libs, rip, isis: change northbound operation enum to DESTROY
Change the northbound lib operation from DELETE to DESTROY;
make the required changes in the users of the northbound, in
the cli, rip, ripng, and isis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-11 15:49:49 -02:00
Mark Stapp
d01b92fd75 libs, daemons: changes to permit c++ compilation
Some misc changes to resolve some c++ compilation errors.
The goal is only to permit an external module - a plugin,
for example - to see frr headers, not to support or encourage
contributions in c++. The changes include: avoiding use
of keywords like 'new', 'delete'; cleaning up implicit
type-casting from 'void *' in several places.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-11 15:49:49 -02:00
Philippe Guibert
b0b97a7f61 lib: handling vrf backend unknown case
on interface search algorithm, at initialisation, when reading config
file, the vrf backend may not be yet known ( because zebra did not sync
yet with daemon). For that, avoid searching interface name in a separate
vrf. This change of behaviour is induced because the assumption is done
that at config startup, the user is not wrong with the interface
configuration to use. Every usage of vrf_get_backend() should then be
wisely adapted in order to handle that init state.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-02-11 13:48:12 +01:00
Philippe Guibert
72261ecd22 lib: interface handling where zebra not yet ready
other daemons need to sync with zebra to get to know which vrf backend
is available. in that time, there may be interface configuration
available. in that specific case, the vrf backend returned is not known.
A specific return value is sent back. This will be useful to know which
specific algorithm to apply.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-02-11 13:47:04 +01:00
Renato Westphal
a6233bfcb3 lib, ripd: rework API for converted CLI commands
When editing the candidate configuration, the northbound must ensure
that either all changes made by a command are accepted or none are.
This is done to prevent inconsistent states where only parts of a
command are applied in the event any error happens.

The previous API for converted commands, the nb_cli_cfg_change()
function, required callers to pass an array containing all changes
that needed to be applied in the candidate configuration. The
problem with this API is that it was very inconvenient for complex
commands, which change different configuration options depending
on several factors.  This required users to manipulate the array
of configuration changes using low-level primitives, making it
complicated to implement some commands.

To solve this problem, introduce a new API based on the two following
functions:
- nb_cli_enqueue_change()
- nb_cli_apply_changes()

The first function is used to enqueue configuration changes, one
at time. Then the nb_cli_apply_changes() function is used to apply
all the enqueued configuration changes.

To implement this, a static-sized array was allocated in the "vty"
structure, along with a counter of enqueued changes. This eliminates
the need to declare an array of configuration changes in every
converted CLI command, simplifying things quite considerably.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26 15:57:23 -02:00
Renato Westphal
25c780a32a lib: make yang_dnode_get_entry() more flexible
Add the "abort_if_not_found" parameter to the yang_dnode_get_entry()
function instead of always aborting when an user pointer is not
found.  This will make it possible, for example, to use this function
during the validation phase of a configuration transaction. Callers
will only need to check if the function returned NULL or not,
since new configuration objects (if any) won't be created until
the NB_EV_APPLY phase of the transaction.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26 15:53:15 -02:00
Renato Westphal
8f90d89ba9 lib: retrofit interface commands to the new northbound model
The frr-interface YANG module models interfaces using a YANG list keyed
by the interface name and the interface VRF. Interfaces can't be keyed
only by their name since interface names might not be globally unique
when the netns VRF backend is in use. When using the VRF-Lite backend,
however, interface names *must* be globally unique. In this case, we need
to validate the uniqueness of interface names inside the appropriate
northbound callback since this constraint can't be expressed in the
YANG language. We must also ensure that only inactive interfaces can be
removed, among other things we need to validate in the northbound layer.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
a4bed468f9 yang, lib: add 'frr-interface.yang' and associated stub callbacks
Introduce frr-interface.yang, which defines a model for managing FRR
interfaces.

Update the 'frr_yang_module_info' array of all daemons that will
implement this module.

Add automatically generated stub callbacks in if.c. These callbacks will
be implemented in the following commit.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
David Lamparter
6a154c8812 *: list_delete_and_null() -> list_delete()
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02 11:40:52 +02:00
Donald Sharp
b1cc6da84f lib: Allow useful display of default vrf name
When entering a interface name and you fat-finger it
actually display some useful information about the vrf
we are in.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-22 12:10:02 -04:00
Quentin Young
e8275c22b4
Merge pull request #3040 from pacovn/static_analysis__drop_const_1
bgpd isisd ldpd lib: const drop fixes (SA)
2018-09-17 15:25:49 -04:00
F. Aragon
36de6e0e1e
bgpd isisd ldpd lib: const drop fixes (SA)
Can be detected with e.g. ./configure CFLAGS=-Wcast-qual CC=clang

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-17 19:38:59 +02: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
Russ White
88f47ef365
Merge pull request #2944 from thbtcllt/master
fix zebra crash when a vrf interface changes with netns implementation for vrf
2018-09-11 11:33:27 -04:00
David Lamparter
ae9eebcaeb *: fix some solaris warnings
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 21:30:42 +02:00
Thibaut Collet
379eb245f6 lib/if.c: fix CLANG warning
Fix CLANG warning:
Report for if.c | 2 issues
===============================================
< WARNING: else is not generally useful after a break or return
< #390: FILE: /tmp/f1-28557/if.c:390:

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
2018-08-30 16:29:06 +02:00
Thibaut Collet
ee2f2c23ca zebra: fix crash when interface vrf changes
This crash occurs only with netns implementation.
vrf meaning is different regarging its implementation (netns or
vrf-lite)

- With vrf-lite implementation vrf is a property of the interface that
  can be changed as the speed or the state (iproute2 command: "ip link
  set dev IF_NAME master VRF_NAME"). All interfaces of the system are in
  the same netns and so interface name is unique.
- With netns implementation vrf is a characteristic of the interface
  that CANNOT be changed: it is the id of the netns where the interface
  is located. To change the vrf of an interface (iproute2 command to
  move an interface "ip netns exec VRF_NAME1 ip link set dev IF_NAME
  netns VRF_NAME2") the interface is deleted from the old vrf and
  created in the new vrf.
  Interface name is not unique, the same name can be present in the
  different netns (typically the lo interface) and search of interface
  must be done by the tuple (interface name, netns id).

Current tests on the vrf implementation (vrf-lite or netns) are not
sufficient. In some cases (for example when an interface is moved from
a vrf X to the default vrf and then move back to VRF X) we can have a
corruption message and then a crash of zebra.

To avoid this corruption test on the vrf implementation, needed when an
interface changes, has been rewritten:
- For all interface changes except deletion the if_get_by_name function,
  that checks if an interface exists and creates or updates it if
  needed, is changed:
    * The vrf-lite implementation is unchanged: search of the interface
      is based only on the name and update the vrf-id if needed.
    * The netns implementation search of the interface is based on the
      (name, vrf-id) tuple and interface is created if not found, the
      vrf-id is never updated.
- deletion of an interface (reception of a RTM_DELLINK netlink message):
    * The vrf-lite implementation is unchanged: the interface
      information are cleared and the interface is moved to the default
      vrf if it does not belong to (to allow vrf deletion)
    * The netns implementation is changed: only the interface
      information are cleared and the interface stays in its vrf to
      avoid conflict with interface with the same name in the default
      vrf.

This implementation reverts (partially or totally):
commit 393ec5424e ("zebra: fix missing node attribute set in ifp")
commit e9e9b1150f ("lib: create interface even if name is the same")
commit 9373219c67 ("zebra: improve logs when replacing interface to an
other netns")
Fixes: b53686c52a ("zebra: delete interface that disappeared")

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-30 14:37:59 +02:00
Don Slice
fec4ca191e zebra: if multiple connecteds, select loopback or vrf if present
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-23 18:49:48 +00:00
Donald Sharp
03548ae818 lib: Convert debug to error situation
This debug should be moved to an error situation since it's a
developmental escape that needs to be fixed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-23 08:36:07 -04:00
Philippe Guibert
3d4c0b49da lib: change vrf_is_mapped_on_netns API
The function handles not a vrf pointer instead of a vrf_id value.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-22 09:19:04 +02:00
Donald Sharp
4d43f68aeb lib, zebra: Add LIB_ERR_INTERFACE
Add a error type that allows us to track bad interface states.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Renato Westphal
91e5b43ab4 lib, vtysh: fix inconsistent interface commands in vtysh
The definition of the interface commands in vtysh.c were outdated.
Currently, all daemons that call if_cmd_init() will have the "no interface
IFNAME" command and the "[no] description" commands as well, so there's
no need to define exceptions for these commands anymore.

To fix this, make extract.pl parse the if.c file so that vtysh can get the
interface commands from there automatically. Only the "interface IFNAME
[vrf NAME]" must be kept in vtysh.c because it changes the vty node and
thus needs special treatment.

Finally, make pimd and pbrd display interface descriptions on "sh run"
when they are configured.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-08-13 18:59:31 -03:00
Nathan Van Gheem
ec1db5882d lib,zebra: fix json output when vrf1 when not active
When I did a show ip route with `json` on a vrf when it didn't exist,
frr would output invalid json.

Signed-off-by: Nathan Van Gheem <nathan@cumulusnetworks.com>
2018-07-27 10:17:03 -04:00
Philippe Guibert
fda8229965 lib: remove if_lookup_by_index portion of code with unknown vrf
This function should be called with a known vrf_id. All other cases, the
other API should be called.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-10 17:32:40 +02:00
Chirag Shah
0c74bbe03e ospfd: Treat vrf interface as loopback type
Ticket:CM-19914

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-03-08 13:15:58 -08: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
e9e9b1150f lib: create interface even if name is the same
For supporting vrf based on namespaces, it is possible that an interface
with the same index is present. This is the case for loopback
interfaces. For that, for each query, if the interface is not found
, matching the vrf identifier, then a new interface is created, when the
backens for VRF is NETNS.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Donald Sharp
55cd0f612a *: Make assignment from RB_ROOT in while loop work better
Fix up the assignment of the variable = RB_ROOT inside of
while loop patter we were using.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-23 07:08:36 -05:00
Donald Sharp
c7974c0f1a lib: When we shutdown we would leak interface description
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com.
2018-01-29 15:38:03 -05:00
Donald Sharp
14fcc65cbb lib: Allow interface lookup by VRF_UNKNOWN
Modify if_lookup_by_index to accept a VRF_UNKNOWN
as a vrf_id.  This will cause it to look in all
vrf's for the interface pointer.

Subsequently all if_XXXX functions that call this function
will also get this behavior.

VRF_UNKNOWN *should* not be used for interface creation
as that this will break some core assumptions.

This work is part of allowing vrf route leaking.  Currently
it is possible to create a route in the linux kernel that has
a nexthop across vrf boundaries.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:19:43 -05:00
Chirag Shah
1505b537a8 lib: Fix no interface cmd vrf parsing
For no interface <ifname> vrf VRFNAME,
vrf-name is not parsed properly.

Ticket:CM-19274

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-01-03 11:41:45 -08:00
Renato Westphal
5b8524f5c2 lib: fix coverity warnings introduced by the iface rb-tree conversion
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24 18:26:02 -02:00
Renato Westphal
451fda4f9a *: use the FOR_ALL_INTERFACES abstraction from babeld
This improves code readability and also future-proofs our codebase
against new changes in the data structure used to store interfaces.

The FOR_ALL_INTERFACES_ADDRESSES macro was also moved to lib/ but
for now only babeld is using it.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:46 -03:00
Renato Westphal
c9cbbb4054 lib: fix bug in if_cmp_name_func()
If the p1 and p2 arguments pointed to identical strings ending with
a non-numeric character (e.g. "lo"), this function would return -1
instead of 0 as one would expect. This inconsistency didn't matter
for sorted linked-lists but for red-black trees it's a major source
of problems.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:02 -03:00
Renato Westphal
ff880b78ef *: introduce new rb-tree to optimize interface lookup by ifindex
Performance tests showed that, when running on a system with a large
number of interfaces, some daemons would spend a considerable amount
of time in the if_lookup_by_index() function. Introduce a new rb-tree
to solve this problem.

With this change, we need to use the if_set_index() function whenever
we want to change the ifindex of an interface. This is necessary to
ensure that the 'ifaces_by_index' rb-tree is updated accordingly. The
return value of all insert/remove operations in the interface rb-trees
is checked to ensure that an error is logged if a corruption is
detected.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:02 -03:00
Renato Westphal
f4e14fdba7 *: use rb-trees to store interfaces instead of sorted linked-lists
This is an important optimization for users running FRR on systems with
a large number of interfaces (e.g. thousands of tunnels). Red-black
trees scale much better than sorted linked-lists and also store the
elements in an ordered way (contrary to hash tables).

This is a big patch but the interesting bits are all in lib/if.[ch].

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:02 -03:00
Renato Westphal
5d56066e46 lib: register 'if_var_handlers' only once
There's no need to register 'if_var_handlers' for every VRF, we need
to do it only once.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:01:24 -03:00
Renato Westphal
bcc245799b lib: nuke the if_*_by_name_len() functions
Make use of strnlen() and strlcpy() so we can get rid of these
convoluted if_*_by_name_len() functions.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:01:24 -03:00
Donald Sharp
acdf5e2510 *: Convert list_free usage to list_delete
list_free is occassionally being used to delete the
list and accidently not deleting all the nodes.
We keep running across this usage pattern.  Let's
remove the temptation and only allow list_delete
to handle list deletion.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:53:17 -04:00
Donald Sharp
affe9e9983 *: Convert list_delete(struct list *) to ** to allow nulling
Convert the list_delete(struct list *) function to use
struct list **.  This is to allow the list pointer to be nulled.

I keep running into uses of this list_delete function where we
forget to set the returned pointer to NULL and attempt to use
it and then experience a crash, usually after the developer
has long since left the building.

Let's make the api explicit in it setting the list pointer
to null.

Cynical Prediction:  This code will expose a attempt
to use the NULL'ed list pointer in some obscure bit
of code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:53:13 -04:00
Renato Westphal
a2addae8fe *: use clang's 'ForEachMacros' format style option
This fixes the broken indentation of several foreach loops throughout
the code.

From clang's documentation[1]:
  ForEachMacros: A vector of macros that should be interpreted as foreach
  loops instead of as function calls.

[1] http://clang.llvm.org/docs/ClangFormatStyleOptions.html

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-15 14:53:46 -03:00
David Lamparter
ce19a04aea lib: replace if_add_hook with hook_* logic
This allows modules to register their own additional hooks on interface
creation/deletion.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-15 13:25:44 +02:00
whitespace / reindent
d62a17aede *: reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17 14:04:07 +02:00
David Lamparter
2d8270596a Merge remote-tracking branch 'frr/master' into newline-redux
Lots of conflicts from CMD_WARNING_CONFIG_FAILED...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 13:07:30 +02:00
David Lamparter
55f70b671f *: remove VTYNL, part 4 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:03 +02:00
David Lamparter
61b7d449bd *: remove VTYNL, part 3 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:03 +02:00
David Lamparter
26a429fe8e *: remove VTYNL, part 2 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:02 +02:00
David Lamparter
181039f3d7 *: ditch vty_outln(), part 2 of 2
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:19:58 +02:00
Daniel Walton
f1a05de982 vtysh: return non-zero for configuration failures
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

This allows frr-reload.py (or anything else that scripts via vtysh)
to know if the vtysh command worked or hit an error.
2017-07-13 19:56:08 +00:00
David Lamparter
5c7571d43f *: ditch vty_outln(), part 1 of 2
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13 20:29:22 +02:00
Jafar Al-Gharaibeh
fd576f61bc Merge pull request #767 from donaldsharp/if_update
bgpd, lib, zebra: Fix if_update function to represent what it does
2017-06-29 23:42:21 -05:00
Quentin Young
1318e7c841 *: s/VTY_NEWLINE/VTYNL/g
Should be able to fit more vty_out onto one line now

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:34:54 +00:00
Quentin Young
96ade3ed77 *: use vty_outln
Saves 400 lines

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:31:28 +00:00
Donald Sharp
16895dbf73 bgpd, lib, zebra: Fix if_update function to represent what it does
The if_update function was taking the interface name as
input and reapplying it, using strncpy to reapply the name.
This has several issues.  strncpy should not be used
to copy memory in place.  The second issue is that
the interface name is not actually changing when we
update interface to be in the new vrf.

Since every usage of if_update was just reapplying the same
name the interface actually had, just remove that part of
the function and rename it to if_update_to_new_vrf
to represent what it is actually doing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-29 09:09:23 -04:00
David Lamparter
896014f4bc *: make consistent & update GPLv2 file headers
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-05-15 16:37:41 +02:00
David Lamparter
70d44c5cd4 lib: cli: autocomplete variables
Shows known values in the appropriate naming domain when the user hits
<?> or <Tab>.  This patch only works in the telnet CLI, the next patch
adds vtysh support.

Included completions:
- interface names
- route-map names
- prefix-list names

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 10:27:43 -04:00
Donald Sharp
f15dd9a4ee bgpd, lib, zebra: Rename if_update_vrf -> if_update
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:55:42 -04:00
Donald Sharp
128c2be2a1 bgpd, lib, zebra: Refactor ifname2ifindex to be VRF aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:43:31 -04:00
Donald Sharp
baaea325e6 *: Refactor ifindex2ifname to be VRF aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:43:21 -04:00
Donald Sharp
07a112a1dc lib: Refactor if_get_by_name_len to be VRF aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:41:07 -04:00
Donald Sharp
92a57eb206 *: Refactor if_get_by_name to be VRF aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:36:38 -04:00
Donald Sharp
1306c09a1b *: Refactor if_lookup_by_name to be VRF aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:36:23 -04:00
Donald Sharp
a90607a4ba lib, ospf6d: Refactor if_lookup_prefix
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:33:16 -04:00
Donald Sharp
fa787f911c lib, ospfd: Refactor if_lookup_by_name_len
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:32:09 -04:00
Donald Sharp
95af5f130a lib, ospfd, ripd: Convert if_lookup_address to be vrf aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:31:10 -04:00
Donald Sharp
c5e2cb11ad lib, pimd, zebra: Convert if_lookup_exact_address to VRF only
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:30:58 -04:00
Donald Sharp
4e5266b8a3 lib, ospfd, pimd: Convert to using VRF based interface creation
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:29:09 -04:00
Donald Sharp
7e2b760345 *: Remove non-vrf based ifindex lookup
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:26:53 -04:00
David Lamparter
4525281af1 *: get rid of zlog(*, LOG_LEVEL, ...)
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-03-08 00:15:39 +01:00
Donald Sharp
0527bd80c9 lib: Treat v6 address as a v6 address
The code was making the correct assumption
that the v4 and v6 addresses start in the
same spot in memory and since we were looking
at a v6 prefix it would just work.  This
causes distress in SA systems, so let's just
make it happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-01 19:52:54 -05:00
Donald Sharp
56c1f7d852 frr: Remove HAVE_IPV6 from code base
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-13 08:05:50 -05:00
Olivier Dugeon
daf0a4d29c Rationalize Link Parameters flags
* lib/if.h: Remove LP_TE as Link Parameters is set if different from 0
See IS_LINK_PARAMS_SET macro and use LP_TE_METRIC to determine if TE metric
is set or not
 * lib/if.c: replace LP_TE by LP_TE_METRIC in default LP status
 * zebra/interface.c: replace LP_TE by LP_TE_METRIC and check if TE metric
is equal to standard metric or not
 * ospfd/ospf_te.c: replace LP_TE by LP_TE_METRIC
 * isisd/isis_te.c: replace LP_TE by LP_TE_METRIC

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2017-01-05 08:19:11 +01:00
David Lamparter
a50b7cebd5 lib: remove vty->index
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-09 17:36:25 +01:00
David Lamparter
d7d73ffc8f *: fix up DEFUNs without install_element calls
These now generate warnings which will break the build with -Werror.

Note this may have enabled commands that should be disabled, or the
other way around...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-05 20:28:24 +01:00
David Lamparter
7ddcfca4fb Merge branch 'queue/osr/vtysh-generic'
WARNING: Merge contains nontrivial fixups in vrf_cmd handling.

Conflicts:
	lib/if.c
	zebra/interface.c
2016-12-05 20:04:08 +01:00
David Lamparter
53dc2b05c7 Merge branch 'stable/2.0'
Conflicts:
	bgpd/bgp_route.c
	lib/if.c
	ripd/rip_interface.c
	zebra/interface.c
	zebra/zebra_vty.c
2016-12-05 19:48:38 +01:00
David Lamparter
a93baa31d3 Merge branch '-rip' into stable/2.0
This fixes up a lot of RIP/RIPng compliance tests that were still
flagged up.

Tested-by: Martin Winter <mwinter@opensourcerouting.org>
2016-12-05 16:25:58 +01:00
David Lamparter
8ab22cd4be Merge branch '-renato' into stable/2.0
This contains bgp memory leak fixes as well as cleanups to VRF/namespace
handling and has been run through extended testing in Cumulus' testbed:

Tested-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-05 16:23:28 +01:00
Donald Sharp
b6a9e7b487 lib, zebra: Minimize display of link-params sub data
When link-params is configured it auto starts displaying
6000-02# conf t
dell-s6000-02(config)# int swp1
dell-s6000-02(config-if)# link-params
dell-s6000-02(config-link-params)# admin-grp 0x12345678
dell-s6000-02(config-link-params)# end
dell-s6000-02# show run

interface swp1
 link-params
  enable
  metric 0              <----Remove the bw lines
  max-bw 1.25e+06
  max-rsv-bw 1.25e+06
  unrsv-bw 0 1.25e+06
  unrsv-bw 1 1.25e+06
  unrsv-bw 2 1.25e+06
  unrsv-bw 3 1.25e+06
  unrsv-bw 4 1.25e+06
  unrsv-bw 5 1.25e+06
  unrsv-bw 6 1.25e+06
  unrsv-bw 7 1.25e+06
  admin-grp 305419896
  exit-link-params
!

I'd like to reduce this to:

interface enp0s3
 ip igmp
 ip pim sm
 link-params
  enable
  admin-grp 0x12345678    <----- Fix this to be what we entered
  exit-link-params
!

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-05 16:02:46 +01:00
David Lamparter
0b84f29490 *: make DEFUN installations file-local
This moves all install_element calls into the file where the DEFUNs are
located.  This fixes several small related bugs:

- ospf6d wasn't installing a "no interface FOO" command
- zebra had a useless copy of "interface FOO"
- pimd's copy of "interface FOO" was not setting qobj_index, which means
  "description LINE" commands would fail with an error

The next commit will do the actual act of making "foo_cmd" static.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-01 17:25:56 +01:00
Renato Westphal
a62c490110 zebra: order VRFs by name on user output
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:18:35 -02:00
Renato Westphal
1a1a70655c lib: convert vrf code to use red-black trees as well
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:18:35 -02:00
Renato Westphal
f30c50b992 zebra/lib: move some code around
* move netlink code from zebra_nc.c to kernel_netlink.c;
* move vrf CLI commands from if.c/interface.c to vrf.c/zebra_vrf.c;
* move declaration of the 'ns' structure to a header file.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:18:35 -02:00
David Lamparter
82992fed8c Merge branch 'vtysh-grammar'
Conflicts:
	isisd/isisd.c
	lib/Makefile.am
	lib/thread.c

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-28 17:56:29 +01:00
Renato Westphal
b10ce84103 ripd: fix the "neighbor" command.
We can't use if_lookup_prefix() in rip_update_process() because this
function uses prefix_cmp() internally to try matching an interface
address to a static neighbor's address.

Since prefix_cmp() tries to match exact prefixes, if_lookup_prefix()
was always returning NULL.

What we really need here is to use prefix_match(), which checks if
one prefix includes the other (e.g. one /24 interface including a /32
static neighbor's address). The fix then is to replace the call to
if_lookup_prefix() and use if_lookup_address() instead, which uses
prefix_match() internally.

Fixes IxANVL RIP test 17.1

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-25 11:46:06 -02:00
David Lamparter
c5d9d3bb36 lib: replace strlcpy & strlcat with glibc versions
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-15 17:35:36 +09:00
David Lamparter
24f5e2fc62 build: massively remove needless checks
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-11-15 14:23:17 +09:00
Quentin Young
e52702f29d Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	bgpd/bgp_route.c
	bgpd/bgp_routemap.c
	bgpd/bgp_vty.c
	isisd/isis_redist.c
	isisd/isis_routemap.c
	isisd/isis_vty.c
	isisd/isisd.c
	lib/command.c
	lib/distribute.c
	lib/if.c
	lib/keychain.c
	lib/routemap.c
	lib/routemap.h
	ospf6d/ospf6_asbr.c
	ospf6d/ospf6_interface.c
	ospf6d/ospf6_neighbor.c
	ospf6d/ospf6_top.c
	ospf6d/ospf6_zebra.c
	ospf6d/ospf6d.c
	ospfd/ospf_routemap.c
	ospfd/ospf_vty.c
	ripd/rip_routemap.c
	ripngd/ripng_routemap.c
	vtysh/extract.pl.in
	vtysh/vtysh.c
	zebra/interface.c
	zebra/irdp_interface.c
	zebra/rt_netlink.c
	zebra/rtadv.c
	zebra/test_main.c
	zebra/zebra_routemap.c
	zebra/zebra_vty.c
2016-10-17 23:36:21 +00:00
David Lamparter
be301cc256 lib: use qobj for vty->index context position
Prepares the library CLI functions for concurrent config access.  Note
the vty->index pointer is still kept functional for the daemons to use.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-07 09:09:52 -04:00
David Lamparter
e80e7cced3 lib: qobj: register ifaces, routemaps & keychains
This places the appropriate calls so library objects can be used with
qobj "pointers", especially in the CLI.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-07 09:09:51 -04:00
Daniel Walton
58749582a9 all: scrubbed some argc CHECK MEs
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-30 00:16:31 +00:00
Daniel Walton
abddf07563 all: scrubbed some argc CHECK MEs
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-29 19:51:56 +00:00
Daniel Walton
67656e9b65 all: added CHECK ME for DEFUNs that look at argc
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-29 17:48:57 +00:00
Daniel Walton
199d90a10e Expand #defines in command strings
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-25 16:49:39 +00:00
Daniel Walton
9ccf14f739 Expand #defines in command strings
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-25 14:10:48 +00:00
Daniel Walton
c349116d7c lib: add 'int idx_foo' argv index variables
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 20:17:29 +00:00
Daniel Walton
6147e2c694 convert <1-255> to (1-255), ()s to <>s, etc
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 13:47:20 +00:00
Quentin Young
fcbee69056 lib: argv update for if.c
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-22 21:40:28 +00:00
Daniel Walton
bcff2289ed Revert "lib, zebra: Fixup if.c to work in the new regime"
This reverts commit 2511cb40e6.
2016-09-22 18:23:21 +00:00
Donald Sharp
2511cb40e6 lib, zebra: Fixup if.c to work in the new regime
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-20 21:44:37 -04:00
David Lamparter
4a1ab8e405 *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs
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-09-19 16:31:04 -04:00
Olivier Dugeon
16f1b9ee29 Update Traffic Engineering Support for OSPFD
NOTE: I am squashing several commits together because they
do not independently compile and we need this ability to
do any type of sane testing on the patches.  Since this
series builds together I am doing this. -DBS

This new structure is the basis to get new link parameters for
Traffic Engineering from Zebra/interface layer to OSPFD and ISISD
for the support of Traffic Engineering

* lib/if.[c,h]: link parameters struture and get/set functions
* lib/command.[c,h]: creation of a new link-node
* lib/zclient.[c,h]: modification to the ZBUS message to convey the
link parameters structure
* lib/zebra.h: New ZBUS message

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add support for IEEE 754 format

* lib/stream.[c,h]: Add stream_get{f,d} and stream_put{f,d}) demux and muxers to
  safely convert between big-endian IEEE-754 single and double binary
  format, as used in IETF RFCs, and C99.  Implementation depends on host
  using __STDC_IEC_559__, which should be everything we care about.  Should
  correctly error out otherwise.
* lib/network.[c,h]: Add ntohf and htonf converter
* lib/memtypes.c: Add new memeory type for Traffic Engineering support

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add link parameters support to Zebra

* zebra/interface.c:
   - Add new link-params CLI commands
   - Add new functions to set/get link parameters for interface
* zebra/redistribute.[c,h]: Add new function to propagate link parameters
to routing daemon (essentially OSPFD and ISISD) for Traffic Engineering.
* zebra/redistribute_null.c: Add new function
zebra_interface_parameters_update()
* zebra/zserv.[c,h]: Add new functions to send link parameters

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add support of new link-params CLI to vtysh

In vtysh_config.c/vtysh_config_parse_line(), it is not possible to continue
to use the ordered version for adding line i.e. config_add_line_uniq() to print
Interface CLI commands as it completely break the new LINK_PARAMS_NODE.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Update Traffic Engineering support for OSPFD

These patches update original code to RFC3630 (OSPF-TE) and add support of
RFC5392 (Inter-AS v2) & RFC7471 (TE metric extensions) and partial support
of RFC6827 (ASON - GMPLS).

* ospfd/ospf_dump.[c,h]: Add new dump functions for Traffic Engineering
* ospfd/ospf_opaque.[c,h]: Add new TLV code points for RFC5392
* ospfd/ospf_packet.c: Update checking of OSPF_OPTION
* ospfd/ospf_vty.[c,h]: Update ospf_str2area_id
* ospfd/ospf_zebra.c: Add new function ospf_interface_link_params() to get
Link Parameters information from the interface to populate Traffic Engineering
metrics
* ospfd/ospfd.[c,h]: Update OSPF_OPTION flags (T -> MT and new DN)
* ospfd/ospf_te.[c,h]: Major modifications to update the code to new
link parameters structure and new RFCs

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

tmp
2016-09-03 11:05:50 -04:00
Timo Teräs
8ccc7e802b lib, zebra: unify link layer type and hardware address handling
This removes the BSD specific usage of struct sockaddr_dl
hardware address. This unifies to use explict hw_addr member for
the address, and zebra specific enumeration for the link layer
type.

Additionally the zapi is updated to never send platform specific
structures over the wire, but the ll_type along with hw_addr_len
and hw_addr are now sent for all platforms.

Based on initial work by Paul Jakma.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Author:    Timo Teräs <timo.teras@iki.fi>
#
# rebase in progress; onto 9c2f85d
# You are currently editing a commit while rebasing branch 'renato' on '9c2f85d'.
#
# Changes to be committed:
#	modified:   isisd/isis_circuit.c
#	modified:   lib/if.c
#	modified:   lib/if.h
#	modified:   lib/zclient.c
#	modified:   zebra/interface.c
#	modified:   zebra/interface.h
#	modified:   zebra/kernel_socket.c
#	modified:   zebra/rt_netlink.c
#	modified:   zebra/rtadv.c
#	modified:   zebra/zserv.c
#
# Untracked files:
#	"\033\033OA\033OB\033"
#	0001-bgpd-fix-build-on-Solaris.patch
#	ldpd/
#	redhat/ldpd.init
#	redhat/ldpd.service
#	tags
#
2016-09-03 11:05:50 -04:00
Paul Jakma
b892f1ddfe *: use an ifindex_t type, defined in lib/if.h, for ifindex values
(cherry picked from commit 9099f9b2a66e86f8a90d7fe18f61bd2bb1bc6744)
2016-08-18 07:35:38 -04:00
Don Slice
3f6d6a5db8 zebra/ospf/ospf6: Fix several memory leaks on if up/down
Resolved several memory leaks caused by ifdown/ifup the vrf device or
a swp port.  For bgp/zebra/ospf/ospf6, bouncing the vrf device would cause
a linked list, Interface, and route-table to get leaked.  For ospf6,
bouncing the swp device also caused leaks of Connected and Prefix entries.

Ticket: CM-10841
Signed-off-by: Don Slice
Reviewed-By: Donald Sharp
Testing Done: Manual testing, bgp and ospf mins passed, smokes had fewer failures than base
2016-06-28 04:52:38 -07:00
Paul Jakma
1f9a9fffc1 Fix most compiler warnings in default GCC build.
Fix lots of warnings. Some const and type-pun breaks strict-aliasing
warnings left but much reduced.

* bgp_advertise.h: (struct bgp_advertise_fifo) is functionally identical to
  (struct fifo), so just use that.  Makes it clearer the beginning of
  (struct bgp_advertise) is compatible with with (struct fifo), which seems
  to be enough for gcc.
  Add a BGP_ADV_FIFO_HEAD macro to contain the right cast to try shut up
  type-punning breaks strict aliasing warnings.
* bgp_packet.c: Use BGP_ADV_FIFO_HEAD.
  (bgp_route_refresh_receive) fix an interesting logic error in
  (!ok || (ret != BLAH)) where ret is only well-defined if ok.
* bgp_vty.c: Peer commands should use bgp_vty_return to set their return.
* jhash.{c,h}: Can take const on * args without adding issues & fix warnings.
* libospf.h: LSA sequence numbers use the unsigned range of values, and
  constants need to be set to unsigned, or it causes warnings in ospf6d.
* md5.h: signedness of caddr_t is implementation specific, change to an
  explicit (uint_8 *), fix sign/unsigned comparison warnings.
* vty.c: (vty_log_fixed) const on level is well-intentioned, but not going
  to fly given iov_base.
* workqueue.c: ALL_LIST_ELEMENTS_RO tests for null pointer, which is always
  true for address of static variable.  Correct but pointless warning in
  this case, but use a 2nd pointer to shut it up.
* ospf6_route.h: Add a comment about the use of (struct prefix) to stuff 2
  different 32 bit IDs into in (struct ospf6_route), and the resulting
  type-pun strict-alias breakage warnings this causes.  Need to use 2
  different fields to fix that warning?

general:

* remove unused variables, other than a few cases where they serve a
  sufficiently useful documentary purpose (e.g.  for code that needs
  fixing), or they're required dummies.  In those cases, try mark them as
  unused.
* Remove dead code that can't be reached.
* Quite a few 'no ...' forms of vty commands take arguments, but do not
  check the argument matches the command being negated.  E.g., should
  'distance X <prefix>' succeed if previously 'distance Y <prefix>' was set?
  Or should it be required that the distance match the previously configured
  distance for the prefix?
  Ultimately, probably better to be strict about this.  However, changing
  from slack to strict might expose problems in command aliases and tools.
* Fix uninitialised use of variables.
* Fix sign/unsigned comparison warnings by making signedness of types consistent.
* Mark functions as static where their use is restricted to the same compilation
  unit.
* Add required headers
* Move constants defined in headers into code.
* remove dead, unused functions that have no debug purpose.

(cherry picked from commit 7aa9dcef80b2ce50ecaa77653d87c8b84e009c49)

Conflicts:
	bgpd/bgp_advertise.h
	bgpd/bgp_mplsvpn.c
	bgpd/bgp_nexthop.c
	bgpd/bgp_packet.c
	bgpd/bgp_route.c
	bgpd/bgp_routemap.c
	bgpd/bgp_vty.c
	lib/command.c
	lib/if.c
	lib/jhash.c
	lib/workqueue.c
	ospf6d/ospf6_lsa.c
	ospf6d/ospf6_neighbor.h
	ospf6d/ospf6_spf.c
	ospf6d/ospf6_top.c
	ospfd/ospf_api.c
	zebra/router-id.c
	zebra/rt_netlink.c
	zebra/rt_netlink.h
2016-05-26 18:57:39 +00:00
Donald Sharp
38485402bc lib: Fix connected lookup
When looking up the connected route, the delete was
causing crashes in OSPF due to the oi having copies
of the freshly deleted connected interface.  Fix
code to first lookup the connected route and use that
instead of just deleting it.

Valgrind Findings:

==24112== Invalid read of size 1
==24112== at 0x4E8283F: ospf_intra_add_stub (ospf_route.c:614)
==24112== by 0x4E80B15: ospf_spf_process_stubs (ospf_spf.c:1064)
==24112== by 0x4E80F74: ospf_spf_calculate (ospf_spf.c:1269)
==24112== by 0x4E811C9: ospf_spf_calculate_timer (ospf_spf.c:1339)
==24112== by 0x5126230: thread_call (thread.c:1577)
==24112== by 0x401E00: main (ospf_main.c:377)
==24112== Address 0x7f56a09 is 9 bytes inside a block of size 40 free'd
==24112== at 0x4C29E90: free (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24112== by 0x51290B3: zfree (memory.c:132)
==24112== by 0x51287F0: connected_free (if.c:987)
==24112== by 0x514406A: zebra_interface_address_read (zclient.c:1146)
==24112== by 0x4E5A81C: ospf_interface_address_add (ospf_zebra.c:262)
==24112== by 0x5144838: zclient_read (zclient.c:1397)
==24112== by 0x5126230: thread_call (thread.c:1577)
==24112== by 0x401E00: main (ospf_main.c:377)

Ticket: CM-10890
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-05-12 13:19:58 -04:00
Donald Sharp
bd40c341ee lib: refactor connected_lookup_prefix
The connected_lookup_address function should really
be a connected_lookup_prefix function.  Refactor
the code to use it.

Ticket: CM-10890
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-05-12 10:03:44 -04:00
Donald Sharp
58255d3440 lib, zebra: Refactor vrf creation a bit more
Create the idea of a VRF_UNKNOWN, this is for a vrf where we don't
yet have the vrf_id for it yet.

Refactor the vrf_create code out of existence.  We had two code
paths vrf_create and vrf_get.  We should use vrf_get to create
the new vrf since XXX_get() creates the data structures now.

Signed-off-by: Donald Sharp
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-04-12 20:19:28 -04:00
Donald Sharp
b2d7c082a2 quagga: Remove iflist global variable
The file if.c has a iflist that had the list of interfaces
in the default vrf.  Remove this variable and replace
with a vrf_iflist lookup on the default vrf where it
was used.

Additionally, modify ptm code to iterate over all vrf's
when enabling ptm.

Ticket: CM-10338
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Radhika Mahankali <radhika@cumulusnetworks.com>
2016-04-08 13:15:59 -04:00
Donald Sharp
79694123fd lib, zebra: Rename ZEBRA_VRF_ACTIVE
ZEBRA_VRF_ACTIVE is a poor name for when a vrf is
actually active.  Rename VRF_ACTIVE.

Ticket: CM-10338
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Radhika Mahankali <radhika@cumulusnetworks.com>
2016-04-08 13:15:41 -04:00
Donald Sharp
eaa9cafdce lib: Refactor XX_name_len away
We had two functions XXX_name and XXX_name_len
that both did the same thing.  Remove the
XXX_rename_len functions.

Ticket: CM-10338
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Radhika Mahankali <radhika@cumulusnetworks.com>
2016-04-08 13:14:00 -04:00
Donald Sharp
974fc9d251 lib: Combine name comparison function
The vrf name comparison function was the same as the interface
comparison function.  Combine the forces for the goodness of
mankind.

Ticket: CM-10184
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-03-31 14:00:29 -04:00
Donald Sharp
f896287128 bgpd, lib, zebra: Add ability to retrieve ifp without specifying a vrf
There are cases where we get an interface name but do not have a
corresponding vrf.  We care about getting an interface pointer
so just provide a function that searches all vrf's for the ifp.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Radhicak Mahankali <radhika@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-03-23 12:38:30 -07:00
vivek
53eadacfc0 Quagga: Fix interface move from VRF to default VRF
Ensure that during interface lookup (non-vty context), if the interface is
found in a different VRF, it is "moved" into the requested VRF.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>

Ticket: CM-9579
Reviewed By: CCR-4194
Testing Done: Manual
2016-02-28 03:06:35 +00:00
Don Slice
85f9da7f78 zebra: fix interface lookup for vrf configuration
Ticket:CM-9073
Reviewed By: sharpd
Testing Done:Manual, see ticket

Changed logic when "interface swpxx <vrf foo>" entered so that:

1. it matches when the command is entered without a vrf but the interface already exists in a vrf.
2. If the command is entered with a vrf name that is different than is defined by the kernel, the command is rejected.
3. If the call is made from other than the vty session, believe the new information and update the vrf accordingly.
2016-02-10 13:01:16 -08:00
Donald Sharp
f93e3f696c lib: Allow vrf under the cli
Add the infrastructure to allow the vrf keyword.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-02-01 09:38:33 -08:00
Donald Sharp
70d43d7cd3 Quagga: Fixup decision about what an unnumbered interface is
This Change modifies what zebra thinks is an unnumbered interface.
If the interface is not a loopback and the prefixlength for the
interface is 32 than consider this an unnumbered interface.

Ticket: CM-8016
Reviewed by: CCR-3827
Testing: Full Regression Suites

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-11-20 07:10:47 -08:00
Feng Lu
cd2a8a42e1 lib, zebra, vtysh: configure an interface in non-default VRF
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>

Conflicts:
	zebra/interface.c
2015-10-29 18:08:53 -07:00
Feng Lu
8736158a2b lib: move the interface list into "struct vrf"
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>

Conflicts:
	lib/if.c
2015-10-29 17:25:55 -07:00
Feng Lu
3968dbf8ef lib, zebra: add "vrf_id" into the "struct interface"
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>

Conflicts:
	lib/if.c
	zebra/interface.c
2015-10-29 16:49:39 -07:00
Dinesh G Dutt
0aabccc0a8 Zebra: Add IPv6 protocol filtering support & Setting Src of IPv6 routes
Ticket:
Reviewed By: CCR-3335
Testing Done: bgpsmoke, ENHE tests etc.

    Add support for filtering routes from upper layer protocols to zebra
    via route-maps for IPv6. The same functionality already existed for
    IPv4.

    In addition, add support for setting source of routes via IPv6 protocol
    map.

    Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
    Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
    Reviewed-by: Vivek Venkataraman <vivek@cumulusnetworks.com>
    Reviewed-by: Vipin Kumar <vipin@cumulusnetworks.com>
2015-09-15 23:48:00 -07:00
Donald Sharp
24873f0c06 lib: lib-warnings.patch
Remove compile warnings for the lib directory
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:
2015-05-19 18:04:26 -07:00
Donald Sharp
525c183906 Unnumbered interface support. 2015-05-19 17:58:13 -07:00
Donald Sharp
244c1cdce5 ptm-integration.patch
Integrates Prescriptive Topology Module(ptm) into quagga.

If this module is enabled, link ups are notified only after the link is verified
as being connected to the neighbor specified. The neighbor specification and
checking is done by the ptm daemon.
2015-05-19 17:40:44 -07:00
Donald Sharp
a80beece64 'neighbor <if-name> interface' config support in BGP including RA/Zebra changes.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
             Dinesh Dutt <ddutt@cumulusnetworks.com>
2015-05-19 17:40:40 -07:00
Donald Sharp
c9506a0a6e zebra-enable-link-detect-by-default.patch
zebra: Set link-detect on by default

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt at cumulusnetworks.com>
Reviewed-by: Scott Feldman <sfeldma at cumulusnetworks.com>
2015-05-19 16:33:52 -07:00
David Lamparter
6b0655a251 *: nuke ^L (page feed)
Quagga sources have inherited a slew of Page Feed (^L, \xC) characters
from ancient history.  Among other things, these break patchwork's
XML-RPC API because \xC is not a valid character in XML documents.

Nuke them from high orbit.

Patches can be adapted simply by:
	sed -e 's%^L%%' -i filename.patch
(you can type page feeds in some environments with Ctrl-V Ctrl-L)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-06-04 06:58:02 +02:00
Dinesh Dutt
b81e97a8a7 ospf6d: correct nexthop through directly connected networks
This is implementing this part of RFC 2328:

This is the "first case", see below,

16.1.1. The next hop calculation

...
If there is at least one intervening router in the current
shortest path between the destination and the root, the
destination simply inherits the set of next hops from the
parent. Otherwise, there are two cases. In the first case,
the parent vertex is the root (the calculating router
itself). This means that the destination is either a
directly connected network or directly connected router.
The outgoing interface in this case is simply the OSPF
interface connecting to the destination network/router.
...

The current Quagga code always tries to inherit the nexthop from
a parent vertex, but does not cover the case that the destination
is directly connected to the root vertex. This patch adds support
for that case.

Signed-off-by: James Li <jli at cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt at cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-11-07 18:15:43 -08:00
Avneesh Sachdev
14d2bbaa3f Merge quagga mainline into the google ISIS code.
The steps were:

  $ git checkout google-is-is
  $ git merge quagga
  $ git checkout google-is-is -- isisd

  # Resolve conflicts in the following:
  lib/md5.h
  zebra/rt_netlink.c
  zebra/zebra_rib.c
  zebra/zserv.c

Note that the content in the isisd directory is left unchanged in the
merge. As a result, changes made to isisd as part of the following
commits on the quagga mainline are dropped.

  # 8ced4e82 is the merge base, e96b3121 is the current quagga master
  $ git log --oneline --reverse 8ced4e82..e96b3121 -- isisd
  5574999 isisd: fix crash on "no router isis" (BZ#536)
  8998075 isisd: raise hello rate for DIS (BZ#539)
  306ca83 isisd: include hash.h, not hash.c
  b82cdeb delete CVS keywords
  2f65867 isisd: indent longopts array
  b511468 quagga: option "-z" ("--socket <path>") added
  05e54ee build: delete .cvsignore files
  b4e45f6 fix zebra protocol after MP-BGP changes
  7fd6cd8 isisd: fix circuit state machine
  907fd95 isisd: send proper LSP after DIS election
  d034aa0 isisd: fix wrong next-hops from SPF
  c25eaff isisd: unexpected kernel routing table (BZ#544)
  e6b03b7 isisd: implement MD5 circuit authentication
2012-04-11 23:51:08 -07:00
Josh Bailey
2dd04c5dc8 lib: Tweak to if_delete_retain()
* lib/if.c: Change if_delete_retain() to delete all connected
    addresses, but to not free the list that holds them. Free the list
    just before the interface structure itself is freed, in
    if_delete().
2012-04-08 01:18:41 -07:00
Paul Jakma
23be94ea00 lib/if: trivial, fix rarely used if debug function to print everything
* if.c: (if_dump) loop that doesn't do anything, wants to be
  before the zlog of what it's meant to print out so all the connected
  addresses get printed out. Trival: just a debug function
2012-01-06 16:19:36 +00:00