Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump PCEP session in json format #15125

Merged
merged 2 commits into from
Jan 21, 2024

Conversation

pguibert6WIND
Copy link
Member

@pguibert6WIND pguibert6WIND commented Jan 10, 2024

Add support to dump sr-te pcep session in json output.

ubuntu2204# show sr-te pcep session 

PCE q
 PCE IP 192.0.2.40 port 4189
 PCC IP 192.0.2.10 port 4189
 PCC MSD 10
 Session Status UP
 Precedence 10, best candidate
 Confidence normal
 Timer: KeepAlive config 30, pce-negotiated 70
 Timer: DeadTimer config 120, pce-negotiated 120
 Timer: PcRequest 30
 Timer: SessionTimeout Interval 30
 Timer: Delegation Timeout 10
 No TCP MD5 Auth
 PCE SR Version draft07
 Next PcReq ID 5
 Next PLSP  ID 2
 Connected for 171 seconds, since 2023-10-28 09:36:44 UTC
 PCC Capabilities: [PCC Initiated LSPs] [Stateful PCE] [SR TE PST]
 PCE Capabilities: [Stateful PCE] [SR TE PST]
 PCEP Message Statistics
                        Sent   Rcvd
         Message Open:     2      1
    Message KeepAlive:     1      6
        Message PcReq:     4      0
        Message PcRep:     0      0
       Message Notify:     4      0
        Message Error:     0      5
        Message Close:     0      0
       Message Report:     5      0
       Message Update:     0      1
     Message Initiate:     0      0
     Message StartTls:     0      0
    Message Erroneous:     0      0
                Total:    16     13
PCEP Sessions => Configured 1 ; Connected 1
ubuntu2204# show sr-te pcep session  json 
{
  "pcepSessions":[
    {
      "pceName":"q",
      "pceAddress":"192.0.2.40",
      "pcePort":4189,
      "pccAddress":"192.0.2.10",
      "pccPort":4189,
      "pccMsd":10,
      "sessionStatus":"UP",
      "bestMultiPce":true,
      "precedence":10,
      "confidence":"normal",
      "keepaliveConfig":30,
      "deadTimerConfig":120,
      "PcRequest":30,
      "sessionTimeoutInterval":30,
      "delegationTimeout":10,
      "tcpMd5Authentication":false,
      "draft07":true,
      "draft16AndRfc8408":false,
      "nextPcRequestId":5,
      "nextPLspId":2,
      "sessionKeepalivePceNegotiated":70,
      "sessionDeadTimerPceNegotiated":120,
      "sessionConnectionDurationSeconds":177,
      "sessionConnectionStartTimeUTC":"2023-10-28 09:36:44",
      "pccCapabilities":" [PCC Initiated LSPs] [Stateful PCE] [SR TE PST]",
      "pceCapabilities":" [Stateful PCE] [SR TE PST]",
      "messageStatisticsReceived":{
        "messageOpen":1,
        "messageKeepalive":6,
        "messagePcReq":0,
        "messagePcRep":0,
        "messageNotify":0,
        "messageError":5,
        "messageClose":0,
        "messageReport":0,
        "messageUpdate":1,
        "messageInitiate":0,
        "messageStartTls":0,
        "messageErroneous":0,
        "total":13
      },
      "messageStatisticsSent":{
        "messageOpen":2,
        "messageKeepalive":1,
        "messagePcReq":4,
        "messagePcRep":0,
        "messageNotify":4,
        "messageError":0,
        "messageClose":0,
        "messageReport":5,
        "messageUpdate":0,
        "messageInitiate":0,
        "messageStartTls":0,
        "messageErrneous":0,
        "total":16
      }
    }
  ],
  "pcepSessionsConfigured":1,
  "pcepSessionsConnected":1
}
```

@pguibert6WIND pguibert6WIND force-pushed the srte_pcep_session_json branch 5 times, most recently from 9d3fac8 to 545ba6c Compare January 11, 2024 15:37
@FRRouting FRRouting deleted a comment from mergify bot Jan 11, 2024
Copy link
Member

@ton31337 ton31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits

doc/user/pathd.rst Outdated Show resolved Hide resolved
config_opts->keep_alive_seconds);
json_object_int_add(json, "deadTimerConfig",
config_opts->dead_timer_seconds);
json_object_int_add(json, "PcRequest",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCased please

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

struct pcep_pcc_info *pcc_info,
json_object *json)
{
char buf[1024];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use something, but not static numbers? And initializing to zeros could be buf[xxx] = {}.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUFFER_PCE_SIZE

pathd/path_pcep_cli.c Show resolved Hide resolved

/* Config Options values */
config_opts = &pce_opts->config_opts;
json_object_int_add(json, "keepaliveConfig",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config or Seconds?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuration parameter. (redundant with config on show running)

config_opts->dead_timer_seconds);
json_object_int_add(json, "PcRequest",
config_opts->pcep_request_time_seconds);
json_object_int_add(json, "sessionTimeoutInterval",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We usually specify the units, like sessionTimeoutIntervalSec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

json_object_int_add(json, "nextPLspId", pcc_info->next_plspid);

if (session != NULL) {
json_object_int_add(json, "sessionKeepalivePceNegotiated",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same as previous, with units, sessionKeepalivePceNegotiatedSec

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

json_object_string_add(json, "pceCapabilities", buf);
XFREE(MTYPE_PCEP, session);
} else {
json_object_string_add(json, "warning",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You set messageStatisticsWarning below, so here would be also a better name to be not a generic? Or messageStatisticsWarning should be changed to generic warning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can have both warnings, so I willmove "warning" to "warningSession"

pathd/path_pcep_cli.c Show resolved Hide resolved
@pguibert6WIND pguibert6WIND force-pushed the srte_pcep_session_json branch 2 times, most recently from 6d86ac3 to 77709d8 Compare January 12, 2024 12:11
@@ -43,6 +43,8 @@
#define DEFAULT_TIMER_SESSION_TIMEOUT_INTERVAL 30
#define DEFAULT_DELEGATION_TIMEOUT_INTERVAL 10

#define BUFFER_PCE_SIZE 1024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the naming is misleading, PCE, but PCC buffer also 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets call it BUFFER_PCC_PCE_SIZE. this deals with comm between, PCC and PCE.

config_opts->keep_alive_seconds);
json_object_int_add(json, "deadTimerConfig",
config_opts->dead_timer_seconds);
json_object_int_add(json, "pcRequest",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean pcRequest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pccPcepRequestTimerConfig.
This is a config parameter that defines the time that PCC Waits to have a reply from PCE, before retrying.

pce_opts_cli = pcep_cli_find_pce(pcc_peer);
if (pce_opts_cli == NULL) {
vty_out(vty, "%% PCE [%s] does not exist.\n", pcc_peer);
if (json) {
json_object_string_add(json, "warning",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we print pcc_peer for non-JSON output, why can't it be printed here to? json_object_string_addf() allows that. And same for other warning messages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. added changes.

@mwinter-osr
Copy link
Member

CI:rerun Retest for new ASAN Memory Leaks

Copy link
Member

@riw777 riw777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just waiting on @ton31337 's comments

The created counters in pceplib library are structures with
a string attribute which is used for further display. This
string information is not formatted for json output.

Add a second option in the create_subgroup_counter() creation
API to provide the json attribute output.

Create a json naming compatible with caml format for each
subgroup counter used.

Signed-off-by: Philippe Guibert <[email protected]>
Add support to dump sr-te pcep session in json output.

> ubuntu2204# show sr-te pcep session
> PCE q
>  PCE IP 192.0.2.40 port 4189
>  PCC IP 192.0.2.10 port 4189
>  PCC MSD 10
>  Session Status UP
>  Precedence 10, best candidate
>  Confidence normal
>  Timer: KeepAlive config 30, pce-negotiated 70
>  Timer: DeadTimer config 120, pce-negotiated 120
>  Timer: PcRequest 30
>  Timer: SessionTimeout Interval 30
>  Timer: Delegation Timeout 10
>  No TCP MD5 Auth
>  PCE SR Version draft07
>  Next PcReq ID 5
>  Next PLSP  ID 2
>  Connected for 171 seconds, since 2023-10-28 09:36:44 UTC
>  PCC Capabilities: [PCC Initiated LSPs] [Stateful PCE] [SR TE PST]
>  PCE Capabilities: [Stateful PCE] [SR TE PST]
>  PCEP Message Statistics
>                         Sent   Rcvd
>          Message Open:     2      1
>     Message KeepAlive:     1      6
>         Message PcReq:     4      0
>         Message PcRep:     0      0
>        Message Notify:     4      0
>         Message Error:     0      5
>         Message Close:     0      0
>        Message Report:     5      0
>        Message Update:     0      1
>      Message Initiate:     0      0
>      Message StartTls:     0      0
>     Message Erroneous:     0      0
>                 Total:    16     13
> PCEP Sessions => Configured 1 ; Connected 1
> ubuntu2204# show sr-te pcep session  json
> {
>   "pcepSessions":[
>     {
>       "pceName":"q",
>       "pceAddress":"192.0.2.40",
>       "pcePort":4189,
>       "pccAddress":"192.0.2.10",
>       "pccPort":4189,
>       "pccMsd":10,
>       "sessionStatus":"UP",
>       "bestMultiPce":true,
>       "precedence":10,
>       "confidence":"normal",
>       "keepaliveConfig":30,
>       "deadTimerConfig":120,
>       "pccPcepRequestTimerConfig":30,
>       "sessionTimeoutIntervalSec":30,
>       "delegationTimeout":10,
>       "tcpMd5Authentication":false,
>       "draft07":true,
>       "draft16AndRfc8408":false,
>       "nextPcRequestId":5,
>       "nextPLspId":2,
>       "sessionKeepalivePceNegotiatedSec":70,
>       "sessionDeadTimerPceNegotiatedSec":120,
>       "sessionConnectionDurationSec":177,
>       "sessionConnectionStartTimeUTC":"2023-10-28 09:36:44",
>       "pccCapabilities":" [PCC Initiated LSPs] [Stateful PCE] [SR TE PST]",
>       "pceCapabilities":" [Stateful PCE] [SR TE PST]",
>       "messageStatisticsReceived":{
>         "messageOpen":1,
>         "messageKeepalive":6,
>         "messagePcReq":0,
>         "messagePcRep":0,
>         "messageNotify":0,
>         "messageError":5,
>         "messageClose":0,
>         "messageReport":0,
>         "messageUpdate":1,
>         "messageInitiate":0,
>         "messageStartTls":0,
>         "messageErroneous":0,
>         "total":13
>       },
>       "messageStatisticsSent":{
>         "messageOpen":2,
>         "messageKeepalive":1,
>         "messagePcReq":4,
>         "messagePcRep":0,
>         "messageNotify":4,
>         "messageError":0,
>         "messageClose":0,
>         "messageReport":5,
>         "messageUpdate":0,
>         "messageInitiate":0,
>         "messageStartTls":0,
>         "messageErrneous":0,
>         "total":16
>       }
>     }
>   ],
>   "pcepSessionsConfigured":1,
>   "pcepSessionsConnected":1
> }

Signed-off-by: Philippe Guibert <[email protected]>
@pguibert6WIND pguibert6WIND force-pushed the srte_pcep_session_json branch from 77709d8 to dba04c2 Compare January 18, 2024 21:07
@ton31337 ton31337 added this to the 10.0 milestone Jan 19, 2024
@ton31337 ton31337 merged commit 7041353 into FRRouting:master Jan 21, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants