From 85b0f487473513bbe7a4cc9772ddcddb135f0268 Mon Sep 17 00:00:00 2001 From: Mircea Dan Date: Tue, 21 Nov 2023 16:29:57 -0800 Subject: [PATCH] acl + mapping fix --- dpugen/confbase.py | 11 +++++++---- dpugen/dash.py | 17 ++++++++++++----- dpugen/dashgen/acl_rule.py | 12 ++++++++---- dpugen/dashgen/dash_eni_table.py | 9 +++++++-- dpugen/dashgen/dash_route_table.py | 6 +++++- dpugen/dashgen/dash_vnet_mapping_table.py | 15 +++++++++++---- dpugen/dflt_params.py | 19 ++++++++++--------- dpugen/saigen/address_maps.py | 5 ++++- dpugen/saigen/enis.py | 5 ++++- dpugen/saigen/inbound_routing.py | 5 ++++- dpugen/saigen/outbound_ca_to_pa.py | 6 +++++- dpugen/saigen/outbound_routing.py | 5 ++++- dpugen/saigen/pa_validation.py | 5 ++++- 13 files changed, 85 insertions(+), 35 deletions(-) diff --git a/dpugen/confbase.py b/dpugen/confbase.py index e9cee35..0397ebf 100644 --- a/dpugen/confbase.py +++ b/dpugen/confbase.py @@ -2,7 +2,10 @@ import pprint import socket import struct -from abc import ABC, abstractmethod +from abc import ( + ABC, + abstractmethod +) from copy import deepcopy from datetime import datetime @@ -61,9 +64,9 @@ def cook_params(self): for mac in [ 'MAC_L_START', 'MAC_R_START', - 'ACL_NSG_MAC_STEP', - 'ENI_MAC_STEP', - 'ACL_POLICY_MAC_STEP' + 'MAC_STEP_ENI', + 'MAC_STEP_NSG', + 'MAC_STEP_ACL' ]: self.cooked_params_dict[mac] = int(maca(self.params_dict[mac])) diff --git a/dpugen/dash.py b/dpugen/dash.py index b7e09b8..e2ad926 100644 --- a/dpugen/dash.py +++ b/dpugen/dash.py @@ -2,8 +2,8 @@ """Entry point to generate a DPU Hero test config in DASH format.""" import copy import ipaddress -import sys import multiprocessing +import sys import dpugen.dashgen.acl_group import dpugen.dashgen.acl_rule @@ -14,8 +14,15 @@ import dpugen.dashgen.dash_vnet_mapping_table import dpugen.dashgen.dash_vnet_table -from .confbase import ConfBase, maca -from .confutils import common_arg_parser, common_output, common_parse_args +from .confbase import ( + ConfBase, + maca +) +from .confutils import ( + common_arg_parser, + common_output, + common_parse_args +) class DashConfig(ConfBase): @@ -71,8 +78,8 @@ def create_asic_config(dpu_conf, dpu_params, dpu_id): dpu_params['PAR'] = str(ipaddress.ip_address(conf.params_dict['PAR']) + dpu_id * ENI_COUNT * int(ipaddress.ip_address(conf.params_dict['IP_STEP1']))) dpu_params['IP_L_START'] = str(ipaddress.ip_address(conf.params_dict['IP_L_START']) + dpu_id * ENI_COUNT * int(ipaddress.ip_address(conf.params_dict['IP_STEP_ENI']))) dpu_params['IP_R_START'] = str(ipaddress.ip_address(conf.params_dict['IP_R_START']) + dpu_id * ENI_COUNT * int(ipaddress.ip_address(conf.params_dict['IP_STEP_ENI']))) - dpu_params['MAC_L_START'] = str(int(maca(conf.params_dict['MAC_L_START'])) + dpu_id * ENI_COUNT * int(maca(conf.params_dict['ENI_MAC_STEP']))).replace('-', ':') - dpu_params['MAC_R_START'] = str(int(maca(conf.params_dict['MAC_R_START'])) + dpu_id * ENI_COUNT * int(maca(conf.params_dict['ENI_MAC_STEP']))).replace('-', ':') + dpu_params['MAC_L_START'] = str(int(maca(conf.params_dict['MAC_L_START'])) + dpu_id * ENI_COUNT * int(maca(conf.params_dict['MAC_STEP_ENI']))) + dpu_params['MAC_R_START'] = str(int(maca(conf.params_dict['MAC_R_START'])) + dpu_id * ENI_COUNT * int(maca(conf.params_dict['MAC_STEP_ENI']))) threads.append(multiprocessing.Process(target=create_asic_config, args=(dpu_conf, dpu_params, dpu_id))) diff --git a/dpugen/dashgen/acl_rule.py b/dpugen/dashgen/acl_rule.py index b566f72..02af37c 100644 --- a/dpugen/dashgen/acl_rule.py +++ b/dpugen/dashgen/acl_rule.py @@ -4,7 +4,11 @@ import sys from copy import deepcopy -from dpugen.confbase import ConfBase, socket_inet_ntoa, struct_pack +from dpugen.confbase import ( + ConfBase, + socket_inet_ntoa, + struct_pack +) from dpugen.confutils import common_main @@ -25,9 +29,9 @@ def items(self): l_ip_ac = deepcopy(str(local_ip) + '/32') for stage_in_index in range(p.ACL_NSG_COUNT): # Per inbound group table_id = eni * 1000 + stage_in_index - IP_R_START_stage = ip_int.IP_R_START + (eni_index * ip_int.IP_STEP_ENI) + (stage_in_index * ip_int.IP_STEP_NSG) + IP_R_START_stage = ip_int.IP_R_START + eni_index * ip_int.IP_STEP_ENI + stage_in_index * ip_int.IP_STEP_NSG for ip_index in range(0, p.ACL_RULES_NSG, 2): # Per even ACL rule - remote_ip_a = IP_R_START_stage + ((ip_index // 2) * ip_int.IP_STEP_ACL) + remote_ip_a = IP_R_START_stage + ip_index * p.IP_PER_ACL_RULE ip_list_a = [socket_inet_ntoa(struct_pack('>L', remote_ip_a + expanded_index * ip_int.IP_STEPE)) + '/32' for expanded_index in range(0, p.IP_PER_ACL_RULE)] ip_list_all = [] @@ -83,7 +87,7 @@ def items(self): table_id = eni * 1000 + 500 + stage_out_index IP_R_START_stage = ip_int.IP_R_START + (eni_index * ip_int.IP_STEP_ENI) + (p.ACL_NSG_COUNT + stage_out_index) * ip_int.IP_STEP_NSG for ip_index in range(0, p.ACL_RULES_NSG, 2): - remote_ip_a = IP_R_START_stage + (ip_index // 2) * ip_int.IP_STEP_ACL + remote_ip_a = IP_R_START_stage + ip_index * p.IP_PER_ACL_RULE ip_list_a = [socket_inet_ntoa(struct_pack('>L', remote_ip_a + expanded_index * ip_int.IP_STEPE)) + '/32' for expanded_index in range(0, p.IP_PER_ACL_RULE)] ip_list_all = [] diff --git a/dpugen/dashgen/dash_eni_table.py b/dpugen/dashgen/dash_eni_table.py index fa13ca5..206cd87 100644 --- a/dpugen/dashgen/dash_eni_table.py +++ b/dpugen/dashgen/dash_eni_table.py @@ -3,7 +3,12 @@ import os import sys -from dpugen.confbase import ConfBase, maca, socket_inet_ntoa, struct_pack +from dpugen.confbase import ( + ConfBase, + maca, + socket_inet_ntoa, + struct_pack +) from dpugen.confutils import common_main @@ -19,7 +24,7 @@ def items(self): ip_int = self.cooked_params for eni_index, eni in enumerate(range(p.ENI_START, p.ENI_START + p.ENI_COUNT * p.ENI_STEP, p.ENI_STEP)): # Per ENI - local_mac = str(maca(int(ip_int.MAC_L_START) + eni_index * int(maca(p.ENI_MAC_STEP)))) + local_mac = str(maca(ip_int.MAC_L_START + eni_index * ip_int.MAC_STEP_ENI)) vm_underlay_dip = socket_inet_ntoa(struct_pack('>L', ip_int.PAL + eni_index * ip_int.IP_STEP1)) r_vni_id = p.ENI_L2R_STEP + eni for nsg_index in range(p.ACL_NSG_COUNT * 2): diff --git a/dpugen/dashgen/dash_route_table.py b/dpugen/dashgen/dash_route_table.py index 5924f8b..3797ad4 100644 --- a/dpugen/dashgen/dash_route_table.py +++ b/dpugen/dashgen/dash_route_table.py @@ -5,7 +5,11 @@ import sys from operator import itemgetter -from dpugen.confbase import ConfBase, socket_inet_ntoa, struct_pack +from dpugen.confbase import ( + ConfBase, + socket_inet_ntoa, + struct_pack +) from dpugen.confutils import common_main diff --git a/dpugen/dashgen/dash_vnet_mapping_table.py b/dpugen/dashgen/dash_vnet_mapping_table.py index 3402bc6..5ff9600 100644 --- a/dpugen/dashgen/dash_vnet_mapping_table.py +++ b/dpugen/dashgen/dash_vnet_mapping_table.py @@ -3,7 +3,12 @@ import os import sys -from dpugen.confbase import ConfBase, maca, socket_inet_ntoa, struct_pack +from dpugen.confbase import ( + ConfBase, + maca, + socket_inet_ntoa, + struct_pack +) from dpugen.confutils import common_main @@ -24,16 +29,18 @@ def items(self): r_vni_id = eni + p.ENI_L2R_STEP remote_ip_a_eni = ip_int.IP_R_START + eni_index * ip_int.IP_STEP_ENI + remote_mac_a_eni = ip_int.MAC_R_START + eni_index * ip_int.MAC_STEP_ENI # 1 in 4 enis will have all its ips mapped if (eni % 4) == 1: # mapped IPs print(f' mapped:eni:{eni}', file=sys.stderr) for nsg_index in range(p.ACL_NSG_COUNT * 2): # Per outbound stage remote_ip_a_nsg = remote_ip_a_eni + nsg_index * ip_int.IP_STEP_NSG + remote_mac_a_nsg = remote_mac_a_eni + nsg_index * ip_int.MAC_STEP_NSG # Per half of the rules for acl_index in range(p.ACL_RULES_NSG // 2): - remote_ip_a = remote_ip_a_nsg + acl_index * ip_int.IP_STEP_ACL - remote_mac_a = ip_int.MAC_R_START + eni_index * ip_int.ENI_MAC_STEP + nsg_index * ip_int.ACL_NSG_MAC_STEP + acl_index * ip_int.ACL_POLICY_MAC_STEP + remote_ip_a = remote_ip_a_nsg + acl_index * p.IP_PER_ACL_RULE * 2 + remote_mac_a = remote_mac_a_nsg + acl_index * p.IP_PER_ACL_RULE * 2 # Allow for i in range(p.IP_MAPPED_PER_ACL_RULE): # Per rule prefix @@ -55,7 +62,7 @@ def items(self): # routed IPs print(f' routed:eni:{eni}', file=sys.stderr) - remote_expanded_mac = str(maca(ip_int.MAC_R_START + eni_index * ip_int.ENI_MAC_STEP)) + remote_expanded_mac = str(maca(ip_int.MAC_R_START + eni_index * ip_int.MAC_STEP_ENI)) self.num_yields += 1 yield { 'DASH_VNET_MAPPING_TABLE:vnet-%d:%s' % (r_vni_id, vtep_eni): { diff --git a/dpugen/dflt_params.py b/dpugen/dflt_params.py index 30ee36f..4732e86 100644 --- a/dpugen/dflt_params.py +++ b/dpugen/dflt_params.py @@ -12,25 +12,26 @@ 'ENI_START': 1, # 1 'ENI_COUNT': 256, # 32 - 'ENI_MAC_STEP': '00:00:00:18:00:00', # '00:00:00:18:00:00' 'ENI_STEP': 1, # 1 'ENI_L2R_STEP': 1000, # 1000 'VNET_PER_ENI': 1, # 16 TODO: partialy implemented - 'MAC_L_START': '00:1A:C5:00:00:01', - 'MAC_R_START': '00:1B:6E:00:00:01', - - 'IP_L_START': '1.1.0.1', # local, eni - 'IP_R_START': '1.4.0.1', # remote, the world - 'ACL_NSG_COUNT': 5, # 5 (per direction per ENI) 'ACL_RULES_NSG': 1000, # 1000 'IP_PER_ACL_RULE': 100, # 128 'IP_MAPPED_PER_ACL_RULE': 100, # 128 (must be equal with IP_PER_ACL_RULE) TODO: not implemented - 'ACL_NSG_MAC_STEP': '00:00:00:02:00:00', - 'ACL_POLICY_MAC_STEP': '00:00:00:00:01:00', + + 'MAC_L_START': '00:1A:C5:00:00:01', + 'MAC_R_START': '00:1B:6E:00:00:01', + + 'MAC_STEP_ENI': '00:00:00:18:00:00', # '00:00:00:18:00:00' + 'MAC_STEP_NSG': '00:00:00:02:00:00', + 'MAC_STEP_ACL': '00:00:00:00:01:00', + + 'IP_L_START': '1.1.0.1', # local, eni + 'IP_R_START': '1.4.0.1', # remote, the world 'IP_STEP1': '0.0.0.1', 'IP_STEP_ENI': '0.64.0.0', diff --git a/dpugen/saigen/address_maps.py b/dpugen/saigen/address_maps.py index 326e0a1..cd74f30 100644 --- a/dpugen/saigen/address_maps.py +++ b/dpugen/saigen/address_maps.py @@ -4,7 +4,10 @@ import os import sys -from dpugen.confbase import ConfBase, maca +from dpugen.confbase import ( + ConfBase, + maca +) from dpugen.confutils import common_main diff --git a/dpugen/saigen/enis.py b/dpugen/saigen/enis.py index 377e1a1..ab4521a 100644 --- a/dpugen/saigen/enis.py +++ b/dpugen/saigen/enis.py @@ -4,7 +4,10 @@ import os import sys -from dpugen.confbase import ConfBase, ipa +from dpugen.confbase import ( + ConfBase, + ipa +) from dpugen.confutils import common_main diff --git a/dpugen/saigen/inbound_routing.py b/dpugen/saigen/inbound_routing.py index 18c2cb1..aef39d1 100644 --- a/dpugen/saigen/inbound_routing.py +++ b/dpugen/saigen/inbound_routing.py @@ -4,7 +4,10 @@ import os import sys -from dpugen.confbase import ConfBase, ipa +from dpugen.confbase import ( + ConfBase, + ipa +) from dpugen.confutils import common_main diff --git a/dpugen/saigen/outbound_ca_to_pa.py b/dpugen/saigen/outbound_ca_to_pa.py index f19b34d..ab24666 100644 --- a/dpugen/saigen/outbound_ca_to_pa.py +++ b/dpugen/saigen/outbound_ca_to_pa.py @@ -4,7 +4,11 @@ import os import sys -from dpugen.confbase import ConfBase, ipa, maca +from dpugen.confbase import ( + ConfBase, + ipa, + maca +) from dpugen.confutils import common_main diff --git a/dpugen/saigen/outbound_routing.py b/dpugen/saigen/outbound_routing.py index 7188348..e02647d 100644 --- a/dpugen/saigen/outbound_routing.py +++ b/dpugen/saigen/outbound_routing.py @@ -5,7 +5,10 @@ import os import sys -from dpugen.confbase import ConfBase, ipa +from dpugen.confbase import ( + ConfBase, + ipa +) from dpugen.confutils import common_main diff --git a/dpugen/saigen/pa_validation.py b/dpugen/saigen/pa_validation.py index cce590c..df721aa 100644 --- a/dpugen/saigen/pa_validation.py +++ b/dpugen/saigen/pa_validation.py @@ -4,7 +4,10 @@ import os import sys -from dpugen.confbase import ConfBase, ipa +from dpugen.confbase import ( + ConfBase, + ipa +) from dpugen.confutils import common_main