782 Commits
Author SHA1 Message Date
IWASE YusukeandFUJITA Tomonori bb562572bc server: Enable to configure static TTL for BGP packets
Like "ttl" configuration of Junos OS, this patch enables to set static
TTL value for outgoing BGP packets.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-23 18:13:19 +09:00
IWASE YusukeandFUJITA Tomonori 4af2f4b7d5 server: Implement TTL security
This patch enable to configure Generalized TTL Security Mechanism
(GTSM).

Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-23 18:13:19 +09:00
IWASE YusukeandFUJITA Tomonori 613d8a1e93 server/sockopt: Support to set minimum TTL
Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-23 18:13:19 +09:00
Satoshi Fujimoto 85a62d8ede peer: Set NeighborAddress before initializing dynamic peers
If State.NeighborAddress is not set, setting default configs
for the dynamic peers will fail. This patch set State.NeighborAddress
before setting default configs.
And this patch avoids overwriting State.NeighborAddress if it is set.

Signed-off-by: Satoshi Fujimoto <[email protected]>
2017-06-20 11:28:09 +09:00
Satoshi Fujimoto 1c7829604d peer: Check errors in creating Dynamic Peers
Signed-off-by: Satoshi Fujimoto <[email protected]>
2017-06-20 11:24:05 +09:00
Satoshi Fujimoto d75edf18d7 server: Support Dynamic Neighbor
Signed-off-by: Satoshi Fujimoto <[email protected]>
2017-06-16 15:53:18 +09:00
Satoshi Fujimoto be2524ee3e config: Use State to get NeighborAddress instead of Config
By introducing dynamic neighbor feature,
GoBGP can have dynamic neighbors,
and corresponding Config.NeighboAddress can be empty.

This patch sets State.NeighborAddress for all neighbors,
and gets the neighbor's address from them.

Signed-off-by: Satoshi Fujimoto <[email protected]>
2017-06-16 09:09:47 +09:00
IWASE Yusuke 7854b9a6c3 bmp: Support number of withdraw updates and prefixes
This patch enables to send BMP statistics reports for the following types;
- Stat Type = 11: (32-bit Counter) Number of updates subjected to
  treat-as-withdraw treatment.
- Stat Type = 12: (32-bit Counter) Number of prefixes subjected to
  treat-as-withdraw treatment.

Note: Currently, this implementation considers only updates or prefixes
received from neighbors, but not enough to follow the handling process
described in RFC7606.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-09 11:23:06 +09:00
FUJITA Tomonori d65df0b045 replace github.com/Sirupsen/logrus with github.com/sirupsen/logrus
The usage of "github.com/sirupsen/logrus" is recommended.

Signed-off-by: FUJITA Tomonori <[email protected]>
2017-06-07 21:04:11 +09:00
IWASE YusukeandFUJITA Tomonori 452eb2a4f6 server_test: Test for Graceful Restart timer expired
This test case checks whether BGP session is freed or not when Graceful
Restart timer expired.
If BGP session is not freed as expectedly, this test case will exit with
state 1 after waiting 120 seconds and will output the following.
  FATA[0147] failed to free the fsm.h.t for 127.0.0.1 BGP_FSM_OPENSENT
  BGP_FSM_IDLE  Topic=Peer

Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-06 13:11:21 +09:00
IWASE YusukeandFUJITA Tomonori cb1a3753dc server_test: Add a sleep for stability
Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-06 13:11:21 +09:00
Wataru IshidaandFUJITA Tomonori da94f98e39 server: Close conn when graceful restart timer expired
Signed-off-by: Wataru Ishida <[email protected]>
2017-06-06 13:11:20 +09:00
IWASE YusukeandFUJITA Tomonori d47c818cb0 server_test: stop listening
Listening on well-known port require the root privileges. This patch
stop listening to avoid that because this test doesn't need to accept
a peer.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-06 13:11:19 +09:00
IWASE YusukeandFUJITA Tomonori b79c5f652f server_test: Confirm BgpServer started and stopped
For each test case, this patch enables to confirm BgpServer is started
successfully and stopped at the of each test case, otherwise the context
of some test cases might affect other test cases.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-06 13:09:45 +09:00
Satoshi FujimotoandFUJITA Tomonori 6e9d5b56c4 *: Support Peer-Group Configuration
This patch enables to create peer-groups,
also supports dynamic configuration to peer-groups.

