Commit Graph

1030 Commits

Author SHA1 Message Date
Naveen Thanikachalam
dfb6fd1dd1 bgpd: Assertion failed during shutdown.
A race condition causes the failure.
The function "make_info()" sets the path info's peer to
bgp instance's "peer_self" which is created when BGP is first
configured and deleted only when BGP is brought down completely.
A race condition causes the bgp instances's "peer_self" to be
removed before the routes are being pulled off from the aggregate
address.

If the bgp instance's "peer_self" is NULL or, if BGP is being deleted,
the aggregate route must not be reinstalled.

Signed-off-by: NaveenThanikachalam nthanikachal@vmware.com
2019-08-11 03:56:12 -07:00
Dinesh Dutt
dcc1615e1b bgpd: Display received and advertised EVPN routes from neighbors
"show bgp l2vpn evpn neighbors <neighbor> [advertised-routes|routes]' did
not work due to various bugs. First, the command only accepted IPv4
addresses as valid neighbor ID, thereby rejecting unnumbered BGP and IPv6
neighbor address. Second, the SAFI was hardcoded to MPLS_VPN even though
we were passing the safi. Third, "all" made no sense in the command context
and to make the command uniform across all address families, I removed the
"all" keyword from the command.

Signed-off-by: Dinesh G Dutt <ddps4u@gmail.com>
2019-08-08 04:17:26 +00:00
Russ White
40236bf7c7
Merge pull request #4750 from dslicenc/bgp-remove-replace-as
bgpd: stop removing and replacing private asn if it matches the peer
2019-07-30 11:12:56 -04:00
Don Slice
bf26b80eba bgpd: stop removing and replacing private asn if it matches the peer
Problems reported that if multiple peers have "remove-private-AS
replace-AS" with each other and all are using private asns, the as-path
gets hosed and continues to grow when a prefix is removed.  This fix
disallows removing and replacing the private asn if it matches the
peer's ASN so that normal as-path loop prevention will operate correctly.

Ticket: CM-25489
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-07-29 12:27:03 -07:00
Lakshman Krishnamoorthy
82b692c0cb bgpd: Route-map VNI in-filter filters out all the routes for EVPN
Issue1: When a vni in-filter eg:"neighbor X.X.X.X route-map RM-VNI-FILTER in"
is configured under evpn address-family, all the received routes are dropped
regardless of whether the route has a matching vni or not.
(Where RM-VNI-FILTER contains "match evpn vni 100")

Issue2: Routes with 2 labels are not filtered correctly

Issue3: This filter should not get applied for MPLS routes. For MPLS routes,
we need route-map to handle a 3rd state besides match/nomatch called: noop.

Fix1: The handler bgp_update() that services the received route ignored the
route's label while deciding whether to filter it or not.
As part of the fix, the handler now uses the label info to make the
decision about whether to filter the route or not.

Fix2: route_match_vni() now tries to match both the labels within the route

Fix3: route_match_vni() should return noop when it encounters an mpls based
route. For this, route_map library should handle this 3rd state: RMAP_NOOP.

Related fix : Extract tunnel type
This fix relies on PR 4314 #4314 to extract the tunnel type from bgp extended
communities. The information about the route's tunnel type (vxlan or mpls)
is needed to apply "match evpn vni xx" rule.  This rule is applicable to
vxlan routes, and should exit safely for mpls based evpn routes.

Signed-off-by: Lakshman Krishnamoorthy lkrishnamoor@vmware.com
2019-07-22 08:08:25 -07:00
Lakshman Krishnamoorthy
b68885f9b7 lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP

Traditionally route map MATCH rule apis  were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:

State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away

State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH

We require a 3rd state because of the following situation:

The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.

Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"

With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.

As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-07-22 08:08:13 -07:00
David Lamparter
4a11bf2c09 bgpd: add a hook before bgp_process()
BMP uses this to get notified about any changes to prefixes, at which
point it schedules its own processing to happen later.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-03 16:54:09 +02:00
David Lamparter
b4d46cc9b1 bgpd: count some per-peer stats (for BMP)
These counters are accessible through BMP and may be useful to monitor
bgpd.  A CLI to show them could also be added if people are interested.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-03 16:53:12 +02:00
Biswajit Sadhu
29c8d9da62 bgpd: 'show bgp ipv6 neighbors <X::Y> prefix-counts' prefix-count is
not getting displayed.

Neighbour prefix-count is not getting displayed with IPV6 neighbours
and displays the o/p “ % No such neighbor or address family ”.
However, I observed it is working fine for IPV4 neighbour.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2019-07-01 22:09:57 -07:00
Quentin Young
878918edaa
Merge pull request #4522 from LabNConsulting/working/master/issue4479
bgpd: address issue #4479 crash during instance removal
2019-06-25 11:45:19 -04:00
Sri Mohana Singamsetty
06dbe9ec34
Merge pull request #4544 from chiragshah6/mdev
bgpd: print ecom in evpn route output
2019-06-25 08:45:04 -07:00
Donald Sharp
6d9ed6df1b
Merge pull request #4331 from patrasar/bgp_cli_fix
bgpd : add prefix-length in show ip bgp neighbor advertised routes key
2019-06-21 19:42:19 -04:00
Chirag Shah
6f214dd377 bgpd: print ecom in evpn route output
EVPN route's extended community include
important informations like Mobility sequence,
router mac, and RT values, include the ecomm
in evpn brief output.

Ticket:CM-25353
Testing Done:

Validated in evpn deployment with routes.

TOR#show bgp l2vpn evpn route
...
   Network          Next Hop            Metric LocPrf Weight Path
                    Extended Community

Route Distinguisher: 27.0.0.11:3
*> [2]:[0]:[0]:[48]:[00:02:00:00:00:04]:[128]:[fe80::202:ff:fe00:4]
                    36.0.0.11                              0 4435 5546 i
                    RT:5546:1008 ET:8 ND:Router Flag
*  [2]:[0]:[0]:[48]:[00:02:00:00:00:36]
                    36.0.0.11                              0 4435 5546 i
                    RT:5546:1008 RT:5546:4003 ET:8 MM:0, sticky MAC Rmac:44:38:39:ff:ff:01
*> [2]:[0]:[0]:[48]:[00:02:00:00:00:36]
                    36.0.0.11                              0 4435 5546 i
                    RT:5546:1008 RT:5546:4003 ET:8 MM:0, sticky MAC Rmac:44:38:39:ff:ff:01
*  [3]:[0]:[32]:[36.0.0.11]
                    36.0.0.11                              0 4435 5546 i
                    RT:5546:1008 ET:8
*> [3]:[0]:[32]:[36.0.0.11]
                    36.0.0.11                              0 4435 5546 i
                    RT:5546:1008 ET:8

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-06-21 14:21:38 -07:00
vishaldhingra
36a206db61 bgpd : Support for exact-match in match clause for lcommunity
FRR has a provision to give exact-match in match clause for
standard community, but this option is missing for lcommunity.

Part 3 : show related changes for match clause

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2019-06-19 04:42:48 -07:00
Donald Sharp
3e461df2ea
Merge pull request #4260 from vishaldhingra/lcomm
bgpd: Added the as-set option for IPV6 agg. route
2019-06-18 20:45:57 -04:00
Lou Berger
f4c713ae04 bgpd: handle additional events occuring during instance shutdown
Signed-off-by: Lou Berger <lberger@labn.net>
2019-06-18 11:54:52 +00:00
Donald Sharp
7ec5e2bf70
Merge pull request #4514 from opensourcerouting/warnings-20190612
*: kill more warnings
2019-06-17 15:19:42 -04:00
vishaldhingra
5101feceae bgpd: Added the as-set option for IPV6 agg. route
FRR has no option for the as-set for aggregate route
under IPV6 address family. Added the command to
configure the as-set option for IPV6.

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2019-06-17 01:32:30 -07:00
David Lamparter
2618a52ed3 *: config.h or zebra.h is the first #include
This is mostly relevant for Solaris, where config.h sets up some #define
that affect overall header behaviour, so it needs to be before anything
else.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 13:35:33 +02:00
David Lamparter
899e4095d1 bgpd: fix clang format warning
... by simplifying the code to use %pI6 instead.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 13:35:28 +02:00
Sarita Patra
1608ff7715 bgpd : add prefix-length in show ip bgp neighbor advertised routes key
Issue:
ip route 15.1.1.0/24 10.112.158.15
ip route 15.1.1.0/32 10.112.158.15
Brought up ebgp session between two FRR routers and
redistributed static routes via BGP and verfied the advertising
routes in the peer.

Verify the command "show ip  bgp neighbors <neighbor address>
advertised-routes json". It only shows 15.1.1.0/32 route details.

Root casue:
For both the routes "15.1.1.0/24" and "15.1.1.0/32" the advertised
routes key is the prefix i.e. "15.1.1.0".

Fix:
Modify the key to prefix/prefix-length.

Signed-off-by: Sarita Patra <saritap@vmware.com>
2019-06-11 07:56:15 -07:00
Soman K S
9f822fa2db bgpd: Process core when bgp instance is deleted
* When the bgp is being deleted and routes are in clear workqueue
  and new aggregate address being allocated
* Added flag BGP_FLAG_DELETE_IN_PROGRESS in bgp structure to
  bgp instance is being  deleted
* When adding aggregate route check this flag and  peer_self is valid

Signed-off-by: Soman K S <somanks@vmware.com>
2019-06-11 06:20:09 -07:00
Russ White
488d9e864b
Merge pull request #3555 from pguibert6WIND/bgp_wording_vrf_table
bgpd: use the wording vrf instead of table
2019-06-04 09:14:37 -04:00
Donald Sharp
6fed481c85
Merge pull request #4455 from lkrishnamoor/revert
Revert of PR 4078 and PR 4315
2019-06-04 07:41:09 -04:00
Lakshman Krishnamoorthy
2789041a46 Revert of PR 4078 and PR 4315
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-03 15:43:02 -07:00
Donald Sharp
d8a9922d58 bgpd: Remove BGP_OPT_CONFIG_CISCO
The BGP_OPT_CONFIG_CISCO command could no longer be set
as such remove it from the system as a viable option to
be used.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-03 15:06:16 -04:00
Lakshman Krishnamoorthy
e241544469 bgpd: Filtering received EVPN routes based on VNI does not work
Issue1: When "neighbor X.X.X.X route-map RM-VNI-FILTER in" is configured under evpn address-family,
all the received routes are dropped regardless of whether the route has a matching vni or not.

Issue2: Routes with 2 labels are not filtered correctly

Issue3: Interpreting the label based on tunnel type, vxlan was not done correctly.
Vxlan label has 24 bits, whereas, MPLS label is 20 bits long

Fix1: The handler bgp_update() that services the received route ignored the route's label while deciding whether to filter it or not. As part of the fix, the handler now uses the label info to make the decision about whether to filter the route or not.

Fix2: route_match_vni() now tries to match both the labels within the route, not just the one.

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-05-31 10:22:11 -07:00
Lakshman Krishnamoorthy
eadd168781 lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP

Traditionally route map MATCH rule apis  were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:

Action: Apply route-map match and return the result (RMAP_MATCH/RMAP_NOMATCH)
State1: Receveived RMAP_MATCH
THEN: If Routemap type is PERMIT, execute other rules if applicable,
otherwise we PERMIT!
Else: If Routemap type is DENY, we DENYMATCH right away

State2: Received RMAP_NOMATCH, continue on to next route-map, otherwise,
return DENYMATCH by default if nothing matched.

With reference to PR 4078 (https://github.com/FRRouting/frr/pull/4078),
we require a 3rd state because of the following situation:

The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.

Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"

With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP (or another enum) to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.

Question: Do we repurpose an existing enum RMAP_OKAY or RMAP_ERROR
as the 3rd state (or create a new enum like RMAP_NOOP)?
RMAP_OKAY and RMAP_ERROR are used to return the result of set cmd.

We chose to go with RMAP_NOOP (but open to ideas),
as a way to bypass the rmap filter

As a result we have a 3rd state:
State3: Received RMAP_NOOP
Then, proceed to other route-map, otherwise return RMAP_PERMITMATCH by default.

Signed-off-by:Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-05-30 11:21:28 -07:00
Russ White
4c02c06489
Merge pull request #4377 from ton31337/feature/show_fqdn_in_show_ip_bgp
bgpd: Show FQDN in `show [ip] bgp` output
2019-05-28 07:53:20 -04:00
Donatas Abraitis
25b5da8d50 bgpd: Show FQDN in show [ip] bgp output
We already show this information in `show [ip] bgp <prefix`, thus why don't
show it in global output. It's very handy when using at scale and to see
the whole picture instead of resolving neighbor manually.

It will show FQDN only if `bgp default show-hostname` is toggled.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-05-21 11:28:20 +03:00
David Lamparter
a74879b20e bgpd: fix compiler warning in reason2str
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-20 23:45:34 +02:00
Sri Mohana Singamsetty
02f4c3ab5b
Merge pull request #4349 from donaldsharp/bgp_reason
Bgp reason
2019-05-17 09:51:17 -07:00
Russ White
fca8283e71
Merge pull request #4219 from bisdhdh/biswajitfrr_5
bgpd: Implement 3rd party nexthop for ebgp ipv6 sender, when nexthop matches IPV6 address of the neighbor.
2019-05-16 10:36:02 -04:00
Donald Sharp
0dc8ee7062 bgpd: Display best path selection reason
As part of detailed bgp route detail, include the
reason why a route was selected as best path.

robot# show bgp ipv4 uni 223.255.254.0
BGP routing table entry for 223.255.254.0/24
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  annie(192.168.201.136)
  64539 15096 6939 7473 3758 55415
    192.168.201.136 from annie(192.168.201.136) (192.168.201.136)
      Origin IGP, valid, external, bestpath-from-AS 64539, best (First path received)
      Last update: Wed May 15 21:15:48 2019

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-15 21:47:51 -04:00
Donald Sharp
fdf81fa028 bgpd: Store reason why bestpath was choosen
Store in bgp_node the reason why we choose a particular
best path over another.  At this point we do not do
anything other than just store this data when we make
the decision.  Future commits will display it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-15 21:17:52 -04:00
Donald Sharp
f08b5ca0d9 bgpd: Switch data structure passing to route_vty_out_detail
Instead of just passing in the prefix, pass in the particular
bgp_node we are using.

This is setup for a future commit to use this data.
The long term goal is to collect data about why
a particular bgp_path_info was selected as best and
to display that reason.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-15 21:17:52 -04:00
Lakshman Krishnamoorthy
14f51ebaac bgpd: json cli output for bgp evpn overlay
This diff provides implementation for the cli:
"show bgp l2vpn evpn all overlay json"

Sample output after this change:
leaf-1# sh bgp l2vpn evpn all overlay json
{
  "bgpTableVersion":1,
  "bgpLocalRouterId":"10.100.0.1",
  "defaultLocPrf":100,
  "localAS":65000,
  "10.101.1.4:5":{
    "rd":"10.101.1.4:5",
    "[5]:[0]:[32]:[101.101.101.101]":{
      "prefix":"[5]:[0]:[32]:[101.101.101.101]",
      "prefixLen":288,
      "paths":[
        {
          "valid":true,
          "bestpath":true,
          "pathFrom":"external",
          "nexthop":{
            "ip":"10.100.0.2",
            "afi":"ipv4"
          },
          "overlay":{
            "esi":"00:00:00:00:00:00:00:00:00:00",
            "gw":"0.0.0.0",
            "rmac":"ea:47:79:75:22:1b"
          }
        },
        {
          "valid":true,
          "pathFrom":"external",
          "nexthop":{
            "ip":"10.100.0.2",
            "afi":"ipv4"
          },
          "overlay":{
            "esi":"00:00:00:00:00:00:00:00:00:00",
            "gw":"0.0.0.0",
            "rmac":"ea:47:79:75:22:1b"
          }
        }
      ]
    }
  },

...
...
}

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-05-11 09:47:10 -07:00
Ameya Dharkar
778048bf70 bgpd: BGP debug for route-map apply
Display a debug message while sending a BGP route if the route is filtered by a
route-map.
Debug for incoming filtered route is already present.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-05-10 13:34:08 -07:00
Donatas Abraitis
a8b72dc69e bgpd: Move inbound policy check outside bgp_input_modifier()
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-05-10 17:01:39 +03:00
Biswajit Sadhu
1c42b2e9a1 Merge branch 'master' of https://github.com/frrouting/frr 2019-05-07 03:28:55 -07:00
Donald Sharp
5e76ce5069
Revert "bgpd: Prevent IPv6 routes received via a ibgp session with own ip as nexthop " 2019-05-02 07:15:39 -04:00
Russ White
f4b4d16123
Merge pull request #4192 from bisdhdh/biswajitfrr_4
bgpd: Prevent IPv6 routes received via a ibgp session with own ip as nexthop
2019-05-01 18:12:07 -04:00
Faicker Mo
faf6559a00 bpgd: Add the end of newline of show bgp table json output
Signed-off-by: Faicker Mo <faicker.mo@ucloud.cn>
2019-04-29 17:28:42 +08:00
Biswajit Sadhu
737af8857a bgpd: Prevent the ebgp ipv6 sender from changing of nexthop in a special case.
Prevent the ebgp sender from changing the nexthop( which is same as the ebgp neighbour ipv6 address),
while sending updates to its ipv6 neighbor.So,if the nexthop of the ipv6 route is same as the ipv6
neighbour address do not change the next hop to your own ip.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2019-04-27 04:27:21 -07:00
Russ White
798b3c3469
Merge pull request #4140 from ton31337/fix/do_not_send_notification_again_with_invalid_nlri
bgpd: Do not send UPDATE message with maximum-prefix
2019-04-25 18:43:10 -04:00
Quentin Young
9237bd1807
Merge pull request #4184 from ton31337/fix/documentation_for_as-path_regexp
doc: Specify allowed chars in bgp regular expressions
2019-04-24 11:54:35 -04:00
Donatas Abraitis
513386b57f bgpd: Do not send UPDATE message with maximum-prefix
When using maximum-prefix and count is overflow BGP
sends UPDATE message:

Apr 15 20:45:06 exit1-debian-9 bgpd[9818]: 192.168.0.2 [Error] Error parsing NLRI
Apr 15 20:45:06 exit1-debian-9 bgpd[9818]: %NOTIFICATION: sent to neighbor 192.168.0.2 3/10 (UPDATE Message Error/Invalid Network Field) 0 bytes

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-04-24 14:51:06 +03:00
Biswajit Sadhu
2f6197b044 bgpd: Prevent IPv6 routes received via a ibgp session with own ip as nexthop
Prevent IPv6 routes received via a ibgp session with one of its own interface
ip as nexthop from getting installed in the BGP table.

Implemented IPV6 HASH table, where we need to add any ipv6 address as they
gets configured and delete them from the HASH table as the ipv6 addresses
get unconfigured. The above hash table is used to verify if any route learned
via BGP has nexthop which is equal to one of its its connected ipv6 interface.

Signed-off-by: Biswajit Sadhu sadhub@vmware.com
2019-04-24 00:40:01 -07:00
Donatas Abraitis
a818ea74e6 doc: Specify allowed chars in bgp regular expressions
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-04-23 22:35:20 +03:00
Sri Mohana Singamsetty
48db712fa5
Merge pull request #4163 from chiragshah6/evpn_dev2
bgpd: instance delete unimport evpn routes
2019-04-23 09:10:13 -07:00
Donatas Abraitis
c39008533c bgpd: Validate as-path in show bgp regexp
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-04-23 11:25:35 +03:00
Chirag Shah
1b7bb74761 bgpd: instance delete unimport evpn routes
EVPN routes (type-2/type-5) are imported from
default bgp instance (where they are learnt) to
non-default vrf instance.

When a bgp instance (default) is deleted,
unimport evpn routes from vrfs.

In absence of unimport, the imported routes in vrf
has parent path info points to default instance's path
info which is no longer valid (if instance is deleted).
When accessing parent path info leads to a crash
in non-default vrf instance.

The bgp instance is not cleaned up when
'no router bgp ASN' is performed, the instance's
reference count remains for evpn imported routes.

Ticket:CM-24484
Reviewed By:

Testing Done:
Validated via learning EVPN type-2/type-5 routes in symmetric
routing scenario.
The routes are imported to VRFs based on corresponding
L3VNI. When the default instance is removed, the evpn routes
are cleaned up from the VRF instance.

TURTLE(config)# do show bgp vrf vrf3 ipv4 unicast

   Network          Next Hop            Metric LocPrf Weight Path
*> 70.1.0.0/16      0.0.0.0                            32768 i
s  70.1.1.24/32     110.0.0.2                              0 65100 65002 i
s>                  110.0.0.2                              0 65100 65002 i
s  70.1.1.43/32     110.0.0.4                              0 65100 65004 i
s>                  110.0.0.4                              0 65100 65004 i

TURTLE(config)# no router bgp 65050
TURTLE(config)# do show bgp vrf vrf3 ipv4 unicast
No BGP prefixes displayed, 0 exist

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-04-18 09:13:55 -07:00
Lou Berger
817489896f
Merge pull request #3762 from pguibert6WIND/do_not_alloc_lists_fs_by_def
bgpd: do not allocate lists on fs entries of bgp entries.
2019-04-16 11:24:48 -04:00
Donald Sharp
9591da2653 bgpd: Remove extra alloc function bgp_path_info_new
The bgp_path_info_new function whenever it was called
pretty much duplicated the info_make function call.  So
convert over to using it and remove the bgp_path_info_new
function so people are not tempted.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-06 20:10:52 -04:00
Donald Sharp
ea8b228286 bgpd: pi->peer assignment exists no need for null check
The creation of a new `struct bgp_path_info` requires a legitimate
peer being passed in for creation.  There exists no code paths
where this is not true.  As such checking pi->peer for null convinces
SA that it might happen.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-06 20:10:52 -04:00
Renato Westphal
9c14ec7217 bgpd: fix "show bgp statistics" for the VPN safi
In order to iterate over MPLS VPN routes, it's necessary to use
two nested loops (the outer loop iterates over the MPLS VPN RDs,
and the inner loop iterates over the VPN routes from that RD).

The bgp_table_stats_walker() function wasn't giving this special
treatment to the MPLS VPN safi as it should, which was leading to
crashes and malfunctioning. Fix this.

Signed-off-by: Renato Westphal <renatowestphal@gmail.com>
2019-03-30 01:09:23 -03:00
Renato Westphal
b1ec871ab1 bgpd: remove unused variable
pinum (renamed from rinum) was never used for anything useful since
the initial revision ~17 years ago. Get rid of it.

Signed-off-by: Renato Westphal <renatowestphal@gmail.com>
2019-03-30 01:09:23 -03:00
Emanuele Di Pascale
c512a6429c bgpd: fix show bgp labeled_unicast
while labeled_unicast routes should be fetched in the
unicast table, we cannot set the safi to SAFI_UNICAST
else the peer afc checks and subgroup retrieval will fail

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-03-28 19:04:26 +01:00
Philippe Guibert
3e3708cbd3 bgpd: do not allocate lists on fs entries of bgp entries.
bgp entries in bgp_extra_path structure will be allocated as lists, only
when needed, that is to say when bgp fs entries will be received and
installed on the underlying system.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-03-28 16:57:59 +01:00
Sri Mohana Singamsetty
f05d888049
Merge pull request #3892 from vivek-cumulus/evpn_vrf_route_leak
Leaking of EVPN-based IPv4 and IPv6 routes between VRFs
2019-03-15 10:27:13 -07:00
David Lamparter
d3b05897ed
Merge pull request #3869 from qlyoung/cocci-fixes
Assorted Coccinelle fixes
2019-03-06 15:54:44 +01:00
Chirag Shah
5c14a19182 bgpd: router mac same as self supress bgp update
bgp update can contain router mac address same as one of SVIs
mac address, during processing of evpn route in bpg_update()
check for the flag is set and filter the route from installing.
This check is done prior to attribute lookup or storing in database.

Parse check and set is done once during attribute parse
because all the NLRIs containing evpn prefix
(type-2/type-5) will have same exntended community applicable.

Ticket:CM-23674
Reviewed By:CCR-8336
Testing Done:

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-03-04 09:56:13 -08:00
Donald Sharp
3d47101da7
Merge pull request #3743 from NaveenThanikachalam/2990_New
bgpd: Address performance issues in BGP route aggregation.
2019-03-01 09:54:10 -05:00
Naveen Thanikachalam
fc96884124 bgpd: Code to remove the bottleneck in aggregation.
The code that causes the bottleneck has been written generically to
handle the below two cases:
a) When a new aggregate-address is configured.
b) When new routes, that can be aggregated under an existing
aggregate-address, are received.
This change optimizes the code that handles case-(b).

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2019-02-28 20:22:41 -08:00
Naveen Thanikachalam
e00d800877 bgpd: Code to handle BGP aggregate's as-path.
With this commit:
1) 'struct bgp_aggregate' is moved to bgp_route.h from bgp_route.c
2) Hashes to accommodate the as-path, communities, extended-communities and
   large-communities attributes of all the routes aggregated by an
   aggregate route is introduced in 'struct bgp_aggregate'.
3) Place-holders for the aggregate route's as-path, communities,
   extended-communities and large-communities attributes are introduced in
   'struct bgp_aggregate'.
4) The code to manage the as-path of the routes that are aggregatable under
   a configured aggregate-address is introduced.
5) The code to compute the aggregate-route's as-path is introduced.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2019-02-28 20:22:30 -08:00
Mark Stapp
fd2d11fb27
Merge pull request #3876 from qlyoung/fmt-fixes
style fixes...
2019-02-28 15:16:16 -05:00
vivek
f106e3a72d bgpd: Allow EVPN-sourced routes to be leaked back into EVPN
Refine check on whether a route can be injected into EVPN to allow
EVPN-sourced routes to be injected back into another instance.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-28 16:01:38 +00:00
vivek
c27ee4c4e4 bgpd: Fix EVPN advertise route-map application
When a IPv4 or IPv6 route that was formerly allowed by the route-map
to be injected into EVPN gets an updated set of attributes that now
causes it to be filtered, the route needs to be pulled out of EVPN.

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 08:19:06 +00:00
Quentin Young
dbd587dabc bgpd: fix style for 0f19a8
:|

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-26 19:21:22 +00: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
Tim Bray
e3b78da875 *: Rename backet to bucket
Presume typo from original author

Signed-off-by: Tim Bray <tim@kooky.org>
2019-02-25 16:22:36 +00:00
Renato Westphal
6291837764 bgpd: fix null pointer dereference bug
If path->net is NULL in the bgp_path_info_free() function, then
bgpd would crash in bgp_addpath_free_info_data() with the following
backtrace:

 (gdb) bt
 #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
 #1  0x00007ff7b267a42a in __GI_abort () at abort.c:89
 #2  0x00007ff7b39c1ca0 in core_handler (signo=11, siginfo=0x7ffff66414f0, context=<optimized out>) at lib/sigevent.c:249
 #3  <signal handler called>
 #4  idalloc_free_to_pool (pool_ptr=pool_ptr@entry=0x0, id=3) at lib/id_alloc.c:368
 #5  0x0000560096246688 in bgp_addpath_free_info_data (d=d@entry=0x560098665468, nd=0x0) at bgpd/bgp_addpath.c:100
 #6  0x00005600961bb522 in bgp_path_info_free (path=0x560098665400) at bgpd/bgp_route.c:252
 #7  bgp_path_info_unlock (path=0x560098665400) at bgpd/bgp_route.c:276
 #8  0x00005600961bb719 in bgp_path_info_reap (rn=rn@entry=0x5600986b2110, pi=pi@entry=0x560098665400) at bgpd/bgp_route.c:320
 #9  0x00005600961bf4db in bgp_process_main_one (safi=SAFI_MPLS_VPN, afi=AFI_IP, rn=0x5600986b2110, bgp=0x560098587320) at bgpd/bgp_route.c:2476
 #10 bgp_process_wq (wq=<optimized out>, data=0x56009869b8f0) at bgpd/bgp_route.c:2503
 #11 0x00007ff7b39d5fcc in work_queue_run (thread=0x7ffff6641e10) at lib/workqueue.c:294
 #12 0x00007ff7b39ce3b1 in thread_call (thread=thread@entry=0x7ffff6641e10) at lib/thread.c:1606
 #13 0x00007ff7b39a3538 in frr_run (master=0x5600980795b0) at lib/libfrr.c:1011
 #14 0x000056009618a5a3 in main (argc=3, argv=0x7ffff6642078) at bgpd/bgp_main.c:481

Add a null-check protection to fix this problem.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-20 23:04:12 -03:00
David Lamparter
cbcaac3fb1
Merge pull request #3746 from ton31337/feature/rfc_8212
bgpd: Implement RFC8212
2019-02-19 13:54:23 +01:00
Donatas Abraitis
9dac9fc80e bgpd: Implement RFC8212
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-02-17 23:17:00 +02:00
Anuradha Karuppiah
27f28ccced bgpd: display label as part of the PMSI tunnel attribute
root@TORS1:~# net show bgp l2vpn evpn route rd 27.0.0.15:4 type multicast
EVPN type-2 prefix: [2]:[ESI]:[EthTag]:[MAClen]:[MAC]
EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:[OrigIP]
EVPN type-5 prefix: [5]:[ESI]:[EthTag]:[IPlen]:[IP]

BGP routing table entry for 27.0.0.15:4:[3]:[0]:[32]:[27.0.0.15]
Paths: (1 available, best #1)
  Advertised to non peer-group peers:
  MSP1(uplink-1) MSP2(uplink-2)
  Route [3]:[0]:[32]:[27.0.0.15] VNI 1003
  Local
    27.0.0.15 from 0.0.0.0 (27.0.0.15)
      Origin IGP, weight 32768, valid, sourced, local, bestpath-from-AS Local, best
      Extended Community: ET:8 RT:5550:1003
      AddPath ID: RX 0, TX 10
      Last update: Thu Feb  7 00:17:24 2019
      PMSI Tunnel Type: Ingress Replication, label: 1003 >>>>>>>>>>>>>

Displayed 1 prefixes (1 paths) with this RD (of requested type)
root@TORS1:~#

Ticket: CM-23790

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-02-12 13:06:52 -08:00
rgirada
b4897fa524 bgpd: Added changes to track route-map usage
Made changes and updated the routemap applied counter in the following flows.
1.Increment when route map attached to a list.
2.Decrement when route map removed / modified from a  list.
3.Increment/decrement when route map create/delete callback triggered.
4.Besides ,This counter need not be updated when a route map is got updated.
  i.e changing/adding a match value to the existing routemap.

In BGP , same update api called for all three add/delete/update operation .
But this counter have to be updated only for routemap addition.
Addressed this specific change by identifying the routemap operation based
on routemap pointer.

Signed-off-by: RajeshGirada <rgirada@vmware.com>
2019-02-04 05:27:56 -08: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
Nitin Soni
8ba7105057 bgpd: fix valgrind flagged errors
Executed some evpn related tests with valgrind and saw some errors
related to uninitialized memory and overlapping memcpy. This commit
fixes those.

Ticket: CM-21218
Signed-off-by: Nitin Soni <nsoni@cumulusnetworks.com>
Reviewed-by: CCR-8249
2019-01-29 06:29:57 -08:00
Philippe Guibert
ce3c06147c bgpd: display the list of iprules attached to a fs entry
the list of iprules is displayed in the 'show bgp ipv4 flowspec detail'
The list of iprules is displayed, only if it is installed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-01-29 14:15:10 +01:00
Philippe Guibert
c7d14ba67c bgpd: do not crash when removing ip vpn entries
when removing bgp instance, the parsing of rm->info contexts must be
protected. Also, the main level of hierarchy of rds must not be
allocated more than once.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-01-21 17:37:05 +01:00
Lou Berger
07f451afef
Merge pull request #3532 from donaldsharp/community_list_speedup
bgp Community list speedup
2019-01-15 10:05:20 -05:00
Renato Westphal
1c4213d862
Merge pull request #3198 from donaldsharp/mac_rejection
Mac rejection
2019-01-10 11:21:18 -02:00
Donald Sharp
e237b0d211 bgpd: Further refine hash lookup to store hash value
Further refine the previous commit to store the hash value in
both the `struct community_list` as well as the `struct rmap_community`
structures.  This allows us to know a priori what our hash value
is.  This change cuts another couple of seconds of convergence
off to ~55 seconds and further reduces cpu load of bgp:

   16      40061.706    433732       92    330102      129   1242965 RWTEX TOTAL

Down from ~43 seconds previously.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-08 20:24:13 -05:00
Philippe Guibert
b84060bbed bgpd: use the wording vrf instead of table
in bgp, even if the main vrf implementation relies on tables, the fact
is some vrf implementation rely on network namespaces, and then the
table used is the default table from the network namespace. Use the
wording vrf instead of table.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-01-07 10:26:54 +01:00
Renato Westphal
79bc257a1d bgpd: fix parsing of community number in the "show bgp community" command
Fixes #3545.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-02 19:32:15 -02:00
Anton Degtyarev
57592a53b5 bgpd, zebra: auto assign labels from label pool to regular prefixes in BGP labeled unicast
This commit is the last missing piece to complete BGP LU support in bgpd. To this moment, bgpd (and zebra) supported auto label assignment only for prefixes leaked from VRFs to vpn and for MPLS SR prefixes. This adds auto label assignment to other routes types in bgpd. The following enhancements have been made:
* bgp_route.c:bgp_process_main_one() now sets implicit-null local_label to all local, aggregate and redistributed routes.
* bgp_route.c:bgp_process_main_one() now will request a label from the label pool for any prefix that loses the label for some reason (for example, when the static label assignment config is removed)
* bgp_label.c:bgp_reg_dereg_for_label() now requests labels from label pool for routes which have no associated label index
* zebra_mpls.c:zebra_mpls_fec_register() now expects both label and label_index from the calling function, one of which must be set to MPLS_INVALID_LABEL or MPLS_INVALID_LABEL_INDEX, based on this it will decide how to register the provided FEC.

Signed-off-by: Anton Degtyarev <anton@cumulusnetworks.com>
2018-12-20 15:28:52 +03:00
Renato Westphal
9e7367db49
Merge pull request #3500 from pguibert6WIND/missing_default_vrf_name
bgpd: nexthop vrf name set to default vrf
2018-12-18 10:44:12 -02:00
Martin Winter
f26be30a4b
Merge pull request #3279 from adharkar/frr-default_local
bgpd: Display default local preference and local AS for BGP show commands
2018-12-18 10:46:58 +01:00
Philippe Guibert
03a6facfd3 bgpd: bgp default vrf in show route naming change
Default vrf name has been changed in show route. Because the default vrf
name can be configured in zebra, the default vrf name in bgp is changed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-17 18:57:22 +01:00
Philippe Guibert
4d97eea630 bgpd: nexthop vrf name set to default vrf
if default vrf is not Default, then nexthop vrf name returned may be
"Default", which is not the correct name of default vrf. change it
accordingly.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-17 17:44:02 +01:00
Donald Sharp
4e802e662e bgpd: Add code to reject mac's and to rescan table
Add some code that will reject local mac's from
being installed and add some code that will cause
a rescan when we have a local mac change.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com.
2018-12-12 16:11:45 -05:00
Donald Sharp
8cb687c2cb bgpd: Fix soft clear for evpn routes
When you have configured soft reconfiguration inbound
for evpn allow it to notice and send in the evpn data
as appropriate.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-12 16:10:30 -05:00
Lou Berger
9bdb632c68
Merge pull request #3093 from donaldsharp/bgp_node_continued
Bgp node continued
2018-12-11 11:13:25 -05:00
Donald Sharp
a79c04e7fe bgpd: Convert adj_out to a RB tree
The adj_out data structure is a linked list of adjacencies
1 per update group.  In a large scale env where we are
not using peer groups, this list lookup starts to become
rather costly.  Convert to a better data structure for this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-07 10:26:00 -05:00
Ameya Dharkar
01eced229d bgpd: Display default local preference and local AS for BGP show commands
1. "show bgp ipv4/ipv6 [json]"
2. "show bgp ipv4/ipv6 neighbor <peer> routes [json]"
3. "show bgp ipv4/ipv6 neighbors <peer> advertised-routes [json]"

In the above show commands, when a BGP path is displayed, we do not display the
local preference if it is EBGP route. Route calculation assumes the default
local preference. But, we can change the default local preference using
configuration in FRR. In this case, user should know the default local
preference value that is being used in the route calculation. Thus, adding a
new field 'default local preferece' in the show commands where a BGP path is
displayed.

When a BGP path is displayed in the above show commands, as-path does not
include the local AS. So, user has to execute another show command to display
the local-AS. To avoid this, adding a new field local-AS to above show commands.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2018-12-05 11:38:13 -08:00
Philippe Guibert
a2e219fe2e bgpd: reuse bgp_path_info_extra_free() routing in rfapi
rfapi code should use bgp_path_info_extra_free() routine.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-05 15:09:35 +01:00
Donald Sharp
5b00b40eec bgpd: Cleanup bgp_distance_set|get function names
The bgp_distance_set_node_info and bgp_distance_get_node_info
function names were slightly backwards lets fix them up
to bgp_node_get_bgp_distance_info and bgp_node_set_bgp_distance_info

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Donald Sharp
5a8ba9fc0a bgpd: Cleanup bgp_static_set|get function names
The bgp_static_set_node_info and bgp_static_get_node_info
function names were slightly backwards rename to
bgp_node_get_bgp_static_info and bgp_node_set_bgp_static_info

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Donald Sharp
b613a9183f bgpd: Cleanup bgp_aggregate_set|get function names
The bgp_aggregate_set_node_info and bgp_aggregate_get_node_info
functions names were slightly backwards, rename to
bgp_node_get_bgp_aggregate_info and bgp_node_set_bgp_aggregate_info

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Donald Sharp
67009e2200 bgpd: Abstract bgp_table retrieving/setting from info pointer
Convert the set/get of bgp_table's from the info pointer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Donald Sharp
6f94b685d0 bgpd: Abstract bgp_info retrieving/setting from info pointer
The bgp_info data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05: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
Russ White
2379dbecbd
Merge pull request #3202 from donaldsharp/evpn_dump
Evpn dump
2018-11-08 18:13:27 -05:00
Rafael Zalamena
591328ffc6
Merge pull request #3205 from donaldsharp/default
bgpd: make name of default vrf/bgp instance consistent
2018-11-07 18:48:21 -02:00
adharkar
2531163802
Merge branch 'master' into frr-bgp_cli 2018-10-31 15:54:43 -07:00
Anuradha Karuppiah
6d8c603a93 bgpd: use IP address as tie breaker if the MM seq number is the same
Same sequence number handling is specified by RFC 7432 -
[
If two (or more) PEs advertise the same MAC address with the same
sequence number but different Ethernet segment identifiers, a PE that
receives these routes selects the route advertised by the PE with the
lowest IP address as the best route.

If the PE is the originator of the MAC route and it receives the same
MAC address with the same sequence number that it generated, it will
compare its own IP address with the IP address of the remote PE and
will select the lowest IP.  If its own route is not the best one, it
will withdraw the route.
]

To implement that specification this commit uses nexthop IP as a tie
breaker between two paths of equal seq number with lower IP winning.

Now if a local path already exists with the same sequence number but higher
(local-VTEP) IP it is evicted (deleted and withdrawn from the peers) and
the winning new remote path is installed in zebra. This is existing code
and handled implicitly via evpn_route_select_install.

If a local path is rxed from zebra with the same sequence as the
current remote winner it is rejected (not installed in the bgp
routing tables) and zebra is asked to re-install the older/remote winner.
This is a race condition that can only happen if bgp's add and zebra's add
cross paths. Additional handling has been added in this commit via
evpn_cleanup_local_non_best_route to take care of the race condition.

Ticket: CM-22674
Reviewed By: CCR-7937

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2018-10-31 06:23:32 -04: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
Donald Sharp
6cd85474f8
Merge pull request #3121 from pguibert6WIND/flowspec_json_issue
bgpd: fill in prefix for flowspec entry when json format is requested
2018-10-24 19:41:15 -04:00
Sri Mohana Singamsetty
3c1f53dee9 bgpd:Fixing the signature of community_free function
community_free, lcommunity_free and ecommunity_free are similar type of functions. Most of the places, these three are called together. The signature of community_free is different from other two functions. Modified the community_free API signature to align with other two functions to avoid any confusion. There is no functionality impact with this and this is just to avoid any confusion.

Testing: manual testing and show commands
Signed-off-by: Sri Mohana Singamsetty msingamsetty@vmware.com
2018-10-23 09:52:32 -07:00
Philippe Guibert
625d293183 bgpd: fill in prefix for flowspec entry when json format is requested
as prefix is opaque for flowspec, and json needs to have a non empty
full of meaning value in prefix, the proposal is to encode the
displayable form of flowspec entry.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-10-23 16:07:52 +02:00
Donald Sharp
dd18c5a981 bgpd: Add Large community support to aggregate routes
Add the ability to track and support Large communities for aggregate
routes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-16 08:24:01 -04:00
Donald Sharp
3da2cc323f bgpd: Add extended community to aggregates
Add the ability to aggregate routes to handle
extended communities.  Make the actions similiar
to what we do for normal communities.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-16 08:13:03 -04:00
Vincent Bernat
aa0a10fca2 bgpd: fix IPv6 next-hop field name for routes in JSON
This may break existing clients but the original name contains two
errors.

Signed-off-by: Vincent Bernat <vincent@bernat.ch>
2018-10-15 15:08:37 +02:00
Russ White
97dc689417
Merge pull request #3142 from donaldsharp/bgp_peerhash
Bgp peerhash
2018-10-12 16:55:50 -04:00
Ameya Dharkar
37d4e0dfab bgpd: BGP JSON new fields
1. "show bgp ipv4 json"
  - Added "network" field which displays a prefix in 'prefix/prefixlen' format.

2. "show bgp ipv6 json"
  - Added "network" field which displays a prefix in 'prefix/prefixlen' format.
  - JSON does not have "prefix", "prefixLen" fields which are present in IPv4
    command. Added these fields as they are useful.

3. "show bgp ipv4/ipv6 neighbor <neighbor_addr> advertised-routes json"
  - Added "network" field.

4. "show bgp ipv4/ipv6 summary json"
  - Added "pfxSnt" for peers. This count is obtained from corresponding
    update_subgroup.

5. "show bgp neighbor json"
  - Added "sentPrefixCounter"

Signed-off-by: Ameya Dharkar <adharkar@vmware.org>
2018-10-11 15:35:21 -07:00
Donald Sharp
121e245d4f bgpd: Cleanup warnings issued by CI system from these changes
Modify code to cleanup warnings issued by the CI system from
this series of changes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:26:30 -04:00
Donald Sharp
40381db785 bgpd: Rename various variable names to something more appropriate
ri -> pi
bi -> bpi
info -> path
info -> rmap_path ( for routemap applications )

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:26:30 -04:00
Donald Sharp
9b6d8fcf29 bgpd: Convert binfo to path
Convert the binfo variable to path.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:26:30 -04:00
Donald Sharp
18ee831031 bgpd: Convert all bgp_info_XXX functions to bgp_path_XXX functions
Rename all bgp_info_XXX functions to bgp_path_XXX functions

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
Donald Sharp
4b7e606625 bgpd: Convert struct bgp_info to struct bgp_path_info
Do a straight conversion of `struct bgp_info` to `struct bgp_path_info`.
This commit will setup the rename of variables as well.

This is being done because `struct bgp_info` is not descriptive
of what this data actually is.  It is path information for routes
that we keep to build the actual routes nexthops plus some extra
information.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
Donald Sharp
1defdda8e8 bgpd: Convert BGP_INFO_XXX to BGP_PATH_XXX
Search and replace all BGP_INFO_XXX to BGP_PATH_XXX

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
Donald Sharp
360660c643 bgpd: Rename some BGP_PATH_XXX to BGP_PATH_SHOW_XXX
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
Donald Sharp
825d98347d bgpd: Add ability to dump the bgp peerhash
The bgp->peerhash is a secretive bit of data that we use
to quickly lookup data about peers.  Unfortunately
since we had not way to look at it, we had no way
of knowing if it had gotten in or out of sync.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-07 20:55:52 -04:00
Ameya Dharkar
50e05855f0 bgpd: BGP JSON show commands enhancements
1. "show bgp ipv4 json"
  - Corresponding CLI has "network" field which displays a prefix in
    'prefix/prefixlen' format. Added this "network" field to JSON as well.
  - Following fields have different names in JSON and CLI.
      CLI      JSON
      metric   med
      locPrf   localPref
      path     aspath

    Added fields "metric", "locPrf" and "path" in JSON for CLI/JSON
    consistency. Older JSON fields med, localPref, aspath will be
    deprecated in future.

2. "show bgp ipv6 json"
  - Similar changes as "show bgp ipv4 json"
  - JSON does not have "prefix", "prefixLen" fields which are present in IPv4
  command. Added these fields as they are useful.

3. "show bgp ipv4/ipv6 neighbor <neighbor_addr> advertised-routes json"
  - Added "network" field.
  - Added locPrf, path fields for CLI/JSON consistency. localPref, aspath will
  be deprecated in future.

4. "show bgp ipv4/ipv6 summary json"
  - Added "pfxRcd" for CLI/JSON consistency.
    "prefixReceivedCount" will be deprecated in future.
  - Added "pfxSnt" for peers. This count is obtalned from corresponding
    update_subgroup. This needed a fix in the code where we copy fields
    for a split update_subgroup from the parent update_subgrp.
    New subgrp should inherit subgrp->scount(Count of advertized prefixes)
    of the parent subgrp.

5. "show bgp neighbor json"
  - Added "sentPrefixCounter"

6. "show bgp ipv4/ipv6 <prefix> json"
  - Added "metric" field for CLI/JSON consistency.
    "med" will be deprecated in future.

Signed-off-by: Ameya Dharkar <adharkar@vmware.org>
2018-10-05 15:06:17 -07:00
Quentin Young
cee9c03192 bgpd: complete description code for communities
When this description code was added, it was all dead code since none of
the bools that checked if the communities were present were ever changed
from 0.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-10-04 18:12:33 +00:00
Quentin Young
cf4898bc99 bgpd: fix broken show community commands
SHA c5f1e1b broke about half of the community-related show commands; fix
them

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-10-04 17:46:52 +00:00
David Lamparter
f712c6b369
Merge pull request #3113 from donaldsharp/uninited_value
bgpd: prevent uninited variable from being used.
2018-10-02 16:17:10 +02:00
Donald Sharp
11ebf4ed88 bgpd: prevent uninited variable from being used.
Valgrind reports that temp could be used uninitialized
sometimes.

Signed-off-by: Donald sharp <sharpd@cumulusnetworks.com>
2018-10-02 08:23:11 -04: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
Don Slice
7ce8a8e022 bgpd: solve issue entering aggregate twice
Problem reported that frr-relaod.py was not installing an aggregate
properly.  Problem was actually that frr-reload.py does the command
twice, and the second time the aggregate command was entered, it would
appear in the config but the aggregate was removed from the bgp table
and not advertised to peers.  Solved by noticing when an aggregate
was marked for deletion (info_invalid) and allowing the re-entry if
the old one was being removed.

Ticket: CM-22509
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-09-28 16:03:42 +00:00
Donald Sharp
a78beeb544 bgpd: Abstract bgp_static retrieving/setting from info pointer
The bgp_static data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-22 14:59:23 -04:00
Donald Sharp
ca2e160d7d bgpd: Abstract distance retrieving/setting from info pointer
The bgp_distance data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-22 14:59:23 -04:00
Donald Sharp
b1e62edd5e bgpd: Abstract aggregate retrieving/setting from info pointer
The aggregate data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-22 14:59:23 -04:00
Quentin Young
1c50c1c0d6 *: style for EC replacements
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:38:57 +00:00
Quentin Young
450971aa99 *: LIB_[ERR|WARN] -> EC_LIB
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:34:28 +00:00
Quentin Young
e50f7cfdbd bgpd: BGP_[WARN|ERR] -> EC_BGP
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 18:51:04 +00:00
F. Aragon
f7813c7c7f
bgpd isisd ospf6d ospfd: variable shadowing fixes
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-12 16:44:36 +02:00
Donald Sharp
29f7d0232e bgpd: Honor origin change in bgp aggregates
When the origin changed we must honor and update the aggregate
to the peer.  This code adds a bit of code to the bgp_aggregate_info_same
code to see if the origin has changed and to indicate that it has.

Fixes: #2993
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-10 10:19:03 -04:00
Don Slice
088f109866 bgpd, ospfd, pimd, zebra: Convert more use_json locations to bool
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-09-04 17:39:04 +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
Christoffer
c5f1e1b240
bgp: Add documentation for IANA well-known communities
Coded as part of #2684 and most code written while participating at
BornHack@2018.

bgp_route.c: Changes regarding adding explanations for the IANA
well-known communities added in #2684

Signed-off-by: Christoffer <netravnen@gmail.com>
2018-08-24 23:57:42 +02:00
Donald Sharp
d8d084d97f bgpd: convert zlog_warns to debugs or errors
Several zlog_warns were being used to tell the end
user that bgp had detected a bug.  These all look like information
added during development that can be noted as debugs or logged
as an error situation.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-23 08:36:07 -04:00
Donald Sharp
9ab2969de8 bgpd: Remove warn to file an issue
A warn with a backtrace does not need another warn
to file an issue with Quagga, so just remove it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-23 08:35:01 -04:00
root
b2a9fc6b23 bgpd: Fix memory leak show ip bgp json
Root Cause: In the function bgp_show_table(), we are creating a
json object and a json array with the same name as “json_paths”.
First it will create a json object variable "json_paths" pointing
to the memory allocated for the json object. Then it will create
a json array for each bap node rn (if rn->info is available) with
the same name as json_paths. Because of this, json_paths which was
pointing to the memory allocated for the json object earlier, now
will be overwritten with the memory allocated for the json array.
As per the existing code, at the end of each iteration loop of bgp
node, it will deallocate the memory used by the json array and
assigned NULL to the variable json_paths. Since we don’t have the
pointer pointing to the memory allocated for json object, will be
not able to de-allocate the memory, which is a memory leak here.

Fix: Removing this json object since it is never getting used in
this function.

Testing:  Reproduced the memory leak with valgrind.
With the fix, memory leak gets resolved and checked with valgrind.

Signed-off-by: Sarita Patra saritap@vmware.com
2018-08-22 16:22:17 -07:00
Donald Sharp
1f063a699b
Merge pull request #2884 from opensourcerouting/assorted-20180821
assorted warning fixes
2018-08-22 08:17:32 -04:00
David Lamparter
0e70e6c89d lib/bgpd: re-fix bgp_info_extra_free()
Make the wart slightly less bad... also there is still a possible write
after free here.  This needs to be fixed again, properly, by some
structure changes.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-22 06:32:43 +02:00
Philippe Guibert
503d1ec6eb bgpd: avoid memory leak in bgp flowspec list, plus usage of bool
Avoid memory leak in bgp flowspec list.
Usage of bool parameter instead of int, to handle the number of entries
PBR.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-21 18:30:26 +02:00
Russ White
91a4566c1c
Merge pull request #2852 from donaldsharp/bgp_clean
Bgp clean
2018-08-16 11:30:03 -04:00
David Lamparter
55d3dad27c
Merge pull request #2448 from qlyoung/error-reference-cards
Error Reference Cards
2018-08-16 16:39:40 +02:00
Donald Sharp
deff24cad5 bgpd: Convert warn to debug
There exists a few places where actual debugs were being
displayed as warns.  Convert them over to debugs and
guard as appropriate.

Signed-off-by: Donald Sharp <sharpd@cumulsunetworks.com>
2018-08-16 08:24:16 -04:00
Quentin Young
af4c27286d *: rename zlog_fer -> flog_err
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Don Slice
14454c9fdd bgpd: implement zlog_ferr facility for enhance error messages in bgp
Signed-off-by: Don Slice <dslice@cumulusnetworks.com<
2018-08-14 20:02:05 +00:00
Pascal Mathis
89e5e9f028
bgpd: Always show CIDR mask when displaying routes
Classful networking has been obsolete for ages and there is currently an
inconsistency between `show ip route` and `show bgp`, where the first
one always displays the CIDR mask while the second one hides classful
network masks.

This commit adjusts the behavior of `show bgp` to always show the CIDR
mask for a route, even when it is classful.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-08-14 19:40:42 +02:00
Donald Sharp
0ce1ca805d *: ALLOC calls cannot fail
There is no need to check for failure of a ALLOC call
as that any failure to do so will result in a assert
happening.  So we can safely remove all of this code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-11 17:14:58 +02:00
Russ White
9728f99449
Merge pull request #2788 from ton31337/fix/print_ipv6_route_if_afi
bgpd: Display `::` if AFI is IPv6, `0.0.0.0` otherwise
2018-08-07 15:58:26 -04:00
Donatas Abraitis
07d0c4ed2d bgpd: Display :: if AFI is IPv6, 0.0.0.0 otherwise
Signed-off-by: Donatas Abraitis donatas.abraitis@gmail.com
2018-08-07 15:37:57 +03:00
F. Aragon
56cb79b6d5
bgpd pimd: return check (Coverity 1472232 1472234)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-08-06 18:17:39 +02:00
Lou Berger
0751b36cd3
Merge pull request #2731 from chiragshah6/mdev
bgpd: route detail output local pref display
2018-08-03 14:12:21 -04:00
Lou Berger
f503378408
Merge pull request #2745 from adharkar/frr-filtered_route
bgpd: Show routes filtered by prefix-list in filter-routes command
2018-07-28 10:16:20 -04:00
Chirag Shah
2551bd4c89 bgpd: route detail output local pref display
Avoid displaying default configured local preference as
part of bgp route's detail output.
Local preference is for iBGP learnt route's. The value could be
default (100) or configured value (via routemap or local pref config cmd).
show bgp afi safi (brief output) does not display,
if the local pref attribute is not set.
Similarly, show bgp afi safi detail route output should display
if the the attribute is set, and should not display configured value.
This way both output would be consistent.
The configured local preference can be seen via running-config.

Ticket:CM-12769
Reviewed By:
Testing Done:

eBGP output:
show bgp ipv4 45.0.3.0/24
BGP routing table entry for 45.0.3.0/24
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  MSP1(uplink-1) MSP2(uplink-2)
  Local
    0.0.0.0 from 0.0.0.0 (27.0.0.9)
      Origin incomplete, metric 0, weight 32768, valid,sourced, bestpath-from-AS Local, best
      AddPath ID: RX 0, TX 7
      Last update: Thu Jul 26 02:10:02 2018

iBGP output:

show bgp ipv4 unicast 6.0.0.16/32
BGP routing table entry for 6.0.0.16/32
Paths: (1 available, best #1, table default)
  Not advertised to any peer
  Local
    6.0.0.16 (metric 20) from tor-12(6.0.0.16) (6.0.0.16)
      Origin incomplete, metric 0, localpref 100, valid, internal, bestpath-from-AS Local, best
      AddPath ID: RX 0, TX 13
      Last update: Thu Jul 26 05:26:18 2018

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-07-27 15:33:26 -07:00
Ameya Dharkar
13c8e163fc bgpd: Show routes filtered by prefix-list in filter-routes command
Update:Addressed review comments

Changed "show bgp ipv4 neighbor filtered-routes"
to show routes filtered by prefx lists, distribute lists and filter lists

Closes: #2653

Signed-off-by: Ameya Dharkar adharkar@vmware.com
2018-07-27 11:23:32 -07:00
Donald Sharp
239b37bb3c bgpd: Notice when we unlock if we should NULL pointer
The bi->net pointer that is being unlocked had a commit
that removed the `bi->net = NULL;` recently.  This code
was preventing a use after free crash being experienced
in other code paths.  While commit 37e679629f was fixing
a different code path crash.

Make the parent->net pointer aware it may be locked/freed
from multiple places and to not NULL the pointer to it
unless we have actually freed the data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-27 10:02:34 -04:00
Russ White
282d51c6be
Merge pull request #2737 from vishaldhingra/master
bgpd: changes for crash seen in BGP on "no rt vpn" bug Id 2667
2018-07-27 09:05:00 -04:00
Ameya Dharkar
f99def6130 bgpd: Show routes filtered by prefix-list in filter-routes command
Changed "show bgp ipv4 neighbor <peer> filtered-routes"
to show routes filtered by prefx lists, distribute lists and filter lists

Closes: #2653

Signed-off-by: Ameya Dharkar adharkar@vmware.com
2018-07-26 14:48:05 -07:00
root
37e679629f bgpd: changes for crash seen in BGP on "no rt vpn" bug Id 2667
There is a default BGP VPN and BGP VRF instance in L3VPN configuration.
The routes are imported and exported between BGP VPN and BGP VRF.
Suppose there is one route in BGP VRF and exported to BGP VPN.
In BGP VPN there is bgp_info struct with bgp_info_extra struct has parent pointer pointing to the bgp_info of BGP VRF.
We take the lock for bgp_node and bgp_info of BGP VRF in the context of BGP VPN.
bgp_info has a back pointer to bgp_node via net.

Now when we have done "no rd vpn" in BGP VRF then in bgp_info_extra_free we have to free the parent resources.
In this context only unlocking is required. It should not set the BGP VRF (bgp_info->net) to NULL.

Signed-off-by: vishaldhingra vdhingra@vmware.com
2018-07-25 05:27:05 -07:00
Philippe Guibert
63a0b7a9f1 bgpd: display more than one FS entre per IP
because the IP destination criterium may match several entries, the show
command may return more than one entry.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-24 12:17:57 +02:00
Philippe Guibert
c26edcda4e bgpd: flowspec pbr entries listed on the bgp information entry
Because one flowspec entry can create 1-N bgp pbr entries, the list is
now updated and visible. Also, because the bgp_extra structure is used,
this list is flushed when the bgp_extra structure is deleted.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-24 12:17:57 +02:00
Ameya Dharkar
d0086e8e39 bgpd: Changes to BGP show json commands
Added localRouterID to "show bgp neighbor json"
Added json O/P to "show bgp [AFI] community <community>"

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2018-07-19 13:46:46 -07: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
Quentin Young
32ec4bc474
Merge pull request #2602 from pacovn/PVS-Studio_element_overflow
bgpd zebra: element overflow (PVS-Studio)
2018-07-05 17:49:49 -04:00
F. Aragon
b575a12c87
bgpd lib ospfd pimd ripngd: null chk (PVS-Studio)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-07-03 15:39:50 +02:00
F. Aragon
a85297a7c9
bgpd zebra: element overflow (PVS-Studio)
The warning given by PVS-Studio is related to per-element overflow (there is
no real overflow, because of how elements are mapped in the union). This
same warning is typically reported by Coverity, too.

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-07-02 19:06:54 +02:00
Donald Sharp
6a527b2fc1 bgpd: Fix some build issues from removing HAVE_CUMULUS
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-28 20:57:36 -04:00
Donald Sharp
e093d9d57b bgpd: Remove HAVE_CUMULUS from evpn commands
In order to make EVPN behavior work without special casing
the code, bring the evpn commands under HAVE_CUMULUS into
the fold.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-28 20:18:17 -04:00
Quentin Young
dfc5d40e91
Merge pull request #2519 from pacovn/Coverity_1399238_Logically_dead_code
bgpd: dead code (Coverity 1399238)
2018-06-21 14:20:48 -04:00
paco
990f4f9112
bgpd: null check (Coverity 1455380)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-21 18:51:52 +02:00
paco
d87ff2ddf4
bgpd: dead code (Coverity 1399238)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-21 17:22:55 +02:00
Pascal Mathis
1f2263be24
bgpd: Fix crash when showing filtered routes
This commit fixes the issue mentioned in #2419, which is caused by a
double-free. The problem of the current implementation is that
*bgp_input_modifier* already frees the passed attributes under specific
circumstances, which can then lead to a double-free as *bgp_attr_undup*
does not check if the attributes are set to NULL.

As it is not transparent to the function caller if the attributes get
freed or not and the similar function *bgp_output_modifier* also does
not flush the passed attributes, the line has been removed altogether.

All callers of *bgp_input_modifier* already deal by themself with
freeing/flushing/unduping BGP attributes, so it is safe to remove.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-15 00:08:46 +02:00
Chirag Shah
80ced71057 bgpd: Fix bgpd crash in evpn vni route-map
When evpn configured wiht route-map with vni which is not
configured. Upon receiving evpn routes (i.e Type-2, Type-3),
route-map match will be triggered. Since there is no l2vni
exists in db, some of the member fields in bgp_info (i.e.
dummy_info_extra) are passed uninitialized to evpn filter match cb.
This results in inaccessible memory causes crash.

Fix is to memset the bgp_info prior to passing to evpn filter cb.
In evpn vni filter cb, ensure to have NULL check for member filed
of the bgp_info.

memset bgp_info at few places where it is passed to route_match.

Ticket:CM-21335
Reviewed By:
Testing Done:

Configure route-map with not configured l2vni
Simulate to learn l2vpn type-2, 3 route

Restart frr.service with below config
address-family l2vpn evpn
  neighbor fear route-map EVPN_VNI out

route-map EVPN_VNI deny 10
 match evpn vni 140010

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-06-13 10:14:24 -07:00
Donald Sharp
c93a3b77e6 bgpd: Move extra free code and fix a bug.
The bgp_info_extra_free code was the correct place to free
up data associated with the bgp_info pointer when we are
deleting the bgp_info node.

Additionally, if we have a parent pointer, we may not have a net
pointer.  So make sure we do.

Finally clean up the bgp_info_extra_free code so it is a bit
easier to read.  Use variables instead of multiple level
of casting.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-12 15:12:48 -04:00
paco
11f9b4505c
bgpd: OoB access (Coverity 1469897, 1469893)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-11 19:07:13 +02:00
Russ White
c96dfcb980
Merge pull request #2385 from donaldsharp/SA_SA_SA
Some small clang 6.0 cleanups
2018-06-08 06:57:30 -04:00
Russ White
06a4faa7e4
Merge pull request #2349 from donaldsharp/aggregate_stuff
Aggregate stuff
2018-06-08 06:42:24 -04:00
Donald Sharp
ff44f57014 bgpd, lib, ospf6d, vtysh: fix possible snprintf possible truncation
With a new version of clang 6.0, the compiler is detecting more
issues where we may be possibly be truncating the output string.
Fix by increasing the size of the output string to make the compiler
happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-07 19:51:13 -04:00
Lou Berger
7348e571b7
Merge pull request #2335 from donaldsharp/bgp_memory_hooliganism
Bgp memory leaks and crashes?
2018-06-07 06:05:38 -04:00
Donald Sharp
f273fef13f bgpd: Collapse bgp_aggregate_add into bgp_aggregate_route
These two functions are functionally the same, except
bgp_aggregate_route is meant to handle the addition and
deletion of routes, while aggregate_add is meant for all of them.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-06 13:33:19 -04:00
Donald Sharp
eaaf8adb7c bgpd: Allow bgp to know when to actually add/delete agg route
The aggregated route was being sent in updates to peers every
time a route changed that we were aggregating.  Modify
the code such that we only send aggregated route updates
if we actually have something different to tell the peer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-06 13:13:00 -04:00
Donald Sharp
3b7db17342 bgpd: Move bgp_aggregate_delete to a better location
The function bgp_aggregate_delete function was forward
declared and not static.  Move it so we can clean that
up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-06 12:46:14 -04:00
Donald Sharp
c701010e1f bgpd: Seperate out install/removal of aggregate from delete function
This is a transitional commit, to get us where we want to go.
Seperate out the install/removal of the aggregate route from
the bgp_aggregate_delete and bgp_aggregate_route functions.

In the future we'll write a bit of code to determine if the
aggregate add has actually changed any information we care
about.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-06 12:44:07 -04:00
Donald Sharp
3624ac8106 bgpd: Dissallow useless aggregation commands from the cli
We were allowing useless aggregation commands (/32 and /128).
These were being silently accepted and nvgenned and then
just ignored.

When a user enters a value that should be rejected tell
them and reject.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 13:22:11 -04:00
Donald Sharp
cb28a7a514 bgpd: first variable is set but never used.
For the bgp_aggregate_route function it is
set but never used.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 12:56:46 -04:00
Donald Sharp
c2ff8b3ec9 bgpd: rework bgp_aggregate_route
Make bgp_aggregate_route easier to read.  It was indented so many
levels that it was extremely hard to figure out what it was doing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 12:55:13 -04:00
Donald Sharp
4c80d4ccba bgpd: Remove AGGREGATE_NEXTHOP_CHECK as it's been unused
The #define AGGREGATE_NEXTHOP_CHECK has not been used
for a very very long time.  Since this is effectively
dead code, let's remove it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 12:55:13 -04:00
Donald Sharp
b89a6450ba bgpd: Trust the bgp_table_top_nolock for aggregates
The safi passed in to short-circuit the aggregate lookup
adds code complexity and little speed improvements for
the case where we actually may have aggregates configured!
Since bgp_table_top_nolock() actually tells us if there
are any aggregates installed and safely returns if there
is nothing to do, trust it.  As that we know for those
safi's were we don't want to have, we dissallow the
creation via the cli anyways.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 12:55:13 -04:00
Donald Sharp
09990cddff bgpd: Cleanup bgp_aggregate_set/unset to not worry about safi so much
The bgp_aggregate_set/unset functions are only called from the cli
invocations which control what AFI/SAFI we are looking at.  Tests
for safi are unimportant.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 12:55:13 -04:00
Russ White
ebb46153b0
Merge pull request #2245 from donaldsharp/type_4
Support EVPN Type 4 Routes
2018-06-01 16:00:14 -04:00
Donald Sharp
21d88ef761 bgpd: Lock originating bgp pointer for vrf route leaking
There exists cases where we will attempt to hard delete
the bgp instance( say a `no router bgp` is issued )
when we have vrf route leaking.  If we do have this
lock the bgp instance of the originator and do not
let it be deleted out from under us until we are
finished processing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-31 09:43:07 -04:00
Donald Sharp
122eebd85a bgpd: Fix memory use after free
We were immediately using memory after it was freed.  Fix.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-31 09:43:07 -04:00
Donald Sharp
a9bafa95d0 bgpd: Notice when peer_clear fails
Issue Found by Coverity Scan.  When we call peer_clear we
are checking the return code in every other call.  Add
a bit of extra code to notice the failure and note it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-30 09:37:03 -04:00
Donald Sharp
2bb9eff45f bgpd, lib: Cleanup CI warnings from system
Make the CI system happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-30 07:48:21 -04:00