Skip to content

Commit

Permalink
Update route control script. Still need to address issue with core
Browse files Browse the repository at this point in the history
…interface
  • Loading branch information
gab-arrobo committed Feb 22, 2024
1 parent 094e687 commit c486faf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions conf/route_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,25 +604,25 @@ def _get_gate_idx(self, route_entry: RouteEntry, module_name: str) -> int:
return self._module_gate_count_cache[module_name]

def _netlink_event_listener(
self, netlink_message: dict, action: str
self, ndb: NDB, netlink_message: dict
) -> None:
"""Listens for netlink events and handles them.
Args:
netlink_message (dict): The netlink message.
action (str): The action.
"""
logger.info("%s netlink event received.", action)
event = netlink_message['event']
logger.info("%s netlink event received.", event)
route_entry = self._parse_route_entry_msg(netlink_message)
if action == KEY_NEW_ROUTE_ACTION and route_entry:
if event == KEY_NEW_ROUTE_ACTION and route_entry:
with self._lock:
self.add_new_route_entry(route_entry)

elif action == KEY_DELETE_ROUTE_ACTION and route_entry:
elif event == KEY_DELETE_ROUTE_ACTION and route_entry:
with self._lock:
self.delete_route_entry(route_entry)

elif action == KEY_NEW_NEIGHBOR_ACTION:
elif event == KEY_NEW_NEIGHBOR_ACTION:
with self._lock:
self.add_unresolved_new_neighbor(netlink_message)

Expand Down
6 changes: 3 additions & 3 deletions conf/test_route_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def test_given_netlink_message_when_rtm_newroute_event_then_add_new_route_entry_
"event": "RTM_NEWROUTE",
}
self.route_controller._netlink_event_listener(
example_route_entry, "RTM_NEWROUTE"
self.ndb, example_route_entry
)
mock_add_new_route_entry.assert_called()

Expand Down Expand Up @@ -443,7 +443,7 @@ def test_given_netlink_message_when_rtm_delroute_event_then_delete_route_entry_i
"event": "RTM_DELROUTE",
}
self.route_controller._netlink_event_listener(
example_route_entry, "RTM_DELROUTE"
self.ndb, example_route_entry
)
mock_delete_route_entry.assert_called()

Expand Down Expand Up @@ -481,6 +481,6 @@ def test_given_netlink_message_when_rtm_newneigh_event_then_add_unresolved_new_n
self, mock_add_unresolved_new_neighbor
):
self.route_controller._netlink_event_listener(
"new neighbour message", "RTM_NEWNEIGH"
self.ndb, "new neighbour message"
)
mock_add_unresolved_new_neighbor.assert_called()

0 comments on commit c486faf

Please sign in to comment.