(2014/07/18 12:53), FUJITA Tomonori wrote:
> On Thu, 17 Jul 2014 14:25:22 +0900
> Hiroshi Yokoi <[email protected]> wrote:
>
>> BGPOpen that is set to sent_open_msg and recv_open_msg doesn't have
>> caps and BGP capabilities are stored in opt_param as List.
>> I changed the way of checking BGP capabilities.
>>
>> Signed-off-by: Hiroshi Yokoi <[email protected]>
>> ---
>> ryu/services/protocols/bgp/speaker.py | 28 ++++++++++++++++++----------
>> 1 file changed, 18 insertions(+), 10 deletions(-)
>>
>> diff --git a/ryu/services/protocols/bgp/speaker.py
>> b/ryu/services/protocols/bgp/speaker.py
>> index fc7ae9d..7884f2e 100644
>> --- a/ryu/services/protocols/bgp/speaker.py
>> +++ b/ryu/services/protocols/bgp/speaker.py
>> @@ -173,12 +173,17 @@ class BgpProtocol(Protocol, Activity):
>> raise ValueError('Did not yet receive peers open message.')
>>
>> err_cap_enabled = False
>> - local_cap = self.sent_open_msg.caps
>> - peer_cap = self.recv_open_msg.caps
>> + local_caps = self.sent_open_msg.opt_param
>> + peer_caps = self.recv_open_msg.opt_param
>> +
>> + local_cap = [cap for cap in local_caps
>> + if cap.cap_code == BGP_CAP_ENHANCED_ROUTE_REFRESH]
>> + peer_cap = [cap for cap in peer_caps
>> + if cap.cap_code == BGP_CAP_ENHANCED_ROUTE_REFRESH]
>> +
>> # Both local and peer should advertise ERR capability for it to be
>> # enabled.
>> - if (local_cap.get(BGP_CAP_ENHANCED_ROUTE_REFRESH) and
>> - peer_cap.get(BGP_CAP_ENHANCED_ROUTE_REFRESH)):
>> + if local_cap and peer_cap:
>> err_cap_enabled = True
>
> The code could be simpler like?
>
> for cap in set(self.sent_open_msg.opt_param) &
> set(self.recv_open_msg.opt_param):
> if cap.cap_code == BGP_CAP_ENHANCED_ROUTE_REFRESH:
> return True
>
> return False
>
Thank you for your comment.
I will change my code and send the patch later.
>> return err_cap_enabled
>> @@ -217,19 +222,22 @@ class BgpProtocol(Protocol, Activity):
>>
>> @property
>> def negotiated_afs(self):
>> - local_caps = self.sent_open_msg.caps
>> - remote_caps = self.recv_open_msg.caps
>> + local_caps = self.sent_open_msg.opt_param
>> + remote_caps = self.recv_open_msg.opt_param
>> +
>> + local_mbgp_cap = [cap for cap in local_caps
>> + if cap.cap_code == BGP_CAP_MULTIPROTOCOL]
>> + remote_mbgp_cap = [cap for cap in remote_caps
>> + if cap.cap_code == BGP_CAP_MULTIPROTOCOL]
>>
>> - local_mbgp_cap = local_caps.get(BGP_CAP_MULTIPROTOCOL)
>> - remote_mbgp_cap = remote_caps.get(BGP_CAP_MULTIPROTOCOL)
>> # Check MP_BGP capabilities were advertised.
>> if local_mbgp_cap and remote_mbgp_cap:
>> local_families = {
>> - (peer_cap.route_family.afi, peer_cap.route_family.safi)
>> + (peer_cap.afi, peer_cap.safi)
>> for peer_cap in local_mbgp_cap
>> }
>> remote_families = {
>> - (peer_cap.route_family.afi, peer_cap.route_family.safi)
>> + (peer_cap.afi, peer_cap.safi)
>> for peer_cap in remote_mbgp_cap
>> }
>> afi_safi = local_families.intersection(remote_families)
>> --
>> 1.8.5.2 (Apple Git-48)
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Want fast and easy access to all the code in your enterprise? Index and
>> search up to 200,000 lines of code with a free copy of Black Duck
>> Code Sight - the same software that powers the world's largest code
>> search on Ohloh, the Black Duck Open Hub! Try it now.
>> http://p.sf.net/sfu/bds
>> _______________________________________________
>> Ryu-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>
--
------------------------------------------------
Hiroshi Yokoi <[email protected]>
Cloud Computing Business Department
NTT Software Corporation
Tel: +81-45-212-7393
Fax: +81-45-662-7856
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel