I don't think it is a big problem.
See my tests:
root@milana:~# ip a l
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state
UP qlen 1000
    link/ether 00:50:fc:98:d7:8b brd ff:ff:ff:ff:ff:ff
    inet 192.168.254.254/24 brd 192.168.254.255 scope global eth1
    inet 1.2.3.4/0 brd 255.255.255.255 scope global eth1:0
    inet 1.2.3.5/0 brd 255.255.255.255 scope global secondary eth1:2
    inet 1.2.3.6/0 brd 255.255.255.255 scope global secondary eth1:test
    inet 1.2.3.7/0 brd 255.255.255.255 scope global secondary eth1:4:4
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state
UP qlen 1000
    link/ether a0:00:00:05:dd:42 brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.201/20 brd 10.10.15.255 scope global eth2


root@milana:~# gcc -g -Wall -o getifaddrs getifaddrs.c

root@milana:~# ./getifaddrs
Interface Name   :  lo
Address / Mask   :  127.0.0.1 / 255.0.0.0

Interface Name   :  eth1
Address / Mask   :  192.168.254.254 / 255.255.255.0

Interface Name   :  eth1:0
Address / Mask   :  1.2.3.4 / 0.0.0.0

Interface Name   :  eth1:2
Address / Mask   :  1.2.3.5 / 0.0.0.0

Interface Name   :  eth1:test
Address / Mask   :  1.2.3.6 / 0.0.0.0

Interface Name   :  eth1:4:4
Address / Mask   :  1.2.3.7 / 0.0.0.0

Interface Name   :  eth2
Address / Mask   :  10.10.1.201 / 255.255.240.0


Test code attached.




2014-06-05 9:31 GMT+04:00 Olle E. Johansson <[email protected]>:

>
> On 04 Jun 2014, at 22:38, Alex Balashov <[email protected]> wrote:
>
> > On 06/04/2014 04:37 PM, Olle E. Johansson wrote:
> >>
> >> On 04 Jun 2014, at 22:35, Alex Balashov <[email protected]>
> wrote:
> >>
> >>> Hello Olle,
> >>>
> >>> Couldn't you get around this by just specifying the IP address of the
> interface? e.g.
> >>>
> >>>   listen=udp:xxx.xxx.xxx.xxx:5060
> >> Not in this configuration, but with some tweaking I may. But it would
> simplify
> >> a lot if I just could point to the interface.
> >
> > I run into this problem a lot, too, with eth0:x subinterfaces. But
> specifying the address is the only way I know of to solve it at present.
>
> I guess it's about time to file a bug report :-)
>
> /O
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> [email protected]
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>


int main()
{
    struct ifaddrs *ia, *tia;
    void *tap;
    int rc;
    
    const char *ta;
    char aob[INET6_ADDRSTRLEN];
    char aob2[1024];
  
    ia = NULL;
    tia = NULL;
    tap = NULL;

    if ((rc = getifaddrs(&ia)) == 0)
    {    
	for(tia=ia; tia!=NULL; tia=tia->ifa_next)
	{
	    memset(aob2, 0, sizeof(aob2));
	    
	    if (tia->ifa_name == NULL || tia->ifa_addr == NULL || tia->ifa_netmask == NULL)
		continue;

	    sprintf(aob2, "Interface Name   :  %s\n", tia->ifa_name);

	    if(tia->ifa_addr->sa_family == AF_INET)
		tap = &((struct sockaddr_in *)tia->ifa_addr)->sin_addr;
	    else
		tap = &((struct sockaddr_in6 *)tia->ifa_addr)->sin6_addr;

	    strcat(aob2,  "Address / Mask   :  ");
	    ta = inet_ntop(tia->ifa_addr->sa_family, tap, aob, sizeof(aob));
	    if (!ta)
		continue;
	    strcat(aob2, ta);
	    strcat(aob2,  " / ");

    	    if (tia->ifa_netmask->sa_family == AF_INET)
	        tap = &((struct sockaddr_in *)tia->ifa_netmask)->sin_addr;
    	    else
	        tap = &((struct sockaddr_in6 *)tia->ifa_netmask)->sin6_addr;

    	    ta = inet_ntop(tia->ifa_netmask->sa_family, tap, aob, sizeof(aob));
	    if (!ta)
	        continue;
    	    strcat(aob2, ta);
            strcat(aob2, "\n");
	    printf("%s\n", aob2);
	}

	freeifaddrs(ia);
	ia = NULL;
    }
    else
    {
	printf("getifaddrs() failed with errno =  %d %s \n", errno, strerror(errno));
	return rc;
    }
  
    return 0;
}

_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to