def Configure(self): nvme_lif = self.session.initiator.ep.intf.lif.nvme_lif self.lif = nvme_lif self.nsid = nvme_lif.GetNextNsid() self.ns = nvme_lif.GetNs(self.nsid) assert self.ns != 0 #for DOL purpose, map session to a sq/cq. #more than one session can map to same sq/cq #for now using nsid%2 as the sq/cq number self.sqid = self.nsid % 2 self.cqid = self.sqid self.sq = self.session.initiator.ep.intf.lif.GetQ('NVME_SQ', self.sqid) self.cq = self.session.initiator.ep.intf.lif.GetQ('NVME_CQ', self.cqid) nvme_lif.NsSessionAttach(self.nsid, self) halapi.NvmeSessionCreate([self]) self.tcp_qid, self.tcp_other_qid = ProxyCbServiceHelper.GetSessionQids( self.session) self.tcp_cbid = "TcpCb%04d" % self.tcp_qid self.tcp_other_cbid = "TcpCb%04d" % self.tcp_other_qid return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) id1, id2 = ProxyCbServiceHelper.GetSessionQids(tc.config.flow._FlowObject__session) if tc.config.flow.IsIflow(): id = id1 other_fid = id2 else: id = id2 other_fid = id1 TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) tcb.debug_dol = 0 # set tcb state to SYN_SENT(2) tcb.state = tcp_proxy.tcp_state_SYN_SENT tcb.SetObjValPd() TcpCbHelper.main(other_fid) tcbid2 = "TcpCb%04d" % (other_fid) logger.info("Configuring %s" % tcbid2) tcb2 = tc.infra_data.ConfigStore.objects.db[tcbid2] tcp_proxy.init_tcb_inorder2(tc, tcb2) tcb2.SetObjValPd() # 2. Clone objects that are needed for verification arq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["CPU0000_ARQ"]) arq.Configure() sesqid = "TCPCB%04d_SESQ" % id sesq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[sesqid]) tlscbid = "TlsCb%04d" % id tlscb_cur = tc.infra_data.ConfigStore.objects.db[tlscbid] tlscb_cur.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_barco tlscb_cur.SetObjValPd() tlscb = copy.deepcopy(tlscb_cur) tcpcb = copy.deepcopy(tcb) tc.pvtdata.Add(tlscb) tc.pvtdata.Add(tcpcb) tc.pvtdata.Add(sesq) tc.pvtdata.Add(arq) return
def get_tcbs(tc): id1, id2 = ProxyCbServiceHelper.GetSessionQids(tc.config.flow._FlowObject__session) if tc.config.flow.IsIflow(): id = id1 other_fid = id2 else: id = id2 other_fid = id1 tcbid1 = "TcpCb%04d" % id tcbid2 = "TcpCb%04d" % other_fid print("%s is flow 1" % tcbid1) print("%s is flow 2" % tcbid2) tcb1 = tc.infra_data.ConfigStore.objects.db[tcbid1] tcb2 = tc.infra_data.ConfigStore.objects.db[tcbid2] tc.pvtdata.tcb1 = tcb1 tc.pvtdata.tcb2 = tcb2 return tcb1, tcb2
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tc.SetRetryEnabled(True) tcp_proxy.SetupProxyArgs(tc) id1, id2 = ProxyCbServiceHelper.GetSessionQids( tc.config.flow._FlowObject__session) if tc.config.flow.IsIflow(): id = id1 other_fid = id2 else: id = id2 other_fid = id1 TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id logger.info("Configuring %s" % tcbid) # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) tcb.SetObjValPd() TcpCbHelper.main(other_fid) tcbid2 = "TcpCb%04d" % (other_fid) logger.info("Configuring %s" % tcbid2) tcb2 = tc.infra_data.ConfigStore.objects.db[tcbid2] tcp_proxy.init_tcb_inorder2(tc, tcb2) tcb2.SetObjValPd() # 2. Configure TLS CB in HBM before packet injection tlscbid = "TlsCb%04d" % id tlscbid2 = "TlsCb%04d" % (other_fid) tlscb = tc.infra_data.ConfigStore.objects.db[tlscbid] tlscb2 = tc.infra_data.ConfigStore.objects.db[tlscbid2] tlscb.debug_dol = 0 tlscb2.debug_dol = 0 if tc.pvtdata.bypass_barco: print("Bypassing Barco") tlscb.is_decrypt_flow = False tlscb2.is_decrypt_flow = False tlscb.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_barco tlscb2.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_barco if tc.pvtdata.same_flow: print("Same flow") tlscb.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_proxy tlscb2.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_proxy tlscb.other_fid = 0xffff tlscb2.other_fid = 0xffff else: print("Other flow") tlscb.other_fid = other_fid tlscb2.other_fid = id tlscb.SetObjValPd() tlscb2.SetObjValPd() # 3. Clone objects that are needed for verification tcpcb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tcbid]) tcpcb.GetObjValPd() tc.pvtdata.Add(tcpcb) tcpcb2 = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tcbid2]) tcpcb2.GetObjValPd() tc.pvtdata.Add(tcpcb2) tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) tlscb.GetObjValPd() tc.pvtdata.Add(tlscb) other_tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid2]) other_tlscb.GetObjValPd() tc.pvtdata.Add(other_tlscb) rnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr_big.GetMeta() tc.pvtdata.Add(rnmdpr_big) return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) skip_config = False if hasattr(tc.module.args, 'skip_config') and tc.module.args.skip_config: print("skipping config") skip_config = True #id = ProxyCbServiceHelper.GetFlowInfo(tc.config.flow._FlowObject__session) id1, id2 = ProxyCbServiceHelper.GetSessionQids(tc.config.flow._FlowObject__session) if tc.config.flow.IsIflow(): id = id1 other_fid = id2 else: id = id2 other_fid = id1 TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] if not skip_config: tcp_proxy.init_tcb_inorder(tc, tcb) # set tcb state to ESTABLISHED(1) tcb.state = 1 tcb.SetObjValPd() else: tc.pvtdata.flow1_bytes_rxed = 0 tc.pvtdata.flow1_bytes_txed = 0 tc.pvtdata.flow2_bytes_rxed = 0 tc.pvtdata.flow2_bytes_txed = 0 TcpCbHelper.main(other_fid) tcbid2 = "TcpCb%04d" % (other_fid) logger.info("Configuring %s" % tcbid2) tcb2 = tc.infra_data.ConfigStore.objects.db[tcbid2] if not skip_config: tcp_proxy.init_tcb_inorder2(tc, tcb2) tcb2.SetObjValPd() tc.pvtdata.tcb1 = tcb tc.pvtdata.tcb2 = tcb2 tlscbid = "TlsCb%04d" % id tlscbid2 = "TlsCb%04d" % (other_fid) tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) #tlscb = tc.infra_data.ConfigStore.objects.db[tlscbid] #tlscb2 = tc.infra_data.ConfigStore.objects.db[tlscbid2] tlscb2 = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid2]) tlscb.serq_pi = 0 tlscb.serq_pi = 0 tlscb.serq_ci = 0 tlscb.serq_ci = 0 tlscb2.serq_pi = 0 tlscb2.serq_pi = 0 tlscb2.serq_ci = 0 tlscb2.serq_ci = 0 tlscb.debug_dol = 0 tlscb2.debug_dol = 0 #tlscb.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_proxy | \ # tcp_tls_proxy.tls_debug_dol_sesq_stop #tlscb.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_proxy #If 'use_random_iv' is set, set the corresponding debug-dol flag to indicate #datapath to pick a random value from DRBG as IV. if hasattr(tc.module.args, 'use_random_iv') and tc.module.args.use_random_iv == 1: tlscb.debug_dol |= tcp_tls_proxy.tls_debug_dol_explicit_iv_use_random tlscb2.debug_dol |= tcp_tls_proxy.tls_debug_dol_explicit_iv_use_random if tc.pvtdata.same_flow: tlscb.other_fid = 0xffff tlscb2.other_fid = 0xffff else: tlscb.other_fid = other_fid tlscb2.other_fid = id if not skip_config: if tc.module.args.key_size == 16: tcp_tls_proxy.tls_aes128_encrypt_setup(tc, tlscb) tcp_tls_proxy.tls_aes128_encrypt_setup(tc, tlscb2) elif tc.module.args.key_size == 32: tcp_tls_proxy.tls_aes256_encrypt_setup(tc, tlscb) tcp_tls_proxy.tls_aes256_encrypt_setup(tc, tlscb2) tlscb.SetObjValPd() tlscb2.SetObjValPd() if skip_config: return # 2. Clone objects that are needed for verification rnmdpr = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr.GetMeta() rnmdpr.GetRingEntries([rnmdpr.pi]) tnmdpr = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["TNMDPR_BIG"]) tnmdpr.GetMeta() tnmdpr.GetRingEntries([tnmdpr.pi]) print("snapshot1: tnmdpr_alloc %d enc_requests %d" % (tlscb.tnmdpr_alloc, tlscb.enc_requests)) print("snapshot1: rnmdpr_free %d enc_completions %d" % (tlscb.rnmdpr_free, tlscb.enc_completions)) if tc.module.args.cipher_suite == "CCM": brq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["BRQ_ENCRYPT_CCM"]) elif tc.module.args.cipher_suite == "CBC": brq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["BRQ_ENCRYPT_CBC"]) else: brq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["BRQ_ENCRYPT_GCM"]) tcpcb = copy.deepcopy(tcb) tcpcb.GetObjValPd() tc.pvtdata.Add(tcpcb) tcpcb2 = copy.deepcopy(tcb2) tcpcb2.GetObjValPd() tc.pvtdata.Add(tcpcb2) tlscb.GetObjValPd() tc.pvtdata.Add(tlscb) tlscb2.GetObjValPd() tc.pvtdata.Add(tlscb2) tc.pvtdata.Add(rnmdpr) tc.pvtdata.Add(tnmdpr) return
def TestCaseSetup(tc): skip_config = False if hasattr(tc.module.args, 'skip_config') and tc.module.args.skip_config: logger.info("skipping config") skip_config = True tc.pvtdata = ObjectDatabase() if hasattr(tc.module.args, 'rnmdr_big_pi'): tc.pvtdata.rnmdr_big_pi = tc.module.args.rnmdr_big_pi else: tc.pvtdata.rnmdr_big_pi = None if hasattr(tc.module.args, 'rnmdr_big_ci'): tc.pvtdata.rnmdr_big_ci = tc.module.args.rnmdr_big_ci else: tc.pvtdata.rnmdr_big_ci = None tcp_proxy.SetupProxyArgs(tc) id1, id2 = ProxyCbServiceHelper.GetSessionQids( tc.config.flow._FlowObject__session) if tc.config.flow.IsIflow(): id = id1 other_fid = id2 else: id = id2 other_fid = id1 TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id logger.info("Configuring %s" % tcbid) # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] if not skip_config: tcp_proxy.init_tcb_inorder(tc, tcb) if tc.pvtdata.serq_full: tcb.serq_pi = 5 tcb.serq_ci = 6 else: if tc.pvtdata.serq_pi: tcb.serq_pi = tc.pvtdata.serq_pi if tc.pvtdata.serq_ci: tcb.serq_ci = tc.pvtdata.serq_ci tcb.SetObjValPd() else: tc.pvtdata.flow1_bytes_rxed = 0 tc.pvtdata.flow1_bytes_txed = 0 tc.pvtdata.flow2_bytes_rxed = 0 tc.pvtdata.flow2_bytes_txed = 0 TcpCbHelper.main(other_fid) tcbid2 = "TcpCb%04d" % (other_fid) logger.info("Configuring %s" % tcbid2) tcb2 = tc.infra_data.ConfigStore.objects.db[tcbid2] if not skip_config: tcp_proxy.init_tcb_inorder2(tc, tcb2) tcb2.SetObjValPd() tc.pvtdata.tcb1 = tcb tc.pvtdata.tcb2 = tcb2 # 2. Configure TLS CB in HBM before packet injection tlscbid = "TlsCb%04d" % id tlscbid2 = "TlsCb%04d" % (other_fid) tlscb = tc.infra_data.ConfigStore.objects.db[tlscbid] tlscb2 = tc.infra_data.ConfigStore.objects.db[tlscbid2] if tc.pvtdata.serq_full: tlscb.serq_pi = 5 tlscb.serq_ci = 6 tlscb2.serq_pi = 5 tlscb2.serq_ci = 6 else: tlscb.serq_pi = 0 tlscb.serq_pi = 0 tlscb.serq_ci = 0 tlscb.serq_ci = 0 tlscb2.serq_pi = 0 tlscb2.serq_pi = 0 tlscb2.serq_ci = 0 tlscb2.serq_ci = 0 tlscb.debug_dol = 0 tlscb2.debug_dol = 0 tlscb.other_fid = other_fid tlscb2.other_fid = id if tc.pvtdata.bypass_barco: logger.info("Bypassing Barco") tlscb.is_decrypt_flow = False tlscb2.is_decrypt_flow = False tlscb.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_barco tlscb2.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_barco if not skip_config: tlscb.SetObjValPd() tlscb2.SetObjValPd() if skip_config: return # 3. Clone objects that are needed for verification tcpcb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tcbid]) tcpcb.GetObjValPd() tc.pvtdata.Add(tcpcb) tcpcb2 = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tcbid2]) tcpcb2.GetObjValPd() tc.pvtdata.Add(tcpcb2) tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) tlscb.GetObjValPd() tc.pvtdata.Add(tlscb) other_tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid2]) other_tlscb.GetObjValPd() tc.pvtdata.Add(other_tlscb) rnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr_big.GetMeta() if tc.pvtdata.sem_full and tc.pvtdata.sem_full == 'nmdr': rnmdpr_big.pi = 0 rnmdpr_big.ci = 2 # ring size of 2, so can hold 1 entry rnmdpr_big.SetMeta() else: setMeta = False if tc.pvtdata.rnmdr_big_pi is not None: rnmdpr_big.pi = tc.pvtdata.rnmdr_big_pi setMeta = True if tc.pvtdata.rnmdr_big_ci is not None: rnmdpr_big.ci = tc.pvtdata.rnmdr_big_ci setMeta = True if setMeta: rnmdpr_big.SetMeta() tc.pvtdata.Add(rnmdpr_big) if tc.pvtdata.test_ooo_queue: ooo_rx_wring = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["OOO_RX"]) ooo_rx_wring.GetMeta() tc.pvtdata.Add(ooo_rx_wring) tnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["TNMDPR_BIG"]) tnmdpr_big.GetMeta() tc.pvtdata.Add(tnmdpr_big) return