On Thu, Nov 05, 2015 at 11:59:45AM +0100, Martin Pieuchot wrote:
> Stop using rt_ifp in mpe(4), ok?

Looks good untested but just move on. OK claudio
 
> Index: net/if_mpe.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_mpe.c,v
> retrieving revision 1.49
> diff -u -p -r1.49 if_mpe.c
> --- net/if_mpe.c      22 Oct 2015 17:48:34 -0000      1.49
> +++ net/if_mpe.c      5 Nov 2015 10:58:07 -0000
> @@ -139,17 +139,18 @@ struct sockaddr_storage  mpedst;
>   * Start output on the mpe interface.
>   */
>  void
> -mpestart(struct ifnet *ifp)
> +mpestart(struct ifnet *ifp0)
>  {
>       struct mbuf             *m;
>       struct sockaddr         *sa = (struct sockaddr *)&mpedst;
>       int                      s;
>       sa_family_t              af;
>       struct rtentry          *rt;
> +     struct ifnet            *ifp;
>  
>       for (;;) {
>               s = splnet();
> -             IFQ_DEQUEUE(&ifp->if_snd, m);
> +             IFQ_DEQUEUE(&ifp0->if_snd, m);
>               splx(s);
>  
>               if (m == NULL)
> @@ -172,19 +173,25 @@ mpestart(struct ifnet *ifp)
>               }
>  
>               rt = rtalloc(sa, RT_REPORT|RT_RESOLVE, 0);
> -             if (rt == NULL) {
> -                     /* no route give up */
> +             if (!rtisvalid(rt)) {
>                       m_freem(m);
>                       continue;
>               }
>  
> +             ifp = if_get(rt->rt_ifidx);
> +             if (ifp == NULL) {
> +                     m_freem(m);
> +                     rtfree(rt);
> +                     continue;
> +             }
> +
>  #if NBPFILTER > 0
> -             if (ifp->if_bpf) {
> +             if (ifp0->if_bpf) {
>                       /* remove MPLS label before passing packet to bpf */
>                       m->m_data += sizeof(struct shim_hdr);
>                       m->m_len -= sizeof(struct shim_hdr);
>                       m->m_pkthdr.len -= sizeof(struct shim_hdr);
> -                     bpf_mtap_af(ifp->if_bpf, af, m, BPF_DIRECTION_OUT);
> +                     bpf_mtap_af(ifp0->if_bpf, af, m, BPF_DIRECTION_OUT);
>                       m->m_data -= sizeof(struct shim_hdr);
>                       m->m_len += sizeof(struct shim_hdr);
>                       m->m_pkthdr.len += sizeof(struct shim_hdr);
> @@ -193,7 +200,8 @@ mpestart(struct ifnet *ifp)
>               /* XXX lie, but mpls_output will only look at sa_family */
>               sa->sa_family = AF_MPLS;
>  
> -             mpls_output(rt->rt_ifp, m, sa, rt);
> +             mpls_output(ifp, m, sa, rt);
> +             if_put(ifp);
>               rtfree(rt);
>       }
>  }

-- 
:wq Claudio

Reply via email to