Skip to content

Commit

Permalink
feat(neighbor): support announce all processes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmet2mir committed Sep 27, 2023
1 parent f3580c5 commit cf00e1e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/exabgp/bgp/neighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

# The definition of a neighbor (from reading the configuration)
class Neighbor(dict):
PROCESS_ALL = "all"

class Capability(dict):
defaults = {
'asn4': True,
Expand Down
32 changes: 25 additions & 7 deletions src/exabgp/configuration/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,31 @@ def _reload(self):

def validate(self):
for neighbor in self.neighbors.values():
for notification in neighbor.api:
for api in neighbor.api[notification]:
if not self.processes[api].get('run', ''):
return self.error.set(
"\n\nan api called '%s' is used by neighbor '%s' but not defined\n\n"
% (api, neighbor['peer-address']),
)
# only processes are validated here
if "processes" not in neighbor.api:
continue

if not neighbor.api["processes"]:
return self.error.set(
"\n\nneighbor '%s' declared processes key but it's empty.n\n"
% (neighbor['peer-address']),
)

if len(neighbor.api["processes"]) > 1 and neighbor.PROCESS_ALL in neighbor.api["processes"]:
return self.error.set(
"\n\nneighbor '%s' declared '%s' in processes but it's mutual exclusive with other '%s'.\n\n"
% (neighbor['peer-address'], neighbor.PROCESS_ALL, neighbor.api["processes"]),
)

if neighbor.api["processes"] == [neighbor.PROCESS_ALL]:
continue

for api in neighbor.api["processes"]:
if not self.processes[api].get('run', ''):
return self.error.set(
"\n\nan api called '%s' is used by neighbor '%s' but not defined\n\n"
% (api, neighbor['peer-address']),
)
return None

def _link(self):
Expand Down
4 changes: 4 additions & 0 deletions src/exabgp/reactor/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ def peers(self, service=''):
if service in peer.neighbor.api['processes']:
matching.append(peer_name)
continue
if peer.neighbor.api['processes'] == [peer.neighbor.PROCESS_ALL]:
matching.append(peer_name)
continue

return matching

def handle_connection(self, peer_name, connection):
Expand Down

0 comments on commit cf00e1e

Please sign in to comment.