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


Change subject: AS loadsharing: show cs7 instance <0-15> route binding-table 
[POINT_CODE]
......................................................................

AS loadsharing: show cs7 instance <0-15> route binding-table [POINT_CODE]

Similar to the one available for ASP loadsharing:
'show cs7 instance <0-15> as binding-table name AS_NAME'

This allows debugging the state of the loadsharing seed table.

Change-Id: I31664ca795d1a8572077f173ae95b504bc019eb3
---
M src/osmo_ss7_vty.c
M tests/vty/osmo_stp_route_prio.vty
M tests/vty/osmo_stp_test.vty
3 files changed, 216 insertions(+), 0 deletions(-)



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

diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 4344ea2..6ef94c0 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -49,6 +49,7 @@
 #include "ss7_as.h"
 #include "ss7_asp.h"
 #include "ss7_combined_linkset.h"
+#include <ss7_linkset.h>
 #include "ss7_route.h"
 #include "ss7_route_table.h"
 #include "ss7_internal.h"
@@ -607,6 +608,84 @@
        return CMD_SUCCESS;
 }

+DEFUN(show_cs7_route_bindingtable, show_cs7_route_bindingtable_cmd,
+       "show cs7 instance <0-15> route binding-table [POINT_CODE] 
[all-matches]",
+       SHOW_STR CS7_STR INST_STR INST_STR
+       "Routing Table\n"
+       "Display binding table\n"
+       "Destination Point Code\n"
+       "Display all matching Combination Links\n")
+{
+       int id = atoi(argv[0]);
+       bool all = argc > 2;
+       struct osmo_ss7_instance *inst;
+       uint32_t filter_pc = OSMO_SS7_PC_INVALID;
+       struct osmo_ss7_combined_linkset *clset;
+
+       inst = osmo_ss7_instance_find(id);
+       if (!inst) {
+               vty_out(vty, "No SS7 instance %d found%s", id, VTY_NEWLINE);
+               return CMD_WARNING;
+       }
+
+       if (argc > 1) {
+               int pc = osmo_ss7_pointcode_parse(inst, argv[1]);
+               if (pc < 0 || !osmo_ss7_pc_is_valid((uint32_t)pc)) {
+                       vty_out(vty, "Invalid point code (%s)%s", argv[1], 
VTY_NEWLINE);
+                       return CMD_WARNING;
+               }
+               filter_pc = (uint32_t)pc;
+       }
+
+       llist_for_each_entry(clset, &inst->rtable_system->combined_linksets, 
list) {
+               if ((filter_pc != OSMO_SS7_PC_INVALID) && ((filter_pc & 
clset->cfg.mask) != clset->cfg.pc))
+                       continue; /* Skip combined linksets not matching 
destination */
+
+               vty_out(vty, "%sCombined Linkset: dpc=%u=%s, mask=0x%x=%s, 
prio=%u%s", VTY_NEWLINE,
+                       (clset)->cfg.pc, 
osmo_ss7_pointcode_print(clset->rtable->inst, clset->cfg.pc),
+                       (clset)->cfg.mask, 
osmo_ss7_pointcode_print2(clset->rtable->inst, clset->cfg.mask),
+                       (clset)->cfg.priority, VTY_NEWLINE);
+               vty_out(vty, "Loadshare Seed  Normal Route           Available  
Alternative Route      Available%s", VTY_NEWLINE);
+               vty_out(vty, "--------------  ---------------------  ---------  
---------------------  ---------%s", VTY_NEWLINE);
+
+               for (unsigned int i = 0; i < ARRAY_SIZE(clset->esls_table); 
i++) {
+                       struct osmo_ss7_esls_entry *e = &clset->esls_table[i];
+                       char normal_buf[128];
+                       char alt_buf[128];
+
+                       #define RT_DEST_SPRINTF(buf, rt) \
+                               do { \
+                                       if (rt) { \
+                                               if ((rt)->dest.as) { \
+                                                       snprintf(buf, 
sizeof(buf), "%s", (rt)->dest.as->cfg.name); \
+                                               } else if ((rt)->dest.linkset) 
{ \
+                                                       snprintf(buf, 
sizeof(buf), "%s", (rt)->dest.linkset->cfg.name); \
+                                               } else { \
+                                                       snprintf(buf, 
sizeof(buf), "<error>"); \
+                                               } \
+                                       } else { \
+                                               snprintf(buf, sizeof(buf), 
"-"); \
+                                       } \
+                               } while (0)
+
+                       RT_DEST_SPRINTF(normal_buf, e->normal_rt);
+                       RT_DEST_SPRINTF(alt_buf, e->alt_rt);
+
+                       vty_out(vty, "%-15u %-22s %-10s %-22s %-10s%s",
+                               i,
+                               normal_buf,
+                               e->normal_rt ? 
(ss7_route_is_available(e->normal_rt) ? "Yes" : "No") : "-",
+                               alt_buf,
+                               e->alt_rt ? (ss7_route_is_available(e->alt_rt) 
? "Yes" : "No") : "-",
+                               VTY_NEWLINE);
+               }
+
+               if (!all)
+                       break;
+       }
+       return CMD_SUCCESS;
+}
+
 DEFUN(show_cs7_route_lookup, show_cs7_route_lookup_cmd,
       "show cs7 instance <0-15> route-lookup POINT_CODE from POINT_CODE sls 
<0-15> [list-asps]",
       SHOW_STR CS7_STR INST_STR INST_STR
@@ -3369,6 +3448,7 @@
        install_lib_element(L_CS7_AS_NODE, &as_pc_patch_sccp_cmd);

        install_lib_element_ve(&show_cs7_route_cmd);
+       install_lib_element_ve(&show_cs7_route_bindingtable_cmd);
        install_lib_element_ve(&show_cs7_route_lookup_cmd);

        vty_init_addr();
diff --git a/tests/vty/osmo_stp_route_prio.vty 
b/tests/vty/osmo_stp_route_prio.vty
index 2b7cec6..9e34d6e 100644
--- a/tests/vty/osmo_stp_route_prio.vty
+++ b/tests/vty/osmo_stp_route_prio.vty
@@ -87,6 +87,140 @@
 3.2.1/14         INACC   0 5 as2                 UNAVAIL ?       UNAVAIL
 3.2.1/14         INACC   7 6 as1                 UNAVAIL ?       UNAVAIL

+OsmoSTP(config-cs7-rt)# do show cs7 instance 0 route binding-table 3.2.1
+
+Combined Linkset: dpc=6161=3.2.1, mask=0x3fff=7.255.7, prio=2
+Loadshare Seed  Normal Route           Available  Alternative Route      
Available
+--------------  ---------------------  ---------  ---------------------  
---------
+0               -                      -          -                      - 
+1               -                      -          -                      -
+2               -                      -          -                      -
+3               -                      -          -                      -
+4               -                      -          -                      -
+5               -                      -          -                      -
+6               -                      -          -                      -
+7               -                      -          -                      -     
 
+8               -                      -          -                      -
+9               -                      -          -                      -
+10              -                      -          -                      -
+11              -                      -          -                      -
+12              -                      -          -                      -
+13              -                      -          -                      -
+14              -                      -          -                      -
+15              -                      -          -                      - 
+16              -                      -          -                      -
+17              -                      -          -                      -
+18              -                      -          -                      -
+19              -                      -          -                      -
+20              -                      -          -                      -
+21              -                      -          -                      -
+22              -                      -          -                      -     
 
+23              -                      -          -                      -
+24              -                      -          -                      -
+25              -                      -          -                      -
+26              -                      -          -                      -
+27              -                      -          -                      -
+28              -                      -          -                      -
+29              -                      -          -                      -
+30              -                      -          -                      - 
+31              -                      -          -                      -
+32              -                      -          -                      -
+33              -                      -          -                      -
+34              -                      -          -                      -
+35              -                      -          -                      -
+36              -                      -          -                      -
+37              -                      -          -                      -     
 
+38              -                      -          -                      -
+39              -                      -          -                      -
+40              -                      -          -                      -
+41              -                      -          -                      -
+42              -                      -          -                      -
+43              -                      -          -                      -
+44              -                      -          -                      -
+45              -                      -          -                      - 
+46              -                      -          -                      -
+47              -                      -          -                      -
+48              -                      -          -                      -
+49              -                      -          -                      -
+50              -                      -          -                      -
+51              -                      -          -                      -
+52              -                      -          -                      -     
 
+53              -                      -          -                      -
+54              -                      -          -                      -
+55              -                      -          -                      -
+56              -                      -          -                      -
+57              -                      -          -                      -
+58              -                      -          -                      -
+59              -                      -          -                      -
+60              -                      -          -                      - 
+61              -                      -          -                      -
+62              -                      -          -                      -
+63              -                      -          -                      -
+64              -                      -          -                      -
+65              -                      -          -                      -
+66              -                      -          -                      -
+67              -                      -          -                      -     
 
+68              -                      -          -                      -
+69              -                      -          -                      -
+70              -                      -          -                      -
+71              -                      -          -                      -
+72              -                      -          -                      -
+73              -                      -          -                      -
+74              -                      -          -                      -
+75              -                      -          -                      - 
+76              -                      -          -                      -
+77              -                      -          -                      -
+78              -                      -          -                      -
+79              -                      -          -                      -
+80              -                      -          -                      -
+81              -                      -          -                      -
+82              -                      -          -                      -     
 
+83              -                      -          -                      -
+84              -                      -          -                      -
+85              -                      -          -                      -
+86              -                      -          -                      -
+87              -                      -          -                      -
+88              -                      -          -                      -
+89              -                      -          -                      -
+90              -                      -          -                      - 
+91              -                      -          -                      -
+92              -                      -          -                      -
+93              -                      -          -                      -
+94              -                      -          -                      -
+95              -                      -          -                      -
+96              -                      -          -                      -
+97              -                      -          -                      -     
 
+98              -                      -          -                      -
+99              -                      -          -                      -
+100             -                      -          -                      -
+101             -                      -          -                      -
+102             -                      -          -                      -
+103             -                      -          -                      -
+104             -                      -          -                      -
+105             -                      -          -                      - 
+106             -                      -          -                      -
+107             -                      -          -                      -
+108             -                      -          -                      -
+109             -                      -          -                      -
+110             -                      -          -                      -
+111             -                      -          -                      -
+112             -                      -          -                      -     
 
+113             -                      -          -                      -
+114             -                      -          -                      -
+115             -                      -          -                      -
+116             -                      -          -                      -
+117             -                      -          -                      -
+118             -                      -          -                      -
+119             -                      -          -                      -
+120             -                      -          -                      - 
+121             -                      -          -                      -
+122             -                      -          -                      -
+123             -                      -          -                      -
+124             -                      -          -                      -
+125             -                      -          -                      -
+126             -                      -          -                      -
+127             -                      -          -                      -     
 
+
 OsmoSTP(config-cs7-rt)# ! NOW TEST LOOKUP FAILS AS EXPECTED (all route links 
are down):
 OsmoSTP(config-cs7-rt)# do show cs7 instance 0 route-lookup 3.2.1 from 0.0.1 
sls 0
 No route found for label 'OPC=1=0.0.1,DPC=6161=3.2.1,SLS=0'
diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty
index 75f3eae..fbe69a8 100644
--- a/tests/vty/osmo_stp_test.vty
+++ b/tests/vty/osmo_stp_test.vty
@@ -14,6 +14,7 @@
   show cs7 instance <0-15> as name AS_NAME
   show cs7 instance <0-15> as binding-table name AS_NAME
   show cs7 instance <0-15> route [POINT_CODE]
+  show cs7 instance <0-15> route binding-table [POINT_CODE] [all-matches]
   show cs7 instance <0-15> route-lookup POINT_CODE from POINT_CODE sls <0-15> 
[list-asps]
   show cs7 instance <0-15> sccp addressbook
   show cs7 instance <0-15> sccp users
@@ -40,6 +41,7 @@
   show cs7 instance <0-15> as name AS_NAME
   show cs7 instance <0-15> as binding-table name AS_NAME
   show cs7 instance <0-15> route [POINT_CODE]
+  show cs7 instance <0-15> route binding-table [POINT_CODE] [all-matches]
   show cs7 instance <0-15> route-lookup POINT_CODE from POINT_CODE sls <0-15> 
[list-asps]
   show cs7 instance <0-15> sccp addressbook
   show cs7 instance <0-15> sccp users

--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39712?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: I31664ca795d1a8572077f173ae95b504bc019eb3
Gerrit-Change-Number: 39712
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>

Reply via email to