Commit Graph

415 Commits

Author SHA1 Message Date
David Lamparter
ab04f34ff8
Merge pull request #3860 from AkhileshSamineni/show_bgp_af_neigh_fix
bgpd: 'show bgp [ipv4|ipv6] neighbors' displays all address family neighbors
2019-03-11 19:43:05 +01:00
Akhilesh Samineni
210ec2a0d6 bgpd: Incorrect number of peers count in "show bgp ipv6 summary output
The "show bgp ipv6 summary" output displays incorrect number of peers count.

sonic# show bgp ipv6 summary

IPv6 Unicast Summary:
BGP router identifier 10.1.0.1, local AS number 65100 vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 5, using 103 KiB of memory
Peer groups 1, using 64 bytes of memory

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2003::1 4 65099 0 0 0 0 0 never Active
2088::1 4 65100 0 0 0 0 0 never Active
3021::2 4 65100 0 0 0 0 0 never Active

Total number of neighbors 3
sonic#
In the above output, the peers count displays as 5 but the actual peer count is 3, i.e.. 3 neighbors are activated in ipv6 unicast address family.
Displayed peer count (5) is the number of the neighbors activated in a BGP instance.

Fix : Now the peers count displays the number of neighbors activated per afi/safi.
After Fix:
sonic# show bgp ipv6 summary

IPv6 Unicast Summary:
BGP router identifier 10.1.0.1, local AS number 65100 vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 3, using 62 KiB of memory
Peer groups 1, using 64 bytes of memory

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2003::1 4 65099 0 0 0 0 0 never Active
2088::1 4 65100 0 0 0 0 0 never Active
3021::2 4 65100 0 0 0 0 0 never Active

Total number of neighbors 3
sonic#

Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
2019-03-07 13:17:25 +05:30
vivek
0483af6e4c zebra, bgpd: Exchange L3 interface for VRF's VNI
In the case of EVPN symmetric routing, the tenant VRF is associated with
a VNI that is used for routing and commonly referred to as the L3 VNI or
VRF VNI. Corresponding to this VNI is a VLAN and its associated L3 (IP)
interface (SVI). Overlay next hops (i.e., next hops for routes in the
tenant VRF) are reachable over this interface.

https://tools.ietf.org/html/draft-ietf-bess-evpn-prefix-advertisement
section 4.4 provides additional description of the above constructs.

The implementation currently derives this L3 interface for EVPN tenant
routes using special code that looks at route flags. This patch
exchanges the L3 interface between zebra and bgpd as part of the L3-VNI
exchange in order to eliminate some this special code.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-27 11:52:34 +00:00
Akhilesh Samineni
d1927ebe5f bgpd: 'show bgp [ipv4|ipv6] neighbors' displays all address family neighbors
Display only ipv4 neighbors when 'show bgp ipv4 neighbors' command is issued.
Display only ipv6 neighbors when 'show bgp ipv6 neighbors' command is issued.
Take the address family of the peer address into account, while displaying the neighbors.

Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
2019-02-24 15:00:31 +05:30
Donatas Abraitis
9dac9fc80e bgpd: Implement RFC8212
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-02-17 23:17:00 +02:00
Donald Sharp
2b697c3d47
Merge pull request #3414 from pguibert6WIND/iprule_any_flowspec_handling_2
Iprule any flowspec handling
2019-01-29 14:01:38 -05:00
Philippe Guibert
27e376d4e1 bgpd: an hash list of pbr iprule is created
that iprule list stands for the list of fs entries that are created,
based only on ip rule from/to rule.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-01-29 14:15:09 +01:00
Don Slice
faa16034cb bgpd: improve peer-group remote-as definitions
Problem reported that with certain sequences of defining the
remote-as on the peer-group and the members, the configuration would
become wrong, with configured remote-as settings not reflected in
the config but peers unable to come up.  This fix resolves these
inconsistencies.

