Skip to content

Commit

Permalink
acl + mapping fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mgheorghe committed Nov 22, 2023
1 parent a6486e9 commit 85b0f48
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 35 deletions.
11 changes: 7 additions & 4 deletions dpugen/confbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]))

Expand Down
17 changes: 12 additions & 5 deletions dpugen/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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)))

Expand Down
12 changes: 8 additions & 4 deletions dpugen/dashgen/acl_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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 = []
Expand Down Expand Up @@ -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 = []
Expand Down
9 changes: 7 additions & 2 deletions dpugen/dashgen/dash_eni_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion dpugen/dashgen/dash_route_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
15 changes: 11 additions & 4 deletions dpugen/dashgen/dash_vnet_mapping_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand All @@ -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): {
Expand Down
19 changes: 10 additions & 9 deletions dpugen/dflt_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 4 additions & 1 deletion dpugen/saigen/address_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
5 changes: 4 additions & 1 deletion dpugen/saigen/enis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
5 changes: 4 additions & 1 deletion dpugen/saigen/inbound_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 5 additions & 1 deletion dpugen/saigen/outbound_ca_to_pa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
5 changes: 4 additions & 1 deletion dpugen/saigen/outbound_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
5 changes: 4 additions & 1 deletion dpugen/saigen/pa_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 85b0f48

Please sign in to comment.