Manually set fields in neighbor configs have priority over its peer-group's config,
except some fields, like "peer-as", or "minimum-advertisement-interval" and so on.

Signed-off-by: Satoshi Fujimoto <[email protected]>
2017-06-05 14:24:45 +09:00
IWASE YusukeandFUJITA Tomonori 76e2fbd5f0 bmp: Enable to send BMP Route Mirroring messages
Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-03 18:18:23 +09:00
IWASE YusukeandFUJITA Tomonori 1fef6db600 server: Implement event for BGP message watcher
This patch enables to watch events for monitoring received BGP messages
before the state comparison.

Note: Currently, this event nortifies UPDATE message only, because the
other messages will be handled in FSMHandler and not received at
BgpServer, so BgpServer cannot send event for these messages.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-03 18:18:23 +09:00
LamannaandFUJITA Tomonori 52a0f71987 Fix RouteDistinguisher parsing and VPNV6 VRF rib parsing 2017-06-01 12:46:40 +09:00
IWASE YusukeandFUJITA Tomonori 99336372ab packet/mrt: BGP Additional Path Extensions (RFC8050)
This patch enables to decode/encode MRT format with BGP Additional Path
Extensions which described in RFC8050.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-06-01 09:31:52 +09:00
IWASE YusukeandFUJITA Tomonori 0ff4c8b20d bmp: Implement Information TLV on Termination messages
Signed-off-by: IWASE Yusuke <[email protected]>
2017-05-23 14:34:55 +09:00
IWASE YusukeandFUJITA Tomonori d936841fb3 bmp: Implement Information TLV on Initiation message
Currently, the TLV fields are implemented as BMPTLV on the Initiation
messages, but not enough decoded and required to be constructed in
binary format.

This patch introduces BMPInfoTLV and makes easy to handle the TLV
fields.

Note: This patch obsoletes BMPTLV structure.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-05-23 14:34:55 +09:00
IWASE Yusuke b42dec1195 bmp: Stats reports for Adj-RIBs-In and Loc-RIB routes
This patch enable to send BMP statistics reports for the following types;
- Stat Type = 7: Number of routes in Adj-RIBs-In
  = Regarding number of "accepted" routes in AdjTable state
- Stat Type = 8: Number of routes in Loc-RIB
  = Regarding number of "advertised" and "filtered" routes in AdjTable
    state which means the all routes selected by the local BGP speaker's
    Decision Process.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-05-22 13:14:07 +09:00
IWASE Yusuke 76ba8fcbda server/peer: Number of filtered routes to advertise
This patch extend the "AdjTable" container to store the number of the
"filtered" routes which should not be advertised to the given neighbor.
This routes mean the filterd routes because of RTC, VRFs, policy and
other constraints.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-05-22 13:12:02 +09:00
IWASE YusukeandFUJITA Tomonori fa1378f58b bmp: Obsolete "both" option for route-monitoring-policy
Because of the introduction of "local-rib" and "all" options for
route-monitoring-policy, this patch obsoletes "both" option.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-05-22 12:10:07 +09:00
IWASE YusukeandFUJITA Tomonori d2840e6760 bmp: Fix peer header info in Loc-RIB route message
"draft-evens-grow-bmp-local-rib" says the peer header for Loc-RIB
monitoring should include the following values;
- Peer Address: Zero-filled as remote peer address is not applicable.
- Peer AS: Set to the BGP instance global or default ASN value.
- Peer BGP ID: Set to the BGP instance global or RD (e.g. VRF) specific
  router-id.

This patch fixes the peer header construction to follow this
specification.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-05-22 12:10:07 +09:00
IWASE YusukeandFUJITA Tomonori ea56b24395 bmp: Enable to specify all route monitoring policies
This patch adds the new key "all" for specifying the all BMP route
monitoring policies.

Configuration Example:
  [[bmp-servers]]
    [bmp-servers.config]
      address = "127.0.0.1"
      port=11019
      route-monitoring-policy = "all"