Ticket: CM-19560
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-01-23 12:23:47 +00:00
Renato Westphal
1c4213d862
Merge pull request #3198 from donaldsharp/mac_rejection
Mac rejection
2019-01-10 11:21:18 -02:00
Lou Berger
943d595a01 bgpd: don't use BGP_ATTR_VNC(255) unless ENABLE_BGP_VNC_ATTR is defined
Signed-off-by: Lou Berger <lberger@labn.net>
2019-01-07 11:51:06 -05:00
Donald Sharp
48ecf8f510 bgpd: Add code to dump the forthcoming mac hash
Add a bit of code that allows us to dump the mac hash.  Future
commits will actually add entries to the mac hash and then operate
on it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-12 16:11:45 -05:00
Russ White
19e5a46591
Merge pull request #3176 from chiragshah6/evpn_dev
zebra: duplicate address detection and dampening
2018-11-25 22:17:33 -05:00
Mark Stapp
fb88590c77
Merge pull request #3359 from qlyoung/true-atomics
Restrict atomics to 32-bits only
2018-11-20 11:43:10 -05:00
Quentin Young
0545c37384 *: only use 32-bit atomics
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-11-19 18:44:35 +00:00
root
36dc75886d bgpd: Creating Loopback Interface Flaps BGPd (#2865)
* The function bgp_router_id_zebra_bump() will check for active bgp
  peers before chenging the router ID.
  If there are established peers, router ID is not modified
  which prevents the flapping of established peer connection

* Added field in bgp structure to store the count of established peers

Signed-off-by: kssoman <somanks@vmware.com>
2018-11-19 04:35:32 -08:00
Chirag Shah
85c8d83b81 bgpd: dup addr detect data struct for cfg
Enable/disable duplicate address detection
there are 3 actions
warning-only: Default action which generates
only frr warning (syslog) to user for any
duplicate detecton
freeze: Permanently freezes address, manual
intervene required.
freeze with time: An address will recover once
the time has expired (auto-recovery).

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-11-17 19:22:16 -08:00
Philippe Guibert
0b014ea675 bgpd: allow vrf validity and bgp vrf import/export, when zebra is off
if zebra is not started, then vrf identifiers are not available. This
prevents import/exportation to be available. This commit permits having
import/export available, even when zebra is not started.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-11-13 15:29:11 +01:00
Mitch Skiba
dcc68b5e2a bgpd: Re-use TX Addpath IDs where possible
The motivation for this patch is to address a concerning behavior of
tx-addpath-bestpath-per-AS. Prior to this patch, all paths' TX ID was
pre-determined as the path was received from a peer. However, this meant
that any time the path selected as best from an AS changed, bgpd had no
choice but to withdraw the previous best path, and advertise the new
best-path under a new TX ID. This could cause significant network
disruption, especially for the subset of prefixes coming from only one
AS that were also communicated over a bestpath-per-AS session.

The patch's general approach is best illustrated by
txaddpath_update_ids. After a bestpath run (required for best-per-AS to
know what will and will not be sent as addpaths) ID numbers will be
stripped from paths that no longer need to be sent, and held in a pool.
Then, paths that will be sent as addpaths and do not already have ID
numbers will allocate new ID numbers, pulling first from that pool.
Finally, anything left in the pool will be returned to the allocator.

In order for this to work, ID numbers had to be split by strategy. The
tx-addpath-All strategy would keep every ID number "in use" constantly,
preventing IDs from being transferred to different paths. Rather than
create two variables for ID, this patch create a more generic array that
will easily enable more addpath strategies to be implemented. The
previously described ID manipulations will happen per addpath strategy,
and will only be run for strategies that are enabled on at least one
peer.

Finally, the ID numbers are allocated from an allocator that tracks per
AFI/SAFI/Addpath Strategy which IDs are in use. Though it would be very
improbable, there was the possibility with the free-running counter
approach for rollover to cause two paths on the same prefix to get
assigned the same TX ID. As remote as the possibility is, we prefer to
not leave it to chance.

This ID re-use method is not perfect. In some cases you could still get
withdraw-then-add behaviors where not strictly necessary. In the case of
bestpath-per-AS this requires one AS to advertise a prefix for the first
time, then a second AS withdraws that prefix, all within the space of an
already pending MRAI timer. In those situations a withdraw-then-add is
more forgivable, and fixing it would probably require a much more
significant effort, as IDs would need to be moved to ADVs instead of
paths.

Signed-off-by Mitchell Skiba <mskiba@amazon.com>
2018-11-10 00:16:36 +00:00
Don Slice
5742e42b98 bgpd: make name of default vrf/bgp instance consistent
Problems were reported with the name of the default vrf and the
default bgp instance being different, creating confusion.  This
fix changes both to "default" for consistency.

Ticket: CM-21791
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: CCR-7658
Testing: manual testing and automated tests before pushing
2018-10-31 06:20:37 -04:00
Russ White
79e8a97c1a
Merge pull request #3024 from ton31337/fix/validate_route-map
bgpd: Check if route-map really exists before applying to the peer
2018-10-14 08:48:48 -04:00
Donald Sharp
fd06964433 bgpd: Add '[no] flood <disable|head-end-replication>'
Add the '[no] flood <disable|head-end-replication>' command
to the l2vpn evpn afi/safi sub commands for bgp.  This command
when entered as 'flood disable' will turn off type 3 route
generation for the transmittal of the type 3 route necessary
for BUM replication on the remote VTEP.  Additionally it will
turn off the BUM handling via the new zebra command,
ZEBRA_VXLAN_FLOOD_CONTROL.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-11 20:27:28 -04:00
Donatas Abraitis
1de2762153 bgpd: Check if route-map really exists before applying to the peer
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2018-10-11 10:56:12 +03:00
Lou Berger
d127c61aeb
Merge pull request #3010 from opensourcerouting/no-frr-thread-id
lib: frr_pthread minor simplification
2018-09-22 15:02:09 -04:00
David Lamparter
1ac267a2d9 lib: remove frr_pthread->id
All I can see is an unneccessary complication.  If there's some purpose
here it needs to be documented...

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-19 22:01:46 +02:00
paco
f533be73f6
bgpd, doc, ldpd, lib, tests, zebra: LM fixes
Corrections so that the BGP daemon can work with the label manager properly
through a label-manager proxy. Details:

- Correction so the BGP daemon behind a proxy label manager gets the range
  correctly (-I added to the BGP daemon, to set the daemon instance id)
- For the BGP case, added an asynchronous label manager connect command so
  the labels get recycled in case of a BGP daemon reconnection. With this,
  BGPd and LDPd would behave similarly.

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-18 17:39:16 +02:00
Donald Sharp
17cdd31e00 bgpd: Prevent possible crash when parsing v6 attributes
The peer->nexthop.ifp pointer must be set when parsing the
attributes in bgp_mp_reach_parse, notice this
and fail gracefully.

Rework bgp_nexthop_set to remove the HAVE_CUMULUS and to
fail the nexthop_set when we have a zebra connection and
no ifp pointer, as that not havinga zebra connection and
no ifp pointer is legal.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-12 09:00:43 -04:00
Don Slice
94d4c685c5 bgpd/ospfd: resolve warnings for bgp/ospf json commit
Signed-off-by: Don Slice <dslice@cumulusnetwork.com>
2018-08-30 15:54:46 +00:00
Don Slice
9f049418bc bgpd/ospfd: make bgp and ospf json response a bit more consistent
Problem reported that some bgp and ospf json commands did not return
any json output at all if the bgp/ospf instance did not exist.
Additionally, some bgp and ospf json commands did not return any json
output if the instance existed but no neighbors were defined.  This
fix makes these commands more consistent in returning empty braces for
json output and issue a message if not using json output.  Additionally,
made the flag "use_json" a bool to make it consistent since previously,
it had been defined as an int, char, u_char, and bool at various places.

Ticket: CM-21040
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-30 12:40:18 +00:00
Pascal Mathis
3f54c705ec
bgpd: Cleanup of bgp daemon code
This commit removes various parts of the bgpd implementation code which
are unused/useless, e.g. unused functions, unused variable
initializations, unused structs, ...

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-07-07 22:51:13 +02:00
Pascal Mathis
a14810f43f
bgpd: Implement group-overrides for peer attrs
This commit introduces BGP peer-group overrides for the last set of
peer-level attrs which did not offer that feature yet. The following
attributes have been implemented: description, local-as, password and
update-source.

Each attribute, with the exception of description because it does not
offer any inheritance between peer-groups and peers, is now also setting
a peer-flag instead of just modifying the internal data structures. This
made it possible to also re-use the same implementation for attribute
overrides as already done for peer flags, AF flags and AF attrs.

The `no neighbor <neigh> description` command has been slightly changed
to support negation for no parameters, one parameter or * parameters
(LINE...). This was needed for the test suite to pass and is a small
change without any bigger impact on the CLI.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-14 18:55:32 +02:00
Pascal Mathis
b90a8e13ee
bgpd: Implement group-overrides for peer timers
This commit implements BGP peer-group overrides for the timer flags,
which control the value of the hold, keepalive, advertisement-interval
and connect connect timers. It was kept separated on purpose as the
whole timer implementation is quite complex and merging this commit
together with with the other flag implementations did not seem right.

Basically three new peer flags were introduced, namely
*PEER_FLAG_ROUTEADV*, *PEER_FLAG_TIMER* and *PEER_FLAG_TIMER_CONNECT*.
The overrides work exactly the same way as they did before, but
introducing these flags made a few conditionals simpler as they no
longer had to compare internal data structures against eachother.

Last but not least, the test suite has been adjusted accordingly to test
the newly implemented flag overrides.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-14 18:55:30 +02:00
Pascal Mathis
e7103a9644
bgpd: Fix AF-attribute overrides when binding peer
The current implementation of the overrides for peer address-family
attributes suffered a bug, which caused all peer-specific attributes to
be lost when the peer was added to a peer-group which already had that
specific address-family active.

This commit extends the *peer_group2peer_config_copy_af* function to
respect overridden flags properly. Additionally, the arguments of the
macros *PEER_ATTR_INHERIT* and *PEER_STR_ATTR_INHERIT* have been
reordered to be more consistent and easy to read.

This commit also adds further test cases to the BGP peer attributes test
suite, so that this kind of error is being caught in future commits. The
missing AF-attribute *distribute-list* has also been added to the test
suite.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-14 18:55:25 +02:00
Pascal Mathis
9fb964de21
bgpd: Implement group-overrides for peer flags
The current implementation of peer flags (e.g. shutdown, passive, ...)
only has partial support for overriding flags of a peer-group when the
peer is a member. Often settings might get lost if the user toys around
with the peer-group configuration, which can lead to disaster.

This commit introduces the same override implementation which was
previously integrated to support proper peer flag/attribute override on
the address-family level. The code is very similar and the global
attributes now use their separate state-arrays *flags_invert* and
*flags_override*.

The test suite for BGP peer attributes was extended to also check peer
global attributes, so that the newly introduced changes are covered. An
additional feature was added which allows to test an attribute with an
*interface-peer*, which can be configured by running `neighbor IF-TEST
interface`. This was introduced so that the dynamic runtime inversion of
the `extended-nexthop` flag, which is only enabled by default for
interface peers, can also be tested.

Last but not least, two small changes have been made to the current bgpd
implementation:

- The command `strict-capability-match` can now also be set on a
peer-group, it seems like this command slipped through while
implementing peer-groups in the very past.

- The macro `COND_FLAG` was introduced inside lib/zebra.h, which now
allows to either set or unset a flag based on a condition. The syntax
for using this macro is: `COND_FLAG(flag_variable, flag, condition)`

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-14 18:55:18 +02:00
paco
cc32742c09
bgpd: null check (Coverity 1399270)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-13 17:15:21 +02:00
Quentin Young
483e5a3aa5
Merge pull request #2304 from ppmathis/enhancement/bgp-pg-overrides
bgpd: Add proper support for overriding peer-group AF-flags/filters
2018-06-05 11:51:57 -04:00
Donald Sharp
3b7268448f
Merge pull request #2259 from ppmathis/enhancement/peer-enforce-first-as
bgpd: Move 'enforce-first-as' from global to peer
2018-06-04 09:35:00 -04:00
mitesh
50f74cf131 *: support for evpn type-4 route
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-05-30 07:48:20 -04:00
Pascal Mathis
cf9ac8bfb0
bgpd: Fix style issues for peer-group overrides
This commit fixes all outstanding style/formatting issues as detected by
'git clang-format' or 'checkpath' for the new peer-group override
implementation, which spanned across several commits.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-28 19:25:51 +02:00
Pascal Mathis
27c05d4d43
bgpd: Fix group overrides for inverted AF flags
This commit fixes peer-group overrides for inverted AF flags. This
implementation is currently only being used by the three 'send-community'
flags. Commit 70ee29b4d introduced generic support for overriding AF
flags, but did not support inverted flags.

By introducing an additional array on the BGP peer structure called
'af_flags_invert' all current and future flags which should work in an
inverted way can now also be properly overridden.

The CLI commands will work exactly the same way as before, just that 'no
<command>' now sets the flag and override whereas '<command>' will unset
the flag and remove the override.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-28 19:20:25 +02:00
Pascal Mathis
70ee29b4db
bgpd: Improve group overrides for AF filters
This commit adds the same peer-group override capabilites as d122d7cf7
for all filter/map options that can be enabled/disabled on each
address-family of a BGP peer.

All currently existing filter/map options are being supported:
filter-list, distribute-list, prefix-list, route-map and unsuppress-map

To implement this behavior, a new peer attribute 'filter_override' has
been added together with various PEER_FT_ (filter type) constants for
tracking the state of each filter in the same way as it is being done
with 'af_flags_override'.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-27 19:41:25 +02:00
Pascal Mathis
598ce6bd70
bgpd: Improve group overrides for AF flags
The current implementation for overriding peer-group configuration on a
peer member consists of several bandaids, which introduce more issues
than they fix. A generic approach for implementing peer-group overrides
for address-family flags is clearly missing.

This commit implements a generic and sane approach to overriding
peer-group configuration on a peer-member. A separate peer attribute
called 'af_flags_override' which was introduced in 04e1c5b is being used
to keep track of all address-family flags, storing whether the
configuration is being inherited from the parent-group or overridden.

All address-family flags are being supported by this implementation
(note: flags, not filters/maps) except 'send-community', which currently
breaks due to having the three flags enabled by default, which is not
being properly handled within this commit; all flags are supposed to
have an 'off'/'false' state by default.

In the interest of readability and comprehensibility, the flag
'send-community' is being fixed in a separate commit.

The following rules apply when looking at the new peer-group override
implementation this commit provides:

- Each peer-group can enable every flag (except the limitations noted
above), which gets automatically inherited to all members.

- Each peer can enable each flag independently and/or modify their
value, if available. (e.g.: weight <value>)

- Each command executed on a neighbor/peer gets explicitely set as an
override, so even when the peer-group has the same kind of
configuration, both will show up in 'show running-configuration'.

- Executing 'no <command>' on a peer will remove the peer-specific
configuration and make the peer inherit the configuration from the
peer-group again.

- Executing 'no <command>' on a peer-group will only remove the flag
from the peer-group, however not from peers explicitely setting that
flag.

This guarantees a clean implementation which does not break, even when
constantly messing with the flags of a peer-group. The same behavior is
present in Cisco devices, so people familiar with those should feel safe
when dealing with FRRs peer-groups.

The only restriction that now applies is that single peer cannot
disable a flag which was set by a peer-group, because 'no <command>' is
already being used for disabling a peer-specific override. This is not
supported by any known vendor though, would require many specific
edge-cases and magic comparisons and will most likely only end up
confusing the user. Additionally, peer-groups should only contain flags
which are being used by all peer members.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-27 19:41:23 +02:00
Philippe Guibert
4762c2137d bgpd: add vty command to restrict FS policy routing to a defined interface
policy routing is configurable via address-family ipv4 flowspec
subfamily node. This is then possible to restrict flowspec operation
through the BGP instance, to a single or some interfaces, but not all.

Two commands available:
[no] local-install [IFNAME]

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-05-25 15:49:38 +02:00
Pascal Mathis
47cbc09b63
bgpd: Move 'enforce-first-as' from global to peer
This commit moves the command 'bgp enforce-first-as' from global BGP
instance configuration to peer/neighbor configuration, which can now be
changed by executing '[no] neighbor <neighbor> enforce-first-as'.

End users can now enforce sane first-AS checking on regular sessions
while e.g. disabling the checks on routeserver sessions, which usually
strip away their own AS number from the path.

To ensure backwards-compatibility, a migration routine was added which
automatically sets the 'enforce-first-as' flag on all configured
neighbors if the old global setting was activated. The old global
command immediately disappears after running the migration routine once.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-19 14:43:42 +02:00
Donald Sharp
51f9d3e70f
Merge pull request #2034 from vincentbernat/fix/rfc8365-auto-rt
bgpd: add an option for RT auto-derivation to use RFC 8635.
2018-05-16 12:13:04 -04:00
Russ White
2d6d27bcf1
Merge pull request #2196 from LabNConsulting/working/master/bgpd-shutdown-race
BGP: Preclude race condition between listener thread and core during shutdown
2018-05-12 06:27:00 -04:00
Lou Berger
97b4a0ec78 bgpd: block io thread reads once shutdown has started
Signed-off-by: Lou Berger <lberger@labn.net>
2018-05-10 08:47:11 -04:00
Quentin Young
04e1c5bb4a bgpd: fix maximum-prefix + peer-group
Attribute set on peer was being overridden when set on the peer-group.

This commit also adds a parallel flags array that indicates whether a
particular flag is sourced from the peer-group or is peer-specific. It
assumes the default state of all flags is unset. This looks to be true
except in the case of PEER_FLAG_SEND_COMMUNITY,
PEER_FLAG_SEND_EXT_COMMUNITY, and PEER_FLAG_SEND_LARGE_COMMUNITY; these
flags are set by default except when the user specifies to use
config-type = cisco. However the flag field can merely be flipped to
mean the negation of those options in a future commit.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-07 14:44:10 -04:00
Philippe Guibert
f3d32faaed bgpd: initialise hash lists for pbr
bgp structure is being extended with hash sets that will be used by
flowspec to give policy routing facilities.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-30 11:56:23 +02:00
Don Slice
a8dadcf6cc bgpd: add ability to import default vrf routes
signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-04-25 12:39:17 -04:00
Donald Sharp
1d4e8b0d99 bgpd: Add some vrf <-> vrf code comments
Note that when we are importing vrf EVA into vrf DONNA
we must keep track of all the vrfs EVA is being
exported into and we must also keep track of all the vrf's
that DONNA is receiving data from as well.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-25 12:39:17 -04:00
vivek
92708db6c3 bgpd: Auto RD definitions and encoding
Setup a per-VRF identifier to use along with the Router Id to build the
RD. Define a function to encode the RD. Code is brought over from EVPN
and EVPN code has been modified to use the generic function.

Ticket: CM-20256
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-04-25 12:39:16 -04:00
Mitesh Kanjariya
f4882003c6 bgpd: resolve flag definition confict for af_flags under bgp vrf
afi/safi flags defined under bgp vrf needs to be unique across afi/safi.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-04-25 12:39:16 -04:00
Donald Sharp
12a844a506 bgpd: Implement vrf - vrf route leaking cli
add the `import vrf XXXX` command

router bgp 4 vrf DONNA
  <config>
!

router bgp 4 vrf EVA
  <config>
  address-family ipv4 uni
    import vrf DONNA
  !
!

This command will allow for vrf EVA to specify that it would like
to receive the routes from vrf DONNA into it's table.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-25 12:39:16 -04:00
Vincent Bernat
bf1061d876 bgpd: add an option for RT auto-derivation to use RFC 8635.
RFC 8635 explains how RT auto-derivation should be done in section
5.1.2.1 [1]. In addition to encoding the VNI in the lowest bytes, a
3-bit field is used to encode a namespace. For VXLAN, we have to put 1
in this field. This is needed for proper interoperability with RT
auto-derivation in JunOS. Since this would break existing setup, an
additional option, "autort rfc8365-compatible" is used.

[1]: https://tools.ietf.org/html/rfc8365#section-5.1.2.1

Signed-off-by: Vincent Bernat <vincent@bernat.im>
2018-04-23 17:05:23 +02:00
G. Paul Ziemba
e70e9f8e24 bgpd: vpn-vrf leaking: use dynamic label pool for "auto" labels
Add support for CLI "auto" keyword in vrf->vpn export label:

    router bgp NNN vrf FOO
	address-family ipv4 unicast
	    label vpn export auto
	exit-address-family

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-04-11 23:18:35 -07:00
G. Paul Ziemba
955bfd984f bgpd: dynamic mpls label pool
MPLS label pool backed by allocations from the zebra label manager.

A caller requests a label (e.g., in support of an "auto" label
specification in the CLI) via lp_get(), supplying a unique ID and
a callback function. The callback function is invoked at a later
time with the unique ID and a label value to inform the requestor
of the assigned label.

Requestors may release their labels back to the pool via lp_release().

The label pool is stocked with labels allocated by the zebra label
manager. The interaction with zebra is asynchronous so that bgpd
is not blocked while awaiting a label allocation from zebra.

The label pool implementation allows for bgpd operation before (or
without) zebra, and gracefully handles loss and reconnection of
zebra. Of course, before initial connection with zebra, no labels
are assigned to requestors. If the zebra connection is lost and
regained, callbacks to requestors will invalidate old assignments
and then assign new labels.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-04-11 23:18:28 -07:00
G. Paul Ziemba
3572fb26ca bgpd: simplify bgp instance name printing
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-04-04 09:24:17 -07:00
jaydom
7c40bf391c bgpd: add flowspec feature
This work is derived from a work done by China-Telecom.
That initial work can be found in [0].
As the gap between frr and quagga is important, a reworks has been
done in the meantime.
The initial work consists of bringing the following:
- Bringing the client side of flowspec.
- the enhancement of address-family ipv4/ipv6 flowspec
- partial data path handling at reception has been prepared
- the support for ipv4 flowspec or ipv6 flowspec in BGP open messages,
  and the internals of BGP has been done.
- the memory contexts necessary for flowspec has been provisioned

In addition to this work, the following has been done:
- the complement of adaptation for FS safi in bgp code
- the code checkstyle has been reworked so as to match frr checkstyle
- the processing of IPv6 FS NLRI is prevented
- the processing of FS NLRI is stopped ( temporary)

[0] https://github.com/chinatelecom-sdn-group/quagga_flowspec/

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: jaydom <chinatelecom-sdn-group@github.com>
2018-03-30 14:00:47 +02:00
Lou Berger
615e608d76
Merge pull request #1854 from qlyoung/integer-standards-compliance
*: use C99 standard fixed-width integer types
2018-03-28 10:30:54 -04:00
Quentin Young
d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27 15:13:34 -04:00
Philippe Guibert
301ad80a99 bgpd: add an API to get incoming VRF from a RT
This commit is relying on bgp vpn-policy. It is needed to configure
several bgp vrf instances, and in each of the bgp instance, configure
the following command under address-family ipv4 unicast node:
[no] rt redirect import RTLIST

Then, a function is provided, that will parse the BGP instances.
The incoming ecommunity will be compared with the configured rt redirect
import ecommunity list, and return the VRF first instance of the matching
route target.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-27 15:21:51 +02:00
G. Paul Ziemba
b9c7bc5ab0 bgpd: new vpn-policy CLI
PR #1739 added code to leak routes between (default VRF) VPN safi and unicast RIBs in any VRF. That set of changes included temporary CLI including vpn-policy blocks to specify RD/RT/label/&c. After considerable discussion, we arrived at a consensus CLI shown below.

The code of this PR implements the vpn-specific parts of this syntax:

router bgp <as> [vrf <FOO>]
    address-family <afi> unicast
        rd (vpn|evpn) export (AS:NN | IP:nn)
        label (vpn|evpn) export (0..1048575)
        rt (vpn|evpn) (import|export|both) RTLIST...
        nexthop vpn (import|export) (A.B.C.D | X:X::X:X)
        route-map (vpn|evpn|vrf NAME) (import|export) MAP

        [no] import|export [vpn|evpn|evpn8]
        [no] import|export vrf NAME

User documentation of the vpn-specific parts of the above syntax is in PR #1937

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-03-19 22:13:43 -07:00
paulzlabn
3f1224cd1a
Merge branch 'master' into working/master/bgp-vpn-vrf-leaking 2018-03-14 13:31:58 -07:00
Mitesh Kanjariya
9bb3ca515b
Merge branch 'master' into type5-default-originate 2018-03-12 14:47:28 -07:00
G. Paul Ziemba
ddb5b4880b bgpd: vpn-vrf route leaking
- add "debug bgp vpn label" CLI
    - improved debug messages for "debug bgp bestpath"
    - send vrf label to zebra after zebra informs bgpd of vrf_id
    - withdraw vrf_label from zebra if zebra informs bgpd that vrf_id is disabled
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-03-09 16:42:40 -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
Mitesh Kanjariya
58f9e4d3f2
Merge branch 'master' into type5-default-originate 2018-02-27 12:52:24 -08:00
Russ White
7a684566d4
Merge pull request #1802 from dwalton76/bgpd-multipath-same-link-local
bgpd: use peer->ifp->ifindex instead of peer->ifindex
2018-02-27 08:31:06 -05:00
mitesh
2c29b18a1b bgpd: reassign the flags in struct bgp af_flags to avoid conflict
We have af_flags in struct bgp which holds address family related flags.
Seems like we had a conflict between two flags.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-27 02:19:57 -08:00
Philippe Guibert
e5619c289a bgpd: server socket is created for all enabled VRF
Upon creation of BGP instances, server socket may or may not be created.
In the case of VRF instances, if the VRF backend relies on NETNS, then
a new server socket will be created for each BGP VRF instance. If the
VRF backend relies on VRF LITE, then only one server socket will be
enough. Moreover, At startup, with BGP VRF configuration, a server
socket may not be created if VRF is not the default one or VRF is not
recognized yet.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Mitesh Kanjariya
23e386ac71
Merge branch 'master' into type5-default-originate 2018-02-27 01:46:26 -08:00
Philippe Guibert
ac3133a35d
Merge pull request #1736 from mkanjari/type5-with-asymm
zebra, bgp: Support type-5 routes with asymmetric routing
2018-02-27 10:36:57 +01:00
Daniel Walton
194a4f2c5c bgpd: use peer->ifp->ifindex instead of peer->ifindex
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

peer->ifindex was only used in two places but it was never populated so
neither of them worked as they should.  'struct peer' also has a 'struct
interface' pointer which we can use to get the ifindex.
2018-02-26 22:13:22 +00:00
Mitesh Kanjariya
486456ca92 bgpd: support for default-originate type-5 route
Implement support for 'default-originate' for L2VPN/EVPN address family.
This is needed for the case where external routing within a POD,
will follow the default route to the border/exit leaf.
The border leaf has more than one next hop to forward the packet on to,
depending on the destination IP.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-22 17:31:58 -08:00
Mitesh Kanjariya
154faa5007 bgpd: move l2vpn evpn related flags in struct bgp to af_flags
We have af_flags in struct bgp to hold address family related flags,
l2vpn evpn flags to indicate advertise ipvX unicast should be moved there.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-22 17:24:36 -08:00
Mitesh Kanjariya
53c84f7800 bgpd: Policy to control which RIB routes are injected into EVPN
FRR/CL provides the means for injecting regular (IPv4) routes
from the BGP RIB into EVPN as type-5 routes.
This needs to be enhanced to allow selective injection.
This can be achieved by adding a route-map option
for the "advertise ipv4/ipv6 unicast" command.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-12 16:02:15 -08:00
Mitesh Kanjariya
efc812a379
Merge branch 'master' into type5-with-asymm 2018-02-12 02:05:00 -08:00
Mitesh Kanjariya
c48d9f5f85 zebra, bgp: Support type-5 routes with asymmetric routing
Asymmetric routing is an ideal choice when all VLANs are cfged on all leafs.
It simplifies the routing configuration and
eliminates potential need for advertising subnet routes.
However, we need to reach the Internet or global destinations
or to do subnet-based routing between PODs or DCs.
This requires EVPN type-5 routes but those routes require L3 VNI configuration.

This task is to support EVPN type-5 routes for prefix-based routing in
conjunction with asymmetric routing within the POD/DC.
It is done by providing an option to use the L3 VNI only for prefix routes,
so that type-2 routes (host routes) will only use the L2 VNI.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-10 00:41:28 -08:00
G. Paul Ziemba
d316210b65 whitespace/comment fixes per qlyoung
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-02-09 13:14:22 -08:00
G. Paul Ziemba
a4d82a8adc bgpd: ran indent.py on some files prior to bgp vpn-vrf leaking changes
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-02-09 10:22:50 -08:00
Donald Sharp
48a67e2c0a bgpd: Remove peer->hash as that it is unused
The peer->hash pointer is allocating a bunch of memory
but is never used.  Remove.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-17 14:17:15 -05:00
Russ White
7256280c1b
Merge pull request #1627 from qlyoung/bgp-autoshutdown
BGP auto-shutdown
2018-01-16 15:29:17 -05:00
Quentin Young
f26845f9a6
bgpd: add neighbor autoshutdown
Adds ability to specify that peers should be administratively shutdown
when first configured.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-01-12 15:03:24 -05:00
Mitesh Kanjariya
9bb77a5b3d
Merge branch 'master' into evpn-symmetric-routing 2018-01-11 09:00:23 -08:00
Russ White
2ed7e4c3c3
Merge pull request #1591 from qlyoung/bgpd-ringbuf
bgpd: use ring buffer for network input
2018-01-10 19:59:24 -05:00
Quentin Young
0112e9e0b9
bgpd: use atomic_* ops on _Atomic variables
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-01-09 15:40:48 -05:00
Dario Wiesner
a21bd7a3b9 bgpd: add PMSI_TUNNEL_ATTRIBUTE to EVPN IMET routes
Signed-off-by: Dario Wiesner <dario.wiesner@gmail.com>
2018-01-04 13:51:15 +01:00
Quentin Young
74ffbfe6fe
bgpd: use ring buffer for network input
The multithreading code has a comment that reads:
"XXX: Heavy abuse of stream API. This needs a ring buffer."

This patch makes the relevant code use a ring buffer.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-01-03 14:35:11 -05:00
Quentin Young
37a333fef1
bgpd: fix configuration of 0 for coalesce-time
Was using 0 as a sentinel value, so user couldn't configure 0 as the
value of the coalesce timer.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-12-14 16:43:31 -05:00
mitesh
342dd0c623 bgpd: advertise/withdraw type-5 routes upon user config
CLI config for enabling/disabling type-5 routes

router bgp <as> vrf <vrf>
  address-family l2vpn evpn
    [no] advertise <ipv4|ipv6|both>

loop through all the routes in VRF instance and advertise/withdraw
all ip routes as type-5 routes in default instance.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:07 -08:00
mitesh
b67a60d2cf bgpd: set vrf originator ip to kernels local-ip
For EVPN type-5 route the NH in the NLRI is set to the local tunnel ip.
This information has to be obtained from kernel notification.
We need to pass this info from zebra to bgp in l3vni call flow.
This patch doesn't handle the tunnel-ip change.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:07 -08:00
mitesh
676f83b991 bgpd: RD derivation for VRF
1. VRF RD can be auto-derived (simillar to RD for a VNI)
2. VRF RD can be configured manually through a config

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:07 -08:00
mitesh
e9eb5f63ed bgpd: move rd id bitfield to bgp_master
currently, we have a rd_id bitfield
to assign an unique index for auto RD.
This bitfield currently resides under struct bgp which seems wrong.
We need to shift this to a global space
as this ID space is really global per box.
One more reason to keep it at a global data structure is,
the ID space could be used by both VNIs and VRFs.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:07 -08:00
Mitesh Kanjariya
10ebe1ab54 bgpd: import rt to vrf mapping
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
Mitesh Kanjariya
6a8657d0f0 bgpd: link l2vnis(bgpevpn) to l3vni(vrf)
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
Mitesh Kanjariya
c581d8b0f4 bgpd: import/export rt for BGP vrf
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
Mitesh Kanjariya
fe1dc5a374 bgpd: l3vni/rmac association with bgp vrf
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
Quentin Young
14b8641a5e
bgpd: fix config display of coalesce-time
Since coalesce time is now heuristically adjusted based on peer count,
we need to separate out specific configuration by the user from the
current value. Behavior established is to not adjust if the user has a
value set.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-12-06 17:38:24 -05:00
Quentin Young
2d34fb80b8
*: don't use deprecated stream.h macros
Some of the deprecated stream.h macros see such little use that we may
as well just remove them and use the non-deprecated macros.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-12-01 13:51:06 -05:00
Quentin Young
387f984e58
bgpd: fix bgp active open
At some point when rearranging FSM code, bgpd lost the ability to
perform active opens because it was only paying attention to POLLIN and
not POLLOUT, when the latter is used to signify a successful connection
in the active case.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:18:05 -05:00
Quentin Young
1588f6f441
bgpd: update atomic memory orders
Use best-performing memory orders where appropriate.
Also update some style and add missing comments.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:18:04 -05:00
Quentin Young
b750b0ba76
bgpd: small i/o threading improvements
* Start bit flags at 1, not 2
* Make run-flags atomic for i/o thread
* Remove work_cond mutex, it should no longer be necessary
* Add asserts to ensure proper ordering in bgp_connect()
* Use true/false with booleans, not 1/0

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:18:01 -05:00
Quentin Young
555e09d4a2
bgpd: atomize write-quanta, add read-quanta
bgpd supports setting a write-quanta that serves as a hint on how many
packets to write per I/O cycle. Now that input is buffered, it makes
sense to add the equivalent parameter for how many packets are processed
per cycle. This is *not* how many packets are read off the wire per I/O
cycle; rather it is how many packets are processed from the input buffer
in a given cycle after having been read off the wire and sanitized.

Since these values must be used from multiple threads, they have also
been made atomic.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:18:00 -05:00
Quentin Young
424ab01d0f
bgpd: implement buffered reads
* Move and modify all network input related code to bgp_io.c
* Add a real input buffer to `struct peer`
* Move connection initialization to its own thread.c task instead of
  piggybacking off of bgp_read()
* Tons of little fixups

Primary changes are in bgp_packet.[ch], bgp_io.[ch], bgp_fsm.[ch].
Changes made elsewhere are almost exclusively refactoring peer->ibuf to
peer->curr since peer->ibuf is now the true FIFO packet input buffer
while peer->curr represents the packet currently being processed by the
main pthread.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:17:59 -05:00
Quentin Young
56257a44e4
bgpd: move bgp i/o to a separate source file
After implement threading, bgp_packet.c was serving the double purpose
of consolidating packet parsing functionality and handling actual I/O
operations. This is somewhat messy and difficult to understand. I've
thus moved all code and data structures for handling threaded packet
writes to bgp_io.[ch].

Although bgp_io.[ch] only handles writes at the moment to keep the noise
on this commit series down, for organization purposes, it's probably
best to move bgp_read() and its trappings into here as well and
restructure that code so that read()'s happen in the pthread and packet
processing happens on the main thread.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:17:59 -05:00
Quentin Young
0ca8b79f38
bgpd: use new threading infra
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:17:59 -05:00
Quentin Young
419dfe6a70
bgpd: dynamically allocate synchronization primitives
Changes all synchronization primitives to be dynamically allocated. This
should help catch any subtle errors in pthread lifecycles.

This change also pre-initializes synchronization primitives before
threads begin to run, eliminating a potential race condition that
probably would have caused a segfault on startup on a very fast box.

Also changes mutex and condition variable allocations to use
MTYPE_PTHREAD and updates tests to do the proper initializations.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:17:58 -05:00
Quentin Young
49507a6f6a
bgpd: remove unused struct thread from peer
* Remove t_write
* Remove t_keepalive

These have been replaced by pthreads and are no longer needed. Since
some code looks at these values to determine if the threads are
scheduled, also add a new bitfield to store the same information.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:17:58 -05:00
Quentin Young
2d4ee77490
lib, bgpd: implement pthread lifecycle management
Removes the WiP shim and implements proper thread lifecycle management.

* Declare necessary pthread_t's in bgp_master
* Define new MTYPE in lib/thread.c for pthreads
* Allocate and free BGP's pthreads appropriately
* Terminate and join threads appropriately

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:17:57 -05:00
Quentin Young
d3ecc69e5f
bgpd: move packet writes into dedicated pthread
* BGP_WRITE_ON() removed
* BGP_WRITE_OFF() removed
* peer_writes_on() added
* peer_writes_off() added
* bgp_write_proceed_actions() removed

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:17:57 -05:00
Donald Sharp
ccd2b0e6ce
Merge pull request #1391 from LabNConsulting/working/master/patch-set/vnc-vrf-export
Support vrf export/import based on vrf-policy
2017-11-09 08:53:24 -05:00
Lou Berger
02a82b47b3 bgpd: allow for vpn->vrf imports
ignore nexthop checks for RFAPI imported routes (as is self)
      note: NHT is still updated

Signed-off-by: Lou Berger <lberger@labn.net>
2017-10-31 11:06:17 -04:00
Don Slice
d25e4efc52 bgpd: fix various problems with hold/keepalive timers
Problem reported that we weren't adjusting the keepalive timer
correctly when we negotiated a lower hold time learned from a
peer.  While working on this, found we didn't do inheritance
correctly at all.  This fix solves the first problem and also
ensures that the timers are configured correctly based on this
priority order - peer defined > peer-group defined > global config.
This fix also displays the timers as "configured" regardless of
which of the three locations above is used.

Ticket: CM-18408
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: CCR-6807
Testing-performed:  Manual testing successful, fix tested by
submitter, bgp-smoke completed successfully
2017-10-26 11:55:31 -04:00
Renato Westphal
5ba345ccb2 Merge pull request #1047 from dwalton76/bgpd-draft-ietf-grow-bgp-gshut-10
bgpd: implement draft-ietf-grow-bgp-gshut-10
2017-09-05 10:20:49 -03:00
Donald Sharp
32592ffb4f Merge pull request #1056 from opensourcerouting/oldbits-0
"pathspace" options, vtysh-suid-cleanups, "vty_frame()"
2017-08-29 17:48:36 -04:00
David Lamparter
2b79110731 bgpd: get rid of afi_header_vty_out() & co.
afi_header_vty_out() is easily replaced with vty_frame(), which means we
can drop a whole batch of "int *write" args as well as the entirety of
bgp_config_write_family_header().

=> AFI/SAFI config writing is now a lot simpler.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-29 08:36:03 +02:00
Mitesh Kanjariya
09fdc88c8c Merge branch 'master' into dev-master 2017-08-28 18:19:03 -07:00
Daniel Walton
31d5efe2ea Merge branch 'master' of https://github.com/dwalton76/frr into bgpd-draft-ietf-grow-bgp-gshut-10
Conflicts:
	bgpd/bgp_route.c
2017-08-28 06:59:38 -07:00
Daniel Walton
7f32323620 bgpd: implement draft-ietf-grow-bgp-gshut-10
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-08-25 18:27:49 +00:00
Daniel Walton
318cac96ef bgpd: Memory wasting in zebra by non used MPLS FECs
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-08-22 18:14:50 +00:00
Jorge Boncompte
92375c917e bgpd: inline bgp_lock()/bgp_unlock()
Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-17 17:47:07 +02:00
Mitesh Kanjariya
db0e1937ca bgpd: Ignore EVPN routes from CLAG peer when VNI comes up
There are two parts to this commit:
1. create a database of self tunnel-ip for used in martian nexthop check
In a CLAG setup, the tunnel-ip (VNI UP) notification comes before the clag-anycast-ip comes up in the system.
This was causing our self next hop check to fail and we were instaling routes with martian nexthop in zebra.
We need to keep this info in a seperate database for all local tunnel-ip.
This database will be used in parallel with the self next hop database to martian nexthop checks.
2. When a local VNI comes up, update the tunnel-ip database and filter routes in the RD table if necessary
In case of EVPN we might receive routes from clag peer before the clag-anycast ip and VNI is up on the system.
We will store the routes in the RD table for later processing.
When VNI comes UP, we loop thorugh all the routes and install them in zebra if required.
However, we were missing the martian nexthop check in this code path.
From now onwards, when a VNI comes UP,
we will first update the tunnel-ip database
We then loop through all the routes in RD table and apply martian next hop filter if required.

Things not covered in this commit but are required:

This processing is needed in general when an address becomes a connected address.
We need to loop through all the routes in BGP and apply martian nexthop filter if necessary.
This will be taken care in a seperate bug

Ticket:CM-17271/CM-16911
Reviewed By: ccr-6542
Testing Done: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-16 23:19:58 -07:00
Mitesh Kanjariya
1a98c08704 bgpd/zebra/lib: EVPN support for asymmetric VxLan routing
1. Advertise gateway mac-ip in EVPN
2. Advertise VRR mac-ip in EVPN
3. Ignore gateway mac-ip advertisements in case of distributed gateway
4. Config knob to enable/disable gateway mac-ip advertisements

Ticket: CM-16456, CM-16543, CM-16555, CM-16778
Review: CCR-6283
Unit-test: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-08 10:28:46 -04:00
vivek
ba0fcaf6df bgpd: Fix incorrect AFI reference
Fixes: "bgpd: Fixes related to use of L2VPN/EVPN"
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-08-08 10:09:37 -04:00
Donald Sharp
ab665082fe Merge pull request #882 from opensourcerouting/safi-cleanup
lib/bgpd: cleanup SAFI values
2017-08-01 14:21:26 -04:00
Renato Westphal
a46a2e9b4e bgpd: don't make any assumptions about the size of an enum
The size of an enum is compiler dependent and thus we shouldn't use
enums inside structures that represent fields of a packet.

Problem detected by the 'test_capability' unit test.

The problem was not apparent before because the 'iana_safi_t' enum didn't
exist and 'safi_t' was a typedef to uint8_t. Now we have two different
enums, 'iana_afi_t' and 'iana_safi_t', and both need to be encoded in
different ways on the wire (2 bytes vs 1 byte).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-07-31 23:45:03 -03:00
Renato Westphal
5c5255381e lib/bgpd: introduce the iana_safi_t enum
We had afi_t/iana_afi_t for AFIs but only safi_t for SAFIs. Fix this
inconsistency.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-07-31 23:44:42 -03:00
Daniel Walton
40520c3649 bgpd: peer hash expands until we are out of memory
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

swpX peers all start out with the same sockunion so initially they all
go into the same hash bucket. Once IPv6 ND has worked its magic they
will have different sockunions and will go in different buckets...life
is good.

Until then though, we are in a phase where all swpX peers have the same
socknunion. Once we have HASH_THRESHOLD (10) swpX peers and call
hash_get for a new swpX peer the hash code calls hash_expand(). This
happens because there are more than HASH_THRESHOLD entries in a single
bucket so the logic is "expand the hash to spread things out"...in our
case expanding doesn't spread out the swpX peers because all of their
sockunions are the same.

I looked at having peer_hash_make and peer_hash_same consider the ifname
of the swpX peer but that is a large change that we don't want to make
at the moment. So the fix is to put a cap on how large we are
willing to let the hash table get. By default there is no limit but if
max_size is set we will not allow the hash to expand above that.
2017-07-31 21:22:23 +00:00
David Lamparter
9d303b37d7 Revert "*: reindent pt. 2"
This reverts commit c14777c6bf.

clang 5 is not widely available enough for people to indent with.  This
is particularly problematic when rebasing/adjusting branches.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-22 14:52:33 +02:00
whitespace / reindent
c14777c6bf
*: reindent pt. 2
w/ clang 5

* reflow comments
* struct members go 1 per line
* binpack algo was adjusted
2017-07-17 15:26:02 -04: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
vivek
14c1a7bf91 bgpd: EVPN initialization and cleanup
Define the EVPN (EVI) hash table and related structures and initialize
and cleanup.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 12:36:34 -04:00
David Lamparter
21bb7c8774 Merge commit '3d22338f04d9554fa' into evpn-prep
Conflicts:
	lib/Makefile.am

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-10 22:15:19 +02:00
Daniel Walton
4fbf55e986 Merge branch 'master' of https://github.com/dwalton76/frr into bgpd-ipv4-plus-label-misc3 2017-06-26 17:24:44 +00:00
Quentin Young
56b4067930 *: simplify log message lookup
log.c provides functionality for associating a constant (typically a
protocol constant) with a string and finding the string given the
constant. However this is highly delicate code that is extremely prone
to stack overflows and off-by-one's due to requiring the developer to
always remember to update the array size constant and to do so correctly
which, as shown by example, is never a good idea.b

The original goal of this code was to try to implement lookups in O(1)
time without a linear search through the message array. Since this code
is used 99% of the time for debugs, it's worth the 5-6 additional cmp's
worst case if it means we avoid explitable bugs due to oversights...

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-21 15:22:21 +00:00
Daniel Walton
9bedbb1e52 bgpd: Install SAFI_LABELED_UNICAST routes in SAFI_UNICAST table
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

- All ipv4 labeled-unicast routes are now installed in the ipv4 unicast
  table. This allows us to do things like take routes from an ipv4
  unicast peer, allocate a label for them and TX them to a ipv4
  labeled-unicast peer. We can do the opposite where we take routes from
  a labeled-unicast peer, remove the label and advertise them to an ipv4
  unicast peer.

- Multipath over a labeled route and non-labeled route is not allowed.

- You cannot activate a peer for both 'ipv4 unicast' and 'ipv4
  labeled-unicast'

- The 'tag' variable was overloaded for zebra's route tag feature as
  well as the mpls label. I added a 'mpls_label_t mpls' variable to
  avoid this.  This is much cleaner but resulted in touching a lot of
  code.
2017-06-16 19:12:57 +00:00
vivek
3d22338f04 bgpd: Fixes related to use of L2VPN/EVPN
Add checks related to AFI_L2VPN/SAFI_EVPN that were missing in some parts
of the code. Fix incorrect check skipping EVPN when sending End of RIB.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-05-25 10:20:04 -07: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
Daniel Walton
343e90c328 bgpd: add ENHE support for "address-family ipv4 labeled-unicast"
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-05-10 10:06:47 -04:00
Daniel Walton
c5a543b433 Update to draft-ietf-idr-bgp-prefix-sid-05
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

The initial implementation was against draft-keyupate-idr-bgp-prefix-sid-02
This updates our label-index implementation up to draft-ietf-idr-bgp-prefix-sid-05
- changed BGP_ATTR_LABEL_INDEX to BGP_ATTR_PREFIX_SID
- since there are multiple TLVs in BGP_ATTR_PREFIX_SID you can no longer
  rely on that flag to know if there is a label-index for the path. I
changed bgp_attr_extra_new() to init the label_index to
BGP_INVALID_LABEL_INDEX
- put some placeholder code in for the other two TLVs (IPv6 and
  Originator SRGB)
2017-04-26 21:45:32 +00:00
Donald Sharp
64d222e2c3 bgpd: Use appropriate Attribute number for labels
The draft-ietf-idr-bgp-prefix-sid-04 specifies the label attribute
should be 40 not 30.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-04-06 10:32:08 -04:00
Vivek Venkatraman
6cf48acc1c bgpd: This patch implements the exchange of the BGP-Prefix-SID label index attr
Implement BGP Prefix-SID IETF draft to be able to signal a labeled-unicast
prefix with a label index (segment ID). This makes it easier to deploy
global MPLS labels with BGP, even without other aspects of Segment Routing
implemented.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-04-06 10:32:07 -04:00
Don Slice
cd1964ff38 bgpd: labeled unicast processing
Implement support for negotiating IPv4 or IPv6 labeled-unicast address
family, exchanging prefixes and installing them in the routing table, as
well as interactions with Zebra for FEC registration. This is the
implementation of RFC 3107.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2017-04-06 10:32:07 -04:00
David Lamparter
3e7c8d040c Merge branch 'stable/2.0'
Fixed minor conflicts from "defaults" change on stable.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-04-04 19:01:47 +02:00
David Lamparter
8efe88eacf *: track version & "defaults" in configs
[CF]: Move default name to autoconf and update tests

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-03-28 19:18:42 +02:00
David Lamparter
4f04a76b71 *: add frr_init() infrastructure
Start centralising startup & option parsing into the library.

FRR_DAEMON_INFO is a bit weird, but it will become useful later (e.g.
for killing the ZLOG_* enum, and having the daemon name available)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-07 23:07:20 +01:00
Donald Sharp
1a664f5e36 Merge pull request #254 from donaldsharp/shutdown3
Shutdown take 3
2017-03-07 11:29:44 -05:00
David Lamparter
f6e250f850 Merge branch 'frr/pull/240' ("lib, bgpd: clean up headers")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-07 16:03:36 +01:00
David Lamparter
73d70fa68a bgpd: TX shutdown message
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-03-06 19:40:26 -05:00
David Lamparter
38de8d0229 bgpd: RX shutdown message in "show bgp neighbor"
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-03-06 19:40:26 -05:00