Skip to content

Commit

Permalink
Refactor: Better Control plane AVT for WAN route servers
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc committed Jan 25, 2024
1 parent b35849b commit cb9faad
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ interface Vxlan1
application traffic recognition
!
application ipv4 CONTROL-PLANE-APPLICATION
destination prefix field-set CONTROL-PLANE-APP-DEST-PREFIXES
source prefix field-set CONTROL-PLANE-APP-SRC-PREFIXES
!
application-profile CONTROL-PLANE-APPLICATION-PROFILE
application CONTROL-PLANE-APPLICATION
Expand All @@ -113,8 +113,8 @@ application traffic recognition
!
application-profile VOICE
!
field-set ipv4 prefix CONTROL-PLANE-APP-DEST-PREFIXES
192.168.30.0/24 192.168.31.2/32
field-set ipv4 prefix CONTROL-PLANE-APP-SRC-PREFIXES
192.168.31.1/32
!
ip routing
no ip routing vrf MGMT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ interface Vxlan1
application traffic recognition
!
application ipv4 CONTROL-PLANE-APPLICATION
destination prefix field-set CONTROL-PLANE-APP-DEST-PREFIXES
source prefix field-set CONTROL-PLANE-APP-SRC-PREFIXES
!
application-profile CONTROL-PLANE-APPLICATION-PROFILE
application CONTROL-PLANE-APPLICATION
Expand All @@ -112,8 +112,8 @@ application traffic recognition
!
application-profile VOICE
!
field-set ipv4 prefix CONTROL-PLANE-APP-DEST-PREFIXES
192.168.30.0/24 192.168.31.1/32
field-set ipv4 prefix CONTROL-PLANE-APP-SRC-PREFIXES
192.168.31.2/32
!
ip routing
no ip routing vrf MGMT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ interface Vxlan1
application traffic recognition
!
application ipv4 CONTROL-PLANE-APPLICATION
destination prefix field-set CONTROL-PLANE-APP-DEST-PREFIXES
source prefix field-set CONTROL-PLANE-APP-SRC-PREFIXES
!
application ipv4 CUSTOM-APPLICATION-1
source prefix field-set CUSTOM-SRC-PREFIX-1
Expand All @@ -255,8 +255,8 @@ application traffic recognition
application-profile VOICE
application CUSTOM-VOICE-APPLICATION
!
field-set ipv4 prefix CONTROL-PLANE-APP-DEST-PREFIXES
192.168.42.0/24 192.168.43.0/24
field-set ipv4 prefix CONTROL-PLANE-APP-SRC-PREFIXES
192.168.44.1/32
!
field-set ipv4 prefix CUSTOM-DEST-PREFIX-1
6.6.6.0/24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ interface Vxlan1
application traffic recognition
!
application ipv4 CONTROL-PLANE-APPLICATION
destination prefix field-set CONTROL-PLANE-APP-DEST-PREFIXES
source prefix field-set CONTROL-PLANE-APP-SRC-PREFIXES
!
application ipv4 CUSTOM-APPLICATION-1
source prefix field-set CUSTOM-SRC-PREFIX-1
Expand All @@ -244,8 +244,8 @@ application traffic recognition
application-profile VOICE
application CUSTOM-VOICE-APPLICATION
!
field-set ipv4 prefix CONTROL-PLANE-APP-DEST-PREFIXES
192.168.42.0/24 192.168.43.0/24 192.168.44.3/32 6.6.6.6/32
field-set ipv4 prefix CONTROL-PLANE-APP-SRC-PREFIXES
192.168.44.2/32
!
field-set ipv4 prefix CUSTOM-DEST-PREFIX-1
6.6.6.0/24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ interface Vxlan1
application traffic recognition
!
application ipv4 CONTROL-PLANE-APPLICATION
destination prefix field-set CONTROL-PLANE-APP-DEST-PREFIXES
source prefix field-set CONTROL-PLANE-APP-SRC-PREFIXES
!
application ipv4 CUSTOM-APPLICATION-1
source prefix field-set CUSTOM-SRC-PREFIX-1
Expand All @@ -259,8 +259,8 @@ application traffic recognition
application-profile VOICE
application CUSTOM-VOICE-APPLICATION
!
field-set ipv4 prefix CONTROL-PLANE-APP-DEST-PREFIXES
192.168.42.0/24 192.168.43.0/24 192.168.44.2/32 6.6.6.6/32
field-set ipv4 prefix CONTROL-PLANE-APP-SRC-PREFIXES
192.168.44.3/32
!
field-set ipv4 prefix CUSTOM-DEST-PREFIX-1
6.6.6.0/24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,12 @@ application_traffic_recognition:
applications:
ipv4_applications:
- name: CONTROL-PLANE-APPLICATION
dest_prefix_set_name: CONTROL-PLANE-APP-DEST-PREFIXES
src_prefix_set_name: CONTROL-PLANE-APP-SRC-PREFIXES
field_sets:
ipv4_prefixes:
- name: CONTROL-PLANE-APP-DEST-PREFIXES
- name: CONTROL-PLANE-APP-SRC-PREFIXES
prefix_values:
- 192.168.31.2/32
- 192.168.30.0/24
- 192.168.31.1/32
dps_interfaces:
- name: Dps1
description: DPS Interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,12 @@ application_traffic_recognition:
applications:
ipv4_applications:
- name: CONTROL-PLANE-APPLICATION
dest_prefix_set_name: CONTROL-PLANE-APP-DEST-PREFIXES
src_prefix_set_name: CONTROL-PLANE-APP-SRC-PREFIXES
field_sets:
ipv4_prefixes:
- name: CONTROL-PLANE-APP-DEST-PREFIXES
- name: CONTROL-PLANE-APP-SRC-PREFIXES
prefix_values:
- 192.168.31.1/32
- 192.168.30.0/24
- 192.168.31.2/32
dps_interfaces:
- name: Dps1
description: DPS Interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ application_traffic_recognition:
tcp_src_port_set_name: TCP-SRC-2
tcp_dest_port_set_name: TCP-DEST-2
- name: CONTROL-PLANE-APPLICATION
dest_prefix_set_name: CONTROL-PLANE-APP-DEST-PREFIXES
src_prefix_set_name: CONTROL-PLANE-APP-SRC-PREFIXES
field_sets:
l4_ports:
- name: TCP-SRC-2
Expand All @@ -354,10 +354,9 @@ application_traffic_recognition:
- name: CUSTOM-DEST-PREFIX-1
prefix_values:
- 6.6.6.0/24
- name: CONTROL-PLANE-APP-DEST-PREFIXES
- name: CONTROL-PLANE-APP-SRC-PREFIXES
prefix_values:
- 192.168.42.0/24
- 192.168.43.0/24
- 192.168.44.1/32
dps_interfaces:
- name: Dps1
description: DPS Interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ application_traffic_recognition:
tcp_src_port_set_name: TCP-SRC-2
tcp_dest_port_set_name: TCP-DEST-2
- name: CONTROL-PLANE-APPLICATION
dest_prefix_set_name: CONTROL-PLANE-APP-DEST-PREFIXES
src_prefix_set_name: CONTROL-PLANE-APP-SRC-PREFIXES
field_sets:
l4_ports:
- name: TCP-SRC-2
Expand All @@ -364,12 +364,9 @@ application_traffic_recognition:
- name: CUSTOM-DEST-PREFIX-1
prefix_values:
- 6.6.6.0/24
- name: CONTROL-PLANE-APP-DEST-PREFIXES
- name: CONTROL-PLANE-APP-SRC-PREFIXES
prefix_values:
- 192.168.44.3/32
- 6.6.6.6/32
- 192.168.42.0/24
- 192.168.43.0/24
- 192.168.44.2/32
dps_interfaces:
- name: Dps1
description: DPS Interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ application_traffic_recognition:
tcp_src_port_set_name: TCP-SRC-2
tcp_dest_port_set_name: TCP-DEST-2
- name: CONTROL-PLANE-APPLICATION
dest_prefix_set_name: CONTROL-PLANE-APP-DEST-PREFIXES
src_prefix_set_name: CONTROL-PLANE-APP-SRC-PREFIXES
field_sets:
l4_ports:
- name: TCP-SRC-2
Expand All @@ -382,12 +382,9 @@ application_traffic_recognition:
- name: CUSTOM-DEST-PREFIX-1
prefix_values:
- 6.6.6.0/24
- name: CONTROL-PLANE-APP-DEST-PREFIXES
- name: CONTROL-PLANE-APP-SRC-PREFIXES
prefix_values:
- 192.168.44.2/32
- 6.6.6.6/32
- 192.168.42.0/24
- 192.168.43.0/24
- 192.168.44.3/32
dps_interfaces:
- name: Dps1
description: DPS Interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,49 @@ def _wan_control_plane_application(self) -> str:
def _wan_cp_app_dst_prefix(self) -> str:
return "CONTROL-PLANE-APP-DEST-PREFIXES"