Signed-off-by: IWASE Yusuke <[email protected]>
2017-05-22 12:10:07 +09:00
Chris Stockton 02b4ee0d90 server/fsm_test.go: fix race condition during tests
Add sync.Mutex to guard access to MockConnection to prevent tests
ran with -race from failing. In addition change the calls to the fmt
package to use t.Log show they only show with the -v flag to prevent
unwanted noise between test runs. It has the added benefit of
providing a file and line number as well.
2017-05-17 13:12:24 -07:00
Wataru Ishida 4215941eec server: avoid sending unwanted withdrawals to iBGP peers
when the old best was from iBGP, we don't need to send withdrawals
to iBGP peers.

Signed-off-by: Wataru Ishida <[email protected]>
2017-05-14 07:25:17 -04:00
Wataru Ishida 9b9a65d410 *: support replace-peer-as (aka as-override)
we use the term replace-peer-as instead of as-override
since openconfig is using it.

cli

```
$ gobgp n add <neighbor-addr> as <asn> replace-peer-as
```

config

```
neighbor:
  config:
    peer-as: <asn>
    neighbor-address: <neighbor-addr>
  as-path-options:
    config:
      replace-peer-as: true
```

Signed-off-by: Wataru Ishida <[email protected]>
2017-05-10 08:15:00 +00:00
ISHIDA Wataru 0f62519cd7 server: ignore routes when local AS is in AS_PATH
RFC4271 9.1.2 Phase 2: Route Selection

If the AS_PATH attribute of a BGP route contains an AS loop, the BGP
route should be excluded from the Phase 2 decision function.  AS loop
detection is done by scanning the full AS path (as specified in the
AS_PATH attribute), and checking that the autonomous system number of
the local system does not appear in the AS path.  Operations of a BGP
speaker that is configured to accept routes with its own autonomous
system number in the AS path are outside the scope of this document.

Also this commit adds support for allow-own-as option to relax this.

Signed-off-by: ISHIDA Wataru <[email protected]>
2017-05-09 11:10:45 -04:00
Wataru IshidaandFUJITA Tomonori 485b882440 api: fix api/server struct conversion
convert default in/import/export policy type
remove remote-private-as, send-community since we are not using them

Signed-off-by: Wataru Ishida <[email protected]>
2017-05-09 02:52:29 -07:00
Wataru Ishida 86d9587f75 cli: speed up showing a specific defined-set
Signed-off-by: Wataru Ishida <[email protected]>
2017-05-06 09:30:10 -04:00
FUJITA Tomonori 163ac0c327 server: fix handling bgp messages right after moving to idle state from established
currently gobgpd continues to handle update messages even if
becomedidle state from establised.

Signed-off-by: FUJITA Tomonori <[email protected]>
2017-04-27 16:17:41 +09:00
FUJITA Tomonori 738c350a67 server: avoid unnecessary path clone with route server
Signed-off-by: FUJITA Tomonori <[email protected]>
2017-04-27 16:00:54 +09:00
FUJITA Tomonori 7fc7956946 improve performance of getting single neighbor information
avoid calculation of the number of adjout that will not be used.

Signed-off-by: FUJITA Tomonori <[email protected]>
2017-04-20 15:31:27 +09:00
ISHIDA Wataru c8cb20e75b policy: send a withdrawal if export policy blocks an existing route
This patch fixes a bug of export policy and implicit withdrawal.

When a path is filtered by export policy, we need to check whether the
old path (implicit withdrawn path) was sent before the new path.
If it has been sent, we need to send a withdrawal message.

Signed-off-by: ISHIDA Wataru <[email protected]>
2017-04-18 07:40:15 +00:00
IWASE YusukeandFUJITA Tomonori 7307b1490e bmp: BMP Route Monitoring for Local RIB routes
This patch enable to send BMP Route Monitoring message for Local RIB
routes described in bmp-draft-evens-grow-bmp-local-rib.

Configuration Example: gobgpd.toml
  ...
  [[bmp-servers]]
    [bmp-servers.config]
      address = "127.0.0.1"
      port=11019
      route-monitoring-policy = "local-rib"
  ...

Signed-off-by: IWASE Yusuke <[email protected]>
2017-04-17 21:57:11 +09:00
IWASE YusukeandFUJITA Tomonori 93c955a415 packet/bmp: Obsolete policy argument for BMPPeerHeader
According to "draft-evens-grow-bmp-local-rib", the L flag in the Peer
Flags is NOT used for the locally sourced routes and the F flag is
defined into the same bit.

This patch removes "policy" argument and add "flags" argument for
BMPPeerHeader and NewBMPPeerHeader in order to distinguish which flag
is set (the L flag or the F flag).
Then introduce IsPostPolicy() func to show if the L flag is set or not.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-04-17 21:57:11 +09:00
ISHIDA WataruandFUJITA Tomonori bba54bdaa1 skip asn negotiation for BGP unnumbered peers
since BGP unnumbered peers are typically trusted, skip asn negotiation
for easy configuration.

from configuration file:

```toml
[[neighbors]]
[[neighbors.config]]
neighbor-interface = "eth0"
```

from cli:

```
$ gobgp neighbor add interface eth0
```

Signed-off-by: ISHIDA Wataru <[email protected]>
2017-04-04 22:07:46 +09:00
ISHIDA WataruandFUJITA Tomonori 00f8406cb6 packet/bgp: add extended-nexthop capability
Signed-off-by: ISHIDA Wataru <[email protected]>
2017-04-04 22:07:46 +09:00
ISHIDA WataruandFUJITA Tomonori 6d55ba613a table: fix bug of UpdatePathAttrs() with ipv6 link-local peer
config.Neighbor.Transport.State.LocalAddress may have zone info and
not be valid ip address format.
Use PeerInfo.LocalAddress instead.

Signed-off-by: ISHIDA Wataru <[email protected]>
2017-04-04 22:07:46 +09:00
ISHIDA WataruandFUJITA Tomonori 029852207a server: fix bug of wrongly set <nil> to PeerInfo.LocalAddress
config.TransportState.LocalAddress may have zone info with ipv6 address
like "fe80::x%eth0".
In this case, net.ParseIP() returns <nil>, which leads to set <nil> to
PeerInfo.LocalAddress.

Signed-off-by: ISHIDA Wataru <[email protected]>
2017-04-04 22:07:46 +09:00
hepengandFUJITA Tomonori 1d3225bd29 server: fix GetRib() to handle error properly
fix a bug that GetRib() doesn't return an error even if an error
happens.
2017-04-01 16:08:52 +09:00
IWASE YusukeandFUJITA Tomonori f664875808 server/zclient: Retry Zebra message version negotiation
Currently, the Zebra message version used by ZClient is configurable
(default 2), but if the given version is miss-matched with that of
Zebra daemon, ZCient will fail to connect.

This patch fixes ZClient to retry the version negotiation.
For example, if failed with the version 2, retry with the version 3.

Note: In order to receive the first message from Zebra daemon when
instantiating ZClient, this patch fixes ZClient to send HELLO and
ROUTER_ID_ADD messages automatically.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-03-27 14:43:54 +09:00
IWASE Yusuke adcb9ac2dc server/zclient: Dampening for Nexthop Tracking
This patch implents dampening for the Nexthop Tracking as Cisco's
routers doing.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-03-06 11:23:41 +09:00
IWASE Yusuke 2c35b2446d server/zclient: Update nexthop state based on NEXTHOP_UPDATE
This patch enables server/zclient to update the metric or the reachability
state to the nexthop for implementing the Nexthop Tracking features.

Signed-off-by: IWASE Yusuke <[email protected]>
2017-03-06 11:11:54 +09:00
IWASE Yusuke 7ba46c1af5 server/zclient: Register nexthop for Nexthop Tracking
This patch enables server/zclient to register the interested nexthop
for implementing the Nexthop Tracking features.
2017-03-06 11:11:49 +09:00
FUJITA Tomonori ce8b4ee0fa server: fix withdraw with ibgp
with two ibgp peers (a and b), when peer a advertizes one route and
then withdraw it, there are two bugs:

- gobgp sends withdrawal to peer a.
- gobgp sends withdrawal to peer b.

this fixes both.

Signed-off-by: FUJITA Tomonori <[email protected]>
2017-03-05 23:11:44 +09:00
FUJITA Tomonori 3c5b07a6c8 server: avoid sending withdraw to peer just sent withdraw
Signed-off-by: FUJITA Tomonori <[email protected]>
2017-03-05 06:10:30 +09:00
FUJITA Tomonori d104f1ec8f server: add filterpath() unittest
Test a scenario where peer A and B advertized the same prefix, and A's
one was best then peer A withdraws. peer B should get withdrawal.

Signed-off-by: FUJITA Tomonori <[email protected]>
2017-03-05 06:10:30 +09:00