-
Notifications
You must be signed in to change notification settings - Fork 938
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
IPv6 parse_uri error #1136
Comments
Do you set the r-uri value inside kamailio.cfg via some assignment operations? Or it is updated only by the ims modules you are using? If later, maybe @jaybeepee, @ngvoice or @richardgood can comment more on what happens in the c code for the modules. |
Thank you, miconda. We don't set r-uri value in pcscf.cfg, icscf.cfg or scscf.cfg. I will show more details below using the logs with Jitsi. I will omit SDP to save space.
In the last invite message, there is Any thoughts? |
Attached is wireshark log. Thank you! |
It seems like this issue is introduced by PCSCF when Soft Phone registers. PCSCF adds "sip:FC00:1235:3:1:0:0:0:0:5060" in the Register message to ICSCF. The SIP Register from PCSCF to ICSCF is as below: REGISTER sip:ims.mnc001.mcc001.3gppnetwork.org SIP/2.0 The SIP Register from Soft Phone is fine: REGISTER sip:ims.mnc001.mcc001.3gppnetwork.org SIP/2.0 |
@davidxbwang please use markdown format when pasting. |
@linuxmaniac Thank you. I corrected a format issue in my previous post. How to select "markdown format"? |
@linuxmaniac, @miconda, I work with @davidxbwang I found the issue in modules/pv/pv_core.c. Function pv_get_srcip(). We should substitute the function ip_addr2strz() for ip_addr2a(). ip_addr2strz() correctly inserts the [] in the string when the address is IPv6. Also, I noticed that both of these functions use a static buffer that is one character too small. Since they put a null terminator, if you have a maximum size IPv6 address (no leading zeros) you will overwrite the end of the buffer. We tested the fix, and, it appears to not affect other parts of the code that might not expect the brackets [] added. Below the fix is shown with the old line commented out.
Don. |
This function is behind The function is not used from other modules, therefore you use You can replace do:
Then use $var(si) instead of $si. Maybe a variable to get the source ip with square brackets would be useful, but that will be a new feature, $si will stay as it is, because it is useful in many cases. Anyhow, it looks like an issue in kamailio.cfg, not in code. |
@miconda Thank you so much for your advice! We will try your suggestion. |
Btw, where is the issue with the null termination, the buffers seem to be defined with |
Is there any reason for an IPv6 address string without brackets? Really, any IPv6 address floating around in text format without the brackets is a danger, and will require extra case switch or if-then-else. It might be good to eliminate functions that create the IP address strings without brackets. The code also does not use the standard system call to convert IP addresses to string, and gives a legal, but non-standard string. We will take a look at your suggested solution and provide feedback. We could also change the documentation if it is not yet used anywhere where it it expected without brackets. |
The $si is one of the oldest variables, being in this form from beginning. Not sure about others, but I use it in many API requests or sqlops queries. Moreover, the definition of an IPv6 address is without brackets. The brackets are in the grammar of an address or URI. The $si won't change, I can bet is going to break a lot of configs. I added $siz to master branch that should return the ipv6 address in between brackets. I am closing this one being a config issue, not a code problem. If you still think there is not enough space in the static buffer, open a new issue pointing in the code where you think the problem is. |
My opinion is it is better to just change the existing code, and all existing installations will start working with IPv6 when they upgrade. It is also much simpler. However, the following has been tested and also works to add a $ function that returns a correct IP string for IPv6: The following would need to be added to the table in modules/pv/pv.c Then a new function in modules/pv/pv.c
} Finally, a change to the config file line: |
Ok, sorry, I posted about the same time. We will use your fix using "siz" as the function name. Not sure there is any place you need it without brackets . . . Thanks. |
I have installations with IPv6 since 2002 and they work. I don't get what you mean by "all existing installations will start working with IPv6 when they upgrade". And as I said, I use bare IPv6 in a lot of database tables that I query with sqlops or do HTTP API requests to external systems that expect standard IPv6 format. |
Ok, if you are saying your configuration fix would correctly work to check the address type at run-time, then I guess it would work. Otherwise, it would be all IPv6 or all IPv4. The fix you added that adds the brackets automatically at run-time for $siz is the best way actually, as then you do not need cryptic configuration files. So, in any case, thanks very much for adding the new function that automatically adds the brackets when needed. If I have permission from Verizon, I might like to contribute in the future. I can see a need to immediately parse the incoming messages and immediately reject any message with any part not formed correctly, rather than passing bad things through the code and crashing later. Also, would be good to switch to not use the old depricated system calls for networking (avoids dangerous mucking with the IP address structures and also avoid case switches for IPv4 vs IPv6). The new calls reduce the specific code for IPv4 vs IPv6 to an absolute minimum. I would also use the system calls to convert IP address to string instead of the hand written ones, etc. Don. |
Description
When making end-to-end IMS voice call over IPv6, Kamailio PCSCF doesn't send the Sip Invite to callee. I saw the following error in PCSCF logs:
I saw a similar issue in your database: nat_traversal: Builds wrong URI for IPv6, bad URI parsing #362.
Have you fixed this issue?
Troubleshooting
To me,
sip:FC00:1235:3:2:0:0:0:0:5060
should besip:[FC00:1235:3:2:0:0:0:0]:5060
. After I added the workarround to change it tosip:[FC00:1235:3:2:0:0:0:0]:5060
, PCSCF can send the Sip Invite to callee and the IMS voice call can be established.Reproduction
I can reproduce this issue using two soft phones: Linphone and Jitsi.
Log Messages
SIP Traffic
The following is the Sip Invite message that was received by PCSCF:
Possible Solutions
Additional Information
kamailio -v
The text was updated successfully, but these errors were encountered: