Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action] [PR:15265] Added change to add 'peerType' as element in NEIGH_STATE_TABLE. #15380

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/sonic-bgpcfgd/bgpmon/bgpmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

Initial creation of this daemon is to assist SNMP agent in obtaining the
BGP related information for its MIB support. The MIB that this daemon is
assisting is for the CiscoBgp4MIB (Neighbor state only). If there are other
assisting is for the CiscoBgp4MIB (Neighbor state only). Also for chassis use-case
it identify if the given BGP neighbors as i-BGP vs e-BGP. If there are other
BGP related items that needs to be updated in a periodic manner in the
future, then more can be added into this process.

Expand Down Expand Up @@ -68,7 +69,9 @@ def update_new_peer_states(self, peer_dict):
peer_l = peer_dict["peers"].keys()
self.new_peer_l.update(peer_l)
for peer in peer_l:
self.new_peer_state[peer] = peer_dict["peers"][peer]["state"]
self.new_peer_state[peer] = (peer_dict["peers"][peer]["state"],
peer_dict["peers"][peer]["remoteAs"],
peer_dict["peers"][peer]["localAs"])

# Get a new snapshot of BGP neighbors and store them in the "new" location
def get_all_neigh_states(self):
Expand Down Expand Up @@ -123,17 +126,19 @@ def update_neigh_states(self):
key = "NEIGH_STATE_TABLE|%s" % peer
if peer in self.peer_l:
# only update the entry if state changed
if self.peer_state[peer] != self.new_peer_state[peer]:
if self.peer_state[peer] != self.new_peer_state[peer][0]:
# state changed. Update state DB for this entry
state = self.new_peer_state[peer]
data[key] = {'state':state}
state = self.new_peer_state[peer][0]
peerType = "i-BGP" if self.new_peer_state[peer][1] == self.new_peer_state[peer][2] else "e-BGP"
data[key] = {'state':state, 'peerType':peerType}
self.peer_state[peer] = state
# remove this neighbor from old set since it is accounted for
self.peer_l.remove(peer)
else:
# New neighbor found case. Add to dictionary and state DB
state = self.new_peer_state[peer]
data[key] = {'state':state}
state = self.new_peer_state[peer][0]
peerType = "i-BGP" if self.new_peer_state[peer][1] == self.new_peer_state[peer][2] else "e-BGP"
data[key] = {'state':state, 'peerType':peerType}
self.peer_state[peer] = state
if len(data) > PIPE_BATCH_MAX_COUNT:
self.flush_pipe(data)
Expand Down