Commit 7b7bfdaf authored by Lionel Gauthier's avatar Lionel Gauthier

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6285 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 21fd7cb0
......@@ -55,6 +55,7 @@
#include "spgw_config.h"
extern sgw_app_t sgw_app;
extern spgw_config_t spgw_config;
static uint32_t g_gtpv1u_teid = 0;
......@@ -668,12 +669,13 @@ sgw_lite_handle_sgi_endpoint_updated(
char cmd[256];
int ret;
ret = snprintf(cmd,
256, // TO DO add --mark tun_id
"iptables -t mangle -A POSTROUTING -d %u.%u.%u.%u -j GTPUAH --own-ip %u.%u.%u.%u --own-tun %u --peer-ip %u.%u.%u.%u --peer-tun %u --action add",
256,
"iptables -t mangle -A POSTROUTING -d %u.%u.%u.%u -m mark --mark %u -j GTPUAH --own-ip %u.%u.%u.%u --own-tun %u --peer-ip %u.%u.%u.%u --peer-tun %u --action add",
eps_bearer_entry_p->paa.ipv4_address[0],
eps_bearer_entry_p->paa.ipv4_address[1],
eps_bearer_entry_p->paa.ipv4_address[2],
eps_bearer_entry_p->paa.ipv4_address[3],
eps_bearer_entry_p->s_gw_teid_for_S1u_S12_S4_up,
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,
......@@ -690,16 +692,47 @@ sgw_lite_handle_sgi_endpoint_updated(
exit (-1);
}
//use API when prototype validated
ret = spgw_system(cmd, SPGW_ABORT_ON_ERROR);
ret = spgw_system(cmd, SPGW_ABORT_ON_ERROR, __FILE__, __LINE__);
if (ret < 0) {
SPGW_APP_ERROR("ERROR in setting up downlink TUNNEL\n");
}
// if default bearer
#warning "TODO define constant for default eps_bearer id"
if ((resp_pP->eps_bearer_id == 5) && (spgw_config.pgw_config.pgw_masquerade_SGI == 0)) {
ret = snprintf(cmd,
256,
"iptables -t mangle -A POSTROUTING -d %u.%u.%u.%u -m mark --mark 0 -j GTPUAH --own-ip %u.%u.%u.%u --own-tun %u --peer-ip %u.%u.%u.%u --peer-tun %u --action add",
eps_bearer_entry_p->paa.ipv4_address[0],
eps_bearer_entry_p->paa.ipv4_address[1],
eps_bearer_entry_p->paa.ipv4_address[2],
eps_bearer_entry_p->paa.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,
eps_bearer_entry_p->s_gw_teid_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],
eps_bearer_entry_p->enb_ip_address_for_S1u.address.ipv4_address[3],
eps_bearer_entry_p->enb_teid_for_S1u
);
if ((ret < 0) || (ret > 256)) {
SPGW_APP_ERROR("ERROR in preparing downlink tunnel, tune string length\n");
exit (-1);
}
//use API when prototype validated
ret = spgw_system(cmd, SPGW_ABORT_ON_ERROR, __FILE__, __LINE__);
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) {
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",
"iptables -t raw -A OUTPUT -s %u.%u.%u.%u -d %u.%u.%u.%u -p udp --dport 2152 -j GTPURH --own-ip %u.%u.%u.%u --own-tun %u --peer-ip %u.%u.%u.%u --peer-tun %u --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],
......@@ -707,18 +740,27 @@ sgw_lite_handle_sgi_endpoint_updated(
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);
(sgw_app.sgw_ip_address_for_S1u_S12_S4_up & 0xFF000000) >> 24,
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,
eps_bearer_entry_p->s_gw_teid_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],
eps_bearer_entry_p->enb_ip_address_for_S1u.address.ipv4_address[3],
eps_bearer_entry_p->enb_teid_for_S1u);
if ((ret < 0) || (ret > 256)) {
SPGW_APP_ERROR("ERROR in preparing uplink tunnel, tune string length\n");
exit (-1);
}
ret = spgw_system(cmd, SPGW_ABORT_ON_ERROR);
} else {
ret = spgw_system(cmd, SPGW_ABORT_ON_ERROR, __FILE__, __LINE__);
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",
"iptables -t raw -A PREROUTING -i %s -s %u.%u.%u.%u -d %u.%u.%u.%u -p udp --dport 2152 -j GTPURH --action remove --own-ip %u.%u.%u.%u --own-tun %u --peer-ip %u.%u.%u.%u --peer-tun %u ",
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],
......@@ -727,22 +769,28 @@ sgw_lite_handle_sgi_endpoint_updated(
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
);
(sgw_app.sgw_ip_address_for_S1u_S12_S4_up & 0xFF000000) >> 24,
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,
eps_bearer_entry_p->s_gw_teid_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],
eps_bearer_entry_p->enb_ip_address_for_S1u.address.ipv4_address[3],
eps_bearer_entry_p->enb_teid_for_S1u);
if ((ret < 0) || (ret > 256)) {
SPGW_APP_ERROR("ERROR in preparing uplink tunnel, tune string length\n");
exit (-1);
}
//use API when prototype validated
ret = spgw_system(cmd, SPGW_ABORT_ON_ERROR);
ret = spgw_system(cmd, SPGW_ABORT_ON_ERROR, __FILE__, __LINE__);
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,37 +123,35 @@ 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("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);
spgw_system("modprobe ip_tables", SPGW_ABORT_ON_ERROR, __FILE__, __LINE__);
spgw_system("modprobe x_tables", SPGW_ABORT_ON_ERROR, __FILE__, __LINE__);
spgw_system("iptables -P INPUT ACCEPT", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("iptables -F INPUT", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("iptables -P OUTPUT ACCEPT", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("iptables -F OUTPUT", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("iptables -P FORWARD ACCEPT", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("iptables -F FORWARD", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("iptables -t nat -F", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("iptables -t mangle -F", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("iptables -t filter -F", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("iptables -t raw -F", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("ip route flush cache", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("rmmod iptable_raw > /dev/null 2>&1", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("rmmod iptable_mangle > /dev/null 2>&1", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("rmmod iptable_nat > /dev/null 2>&1", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("rmmod iptable_filter > /dev/null 2>&1", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("rmmod ip_tables > /dev/null 2>&1", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
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, __FILE__, __LINE__);
spgw_system("rmmod x_tables > /dev/null 2>&1", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("rmmod nf_conntrack_netlink nfnetlink nf_nat nf_conntrack_ipv4 nf_conntrack > /dev/null 2>&1", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("modprobe ip_tables", SPGW_ABORT_ON_ERROR, __FILE__, __LINE__);
spgw_system("modprobe x_tables", SPGW_ABORT_ON_ERROR, __FILE__, __LINE__);
spgw_system("sysctl -w net.ipv4.netfilter.ip_conntrack_max=16000", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("sysctl -w net.ipv4.ip_forward=1", SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("sysctl -w net.ipv4.conf.all.accept_local=1",SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("sysctl -w net.ipv4.conf.all.log_martians=1",SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("sysctl -w net.ipv4.conf.all.route_localnet=1",SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
spgw_system("sysctl -w net.ipv4.conf.all.rp_filter=0",SPGW_WARN_ON_ERROR, __FILE__, __LINE__);
#endif
spgw_config_init(config_file_name_pP, &spgw_config);
pgw_lite_load_pool_ip_addresses();
......
This diff is collapsed.
......@@ -96,6 +96,7 @@ typedef struct sgw_config_s {
int sgw_ip_netmask_for_S11;
} ipv4;
int sgw_interface_mtu_for_S1u_S12_S4_up;
int sgw_udp_port_for_S1u_S12_S4_up;
uint8_t sgw_drop_uplink_traffic;
uint8_t sgw_drop_downlink_traffic;
......@@ -148,7 +149,7 @@ extern spgw_config_t spgw_config;
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_system(char *command_pP, spgw_system_abort_control_e abort_on_errorP, const char * const file_nameP, const int line_numberP);
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