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

kamailio 5.4.5: "0 ID or NULL NAME AVP!" in lcr module #2709

Closed
mdyrna opened this issue Apr 15, 2021 · 4 comments
Closed

kamailio 5.4.5: "0 ID or NULL NAME AVP!" in lcr module #2709

mdyrna opened this issue Apr 15, 2021 · 4 comments

Comments

@mdyrna
Copy link

mdyrna commented Apr 15, 2021

Description

After upgrading kamailio from 5.4.4 to 5.4.5, the lcr module logs an error for outgoing calls. load_gws returns success (1), but does not populate the avps. Consequently, next_gw fails.

Troubleshooting

Reproduction

kamailio.cfg:

loadmodule "lcr.so"

...

modparam("lcr", "db_url", "cluster://cls1")
modparam("lcr", "gw_uri_avp", "$avp(i:709)")
modparam("lcr", "ruri_user_avp", "$avp(i:500)")
modparam("lcr", "tag_avp", "$avp(lcr_tag)")
modparam("lcr", "flags_avp", "$avp(i:712)")
modparam("lcr", "defunct_capability", 1)
modparam("lcr", "lcr_id_avp", "$avp(s:lcr_id_avp)")
modparam("lcr", "defunct_gw_avp", "$avp(s:defunct_gw_avp)")
modparam("lcr", "ping_interval", 60)

...

route[LCR] {
        if(!($rU=~"^[+0-9]"))
                return;

        if(is_method("INVITE")) {
                if (!($fU=~"^[+0-9]+$")) {
                        append_hf("P-Asserted-Identity: <sip:+49xxxxxxxxxxx@xxxxx.de>\n");
                        append_hf("Privacy: id\n");
                        $fn = "Anonymous";
                        $fu = "sip:+49xxxxxxxxxxx@xxxxx.de";
                }

                if(load_gws(1, $rU, $var(caller_uri)) != 1) {
                        xlog("L_ERROR", "Couldn't load gateways\n");
                        sl_send_reply("500", "Server Internal Error - Cannot load gateways");
                        exit;
                } else {
                        xlog("L_INFO", "GW Selected '$avp(i:709)'\n");
                        xlog("L_INFO", "Domain of destination: $dd\n");
                        xlog("L_INFO", "To URI: $tu\n");
                }

                if(!next_gw()) {
                        xlog("L_WARN", "No gateway configured for $rU\n");
                        sl_send_reply("503", "Service not available, no gateways found");
                        exit;
                } else {
                        xlog("L_INFO", "Calling the first matched gateway\n");
                        xlog("L_INFO", "ruri_user_avp: '$avp(i:500)'\n");
                        xlog("L_INFO", "To URI after next_gw: $tu\n");
                        xlog("L_INFO", "Request URI: $ru\n");
                }

                t_on_failure("MANAGE_FAILURE_LCR");
                route(RELAY);
                exit;
        }
}

Debugging Data

Log Messages

Apr 15 20:59:27 x /usr/sbin/kamailio[879]: ERROR: <core> [core/usr_avp.c:152]: create_avp(): 0 ID or NULL NAME AVP!
Apr 15 20:59:27 x /usr/sbin/kamailio[879]: ERROR: <core> [core/usr_avp.c:152]: create_avp(): 0 ID or NULL NAME AVP!
Apr 15 20:59:27 x /usr/sbin/kamailio[879]: INFO: <script>: GW Selected '<null>'
Apr 15 20:59:27 x /usr/sbin/kamailio[879]: INFO: <script>: Domain of destination: <null>
Apr 15 20:59:27 x /usr/sbin/kamailio[879]: INFO: <script>: To URI: sip:+49177xxxxxxx@xx.xxx.x.xxx:5060
Apr 15 20:59:27 x /usr/sbin/kamailio[879]: WARNING: <script>: No gateway configured for +49177xxxxxxx

SIP Traffic

SIP request:

        INVITE sip:+49177xxxxxxx@xx.xx.xx.xxx:5060 SIP/2.0
        Via: SIP/2.0/UDP xxx.xx.xx.xxx:xxxxx;branch=z9hG4bK5d833a50
        Max-Forwards: 70
        From: <sip:+xxxxxxxxxxx@xxx.xx.xx.xxx:xxxxx>;tag=as18ff0d47
        To: <sip:+49177xxxxxxx@xx.xx.xx.xxx:5060>
        Contact: <sip:+xxxxxxxxxxx@xxx.xx.xx.xxx:xxxxx>
        Call-ID: 7489c50703b43b2f03980574181a2f81@xxx.xx.xx.xxx:xxxxx
        CSeq: 102 INVITE
        User-Agent: Asterisk PBX 13.18.3~dfsg-1ubuntu4
        Date: Thu, 15 Apr 2021 21:52:42 GMT
        Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
        Supported: replaces, timer
        Content-Type: application/sdp
        Content-Length: 952

...

SIP reply:

        SIP/2.0 503 Service not available, no gateways found
        Via: SIP/2.0/UDP xxx.xx.xx.xxx:xxxxx;branch=z9hG4bK5d833a50;rport=50060;received=xx.xx.xx.xxx
        From: <sip:+xxxxxxxxxxx@xxx.xx.xx.xxx:xxxxx>;tag=as18ff0d47
        To: <sip:+49177xxxxxxx@xx.xx.xx.xxx:5060>;tag=6a823999ce344a0b461cf8d85d526103.51611a36
        Call-ID: 7489c50703b43b2f03980574181a2f81@xxx.xx.xx.xxx:xxxxx
        CSeq: 102 INVITE
        Server: kamailio (5.4.5 (x86_64/linux))
        Content-Length: 0

Possible Solutions

As a workaround, I downgraded to kamailio 5.3.8 because the previous Ubuntu release 5.4.4 is not available anymore at http://deb.kamailio.org/kamailio54/pool/main/k/kamailio/ (why actually?)

Additional Information

  • Kamailio Version 5.4.5
  • Operating System: Ubuntu 18.04

Root Cause Assumption

ca18218 might be involved in the issue.

@miconda
Copy link
Member

miconda commented Apr 16, 2021

Thanks for reporting, I will look into it, the commit ca18218 was related to a fix on a potential issue reported by a static analyzer/fuzzer.

As a workaround to try for now would be to change the next parameters to use string avp name:

modparam("lcr", "gw_uri_avp", "$avp(s:709)")
modparam("lcr", "ruri_user_avp", "$avp(s:500)")
modparam("lcr", "flags_avp", "$avp(s:712)")

@miconda
Copy link
Member

miconda commented Apr 16, 2021

Should be fixed by e450638 in master and backported to 5.4 967dd29.

Can you try with latest git version and report if all ok now?

@mdyrna
Copy link
Author

mdyrna commented Apr 16, 2021

Thanks for your quick reaction.

I can confirm that for both solutions, the lcr module works well:

Since I don't want to use the git version in production, I would be grateful for a quick official 5.4.6 release.

Also, I assume this problem may affect most of kamailio 5.4.5 deployments using lcr because the Integer avp names are suggested by the official documentation (https://www.kamailio.org/docs/modules/stable/modules/lcr.html).

@miconda
Copy link
Member

miconda commented Apr 16, 2021

Thanks for testing and confirming the fix and the workaround!

There are nightly builds from the 5.4.x branch:

It is what you can use to get the fix in deb packages. There will be a 5.4.6 at some point, but for packaging pointing view that's just to have a milestone, because the packages for it are from the branch 5.4, exactly as it is done in the nightly ones.

You can also build debs locally, specs are in the pkg/kamailio/deb/ folder.

@miconda miconda closed this as completed Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants