BGP soft-reconfiguration功能實驗


實驗拓撲

實驗說明:配置RTA和RTB互為鄰居,在RTA上為鄰居RTB開啟soft reconfiguration功能,在RTB上使用network命令發布兩條路由給RTA,改變RTB的路由策略,觸發soft reconfiguration

配置

步驟1

RTA

Current configuration:
!
frr version 7.1
frr defaults traditional
hostname 486cd3e0f81f
log syslog informational
no ipv6 forwarding
service integrated-vtysh-config
!
router bgp 65001
 neighbor 10.1.1.2 remote-as external
 !
 address-family ipv4 unicast
  neighbor 10.1.1.2 soft-reconfiguration inbound
 exit-address-family
!
line vty
!
end

RTB

Current configuration:
!
frr version 7.1
frr defaults traditional
hostname a86b8fff04c7
log syslog informational
no ipv6 forwarding
service integrated-vtysh-config
!
router bgp 65002
 neighbor 10.1.1.1 remote-as external
 !
 address-family ipv4 unicast
  network 6.6.6.0/24
  network 6.6.7.0/24
 exit-address-family
!
line vty
!
end

查看RTA上的鄰居信息

486cd3e0f81f# show bgp neighbors 10.1.1.2 
For address family: IPv4 Unicast
  Update group 1, subgroup 1
  Packet Queue length 0
  Inbound soft reconfiguration allowed
  Community attribute sent to this neighbor(all)
  2 accepted prefixes

  Connections established 1; dropped 0

從上面可以看出,RTB在inbound方向已經開啟soft-reconfiguration功能。

查看RTA上的路由信息

486cd3e0f81f# show ip bgp      
BGP table version is 2, local router ID is 172.17.0.2, vrf id 0
Default local pref 100, local AS 65001
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 6.6.6.0/24       10.1.1.2                 0             0 65002 i
*> 6.6.7.0/24       10.1.1.2                 0             0 65002 i

Displayed  2 routes and 2 total paths
486cd3e0f81f# 

步驟2

在RTA上配置route-map觸發路由策略變化

486cd3e0f81f(config)# route-map LOCPREF permit 10
486cd3e0f81f(config-route-map)# set local-preference 222
486cd3e0f81f(config-route-map)# router bgp 65001
486cd3e0f81f(config-router)# address-family ipv4 unicast 
486cd3e0f81f(config-router-af)# neighbor 10.1.1.2 route-map LOCPREF in
486cd3e0f81f(config-router-af)# 

查看RTA上的路由信息

486cd3e0f81f# show ip bgp      
BGP table version is 4, local router ID is 172.17.0.2, vrf id 0
Default local pref 100, local AS 65001
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 6.6.6.0/24       10.1.1.2                 0    222      0 65002 i
*> 6.6.7.0/24       10.1.1.2                 0    222      0 65002 i

Displayed  2 routes and 2 total paths
486cd3e0f81f# 

從兩個路由信息可以看出,路由的LocPrf從0變到了222,路由進行了刷新。

分析

frr在處理路由策略或者屬性變化的時候,通常可以使用如下三種方式使得路由策略生效:

  • hard reset:強制tcp連接斷開,重新建立bgp鄰居,該方法最簡單,但是會出現斷流現象。
  • route refresh :路由刷新機制,通過給鄰居發送route refresh消息,通知鄰居重新發送所有路由,該方法是最優的,但是老的版本可能不支持該功能。
  • soft reconfiguration :通過在本地存儲鄰居所有的路由信息(沒做任何變化),當發生路由策略變化時,使用緩存的路由信息進行刷新。該機制需要耗費額外的內存來存儲這些信息。

FRR默認使用route refresh功能,如果開啟了soft reconfiguration功能的話,則使用soft reconfiguration。

FRR在存儲路由信息時如下圖所示:

當開啟soft-reconfiguration功能時,adj-RIB-In才會需要。

例如在上面的實驗中,如果沒有開啟soft-reconfiguration功能,則默認使用route refresh功能,其內存使用情況如下:

486cd3e0f81f# show bgp memory 
8 RIB nodes, using 1280 bytes of memory
2 BGP routes, using 224 bytes of memory
1 Packets, using 56 bytes of memory
2 Adj-Out entries, using 176 bytes of memory
1 Nexthop cache entries, using 72 bytes of memory
2 BGP attributes, using 464 bytes of memory
1 BGP AS-PATH entries, using 40 bytes of memory
1 BGP AS-PATH segments, using 24 bytes of memory
3 peers, using 62 KiB of memory
733 hash tables, using 46 KiB of memory
2137 hash buckets, using 67 KiB of memory
486cd3e0f81f# 

開啟soft-reconfiguration功能后,其內存使用情況如下:

486cd3e0f81f# show bgp memory 
8 RIB nodes, using 1280 bytes of memory
2 BGP routes, using 224 bytes of memory
1 Packets, using 56 bytes of memory
2 Adj-In entries, using 80 bytes of memory
2 Adj-Out entries, using 176 bytes of memory
1 Nexthop cache entries, using 72 bytes of memory
3 BGP attributes, using 696 bytes of memory
1 BGP AS-PATH entries, using 40 bytes of memory
1 BGP AS-PATH segments, using 24 bytes of memory
3 peers, using 62 KiB of memory
733 hash tables, using 46 KiB of memory
2138 hash buckets, using 67 KiB of memory
486cd3e0f81f# 

通過對比可以看出,沒有開啟soft-reconfiguration功能時,不會存在Adj-In表項。

抓包分析

在對鄰居配置soft reconfiguration功能時,會向鄰居發送一個route refresh消息,觸發對路由信息進行緩存。
如果不支持route refresh功能的話,會強制進行連接復位。
從下面代碼可以看出:

void peer_change_action(struct peer *peer, afi_t afi, safi_t safi,
			       enum peer_change_type type)
{
	if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
		return;

	if (peer->status != Established)
		return;

	if (type == peer_change_reset) {//強制重新建立連接關系
		/* If we're resetting session, we've to delete both peer struct
		 */
		if ((peer->doppelganger)
		    && (peer->doppelganger->status != Deleted)
		    && (!CHECK_FLAG(peer->doppelganger->flags,
				    PEER_FLAG_CONFIG_NODE)))
			peer_delete(peer->doppelganger);

		bgp_notify_send(peer, BGP_NOTIFY_CEASE,
				BGP_NOTIFY_CEASE_CONFIG_CHANGE);
	} else if (type == peer_change_reset_in) {//對於復位輸入方向的路由信息
		if (CHECK_FLAG(peer->cap, PEER_CAP_REFRESH_OLD_RCV)//如果鄰居支持route refresh的話,則發送route refresh
		    || CHECK_FLAG(peer->cap, PEER_CAP_REFRESH_NEW_RCV))
			bgp_route_refresh_send(peer, afi, safi, 0, 0, 0);
		else {//否則復位連接
			if ((peer->doppelganger)
			    && (peer->doppelganger->status != Deleted)
			    && (!CHECK_FLAG(peer->doppelganger->flags,
					    PEER_FLAG_CONFIG_NODE)))
				peer_delete(peer->doppelganger);

			bgp_notify_send(peer, BGP_NOTIFY_CEASE,
					BGP_NOTIFY_CEASE_CONFIG_CHANGE);
		}
	} else if (type == peer_change_reset_out) {
	    //重新向對等體宣告路由
		update_group_adjust_peer(peer_af_find(peer, afi, safi));
		bgp_announce_route(peer, afi, safi);
	}
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM