mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-05 20:36:10 +02:00
bgp: remove unnecessary OutgoingRoute attribute 'bgp4_format'
Attribute 'bgp4_format' was intended to be used to decide whether to construct UPDATE msg in bgp4 format or mpbgp format. But we can decide this simply by checking the path type which we are going update. If the path type is IPv4, we use bgp4 format. In other cases, we use mpbgp format. Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
2c7ca2ff2d
commit
afc0b98b20
@ -44,11 +44,11 @@ class OutgoingRoute(object):
|
||||
"""Holds state about a route that is queued for being sent to a given sink.
|
||||
"""
|
||||
|
||||
__slots__ = ('_path', '_for_route_refresh', 'bgp4_format',
|
||||
__slots__ = ('_path', '_for_route_refresh',
|
||||
'sink', 'next_outgoing_route', 'prev_outgoing_route',
|
||||
'next_sink_out_route', 'prev_sink_out_route')
|
||||
|
||||
def __init__(self, path, for_route_refresh=False, bgp4_format=False):
|
||||
def __init__(self, path, for_route_refresh=False):
|
||||
assert(path)
|
||||
|
||||
self.sink = None
|
||||
@ -59,9 +59,6 @@ class OutgoingRoute(object):
|
||||
# No sent-route is queued for the destination for this update.
|
||||
self._for_route_refresh = for_route_refresh
|
||||
|
||||
# Construct UPDATE msg using bgp4 format
|
||||
self.bgp4_format = bgp4_format
|
||||
|
||||
# Automatically generated, for list off of Destination.
|
||||
#
|
||||
# self.next_outgoing_route
|
||||
|
||||
@ -33,6 +33,7 @@ from ryu.services.protocols.bgp.net_ctrl import NET_CONTROLLER
|
||||
from ryu.services.protocols.bgp.rtconf.neighbors import NeighborConfListener
|
||||
from ryu.services.protocols.bgp.signals.emit import BgpSignalBus
|
||||
from ryu.services.protocols.bgp.speaker import BgpProtocol
|
||||
from ryu.services.protocols.bgp.info_base.ipv4 import Ipv4Path
|
||||
from ryu.services.protocols.bgp.utils import bgp as bgp_utils
|
||||
from ryu.services.protocols.bgp.utils.evtlet import EventletIOFactory
|
||||
from ryu.services.protocols.bgp.utils import stats
|
||||
@ -607,7 +608,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
|
||||
new_pathattr = []
|
||||
|
||||
if path.is_withdraw:
|
||||
if self._neigh_conf.cap_mbgp_ipv4:
|
||||
if isinstance(path, Ipv4Path):
|
||||
update = BGPUpdate(withdrawn_routes=[path.nlri])
|
||||
return update
|
||||
else:
|
||||
@ -639,7 +640,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
|
||||
nexthop_attr = BGPPathAttributeNextHop(next_hop)
|
||||
assert nexthop_attr, 'Missing NEXTHOP mandatory attribute.'
|
||||
|
||||
if not self._neigh_conf.cap_mbgp_ipv4:
|
||||
if not isinstance(path, Ipv4Path):
|
||||
# We construct mpreach-nlri attribute.
|
||||
mpnlri_attr = BGPPathAttributeMpReachNLRI(
|
||||
path.route_family.afi,
|
||||
@ -754,7 +755,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
|
||||
# Ordering path attributes according to type as RFC says. We set
|
||||
# MPReachNLRI first as advised by experts as a new trend in BGP
|
||||
# implementation.
|
||||
if self._neigh_conf.cap_mbgp_ipv4:
|
||||
if isinstance(path, Ipv4Path):
|
||||
new_pathattr.append(nexthop_attr)
|
||||
else:
|
||||
new_pathattr.append(mpnlri_attr)
|
||||
@ -772,7 +773,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
|
||||
if unkown_opttrans_attrs:
|
||||
new_pathattr.extend(unkown_opttrans_attrs.values())
|
||||
|
||||
if self._neigh_conf.cap_mbgp_ipv4:
|
||||
if isinstance(path, Ipv4Path):
|
||||
update = BGPUpdate(path_attributes=new_pathattr,
|
||||
nlri=nlri_list)
|
||||
else:
|
||||
@ -1661,10 +1662,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
|
||||
|
||||
# Construct OutgoingRoute specific for this peer and put it in
|
||||
# its sink.
|
||||
bgp4_format = False
|
||||
if self._neigh_conf.cap_mbgp_ipv4:
|
||||
bgp4_format = True
|
||||
outgoing_route = OutgoingRoute(path, bgp4_format=bgp4_format)
|
||||
outgoing_route = OutgoingRoute(path)
|
||||
self.enque_outgoing_msg(outgoing_route)
|
||||
LOG.debug('Enqueued outgoing route %s for peer %s' %
|
||||
(outgoing_route.path.nlri, self))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user