From cc8856f9d3671cc64adc611677f1d3f5feff7bbd Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Wed, 8 Oct 2014 13:37:28 +0200 Subject: gbproxy: Refuse to configure conflicting NSEIs Currently it is possible to set the secondary SGSN NSEI to the same value like the (primary) SGSN NSEI. This leads to undefined behaviour and is hard to recognize. This patch adds checks to either NSEI configuration command to refuse conflicting values. Ticket: OW#1306 Sponsored-by: On-Waves ehf --- openbsc/src/gprs/gb_proxy_vty.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/openbsc/src/gprs/gb_proxy_vty.c b/openbsc/src/gprs/gb_proxy_vty.c index eb7eb600a..8a7523c4e 100644 --- a/openbsc/src/gprs/gb_proxy_vty.c +++ b/openbsc/src/gprs/gb_proxy_vty.c @@ -150,9 +150,15 @@ DEFUN(cfg_nsip_sgsn_nsei, "NSEI to be used in the connection with the SGSN\n" "The NSEI\n") { - unsigned int port = atoi(argv[0]); + unsigned int nsei = atoi(argv[0]); - g_cfg->nsip_sgsn_nsei = port; + if (g_cfg->route_to_sgsn2 && g_cfg->nsip_sgsn2_nsei == nsei) { + vty_out(vty, "SGSN NSEI %d conflicts with secondary SGSN NSEI%s", + nsei, VTY_NEWLINE); + return CMD_WARNING; + } + + g_cfg->nsip_sgsn_nsei = nsei; return CMD_SUCCESS; } @@ -359,8 +365,16 @@ DEFUN(cfg_gbproxy_secondary_sgsn, "NSEI to be used in the connection with the SGSN\n" "The NSEI\n") { + unsigned int nsei = atoi(argv[0]); + + if (g_cfg->nsip_sgsn_nsei == nsei) { + vty_out(vty, "Secondary SGSN NSEI %d conflicts with primary SGSN NSEI%s", + nsei, VTY_NEWLINE); + return CMD_WARNING; + } + g_cfg->route_to_sgsn2 = 1; - g_cfg->nsip_sgsn2_nsei = atoi(argv[0]); + g_cfg->nsip_sgsn2_nsei = nsei; g_cfg->patch_ptmsi = 1; -- cgit v1.2.3