Commit 2e8e8227 authored by Lionel Gauthier's avatar Lionel Gauthier

output traffic is now masqueraded depending on EPC config file if epc run on...

output traffic is now masqueraded depending on EPC config file if epc run on same host than eNB.!!@@@###%&!?!!!

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6251 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 5708ab17
......@@ -52,6 +52,7 @@
#include "sgw_lite_context_manager.h"
#include "sgw_lite.h"
#include "pgw_lite_paa.h"
#include "spgw_config.h"
extern sgw_app_t sgw_app;
......@@ -611,7 +612,6 @@ sgw_lite_handle_sgi_endpoint_updated(
task_id_t to_task;
#if defined (ENABLE_USE_GTPU_IN_KERNEL)
static uint8_t iptable_uplink_remove_gtpu = FALSE;
char *interface_name_p = NULL;
#endif
#if defined(ENABLE_STANDALONE_EPC)
......@@ -690,22 +690,37 @@ sgw_lite_handle_sgi_endpoint_updated(
exit (-1);
}
//use API when prototype validated
ret = system(cmd);
ret = spgw_system(cmd, SPGW_ABORT_ON_ERROR);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting up downlink TUNNEL\n");
}
if (iptable_uplink_remove_gtpu == FALSE) {
if (strncasecmp("tun",sgw_app.sgw_interface_name_for_S1u_S12_S4_up, strlen("tun")) == 0) {
interface_name_p = "lo";
} else {
interface_name_p = sgw_app.sgw_interface_name_for_S1u_S12_S4_up;
ret = snprintf(cmd,
256,
"iptables -t raw -I OUTPUT -s %u.%u.%u.%u -d %u.%u.%u.%u -p udp --dport 2152 -j GTPURH --action remove",
eps_bearer_entry_p->enb_ip_address_for_S1u.address.ipv4_address[0],
eps_bearer_entry_p->enb_ip_address_for_S1u.address.ipv4_address[1],
eps_bearer_entry_p->enb_ip_address_for_S1u.address.ipv4_address[2],
eps_bearer_entry_p->enb_ip_address_for_S1u.address.ipv4_address[3],
sgw_app.sgw_ip_address_for_S1u_S12_S4_up & 0x000000FF,
(sgw_app.sgw_ip_address_for_S1u_S12_S4_up & 0x0000FF00) >> 8,
(sgw_app.sgw_ip_address_for_S1u_S12_S4_up & 0x00FF0000) >> 16,
(sgw_app.sgw_ip_address_for_S1u_S12_S4_up & 0xFF000000) >> 24);
if ((ret < 0) || (ret > 256)) {
SPGW_APP_ERROR("ERROR in preparing uplink tunnel, tune string length\n");
exit (-1);
}
SPGW_APP_DEBUG("%s\n", cmd);
ret = spgw_system(cmd, SPGW_ABORT_ON_ERROR);
} else {
ret = snprintf(cmd,
256,
// no "-p udp --dport 2152" because of fragmented packets
"iptables -t raw -I PREROUTING -i %s -s %u.%u.%u.%u -d %u.%u.%u.%u -p udp --dport 2152 -j GTPURH --action remove",
interface_name_p,
sgw_app.sgw_interface_name_for_S1u_S12_S4_up,
eps_bearer_entry_p->enb_ip_address_for_S1u.address.ipv4_address[0],
eps_bearer_entry_p->enb_ip_address_for_S1u.address.ipv4_address[1],
eps_bearer_entry_p->enb_ip_address_for_S1u.address.ipv4_address[2],
......@@ -719,15 +734,16 @@ sgw_lite_handle_sgi_endpoint_updated(
SPGW_APP_ERROR("ERROR in preparing uplink tunnel, tune string length\n");
exit (-1);
}
//use API when prototype validated
SPGW_APP_DEBUG("%s\n", cmd);
ret = system(cmd);
ret = spgw_system(cmd, SPGW_ABORT_ON_ERROR);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting up uplink TUNNEL\n");
} else {
iptable_uplink_remove_gtpu = TRUE;
}
}
}
#endif
}
return itti_send_msg_to_task(to_task, INSTANCE_DEFAULT, message_p);
......
......@@ -123,31 +123,37 @@ int sgw_lite_init(char* config_file_name_pP)
{
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);
spgw_system("modprobe ip_tables", SPGW_ABORT_ON_ERROR);
spgw_system("modprobe x_tables", SPGW_ABORT_ON_ERROR);
spgw_system("iptables -P INPUT ACCEPT", SPGW_WARN_ON_ERROR);
spgw_system("iptables -F INPUT", SPGW_WARN_ON_ERROR);
spgw_system("iptables -P OUTPUT ACCEPT", SPGW_WARN_ON_ERROR);
spgw_system("iptables -F OUTPUT", SPGW_WARN_ON_ERROR);
spgw_system("iptables -P FORWARD ACCEPT", SPGW_WARN_ON_ERROR);
spgw_system("iptables -F FORWARD", SPGW_WARN_ON_ERROR);
spgw_system("iptables -t nat -F", SPGW_WARN_ON_ERROR);
spgw_system("iptables -t mangle -F", SPGW_WARN_ON_ERROR);
spgw_system("iptables -t filter -F", SPGW_WARN_ON_ERROR);
spgw_system("iptables -t raw -F", SPGW_WARN_ON_ERROR);
spgw_system("ip route flush cache", SPGW_WARN_ON_ERROR);
spgw_system("rmmod iptable_raw > /dev/null 2>&1", SPGW_WARN_ON_ERROR);
spgw_system("rmmod iptable_mangle > /dev/null 2>&1", SPGW_WARN_ON_ERROR);
spgw_system("rmmod iptable_nat > /dev/null 2>&1", SPGW_WARN_ON_ERROR);
spgw_system("rmmod iptable_filter > /dev/null 2>&1", SPGW_WARN_ON_ERROR);
spgw_system("rmmod ip_tables > /dev/null 2>&1", SPGW_WARN_ON_ERROR);
spgw_system("rmmod xt_state xt_mark xt_GTPUAH xt_GTPURH xt_tcpudp xt_connmark ipt_LOG ipt_MASQUERADE > /dev/null 2>&1", SPGW_WARN_ON_ERROR);
spgw_system("rmmod x_tables > /dev/null 2>&1", SPGW_WARN_ON_ERROR);
spgw_system("rmmod nf_conntrack_netlink nfnetlink nf_nat nf_conntrack_ipv4 nf_conntrack > /dev/null 2>&1", SPGW_WARN_ON_ERROR);
spgw_system("modprobe ip_tables", SPGW_ABORT_ON_ERROR);
spgw_system("modprobe x_tables", SPGW_ABORT_ON_ERROR);
spgw_system("sysctl -w net.ipv4.netfilter.ip_conntrack_max=16000", SPGW_WARN_ON_ERROR);
spgw_system("sysctl -w net.ipv4.ip_forward=1", SPGW_WARN_ON_ERROR);
spgw_system("sysctl -w net.ipv4.conf.all.accept_local=1",SPGW_WARN_ON_ERROR);
spgw_system("sysctl -w net.ipv4.conf.all.log_martians=1",SPGW_WARN_ON_ERROR);
spgw_system("sysctl -w net.ipv4.conf.all.route_localnet=1",SPGW_WARN_ON_ERROR);
spgw_system("sysctl -w net.ipv4.conf.all.rp_filter=0",SPGW_WARN_ON_ERROR);
spgw_system("insmod $OPENAIR_TARGETS/bin/xt_GTPUAH.ko", SPGW_ABORT_ON_ERROR);
spgw_system("insmod $OPENAIR_TARGETS/bin/xt_GTPURH.ko", SPGW_ABORT_ON_ERROR);
#endif
spgw_config_init(config_file_name_pP, &spgw_config);
pgw_lite_load_pool_ip_addresses();
......
This diff is collapsed.
......@@ -146,7 +146,9 @@ typedef struct spgw_config_s {
extern spgw_config_t spgw_config;
#endif
int spgw_system(char *command_pP, int abort_on_errorP);
typedef enum { SPGW_WARN_ON_ERROR = 0, SPGW_ABORT_ON_ERROR} spgw_system_abort_control_e;
int spgw_system(char *command_pP, spgw_system_abort_control_e abort_on_errorP);
int spgw_config_process(spgw_config_t* config_pP);
int spgw_config_init(char* lib_config_file_name_pP, spgw_config_t* config_pP);
......
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