Skip to content

Commit ac98b47

Browse files
pshelarfacebook-github-bot
authored andcommitted
SPGW: add Non nat config option
Summary: This option would turn off NAT rule installation on PGW init. Reviewed By: ardzoht Differential Revision: D22080407 fbshipit-source-id: f8a4eb3cd2db1623ac58ebb603db03071ba7a008
1 parent ead5c9b commit ac98b47

File tree

6 files changed

+38
-10
lines changed

6 files changed

+38
-10
lines changed

lte/gateway/c/oai/include/pgw_config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
#define PGW_CONFIG_P_CSCF_IPV4_ADDRESS "P_CSCF_IPV4_ADDRESS"
8484
#define PGW_CONFIG_P_CSCF_IPV6_ADDRESS "P_CSCF_IPV6_ADDRESS"
8585

86+
#define PGW_CONFIG_STRING_NAT_ENABLED "ENABLE_NAT"
87+
8688
// may be more
8789
#define PGW_MAX_ALLOCATED_PDN_ADDRESSES 1024
8890
#define PGW_NUM_UE_POOL_MAX 16
@@ -119,6 +121,7 @@ typedef struct pgw_config_s {
119121
bool force_push_pco;
120122
uint16_t ue_mtu;
121123
bool relay_enabled;
124+
bool enable_nat;
122125

123126
struct {
124127
bool enabled;

lte/gateway/c/oai/lib/openflow/controller/PagingApplication.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ void PagingApplication::install_default_flow(
104104
fluid_base::OFConnection *ofconn,
105105
const OpenflowMessenger &messenger)
106106
{
107-
// Get assigned IP block from mobilityd
108-
struct in_addr netaddr;
109-
uint32_t prefix;
107+
// Get assigned IP block from mobilityd,
108+
// In case of error allow entire IP space.
109+
struct in_addr netaddr = { .s_addr = INADDR_ANY };
110+
uint32_t prefix = 0;
110111
int ret = get_assigned_ipv4_block(0, &netaddr, &prefix);
111112

112113
// Convert to string for logging

lte/gateway/c/oai/tasks/gtpv1-u/gtpv1u_task.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,17 @@ int gtpv1u_init(
7575
return -1;
7676
}
7777

78-
rv = get_ip_block(&netaddr, &netmask);
79-
if (rv != 0) {
80-
OAILOG_CRITICAL(
81-
LOG_GTPV1U, "ERROR in getting assigned IP block from mobilityd\n");
82-
return -1;
78+
if (spgw_config->pgw_config.enable_nat) {
79+
rv = get_ip_block(&netaddr, &netmask);
80+
if (rv != 0) {
81+
OAILOG_CRITICAL(
82+
LOG_GTPV1U, "ERROR in getting assigned IP block from mobilityd\n");
83+
return -1;
84+
}
85+
} else {
86+
// Allow All IPs in Non-NAT case.
87+
netaddr.s_addr = INADDR_ANY;
88+
netmask = 0;
8389
}
8490

8591
// Init GTP device, using the same MTU as SGi.

lte/gateway/c/oai/tasks/sgw/pgw_config.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int pgw_config_process(pgw_config_t* config_pP) {
155155
close(fd);
156156
}
157157
// Get IP block information
158-
{
158+
if (config_pP->enable_nat) {
159159
int rv = 0;
160160
struct in_addr netaddr;
161161
uint32_t netmask;
@@ -199,6 +199,8 @@ int pgw_config_process(pgw_config_t* config_pP) {
199199
inet_ntoa(netaddr), netmask, min_mtu - 40);
200200
}
201201
#endif
202+
} else {
203+
OAILOG_DEBUG(LOG_SPGW_APP, "Nat is OFF");
202204
}
203205

204206
// TODO: Fix me: Add tc support
@@ -231,6 +233,7 @@ int pgw_config_parse_file(pgw_config_t* config_pP) {
231233
int prefix_mask = 0;
232234
char* pcscf_ipv4 = NULL;
233235
char* pcscf_ipv6 = NULL;
236+
char* nat_enabled = NULL;
234237

235238
config_init(&cfg);
236239

@@ -387,6 +390,18 @@ int pgw_config_parse_file(pgw_config_t* config_pP) {
387390
OAILOG_WARNING(LOG_SPGW_APP, "NO DNS CONFIGURATION FOUND\n");
388391
}
389392
}
393+
config_pP->enable_nat = true;
394+
if (config_setting_lookup_string(setting_pgw, PGW_CONFIG_STRING_NAT_ENABLED,
395+
(const char**)&nat_enabled)) {
396+
if (strcasecmp(nat_enabled, "false") == 0) {
397+
config_pP->enable_nat = false;
398+
} else {
399+
config_pP->enable_nat = true;
400+
}
401+
OAILOG_INFO(
402+
LOG_SPGW_APP, "Parsing configuration file Nat enable: %s\n",
403+
nat_enabled);
404+
}
390405

391406
if (config_setting_lookup_string(
392407
setting_pgw, PGW_CONFIG_P_CSCF_IPV4_ADDRESS,
@@ -577,6 +592,9 @@ void pgw_config_display(pgw_config_t* config_p) {
577592
inet_ntoa(*((struct in_addr*) &config_p->ipv4.SGI)));
578593
OAILOG_INFO(
579594
LOG_SPGW_APP, " SGi MTU (read)........: %u\n", config_p->ipv4.mtu_SGI);
595+
OAILOG_INFO(
596+
LOG_SPGW_APP, " NAT ..................: %s\n",
597+
config_p->enable_nat == 0 ? "false" : "true");
580598
OAILOG_INFO(
581599
LOG_SPGW_APP, " User TCP MSS clamping : %s\n",
582600
config_p->ue_tcp_mss_clamp == 0 ? "false" : "true");

lte/gateway/c/oai/tasks/sgw/sgw_config.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ int sgw_config_parse_file(sgw_config_t *config_pP)
369369
}
370370
#endif
371371
}
372-
373372
config_destroy(&cfg);
374373
return RETURNok;
375374
}

lte/gateway/configs/templates/spgw.conf.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ P-GW =
7575
FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS = "no"; # STRING, {"yes", "no"}.
7676
UE_MTU = 1400 # MTU - (extended GTPv1 hdr(16 Bytes) + UDP hdr(8) -IPv4(20) hdr + additonal bytes(56)) INTEGER
7777
RELAY_ENABLED = "{{ relay_enabled }}";
78+
ENABLE_NAT = "{{ enable_nat }}"
7879
};

0 commit comments

Comments
 (0)