@cached_property
def _wan_cp_app_src_prefix(self) -> str:
return "CONTROL-PLANE-APP-SRC-PREFIXES"

def _generate_control_plane_application_profile(self, app_dict: dict) -> None:
"""
Generate an application profile using a single application matching the device Pathfinders router_ids.
Generate an application profile using a single application matching:
* the device Pathfinders router_ids as destination for non Pathfinders.
* the device Pathfinder router_id as source
Create a structure as follow. If any object already exist, it is kept as defined by user and override the defaults.
application_traffic_recognition:
application_profiles:
- name: CONTROL-PLANE-APPLICATION-PROFILE
Edge and Transit:
application_traffic_recognition:
application_profiles:
- name: CONTROL-PLANE-APPLICATION-PROFILE
applications:
- name: CONTROL-PLANE-APPLICATION
applications:
ipv4_applications:
- name: CONTROL-PLANE-APPLICATION
dest_prefix_set_name: CONTROL-PLANE-APP-DEST-PREFIXES
field_sets:
ipv4_prefixes:
- name: CONTROL-PLANE-APP-DEST-PREFIXES
prefix_values: [Pathfinder to which the router is connected router-ids]
Pathfinder:
application_traffic_recognition:
application_profiles:
- name: CONTROL-PLANE-APPLICATION-PROFILE
applications:
- name: CONTROL-PLANE-APPLICATION
applications:
- name: CONTROL-PLANE-APPLICATION
applications:
ipv4_applications:
- name: CONTROL-PLANE-APPLICATION
dest_prefix_set_name: CONTROL-PLANE-APP-DEST-PREFIXES
field_sets:
ipv4_prefixes:
- name: CONTROL-PLANE-APP-DEST-PREFIXES
prefix_values: [Pathfinder to which the router is connected router-ids]
ipv4_applications:
- name: CONTROL-PLANE-APPLICATION
src_prefix_set_name: CONTROL-PLANE-APP-SRC-PREFIXES
field_sets:
ipv4_prefixes:
- name: CONTROL-PLANE-APP-SRC-PREFIXES
prefix_values: [Pathfinder router_id]
"""
# Adding the application-profile
application_profiles = get(app_dict, "application_profiles", [])
Expand All @@ -78,26 +102,34 @@ def _generate_control_plane_application_profile(self, app_dict: dict) -> None:
ipv4_applications = get(app_dict, "applications.ipv4_applications", [])
if get_item(ipv4_applications, "name", self._wan_control_plane_application) is not None:
return
app_dict.setdefault("applications", {}).setdefault("ipv4_applications", []).append(
{
"name": self._wan_control_plane_application,
"dest_prefix_set_name": self._wan_cp_app_dst_prefix,
}
)
# Adding the field-set based on the connected Pathfinder router-ids
ipv4_prefixes_field_sets = get(app_dict, "field_sets.ipv4_prefixes", [])
if get_item(ipv4_prefixes_field_sets, "name", self._wan_cp_app_dst_prefix) is not None:
return
pathfinder_router_ids = [f"{wan_rs_data.get('router_id')}/32" for wan_rs, wan_rs_data in self.shared_utils.filtered_wan_route_servers.items()]
if self.shared_utils.wan_role == "server":
pathfinder_router_ids.extend(self.shared_utils.wan_listen_ranges)

app_dict.setdefault("field_sets", {}).setdefault("ipv4_prefixes", []).append(
{
"name": self._wan_cp_app_dst_prefix,
"prefix_values": pathfinder_router_ids,
}
)
if self.shared_utils.wan_role == "client":
app_dict.setdefault("applications", {}).setdefault("ipv4_applications", []).append(
{
"name": self._wan_control_plane_application,
"dest_prefix_set_name": self._wan_cp_app_dst_prefix,
}
)
# Adding the field-set based on the connected Pathfinder router-ids
ipv4_prefixes_field_sets = get(app_dict, "field_sets.ipv4_prefixes", [])
if get_item(ipv4_prefixes_field_sets, "name", self._wan_cp_app_dst_prefix) is not None:
return
pathfinder_router_ids = [f"{wan_rs_data.get('router_id')}/32" for wan_rs, wan_rs_data in self.shared_utils.filtered_wan_route_servers.items()]
app_dict.setdefault("field_sets", {}).setdefault("ipv4_prefixes", []).append(
{
"name": self._wan_cp_app_dst_prefix,
"prefix_values": pathfinder_router_ids,
}
)
elif self.shared_utils.wan_role == "server":
app_dict.setdefault("applications", {}).setdefault("ipv4_applications", []).append(
{
"name": self._wan_control_plane_application,
"src_prefix_set_name": self._wan_cp_app_src_prefix,
}
)
app_dict.setdefault("field_sets", {}).setdefault("ipv4_prefixes", []).append(
{"name": self._wan_cp_app_src_prefix, "prefix_values": [f"{self.shared_utils.router_id}/32"]}
)

def _filtered_application_traffic_recognition(self) -> dict:
"""
Expand Down

0 comments on commit cb9faad

Please sign in to comment.