On Thu, Sep 05, 2013 at 10:54:53AM +0200, Martin Pieuchot wrote:
> Diff below makes use of IFP_TO_IA() instead of rolling our own copy.
> 
> For now there's no functional change, but I'd like to get this in so
> that once our multicast code can stop relying on global lists, we only
> need to modify the macro.
> 
> ok?

The old code did run into the EADDRNOTAVAIL case, if the routing
domain did not match.  Now you don't return.

I think you need someting like this;

                ifp = mopts->imo_multicast_ifp;
                if (ifp != NULL) {
                        IFP_TO_IA(ifp, ia);
                        if (ia == NULL ||
                            ifp->if_rdomain != rtable_l2(rtableid)) {
                                *errorp = EADDRNOTAVAIL;
                                return NULL;
                        }

bluhm


> 
> Index: netinet/in_pcb.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/netinet/in_pcb.c,v
> retrieving revision 1.139
> diff -u -p -r1.139 in_pcb.c
> --- netinet/in_pcb.c  1 Jun 2013 13:25:40 -0000       1.139
> +++ netinet/in_pcb.c  5 Sep 2013 08:52:10 -0000
> @@ -794,13 +794,10 @@ in_selectsrc(struct sockaddr_in *sin, st
>       if (IN_MULTICAST(sin->sin_addr.s_addr) && mopts != NULL) {
>               struct ifnet *ifp;
>  
> -             if (mopts->imo_multicast_ifp != NULL) {
> -                     ifp = mopts->imo_multicast_ifp;
> -                     TAILQ_FOREACH(ia, &in_ifaddr, ia_list)
> -                             if (ia->ia_ifp == ifp &&
> -                                 rtable_l2(rtableid) == ifp->if_rdomain)
> -                                     break;
> -                     if (ia == 0) {
> +             ifp = mopts->imo_multicast_ifp;
> +             if (ifp != NULL && ifp->if_rdomain == rtable_l2(rtableid)) {
> +                     IFP_TO_IA(ifp, ia);
> +                     if (ia == NULL) {
>                               *errorp = EADDRNOTAVAIL;
>                               return NULL;
>                       }

Reply via email to