Commit 9de74478 authored by Lionel Gauthier's avatar Lionel Gauthier

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6155 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent ca95fb79
...@@ -122,8 +122,34 @@ static void *sgw_lite_intertask_interface(void *args_p) ...@@ -122,8 +122,34 @@ static void *sgw_lite_intertask_interface(void *args_p)
int sgw_lite_init(char* config_file_name_pP) int sgw_lite_init(char* config_file_name_pP)
{ {
SPGW_APP_DEBUG("Initializing SPGW-APP task interface\n"); SPGW_APP_DEBUG("Initializing SPGW-APP task interface\n");
#if defined (ENABLE_USE_GTPU_IN_KERNEL)
spgw_system("rmmod iptable_raw > /dev/null 2>&1", 0);
spgw_system("rmmod iptable_mangle > /dev/null 2>&1", 0);
spgw_system("rmmod iptable_nat > /dev/null 2>&1", 0);
spgw_system("rmmod iptable_filter > /dev/null 2>&1", 0);
spgw_system("rmmod ip_tables > /dev/null 2>&1", 0);
spgw_system("rmmod xt_state xt_mark xt_GTPUAH xt_GTPURH xt_tcpudp xt_connmark ipt_LOG ipt_MASQUERADE > /dev/null 2>&1", 0);
spgw_system("rmmod x_tables > /dev/null 2>&1", 0);
spgw_system("rmmod nf_conntrack_netlink nfnetlink nf_nat nf_conntrack_ipv4 nf_conntrack > /dev/null 2>&1", 0);
spgw_system("modprobe ip_tables", 1);
spgw_system("modprobe x_tables", 1);
spgw_system("iptables -P INPUT ACCEPT", 0);
spgw_system("iptables -F INPUT", 0);
spgw_system("iptables -P OUTPUT ACCEPT", 0);
spgw_system("iptables -F OUTPUT", 0);
spgw_system("iptables -P FORWARD ACCEPT", 0);
spgw_system("iptables -F FORWARD", 0);
spgw_system("iptables -t nat -F", 0);
spgw_system("iptables -t mangle -F", 0);
spgw_system("iptables -t filter -F", 0);
spgw_system("iptables -t raw -F", 0);
spgw_system("ip route flush cache", 0);
spgw_system("sysctl -w net.ipv4.netfilter.ip_conntrack_max=10000", 0);
spgw_system("sysctl -w net.ipv4.ip_forward=1", 0);
spgw_system("insmod $OPENAIRCN_DIR/GTPV1-U/GTPUAH/Bin/xt_GTPUAH.ko", 1);
spgw_system("insmod $OPENAIRCN_DIR/GTPV1-U/GTPURH/Bin/xt_GTPURH.ko", 1);
#endif
spgw_config_init(config_file_name_pP, &spgw_config); spgw_config_init(config_file_name_pP, &spgw_config);
pgw_lite_load_pool_ip_addresses(); pgw_lite_load_pool_ip_addresses();
sgw_app.s11teid2mme_hashtable = hashtable_create (8192, NULL, NULL); sgw_app.s11teid2mme_hashtable = hashtable_create (8192, NULL, NULL);
......
...@@ -130,6 +130,20 @@ sgw_ipv6_mask_in6_addr( ...@@ -130,6 +130,20 @@ sgw_ipv6_mask_in6_addr(
} }
} }
int spgw_system(char *command_pP, int abort_on_errorP) {
int ret = 0;
ret = system("command_pP");
if (ret < 0) {
SPGW_APP_ERROR("ERROR in system command %s: %d\n",
command_pP,ret);
if (abort_on_errorP) {
exit(-1); // may be not exit
}
}
return ret;
}
int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
config_t cfg; config_t cfg;
...@@ -175,7 +189,6 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -175,7 +189,6 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
pgw_lite_conf_ipv6_list_elm_t *ip6_ref = NULL; pgw_lite_conf_ipv6_list_elm_t *ip6_ref = NULL;
#if defined (ENABLE_USE_GTPU_IN_KERNEL) #if defined (ENABLE_USE_GTPU_IN_KERNEL)
char system_cmd[256]; char system_cmd[256];
int ret;
#endif #endif
memset((char*)config_pP, 0 , sizeof(spgw_config_t)); memset((char*)config_pP, 0 , sizeof(spgw_config_t));
...@@ -224,11 +237,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -224,11 +237,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
free(cidr); free(cidr);
#if defined (ENABLE_USE_GTPU_IN_KERNEL) #if defined (ENABLE_USE_GTPU_IN_KERNEL)
ret = system("echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects"); spgw_system("echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects", 1);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects: %d\n",
ret);
}
#endif #endif
in_addr_var.s_addr = config_pP->sgw_config.ipv4.sgw_ipv4_address_for_S1u_S12_S4_up; in_addr_var.s_addr = config_pP->sgw_config.ipv4.sgw_ipv4_address_for_S1u_S12_S4_up;
SPGW_APP_INFO("Parsing configuration file found sgw_ipv4_address_for_S1u_S12_S4_up: %s/%d on %s\n", SPGW_APP_INFO("Parsing configuration file found sgw_ipv4_address_for_S1u_S12_S4_up: %s/%d on %s\n",
...@@ -275,10 +284,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -275,10 +284,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
config_pP->sgw_config.ipv4.sgw_interface_name_for_S1u_S12_S4_up, config_pP->sgw_config.ipv4.sgw_interface_name_for_S1u_S12_S4_up,
config_pP->sgw_config.sgw_interface_mtu_for_S1u_S12_S4_up) > 0) { config_pP->sgw_config.sgw_interface_mtu_for_S1u_S12_S4_up) > 0) {
SPGW_APP_INFO("Set S1U interface MTU: %s\n",system_cmd); SPGW_APP_INFO("Set S1U interface MTU: %s\n",system_cmd);
ret = system(system_cmd); spgw_system(system_cmd, 1);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting %s: %d\n",system_cmd, ret);
}
} else { } else {
SPGW_APP_ERROR("Set S1U interface MTU\n"); SPGW_APP_ERROR("Set S1U interface MTU\n");
} }
...@@ -298,10 +304,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -298,10 +304,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
"iptables -t raw -I PREROUTING -i %s --protocol udp --destination-port 2152 -j DROP", "iptables -t raw -I PREROUTING -i %s --protocol udp --destination-port 2152 -j DROP",
config_pP->sgw_config.ipv4.sgw_interface_name_for_S1u_S12_S4_up) > 0) { config_pP->sgw_config.ipv4.sgw_interface_name_for_S1u_S12_S4_up) > 0) {
SPGW_APP_INFO("Drop uplink traffic: %s\n",system_cmd); SPGW_APP_INFO("Drop uplink traffic: %s\n",system_cmd);
ret = system(system_cmd); spgw_system(system_cmd, 1);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting %s: %d\n",system_cmd, ret);
}
} else { } else {
SPGW_APP_ERROR("Drop uplink traffic\n"); SPGW_APP_ERROR("Drop uplink traffic\n");
} }
...@@ -371,10 +374,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -371,10 +374,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
"iptables -t nat -A POSTROUTING -o %s ! --protocol sctp -j MASQUERADE", "iptables -t nat -A POSTROUTING -o %s ! --protocol sctp -j MASQUERADE",
config_pP->pgw_config.ipv4.pgw_interface_name_for_SGI) > 0) { config_pP->pgw_config.ipv4.pgw_interface_name_for_SGI) > 0) {
SPGW_APP_INFO("Masquerade SGI: %s\n",system_cmd); SPGW_APP_INFO("Masquerade SGI: %s\n",system_cmd);
ret = system(system_cmd); spgw_system(system_cmd,1);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting %s: %d\n",system_cmd, ret);
}
} else { } else {
SPGW_APP_ERROR("Masquerade SGI\n"); SPGW_APP_ERROR("Masquerade SGI\n");
} }
...@@ -389,10 +389,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -389,10 +389,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
"iptables -I POSTROUTING -t mangle -o %s -m mark ! --mark 0 ! --protocol sctp -j CONNMARK --save-mark", "iptables -I POSTROUTING -t mangle -o %s -m mark ! --mark 0 ! --protocol sctp -j CONNMARK --save-mark",
config_pP->pgw_config.ipv4.pgw_interface_name_for_SGI) > 0) { config_pP->pgw_config.ipv4.pgw_interface_name_for_SGI) > 0) {
SPGW_APP_INFO("Save mark: %s\n",system_cmd); SPGW_APP_INFO("Save mark: %s\n",system_cmd);
ret = system(system_cmd); spgw_system(system_cmd, 1);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting %s: %d\n",system_cmd, ret);
}
} else { } else {
SPGW_APP_ERROR("Save mark\n"); SPGW_APP_ERROR("Save mark\n");
} }
...@@ -400,10 +397,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -400,10 +397,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
"iptables -I PREROUTING -t mangle -i %s ! --protocol sctp -j CONNMARK --restore-mark", "iptables -I PREROUTING -t mangle -i %s ! --protocol sctp -j CONNMARK --restore-mark",
config_pP->pgw_config.ipv4.pgw_interface_name_for_SGI) > 0) { config_pP->pgw_config.ipv4.pgw_interface_name_for_SGI) > 0) {
SPGW_APP_INFO("Restore mark: %s\n",system_cmd); SPGW_APP_INFO("Restore mark: %s\n",system_cmd);
ret = system(system_cmd); spgw_system(system_cmd, 1);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting %s: %d\n",system_cmd, ret);
}
} else { } else {
SPGW_APP_ERROR("Restore mark\n"); SPGW_APP_ERROR("Restore mark\n");
} }
...@@ -436,10 +430,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -436,10 +430,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
atoken2, atoken2,
config_pP->sgw_config.ipv4.sgw_interface_name_for_S1u_S12_S4_up) > 0) { config_pP->sgw_config.ipv4.sgw_interface_name_for_S1u_S12_S4_up) > 0) {
SPGW_APP_INFO("Add route: %s\n",system_cmd); SPGW_APP_INFO("Add route: %s\n",system_cmd);
ret = system(system_cmd); spgw_system(system_cmd, 1);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting %s: %d\n",system_cmd, ret);
}
} else { } else {
SPGW_APP_ERROR("Add route: for %s\n", astring); SPGW_APP_ERROR("Add route: for %s\n", astring);
} }
...@@ -449,10 +440,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -449,10 +440,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
"iptables -t filter -I FORWARD -d %s/%s -j DROP", "iptables -t filter -I FORWARD -d %s/%s -j DROP",
astring, atoken2) > 0) { astring, atoken2) > 0) {
SPGW_APP_INFO("Drop downlink traffic: %s\n",system_cmd); SPGW_APP_INFO("Drop downlink traffic: %s\n",system_cmd);
ret = system(system_cmd); spgw_system(system_cmd, 1);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting %s: %d\n",system_cmd, ret);
}
} else { } else {
SPGW_APP_ERROR("Drop downlink traffic\n"); SPGW_APP_ERROR("Drop downlink traffic\n");
} }
...@@ -460,10 +448,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -460,10 +448,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
"iptables -t filter -I OUTPUT -d %s/%s -j DROP", "iptables -t filter -I OUTPUT -d %s/%s -j DROP",
astring, atoken2) > 0) { astring, atoken2) > 0) {
SPGW_APP_INFO("Drop downlink traffic: %s\n",system_cmd); SPGW_APP_INFO("Drop downlink traffic: %s\n",system_cmd);
ret = system(system_cmd); spgw_system(system_cmd, 1);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting %s: %d\n",system_cmd, ret);
}
} else { } else {
SPGW_APP_ERROR("Drop downlink traffic\n"); SPGW_APP_ERROR("Drop downlink traffic\n");
} }
...@@ -507,10 +492,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) { ...@@ -507,10 +492,7 @@ int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP) {
buf_in_addr, buf_in_addr,
config_pP->sgw_config.ipv4.sgw_interface_name_for_S1u_S12_S4_up) > 0) { config_pP->sgw_config.ipv4.sgw_interface_name_for_S1u_S12_S4_up) > 0) {
SPGW_APP_INFO("Add route: %s\n",system_cmd); SPGW_APP_INFO("Add route: %s\n",system_cmd);
ret = system(system_cmd); spgw_system(system_cmd, 1);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting %s: %d\n",system_cmd, ret);
}
} else { } else {
SPGW_APP_ERROR("Add route: for %s\n", buf_in_addr); SPGW_APP_ERROR("Add route: for %s\n", buf_in_addr);
} }
......
...@@ -146,6 +146,7 @@ typedef struct spgw_config_s { ...@@ -146,6 +146,7 @@ typedef struct spgw_config_s {
extern spgw_config_t spgw_config; extern spgw_config_t spgw_config;
#endif #endif
int spgw_system(char *command_pP, int abort_on_errorP);
int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP); int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP);
#endif /* ENB_CONFIG_H_ */ #endif /* ENB_CONFIG_H_ */
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