stateful_proxy-i686-pc-linux-gnu: segmentation fault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/07/2008 17:34, Filippo Zangheri wrote:
> On 07/07/2008 17:18, Benny Prijono wrote:
>> On Mon, Jul 7, 2008 at 3:51 PM, Filippo Zangheri <filippo.zangheri at yahoo.it>
>> wrote:
>>
>>> Benny,
>>>
>>> I've reached desired behaviour (I guess that's desired behaviour!) by
>>> adding the NULL check already mentioned and commenting out the loopback
>>> address check a few lines below:
>>>
>>>  if (it->ifa_flags & IFF_LOOPBACK) {
>>>
>>
>> Sorry I don't get you. Isn't it that even with this check is in place, you
>> would still get "127.0.0.1" address returned by if_enum_by_af()?
> 
> No, I don't get loopback address returned by if_enum_by_af() when that check
> is in place and when ppp connection is active. I mean, with the check in place:
> 
> ...
> 
> But if I remove that check, I get:
> 
>  1. ppp on
> 
>   17:31:32.313 stateful_proxy  82.59.213.185:5060
>   17:31:32.313 stateful_proxy  127.0.0.1:5060 <--- This was missing with check in place
>   17:31:32.313 stateful_proxy  192.168.2.20:5060
>   17:31:32.313 stateful_proxy  asus-laptop:5060
>   17:31:32.313 stateful_proxy  localhost:5060
>  
>  2. ppp off
> 
>   15:39:34.583 stateful_proxy Local host aliases:
>   15:39:34.583 stateful_proxy  127.0.0.1:5060
>   15:39:34.583 stateful_proxy  asus-laptop:5060
>   15:39:34.583 stateful_proxy  localhost:5060
> 
> 
> So, that's ok. Isn't it?
> ...

I mean, is it ok to remove the loopback-address check from
ip_helper_generic.c:if_enum_by_af()?

I hope to shed some light on getifaddrs() issue.

Sometimes the address list filled up by getifaddrs() may contain some
weird entries:

 1. some entries may have struct sockaddr *ifa_addr = NULL;
    the solution here is to perform a NULL check:

     if (it->ifa_addr == NULL) continue;


 2. some other may appear more than once in that list;
    looking with more attention to all the list entries I got
    the following[1]:

     $ ./test 
     name: lo,       addr: 1.0.0.0,  address_family: 17 <--- ??
     name: eth0,     addr: 2.0.0.0,  address_family: 17
     name: wmaster0, addr: 3.0.0.0,  address_family: 17
     name: wlan0,    addr: 4.0.0.0,  address_family: 17
     interface ppp0 has ifa_addr member NULL!
     name: lo,       addr: 127.0.0.1,        address_family: 2 <---- AF_INET
     name: wlan0,    addr: 192.168.2.20,     address_family: 2
     name: ppp0,     addr: 82.59.213.185,    address_family: 2


    This result suggests that inside the list, every time the
    list is filled up, under any circumstances, there will be
    only one entry with a valid address family, and that should
    be the only list entry taken in consideration.

    This is already implemented. I only suggest that you
    developers (Benny?) comment out that (I'm trying to prove :) )
    useless loopback check.


References

[1] Code:

#include <stdio.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <netinet/ip.h>

int main()
{
    struct ifaddrs *ifap = NULL;

    if (getifaddrs(&ifap) != 0) {
        fprintf(stdout, "getifaddrs() error\n");
        return 1;
    }
    
    while (ifap != NULL) {
        char *name = ifap->ifa_name;
        struct sockaddr *s = ifap->ifa_addr;

        if (s == NULL) {
        
            fprintf(stdout, "interface %s has ifa_addr member NULL!\n", name);
        
        } else {
            char addr_str[16];
            inet_ntop(AF_INET, &((struct sockaddr_in*)s)->sin_addr, &addr_str, sizeof(addr_str));
            
            fprintf(stdout, "name: %s,\taddr: %s,\taddress_family: %u\n", name, addr_str, s->sa_family);
        }
        
        ifap = ifap->ifa_next;
    }

    return 0;
}


Thanks!
Best regards.

-- 
Filippo Zangheri

GPG key ID: 0x6C1F2F2F

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20080707/c30b37b0/attachment.bin 


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux