From notifications@github.com Tue Jul 20 16:19:13 2021 From: Norbixin To: sr-dev@lists.kamailio.org Subject: [sr-dev] [kamailio/kamailio] Wrong return code used by sl_reply_error() (#2802) Date: Tue, 20 Jul 2021 07:19:10 -0700 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2050671008==" --===============2050671008== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable ### Description I wanted to change 478 response to 503 in case of t_relay() failure, but leav= e default behavior in rest error cases. I used part of code from "Example 1.1= ." inside https://www.kamailio.org/docs/modules/devel/modules/outbound.html. = When I get -478 from t_relay() it works fine, but when this code is different= sl_reply_erorr() don't use it as it should be.=20 This is my part of kamailio.cfg: ``` route[RELAY] { if (!t_relay()) { switch($rc) { case -478: xlog("L_WARN","T_Relay returned 478, sending back 503.\n"); sl_send_reply("503", "Service Unavailable"); exit; default: sl_reply_error(); exit; } } exit; } ``` When I log $rc value before sl_reply_error() it is valid, but not used by sl_= reply_error() as SIP error value, it sends 500 instead. ### Troubleshooting #### Reproduction I've added incorrect hostnames with flag 16 to set where the message should b= e sent and t_relay() returns -478. To check the default case inside switch I = changed case -478 to -479. #### Log Messages ``` 1(8) ERROR: [core/resolve.c:1731]: sip_hostport2su(): could not resolv= e hostname: "va4brhino" 1(8) ERROR: tm [ut.h:309]: uri2dst2(): failed to resolve "va4brhino" 1(8) ERROR: tm [t_fwd.c:1759]: t_forward_nonack(): failure to add branches 1(8) ERROR: sl [sl_funcs.c:414]: sl_reply_error(): stateless error reply use= d: I'm terribly sorry, server error occurred (1/SL) ``` Logs with different route relay ``` route[RELAY] { if (!t_relay()) { switch($rc) { case -479: xlog("L_WARN","T_Relay returned 479, sending back 503.\n"); sl_send_reply("503", "Service Unavailable"); exit; default: xlog("L_WARN","Return code: $rc\n"); sl_reply_error(); exit; } } exit; } ``` ``` 1(8) ERROR: [core/resolve.c:1731]: sip_hostport2su(): could not resol= ve hostname: "va4brhino" 1(8) ERROR: tm [ut.h:309]: uri2dst2(): failed to resolve "va4brhino" 1(8) ERROR: tm [t_fwd.c:1759]: t_forward_nonack(): failure to add branches 1(8) WARNING: