pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-sigtran/+/40611?usp=email )


Change subject: vty: Introduce missing cmd 'point-code override opc'
......................................................................

vty: Introduce missing cmd 'point-code override opc'

This patch introduces several improvements and fixes around the
'point-code override' feature:
* properly split overriding OPC vs DPC over VTY: Before this patch only
  DPC cmd was available despite being used for OPC under ASP role. Even
  the VTY command had a description entry for OPC but it was not
  implemented yet.
* Allow proper overriding with PC 0.
* Allow overriding of both OPC and DPC in SG role.
* Figure out role based on role VTY configuration instead of IPA
  client/server config.

Related: OS#6806
Change-Id: Id8ba5252a088dafe85bb25e13298c585acef277d
---
M src/ipa.c
M src/ss7_as.h
M src/ss7_as_vty.c
M tests/vty/osmo_stp_test.vty
4 files changed, 107 insertions(+), 30 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran 
refs/changes/11/40611/1

diff --git a/src/ipa.c b/src/ipa.c
index 58646fa..8afe91b 100644
--- a/src/ipa.c
+++ b/src/ipa.c
@@ -265,25 +265,40 @@
         * information inside the non-CR/CC connection oriented
         * messages.
         *
-        * The only other alternative we have is to simply have a
-        * STP (server) side configuration that specifies which point
-        * code those messages are to be routed to, and then use this
-        * 'override DPC' in the routing decision.  We could do the same
-        * for the source point code to ensure responses are routed back
-        * to us.  This is all quite ugly, but then what can we do :/
+        * The only other alternative we have is to:
+        *
+        * ASP role: we assume whatever was received at the ASP/AS was meant to
+        * reach us and hence set the DPC to he PC configured in the
+        * 'routing-key'. In this case the 'override OPC' is used so that upper
+        * layers can find out where it came from, so it can answer back if 
needed.
+        *
+        * SG role (STP): By default, the AS associated with the ASP assumes the
+        * OPC of the message received was transmitted to us from the PC
+        * configured in the 'routing-key'. If set, 'override OPC' can be used
+        * to also tweak the originating PC, which can be useful in setups with
+        * traffic coming from another STP where want to set eg. the OPC to the
+        * PC of the originating AS. In this case the 'override DPC'.
+        * allows to find out where those messages are to be routed to in the
+        * routing decision.
+        *
+        * This is all quite ugly, but then what can we do :/
         */

        /* First, determine the DPC and OPC to use */
-       if (asp->cfg.is_server) {
-               /* Source: the PC of the routing key */
-               opc = as->cfg.routing_key.pc;
-               /* Destination: Based on VTY config */
-               dpc = as->cfg.pc_override.dpc;
-       } else {
+       if (asp->cfg.role == OSMO_SS7_ASP_ROLE_ASP) {
                /* Source: Based on VTY config */
-               opc = as->cfg.pc_override.dpc;
+               opc = as->cfg.pc_override.opc;
                /* Destination: PC of the routing key */
                dpc = as->cfg.routing_key.pc;
+       } else {
+               /* Source: if set, based on VTY config,
+                * otherwise by default the PC of the routing key */
+               if (as->cfg.pc_override.opc_enabled)
+                       opc = as->cfg.pc_override.opc;
+               else
+                       opc = as->cfg.routing_key.pc;
+               /* Destination: Based on VTY config */
+               dpc = as->cfg.pc_override.dpc;
        }

        /* Second, patch this into the SCCP message */
diff --git a/src/ss7_as.h b/src/ss7_as.h
index be10f48..98151f8 100644
--- a/src/ss7_as.h
+++ b/src/ss7_as.h
@@ -104,6 +104,9 @@
                uint32_t recovery_timeout_msec;
                uint8_t qos_class;
                struct {
+                       bool opc_enabled;
+                       bool dpc_enabled;
+                       uint32_t opc;
                        uint32_t dpc;
                        enum osmo_ss7_as_patch_sccp_mode sccp_mode;
                } pc_override;
diff --git a/src/ss7_as_vty.c b/src/ss7_as_vty.c
index e94e0c2..6ce57d4 100644
--- a/src/ss7_as_vty.c
+++ b/src/ss7_as_vty.c
@@ -344,18 +344,19 @@
 }

 DEFUN_ATTR(as_pc_override, as_pc_override_cmd,
-          "point-code override dpc PC",
+          "point-code override (opc|dpc) PC",
           "Point Code Specific Features\n"
-          "Override (force) a point-code to hard-coded value\n"
-          "Override Source Point Code\n"
-          "Override Destination Point Code\n"
+          "Override (force) a point-code of messages received at the AS\n"
+          "Override Source Point Code of received messages\n"
+          "Override Destination Point Code of received messages\n"
           "New Point Code\n",
           CMD_ATTR_IMMEDIATE)
 {
        struct osmo_ss7_as *as = vty->index;
-       int pc = osmo_ss7_pointcode_parse(as->inst, argv[0]);
+       bool change_dpc = !strcmp(argv[0], "dpc");
+       int pc = osmo_ss7_pointcode_parse(as->inst, argv[1]);
        if (pc < 0) {
-               vty_out(vty, "Invalid point code (%s)%s", argv[0], VTY_NEWLINE);
+               vty_out(vty, "Invalid point code (%s)%s", argv[1], VTY_NEWLINE);
                return CMD_WARNING;
        }

@@ -365,11 +366,48 @@
                return CMD_WARNING;
        }

-       as->cfg.pc_override.dpc = pc;
+       if (change_dpc) {
+               if (cs7_role == CS7_ROLE_ASP) {
+                       vty_out(vty, "%% Overriding the DPC of AS '%s' in role 
ASP makes no sense. "
+                               "Assuming user meant 'point-code override opc 
%s' to stay backway-comaptible. "
+                               "Please update your config!%s",
+                               as->cfg.name, argv[1], VTY_NEWLINE);
+                       as->cfg.pc_override.opc_enabled = true;
+                       as->cfg.pc_override.opc = pc;
+                       return CMD_SUCCESS;
+               }
+               as->cfg.pc_override.dpc_enabled = true;
+               as->cfg.pc_override.dpc = pc;
+       } else {
+               as->cfg.pc_override.opc_enabled = true;
+               as->cfg.pc_override.opc = pc;
+       }

        return CMD_SUCCESS;
 }

+DEFUN_ATTR(as_no_pc_override, as_no_pc_override_cmd,
+          "no point-code override (opc|dpc)",
+          NO_STR
+          "Point Code Specific Features\n"
+          "Override (force) a point-code of messages received at the AS\n"
+          "Override Source Point Code of received messages\n"
+          "Override Destination Point Code of received messages\n",
+          CMD_ATTR_IMMEDIATE)
+{
+       struct osmo_ss7_as *as = vty->index;
+       bool change_dpc = !strcmp(argv[0], "dpc");
+
+       if (change_dpc) {
+               as->cfg.pc_override.dpc_enabled = false;
+               as->cfg.pc_override.dpc = 0;
+       } else {
+               as->cfg.pc_override.opc_enabled = false;
+               as->cfg.pc_override.opc = 0;
+       }
+       return CMD_SUCCESS;
+}
+
 DEFUN_ATTR(as_pc_patch_sccp, as_pc_patch_sccp_cmd,
           "point-code override patch-sccp (disabled|both)",
           "Point Code Specific Features\n"
@@ -450,7 +488,10 @@
                vty_out(vty, " ssn %u", rkey->ssn);
        vty_out(vty, "%s", VTY_NEWLINE);

-       if (as->cfg.pc_override.dpc)
+       if (as->cfg.pc_override.opc_enabled)
+               vty_out(vty, "  point-code override opc %s%s",
+                       osmo_ss7_pointcode_print(as->inst, 
as->cfg.pc_override.opc), VTY_NEWLINE);
+       if (as->cfg.pc_override.dpc_enabled)
                vty_out(vty, "  point-code override dpc %s%s",
                        osmo_ss7_pointcode_print(as->inst, 
as->cfg.pc_override.dpc), VTY_NEWLINE);

@@ -584,15 +625,30 @@

        /* Config sanity checks: */
 
-       /* AS in ASP role should be configured with a local PC which they can
-        * then announce using RKM.
-        * Still, allow STPs to have AS(P) configured in an ASP mode to talk to 
a
-        * peer STP by announcing remove PCs. */
-       if (cs7_role == CS7_ROLE_ASP &&
-           ss7_as_get_local_role(as) == OSMO_SS7_ASP_ROLE_ASP &&
-           !osmo_ss7_pc_is_local(as->inst, as->cfg.routing_key.pc))
-               vty_out(vty, "%% AS with local role ASP should have a local PC 
configured in its routing-key. Fix your config!%s", VTY_NEWLINE);
+       if (cs7_role == CS7_ROLE_ASP) {
+               int as_role = ss7_as_get_local_role(as);
+               /* AS in ASP role should be configured with a local PC which 
they can
+               * then announce using RKM.
+               * Still, allow STPs to have AS(P) configured in an ASP mode to 
talk to a
+               * peer STP by announcing remove PCs. */
+               if (as_role == OSMO_SS7_ASP_ROLE_ASP &&
+                   !osmo_ss7_pc_is_local(as->inst, as->cfg.routing_key.pc))
+                       vty_out(vty, "%% AS '%s' with local role ASP should 
have a local PC configured in its "
+                               "routing-key. Fix your config!%s", 
as->cfg.name, VTY_NEWLINE);

+               if (as->cfg.proto == OSMO_SS7_ASP_PROT_IPA) {
+                       if (as_role == OSMO_SS7_ASP_ROLE_ASP &&
+                           !as->cfg.pc_override.opc_enabled)
+                               vty_out(vty, "%% ipa AS '%s' with local role 
ASP should have a "
+                                       "'point-code override opc PC' 
configured in its routing-key. Fix your config!%s",
+                                        as->cfg.name, VTY_NEWLINE);
+                       if (as_role == OSMO_SS7_ASP_ROLE_SG &&
+                           !as->cfg.pc_override.dpc_enabled)
+                               vty_out(vty, "%% ipa AS '%s' with local role SG 
should have a "
+                                       "'point-code override dpc PC' 
configured in its routing-key. Fix your config!%s",
+                                        as->cfg.name, VTY_NEWLINE);
+               }
+       }
        return 0;
 }

@@ -619,5 +675,6 @@
        install_lib_element(L_CS7_AS_NODE, &as_rout_key_ssn_cmd);
        install_lib_element(L_CS7_AS_NODE, &as_rout_key_si_ssn_cmd);
        install_lib_element(L_CS7_AS_NODE, &as_pc_override_cmd);
+       install_lib_element(L_CS7_AS_NODE, &as_no_pc_override_cmd);
        install_lib_element(L_CS7_AS_NODE, &as_pc_patch_sccp_cmd);
 }
diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty
index 4502c74..a253c5a 100644
--- a/tests/vty/osmo_stp_test.vty
+++ b/tests/vty/osmo_stp_test.vty
@@ -387,7 +387,8 @@
   routing-key RCONTEXT DPC si (aal2|bicc|b-isup|h248|isup|sat-isup|sccp|tup)
   routing-key RCONTEXT DPC ssn SSN
   routing-key RCONTEXT DPC si (aal2|bicc|b-isup|h248|isup|sat-isup|sccp|tup) 
ssn SSN
-  point-code override dpc PC
+  point-code override (opc|dpc) PC
+  no point-code override (opc|dpc)
   point-code override patch-sccp (disabled|both)

 OsmoSTP(config-cs7-as)# ?
@@ -406,6 +407,7 @@
 OsmoSTP(config-cs7-as)# no ?
   asp           Specify ASP to be removed from this AS
   traffic-mode  Remove explicit traffic mode of operation of this AS
+  point-code    Point Code Specific Features

 OsmoSTP(config-cs7-as)# do show cs7 instance 0 as all
                           Routing    Routing Key                          Cic  
 Cic   Traffic

--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/40611?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Id8ba5252a088dafe85bb25e13298c585acef277d
Gerrit-Change-Number: 40611
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>

Reply via email to