Commit 85eb5926 authored by Laurent Thomas's avatar Laurent Thomas

x2 nsa bug

parent 720af7a4
...@@ -372,36 +372,28 @@ class RANManagement(): ...@@ -372,36 +372,28 @@ class RANManagement():
else: else:
pcapfile_prefix="gnb_" pcapfile_prefix="gnb_"
mySSH.open(lIpAddr, lUserName, lPassWord) mySSH.open(lIpAddr, lUserName, lPassWord)
mySSH.command('ip addr show | awk -f /tmp/active_net_interfaces.awk | egrep -v "lo|tun"', '\$', 5) eth_interface = 'any'
result = re.search('interfaceToUse=(?P<eth_interface>[a-zA-Z0-9\-\_]+)done', mySSH.getBefore()) fltr = 'sctp'
if result is not None: logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m')
eth_interface = result.group('eth_interface') pcapfile = pcapfile_prefix + self.testCase_id + '_log.pcap'
fltr = 'port 38412 or port 36412 or port 36422' # NGAP, S1AP, X2AP mySSH.command('echo ' + lPassWord + ' | sudo -S rm -f /tmp/' + pcapfile , '\$', 5)
logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') mySSH.command('echo $USER; nohup sudo -E tshark -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + pcapfile + ' > /dev/null 2>&1 &','\$', 5)
pcapfile = pcapfile_prefix + self.testCase_id + '_log.pcap'
mySSH.command('echo ' + lPassWord + ' | sudo -S rm -f /tmp/' + pcapfile , '\$', 5)
mySSH.command('echo $USER; nohup sudo -E tshark -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + pcapfile + ' > /dev/null 2>&1 &','\$', 5)
mySSH.close() mySSH.close()
# If tracer options is on, running tshark on EPC side and capture traffic b/ EPC and eNB # If tracer options is on, running tshark on EPC side and capture traffic b/ EPC and eNB
result = re.search('T_stdout', str(self.Initialize_eNB_args)) localEpcIpAddr = EPC.IPAddress
if (result is not None): localEpcUserName = EPC.UserName
localEpcIpAddr = EPC.IPAddress localEpcPassword = EPC.Password
localEpcUserName = EPC.UserName mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword)
localEpcPassword = EPC.Password eth_interface = 'any'
mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword) fltr = 'sctp'
mySSH.command('ip addr show | awk -f /tmp/active_net_interfaces.awk | egrep -v "lo|tun"', '\$', 5) logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m')
result = re.search('interfaceToUse=(?P<eth_interface>[a-zA-Z0-9\-\_]+)done', mySSH.getBefore()) self.epcPcapFile = 'enb_' + self.testCase_id + '_s1log.pcap'
if result is not None: mySSH.command('echo ' + localEpcPassword + ' | sudo -S rm -f /tmp/' + self.epcPcapFile , '\$', 5)
eth_interface = result.group('eth_interface') mySSH.command('echo $USER; nohup sudo tshark -f "host ' + lIpAddr +'" -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + self.epcPcapFile + ' > /tmp/tshark.log 2>&1 &', localEpcUserName, 5)
fltr = 'port 38412 or port 36412 or port 36422' # NGAP, S1AP, X2AP mySSH.close()
logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m')
self.epcPcapFile = 'enb_' + self.testCase_id + '_s1log.pcap'
mySSH.command('echo ' + localEpcPassword + ' | sudo -S rm -f /tmp/' + self.epcPcapFile , '\$', 5)
mySSH.command('echo $USER; nohup sudo tshark -f "host ' + lIpAddr +'" -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + self.epcPcapFile + ' > /tmp/tshark.log 2>&1 &', localEpcUserName, 5)
mySSH.close()
mySSH.open(lIpAddr, lUserName, lPassWord) mySSH.open(lIpAddr, lUserName, lPassWord)
mySSH.command('cd ' + lSourcePath, '\$', 5) mySSH.command('cd ' + lSourcePath, '\$', 5)
# Initialize_eNB_args usually start with -O and followed by the location in repository # Initialize_eNB_args usually start with -O and followed by the location in repository
...@@ -519,23 +511,19 @@ class RANManagement(): ...@@ -519,23 +511,19 @@ class RANManagement():
logging.error('\u001B[1;37;41m eNB/gNB/ocp-eNB logging system did not show got sync! \u001B[0m') logging.error('\u001B[1;37;41m eNB/gNB/ocp-eNB logging system did not show got sync! \u001B[0m')
HTML.CreateHtmlTestRow(self.air_interface[self.eNB_instance] + ' -O ' + config_file + extra_options, 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(self.air_interface[self.eNB_instance] + ' -O ' + config_file + extra_options, 'KO', CONST.ALL_PROCESSES_OK)
# In case of T tracer recording, we need to kill tshark on EPC side # In case of T tracer recording, we need to kill tshark on EPC side
result = re.search('T_stdout', str(self.Initialize_eNB_args)) localEpcIpAddr = EPC.IPAddress
if (result is not None): localEpcUserName = EPC.UserName
localEpcIpAddr = EPC.IPAddress localEpcPassword = EPC.Password
localEpcUserName = EPC.UserName mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword)
localEpcPassword = EPC.Password logging.debug('\u001B[1m Stopping tshark \u001B[0m')
mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword) mySSH.command('echo ' + localEpcPassword + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5)
logging.debug('\u001B[1m Stopping tshark \u001B[0m') if self.epcPcapFile != '':
mySSH.command('echo ' + localEpcPassword + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5) mySSH.command('echo ' + localEpcPassword + ' | sudo -S chmod 666 /tmp/' + self.epcPcapFile, '\$', 5)
if self.epcPcapFile != '': mySSH.close()
time.sleep(0.5) if self.epcPcapFile != '':
mySSH.command('echo ' + localEpcPassword + ' | sudo -S chmod 666 /tmp/' + self.epcPcapFile, '\$', 5) copyin_res = mySSH.copyin(localEpcIpAddr, localEpcUserName, localEpcPassword, '/tmp/' + self.epcPcapFile, '.')
mySSH.close() if (copyin_res == 0):
time.sleep(1) mySSH.copyout(lIpAddr, lUserName, lPassWord, self.epcPcapFile, lSourcePath + '/cmake_targets/.')
if self.epcPcapFile != '':
copyin_res = mySSH.copyin(localEpcIpAddr, localEpcUserName, localEpcPassword, '/tmp/' + self.epcPcapFile, '.')
if (copyin_res == 0):
mySSH.copyout(lIpAddr, lUserName, lPassWord, self.epcPcapFile, lSourcePath + '/cmake_targets/.')
self.prematureExit = True self.prematureExit = True
return return
else: else:
......
...@@ -70,8 +70,7 @@ void x2ap_eNB_register_eNB(x2ap_eNB_instance_t *instance_p, ...@@ -70,8 +70,7 @@ void x2ap_eNB_register_eNB(x2ap_eNB_instance_t *instance_p,
net_ip_address_t *local_ip_addr, net_ip_address_t *local_ip_addr,
uint16_t in_streams, uint16_t in_streams,
uint16_t out_streams, uint16_t out_streams,
uint32_t enb_port_for_X2C, uint32_t enb_port_for_X2C);
int multi_sd);
static static
void x2ap_eNB_handle_handover_req(instance_t instance, void x2ap_eNB_handle_handover_req(instance_t instance,
...@@ -249,20 +248,17 @@ static void x2ap_eNB_register_eNB(x2ap_eNB_instance_t *instance_p, ...@@ -249,20 +248,17 @@ static void x2ap_eNB_register_eNB(x2ap_eNB_instance_t *instance_p,
net_ip_address_t *local_ip_addr, net_ip_address_t *local_ip_addr,
uint16_t in_streams, uint16_t in_streams,
uint16_t out_streams, uint16_t out_streams,
uint32_t enb_port_for_X2C, uint32_t enb_port_for_X2C) {
int multi_sd) {
MessageDef *message = NULL; MessageDef *message = NULL;
sctp_new_association_req_multi_t *sctp_new_association_req = NULL;
x2ap_eNB_data_t *x2ap_enb_data = NULL; x2ap_eNB_data_t *x2ap_enb_data = NULL;
DevAssert(instance_p != NULL); DevAssert(instance_p != NULL);
DevAssert(target_eNB_ip_address != NULL); DevAssert(target_eNB_ip_address != NULL);
message = itti_alloc_new_message(TASK_X2AP, 0, SCTP_NEW_ASSOCIATION_REQ_MULTI); message = itti_alloc_new_message(TASK_X2AP, 0, SCTP_NEW_ASSOCIATION_REQ);
sctp_new_association_req = &message->ittiMsg.sctp_new_association_req_multi; sctp_new_association_req_t *sctp_new_association_req = &message->ittiMsg.sctp_new_association_req;
sctp_new_association_req->port = enb_port_for_X2C; sctp_new_association_req->port = enb_port_for_X2C;
sctp_new_association_req->ppid = X2AP_SCTP_PPID; sctp_new_association_req->ppid = X2AP_SCTP_PPID;
sctp_new_association_req->in_streams = in_streams; sctp_new_association_req->in_streams = in_streams;
sctp_new_association_req->out_streams = out_streams; sctp_new_association_req->out_streams = out_streams;
sctp_new_association_req->multi_sd = multi_sd;
memcpy(&sctp_new_association_req->remote_address, memcpy(&sctp_new_association_req->remote_address,
target_eNB_ip_address, target_eNB_ip_address,
sizeof(*target_eNB_ip_address)); sizeof(*target_eNB_ip_address));
...@@ -399,8 +395,7 @@ void x2ap_eNB_handle_sctp_init_msg_multi_cnf( ...@@ -399,8 +395,7 @@ void x2ap_eNB_handle_sctp_init_msg_multi_cnf(
&instance->enb_x2_ip_address, &instance->enb_x2_ip_address,
instance->sctp_in_streams, instance->sctp_in_streams,
instance->sctp_out_streams, instance->sctp_out_streams,
instance->enb_port_for_X2C, instance->enb_port_for_X2C);
instance->multi_sd);
} }
} }
...@@ -645,7 +640,8 @@ void *x2ap_task(void *arg) { ...@@ -645,7 +640,8 @@ void *x2ap_task(void *arg) {
while (1) { while (1) {
itti_receive_msg(TASK_X2AP, &received_msg); itti_receive_msg(TASK_X2AP, &received_msg);
LOG_D(X2AP, "Received message %d:%s\n",
ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
switch (ITTI_MSG_ID(received_msg)) { switch (ITTI_MSG_ID(received_msg)) {
case TERMINATE_MESSAGE: case TERMINATE_MESSAGE:
X2AP_WARN(" *** Exiting X2AP thread\n"); X2AP_WARN(" *** Exiting X2AP thread\n");
...@@ -684,7 +680,6 @@ void *x2ap_task(void *arg) { ...@@ -684,7 +680,6 @@ void *x2ap_task(void *arg) {
case X2AP_ENDC_SGNB_ADDITION_REQ_ACK: case X2AP_ENDC_SGNB_ADDITION_REQ_ACK:
x2ap_gNB_trigger_sgNB_add_req_ack(ITTI_MSG_DESTINATION_INSTANCE(received_msg), x2ap_gNB_trigger_sgNB_add_req_ack(ITTI_MSG_DESTINATION_INSTANCE(received_msg),
&X2AP_ENDC_SGNB_ADDITION_REQ_ACK(received_msg)); &X2AP_ENDC_SGNB_ADDITION_REQ_ACK(received_msg));
LOG_I(X2AP, "Received elements for X2AP_ENDC_SGNB_ADDITION_REQ_ACK \n");
break; break;
case X2AP_ENDC_SGNB_RECONF_COMPLETE: case X2AP_ENDC_SGNB_RECONF_COMPLETE:
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#if defined(ENB_MODE) #if defined(ENB_MODE)
# include "common/utils/LOG/log.h" # include "common/utils/LOG/log.h"
# define SCTP_ERROR(x, args...) LOG_E(SCTP, x, ##args) # define SCTP_ERROR(x, args...) LOG_E(SCTP, x, ##args)
# define SCTP_DEBUG(x, args...) LOG_I(SCTP, x, ##args) # define SCTP_DEBUG(x, args...) LOG_D(SCTP, x, ##args)
# define SCTP_WARN(x, args...) LOG_W(SCTP, x, ##args) # define SCTP_WARN(x, args...) LOG_W(SCTP, x, ##args)
#else #else
# define SCTP_ERROR(x, args...) do { fprintf(stderr, "[SCTP][E]"x, ##args); } while(0) # define SCTP_ERROR(x, args...) do { fprintf(stderr, "[SCTP][E]"x, ##args); } while(0)
......
...@@ -318,7 +318,8 @@ sctp_handle_new_association_req_multi( ...@@ -318,7 +318,8 @@ sctp_handle_new_association_req_multi(
assoc_id, used_address); assoc_id, used_address);
} }
} else { } else {
SCTP_DEBUG("sctp_connectx SUCCESS, used %d addresses assoc_id %d\n", SCTP_DEBUG("sctp_connectx SUCCESS, socket %d used %d addresses assoc_id %d\n",
sd,
used_address, used_address,
assoc_id); assoc_id);
} }
...@@ -750,7 +751,7 @@ static int sctp_create_new_listener( ...@@ -750,7 +751,7 @@ static int sctp_create_new_listener(
} }
if (server_type) { if (server_type) {
if ((sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) { if ((sd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) {
SCTP_ERROR("socket: %s:%d\n", strerror(errno), errno); SCTP_ERROR("socket: %s:%d\n", strerror(errno), errno);
free(addr); free(addr);
return -1; return -1;
...@@ -822,7 +823,7 @@ static int sctp_create_new_listener( ...@@ -822,7 +823,7 @@ static int sctp_create_new_listener(
sctp_cnx = NULL; sctp_cnx = NULL;
return -1; return -1;
} }
SCTP_DEBUG("Created listen socket: %d\n", sd);
/* Insert new element at end of list */ /* Insert new element at end of list */
STAILQ_INSERT_TAIL(&sctp_cnx_list, sctp_cnx, entries); STAILQ_INSERT_TAIL(&sctp_cnx_list, sctp_cnx, entries);
sctp_nb_cnx++; sctp_nb_cnx++;
...@@ -1110,11 +1111,10 @@ void *sctp_eNB_process_itti_msg(void *notUsed) ...@@ -1110,11 +1111,10 @@ void *sctp_eNB_process_itti_msg(void *notUsed)
/* Check if there is a packet to handle */ /* Check if there is a packet to handle */
if (received_msg != NULL) { if (received_msg != NULL) {
LOG_D(SCTP,"Received message %d:%s\n",
ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
switch (ITTI_MSG_ID(received_msg)) { switch (ITTI_MSG_ID(received_msg)) {
case SCTP_INIT_MSG: { case SCTP_INIT_MSG: {
SCTP_DEBUG("Received SCTP_INIT_MSG\n");
/* We received a new connection request */
if (sctp_create_new_listener( if (sctp_create_new_listener(
ITTI_MSG_DESTINATION_INSTANCE(received_msg), ITTI_MSG_DESTINATION_INSTANCE(received_msg),
ITTI_MSG_ORIGIN_ID(received_msg), ITTI_MSG_ORIGIN_ID(received_msg),
...@@ -1126,11 +1126,7 @@ void *sctp_eNB_process_itti_msg(void *notUsed) ...@@ -1126,11 +1126,7 @@ void *sctp_eNB_process_itti_msg(void *notUsed)
break; break;
case SCTP_INIT_MSG_MULTI_REQ: { case SCTP_INIT_MSG_MULTI_REQ: {
int multi_sd; int multi_sd = sctp_create_new_listener(
SCTP_DEBUG("Received SCTP_INIT_MSG_MULTI_REQ\n");
multi_sd = sctp_create_new_listener(
ITTI_MSG_DESTINATION_INSTANCE(received_msg), ITTI_MSG_DESTINATION_INSTANCE(received_msg),
ITTI_MSG_ORIGIN_ID(received_msg), ITTI_MSG_ORIGIN_ID(received_msg),
&received_msg->ittiMsg.sctp_init_multi,1); &received_msg->ittiMsg.sctp_init_multi,1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment