[SR-Users] listening at link local IPv6 address

Sergey Safarov s.safarov at gmail.com
Tue Apr 23 08:00:58 CEST 2019


my five cents about this.
Link local addresses generated using MAC address of NIC.
If server use VLAN interface, then server will have two or more NICs with
same MAC address and two or more same IPv6 link local addresses.

In this case kamailio will bind to first NIC with this IPv6 address. When
server use VLAN, then ipv6_get_netif_scope will give unexpected results.

Think need change this code

                        /* strip the interface name after */
                        for(i=0; ipaddr[i]; i++) {
                                if(ipaddr[i]=='%') {
                                        ipaddr[i]='\0';
                                        break;
                                }
                        }
                        /* if the ips matche, get scope index from
interface name */
                        if(strcmp(ipaddr, ipval)==0){
                                iscope=if_nametoindex(netif->ifa_name);
                                goto done;
                        }




On Tue, Apr 23, 2019 at 8:16 AM Juha Heinanen <jh at tutpro.com> wrote:

> Daniel-Constantin Mierla writes:
>
> > Anyhow, your code has hardcoded interface name, I added a helper
> > function that tries to get the scope by matching the ip address when
> > walking over network interfaces. The commit:
> >
> >
> https://github.com/kamailio/kamailio/commit/ce1138d2d8962296de2867d5751abf770b035da3
> >
> > Can you try using that function to get the scope id?
>
> I tried by changing my udp_server.c test line:
>
>         addr->sin6.sin6_scope_id = if_nametoindex("wlp1s0");
>
> to
>
>         addr->sin6.sin6_scope_id =
> addr->ipv6_get_netif_scope("fe80::6e29:95ff:fe7d:37e6");
>
> and the test again worked fine:
>
> Apr 23 08:10:41 salmon sip-proxy[21888]: Listening on
> Apr 23 08:10:41 salmon sip-proxy[21888]:   udp:
> FE80:0:0:0:6E29:95FF:FE7D:37E6 [FE80:0:0:0:6E29:95FF:FE7D:37E6]:5060
>
> So rather than skipping link local addresses, ipv6_get_netif_scope could
> be used to find the scope id.
>
> -- Juha
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20190423/65aea378/attachment.html>


More information about the sr-users mailing list