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