[Home]

Summary:ASTERISK-18090: ERROR[15785]: chan_iax2.c:1742 iax2_getpeername: Bad address cast to IPv4
Reporter:Marcello Ceschia (marcelloceschia)Labels:
Date Opened:2011-07-06 02:51:16Date Closed:2011-09-12 08:26:40
Priority:MajorRegression?
Status:Closed/CompleteComponents:Channels/chan_iax2
Versions:Frequency of
Occurrence
Frequent
Related
Issues:
Environment:Attachments:( 0) iax.conf
Description:error message comes after REGREQ,ACK,POKE

Rx-Frame Retry[ No] -- OSeqno: 001 ISeqno: 001 Type: IAX     Subclass: ACK    
  Timestamp: 00005ms  SCall: 10105  DCall: 00001 [XX.xx.xx.xxx:4569]
[2011-07-06 09:47:56] ERROR[15792]: chan_iax2.c:1742 iax2_getpeername: Bad address cast to IPv4
Tx-Frame Retry[000] -- OSeqno: 000 ISeqno: 000 Type: IAX     Subclass: POKE  
  Timestamp: 00003ms  SCall: 02985  DCall: 00000 [XX.xx.xx.xxx:4569]

[2011-07-06 09:47:56] ERROR[15793]: chan_iax2.c:1742 iax2_getpeername: Bad address cast to IPv4
Rx-Frame Retry[ No] -- OSeqno: 000 ISeqno: 000 Type: IAX     Subclass: REGREQ
  Timestamp: 00043ms  SCall: 01509  DCall: 00000 [yyy.yyy.yy.yy:4569]
  USERNAME        : testAsterisk
  REFRESH         : 60
  CALLTOKEN       : 51 bytes

[2011-07-06 09:48:20] ERROR[15789]: chan_iax2.c:1742 iax2_getpeername: Bad address cast to IPv4
Comments:By: Kinsey Moore (kmoore) 2011-09-06 15:57:05.635-0500

In my attempts to reproduce this, I have ensured that iax2_getpeername is being called on REGREQs, but I am not seeing the bad address cast failure.  Could you provide more information about the configuration that you are using?

By: Marcello Ceschia (marcelloceschia) 2011-09-07 12:19:07.524-0500

I can add some debug lines in chan_iax source, just tell what to do

By: Kinsey Moore (kmoore) 2011-09-07 13:15:27.829-0500

Looking at your setup, it appears you're binding specifically to IPv6.  Is user2 a IPv6 host?  Which user does this problem follow?

By: Marcello Ceschia (marcelloceschia) 2011-09-07 13:25:12.614-0500

it also happens with
bindaddr=0.0.0.0

user2 is a ipv4 host.


Tx-Frame Retry[-01] -- OSeqno: 002 ISeqno: 002 Type: IAX     Subclass: ACK    
  Timestamp: 00269ms  SCall: 08821  DCall: 14835 [xx.xx.xx.xx:4569]
[2011-09-07 20:23:22] ERROR[10108]: chan_iax2.c:1743 iax2_getpeername: Bad address cast to IPv4
Tx-Frame Retry[000] -- OSeqno: 000 ISeqno: 000 Type: IAX     Subclass: REGREQ
  Timestamp: 00018ms  SCall: 01010  DCall: 00000 [yy.yy.yy.yy:4569]
  USERNAME        : user
  REFRESH         : 60




By: Kinsey Moore (kmoore) 2011-09-07 13:48:59.073-0500

Could you get the value of peer->addr.len just before the call to ast_sockaddr_to_sin?  That information should be helpful in figuring this out.

By: Marcello Ceschia (marcelloceschia) 2011-09-07 14:29:51.089-0500

I added some debug, so I see it comes from an peer that is also available via IPv6

[2011-09-07 21:24:13] NOTICE[17768]: chan_iax2.c:1751 iax2_getpeername: peer->addr.len: 28, 2001:a60:xxxx:yyyy::5
[2011-09-07 21:24:13] ERROR[17768]: chan_iax2.c:1752 iax2_getpeername: Bad address cast to IPv4

but why cast to IPv4 if we can handle IPv6?

By: Kinsey Moore (kmoore) 2011-09-08 14:31:17.134-0500

Unfortunately, IAX2 does not support IPv6 even though many other parts of Asterisk do.  This probably needs better error messages.

By: Marcello Ceschia (marcelloceschia) 2011-09-08 15:02:59.145-0500

so the best workaround would be doing the dns lookups for A records only?

By: Kinsey Moore (kmoore) 2011-09-08 15:08:42.192-0500

Currently, yes.  I'm also writing a patch to avoid this situation where possible by not binding to IPv6 addresses for IAX2.

By: Kinsey Moore (kmoore) 2011-09-08 15:16:23.140-0500

Looking through the code, it should already be impossible for IAX2 to bind to IPv6 addresses.  Is there some kind of IPv4->IPv6 tunnel between these machines?

By: Marcello Ceschia (marcelloceschia) 2011-09-08 15:47:23.786-0500

Yes, it is posible to use IPv6. Both sides have an IPv6 Tunnel.

By: rtausend (rtausend) 2011-09-09 09:31:33.416-0500

Hi there,

i have the same issue as long as i use dns names for the peer and that dns name is resolvable in ipv6.
if i intere the ipv4 address to the peer i don't have that messages anymore.

What information could i provide?
Robert

By: Kinsey Moore (kmoore) 2011-09-09 09:39:46.761-0500

When running your Asterisk instance, what address does netstat report as the listening address of the IAX2 socket?  I see *:iax on the systems I test which should only allow IPv4 traffic.

By: Marcello Ceschia (marcelloceschia) 2011-09-09 10:11:50.409-0500

with bindaddr=0.0.0.0 or bindaddr=::

#netstat -l | grep iax
udp        0      0 *:iax                   *:*



By: Kinsey Moore (kmoore) 2011-09-09 10:40:07.243-0500

I have a patch that may fix the IPv6 DNS resolution problem.

On the systems that are registering, could you put the following line:
peer->addr.ss.ss_family = AF_INET;

just after:
peer->sockfd = defaultsockfd;

in build_peer (around line 12418 in latest trunk)?  This should prevent the DNS manager from returning IPv6 addresses entirely (and fix one part of our problem).  There are still other holes to be fixed, but this should help quite a bit.

By: Marcello Ceschia (marcelloceschia) 2011-09-09 10:54:25.493-0500

This fixes this issue, it is line 12315 in branch 1.8

By: Kinsey Moore (kmoore) 2011-09-09 15:19:14.787-0500

Just to make sure I can fix the other side of the issue as well, can you crank verbosity up to at least 3 and give me the console output upon registration (without the DNS fix)?  I'm looking for a line that starts with:
-- Registered IAX2...

By: Marcello Ceschia (marcelloceschia) 2011-09-09 15:44:24.468-0500

registration does not work, iax2 show registry show the IPv6 address

By: Kinsey Moore (kmoore) 2011-09-09 16:11:36.412-0500

I'm sorry, I meant to check on the side receiving the registration.  "iax2 show peers" should show the desired information.

By: Marcello Ceschia (marcelloceschia) 2011-09-09 16:16:57.823-0500

But this will not work, because dns manager always returns the IPv6 address. I can register with IPv4 address only.


By: Kinsey Moore (kmoore) 2011-09-09 16:23:48.045-0500

The reason for this error message is that a IPv6 address is making it into a peer structure via some vector I don't yet grasp, but maybe the best way to fix this to ensure that the peer structure can only hold a IPv4 address.  I will work down that route along with the DNS manager fixes.  Thanks for your help on this bug!

By: Marcello Ceschia (marcelloceschia) 2011-09-09 16:28:08.950-0500

If you need an IPv6 peer for testing, contact me.