BGPSpeaker: Advertise local routes to RR clients

The current implementation misses the mandatory attributes when sending
locally generated routes to its Route Reflector (RR) clients, then the
clients will reject the received routes.

This patch fixes to add or update attributes to for sending locally
generated routes its RR clients.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
IWASE Yusuke 2018-06-13 15:57:29 +09:00 committed by FUJITA Tomonori
parent a6bda030d3
commit db7338b8db

View File

@ -989,10 +989,9 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
elif self.is_route_server_client: elif self.is_route_server_client:
nlri_list = [path.nlri] nlri_list = [path.nlri]
new_pathattr.extend(pathattr_map.values()) new_pathattr.extend(pathattr_map.values())
elif self.is_route_reflector_client: else:
nlri_list = [path.nlri] if self.is_route_reflector_client:
# Append ORIGINATOR_ID attribute if not already exist.
# Append ORIGINATOR_ID attribute if not already exists.
if BGP_ATTR_TYPE_ORIGINATOR_ID not in pathattr_map: if BGP_ATTR_TYPE_ORIGINATOR_ID not in pathattr_map:
originator_id = path.source originator_id = path.source
if originator_id is None: if originator_id is None:
@ -1002,24 +1001,20 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
new_pathattr.append( new_pathattr.append(
BGPPathAttributeOriginatorId(value=originator_id)) BGPPathAttributeOriginatorId(value=originator_id))
# Append CLUSTER_LIST attribute if not already exists. # Preppend own CLUSTER_ID into CLUSTER_LIST attribute if exist.
if BGP_ATTR_TYPE_CLUSTER_LIST not in pathattr_map: # Otherwise append CLUSTER_LIST attribute.
cluster_lst_attr = pathattr_map.get(BGP_ATTR_TYPE_CLUSTER_LIST)
if cluster_lst_attr:
cluster_list = list(cluster_lst_attr.value)
if self._common_conf.cluster_id not in cluster_list:
cluster_list.insert(0, self._common_conf.cluster_id)
new_pathattr.append(
BGPPathAttributeClusterList(cluster_list))
else:
new_pathattr.append( new_pathattr.append(
BGPPathAttributeClusterList( BGPPathAttributeClusterList(
[self._common_conf.cluster_id])) [self._common_conf.cluster_id]))
for t, path_attr in pathattr_map.items():
if t == BGP_ATTR_TYPE_CLUSTER_LIST:
# Append own CLUSTER_ID into CLUSTER_LIST attribute
# if already exists.
cluster_list = list(path_attr.value)
if self._common_conf.cluster_id not in cluster_list:
cluster_list.append(self._common_conf.cluster_id)
new_pathattr.append(
BGPPathAttributeClusterList(cluster_list))
else:
new_pathattr.append(path_attr)
else:
# Supported and un-supported/unknown attributes. # Supported and un-supported/unknown attributes.
origin_attr = None origin_attr = None
nexthop_attr = None nexthop_attr = None