make mpls_input take struct ifnet *ifp as an argument

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

make mpls_input take struct ifnet *ifp as an argument

David Gwynne-5
i want this so it makes mpls_input have the same function signature
as all the other protocol input functions we care about.

it also helps mpls_input because it looks up the interface the mpls
packet was received on, but it's always called by the interface
that the packet was receieved on.

on a related note, does anyone have an opinion on what a representative
mpls test setup looks like?

anyway, ok?

Index: net/if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.534
diff -u -p -r1.534 if.c
--- net/if.c 4 Jan 2018 10:48:02 -0000 1.534
+++ net/if.c 8 Jan 2018 01:43:50 -0000
@@ -756,7 +756,7 @@ if_input_local(struct ifnet *ifp, struct
 #endif /* INET6 */
 #ifdef MPLS
  case AF_MPLS:
- mpls_input(m);
+ mpls_input(ifp, m);
  break;
 #endif /* MPLS */
  default:
Index: net/if_ethersubr.c
===================================================================
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.248
diff -u -p -r1.248 if_ethersubr.c
--- net/if_ethersubr.c 4 Jan 2018 00:33:54 -0000 1.248
+++ net/if_ethersubr.c 8 Jan 2018 01:43:50 -0000
@@ -434,7 +434,7 @@ ether_input(struct ifnet *ifp, struct mb
 #ifdef MPLS
  case ETHERTYPE_MPLS:
  case ETHERTYPE_MPLS_MCAST:
- mpls_input(m);
+ mpls_input(ifp, m);
  return (1);
 #endif
  default:
Index: netinet/ip_ether.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_ether.c,v
retrieving revision 1.97
diff -u -p -r1.97 ip_ether.c
--- netinet/ip_ether.c 20 Nov 2017 10:35:24 -0000 1.97
+++ netinet/ip_ether.c 8 Jan 2018 01:43:50 -0000
@@ -130,7 +130,7 @@ mplsip_decap(struct mbuf *m, int iphlen)
  pf_pkt_addr_changed(m);
 #endif
 
- mpls_input(m);
+ mpls_input(&sc->gif_if, m);
 }
 
 struct gif_softc *
Index: netinet/ip_gre.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_gre.c,v
retrieving revision 1.68
diff -u -p -r1.68 ip_gre.c
--- netinet/ip_gre.c 20 Nov 2017 10:35:24 -0000 1.68
+++ netinet/ip_gre.c 8 Jan 2018 01:43:50 -0000
@@ -175,7 +175,7 @@ gre_input2(struct mbuf *m, int hlen, int
 #ifdef MPLS
  case ETHERTYPE_MPLS:
  case ETHERTYPE_MPLS_MCAST:
- mpls_input(m);
+ mpls_input(&sc->sc_if, m);
  return (1);
 #endif
  default:   /* others not yet supported */
Index: netmpls/mpls.h
===================================================================
RCS file: /cvs/src/sys/netmpls/mpls.h,v
retrieving revision 1.37
diff -u -p -r1.37 mpls.h
--- netmpls/mpls.h 28 Feb 2017 07:07:07 -0000 1.37
+++ netmpls/mpls.h 8 Jan 2018 01:43:50 -0000
@@ -185,6 +185,6 @@ struct mbuf *mpls_shim_push(struct mbuf
 
 int mpls_output(struct ifnet *, struct mbuf *, struct sockaddr *,
     struct rtentry *);
-void mpls_input(struct mbuf *);
+void mpls_input(struct ifnet *, struct mbuf *);
 
 #endif /* _KERNEL */
Index: netmpls/mpls_input.c
===================================================================
RCS file: /cvs/src/sys/netmpls/mpls_input.c,v
retrieving revision 1.65
diff -u -p -r1.65 mpls_input.c
--- netmpls/mpls_input.c 8 Dec 2017 22:10:34 -0000 1.65
+++ netmpls/mpls_input.c 8 Jan 2018 01:43:50 -0000
@@ -53,36 +53,32 @@ struct mbuf *mpls_ip6_adjttl(struct mbuf
 struct mbuf *mpls_do_error(struct mbuf *, int, int, int);
 
 void
-mpls_input(struct mbuf *m)
+mpls_input(struct ifnet *ifp, struct mbuf *m)
 {
  struct sockaddr_mpls *smpls;
  struct sockaddr_mpls sa_mpls;
  struct shim_hdr *shim;
  struct rtentry *rt;
  struct rt_mpls *rt_mpls;
- struct ifnet   *ifp;
  u_int8_t ttl;
  int hasbos;
 
- if ((ifp = if_get(m->m_pkthdr.ph_ifidx)) == NULL ||
-    !ISSET(ifp->if_xflags, IFXF_MPLS)) {
+ if (!ISSET(ifp->if_xflags, IFXF_MPLS)) {
  m_freem(m);
- if_put(ifp);
  return;
  }
 
  /* drop all broadcast and multicast packets */
  if (m->m_flags & (M_BCAST | M_MCAST)) {
  m_freem(m);
- if_put(ifp);
  return;
  }
 
- if (m->m_len < sizeof(*shim))
- if ((m = m_pullup(m, sizeof(*shim))) == NULL) {
- if_put(ifp);
+ if (m->m_len < sizeof(*shim)) {
+ m = m_pullup(m, sizeof(*shim));
+ if (m == NULL)
  return;
- }
+ }
 
  shim = mtod(m, struct shim_hdr *);
 
@@ -98,10 +94,9 @@ mpls_input(struct mbuf *m)
  if (ttl-- <= 1) {
  /* TTL exceeded */
  m = mpls_do_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0);
- if (m == NULL) {
- if_put(ifp);
+ if (m == NULL)
  return;
- }
+
  shim = mtod(m, struct shim_hdr *);
  ttl = ntohl(shim->shim_label & MPLS_TTL_MASK);
  }
@@ -116,10 +111,8 @@ mpls_input(struct mbuf *m)
 
  if (ntohl(smpls->smpls_label) < MPLS_LABEL_RESERVED_MAX) {
  m = mpls_shim_pop(m);
- if (m == NULL) {
- if_put(ifp);
+ if (m == NULL)
  return;
- }
  if (!hasbos) {
  /*
  * RFC 4182 relaxes the position of the
@@ -135,30 +128,22 @@ mpls_input(struct mbuf *m)
  switch (ntohl(smpls->smpls_label)) {
  case MPLS_LABEL_IPV4NULL:
 do_v4:
- if ((m = mpls_ip_adjttl(m, ttl)) == NULL) {
- if_put(ifp);
+ if ((m = mpls_ip_adjttl(m, ttl)) == NULL)
  return;
- }
  ipv4_input(ifp, m);
- if_put(ifp);
  return;
 #ifdef INET6
  case MPLS_LABEL_IPV6NULL:
 do_v6:
- if ((m = mpls_ip6_adjttl(m, ttl)) == NULL) {
- if_put(ifp);
+ if ((m = mpls_ip6_adjttl(m, ttl)) == NULL)
  return;
- }
  ipv6_input(ifp, m);
- if_put(ifp);
  return;
 #endif /* INET6 */
  case MPLS_LABEL_IMPLNULL:
  if (m->m_len < sizeof(u_char) &&
-    (m = m_pullup(m, sizeof(u_char))) == NULL) {
- if_put(ifp);
+    (m = m_pullup(m, sizeof(u_char))) == NULL)
  return;
- }
  switch (*mtod(m, u_char *) >> 4) {
  case IPVERSION:
  goto do_v4;
@@ -168,18 +153,16 @@ do_v6:
 #endif
  default:
  m_freem(m);
- if_put(ifp);
  return;
  }
  default:
  /* Other cases are not handled for now */
  m_freem(m);
- if_put(ifp);
  return;
  }
  }
  }
- if_put(ifp);
+
  ifp = NULL;
 
  rt = rtalloc(smplstosa(smpls), RT_RESOLVE, m->m_pkthdr.ph_rtableid);

Reply | Threaded
Open this post in threaded view
|

Re: make mpls_input take struct ifnet *ifp as an argument

Alexander Bluhm
On Mon, Jan 08, 2018 at 11:49:05AM +1000, David Gwynne wrote:

> i want this so it makes mpls_input have the same function signature
> as all the other protocol input functions we care about.
>
> it also helps mpls_input because it looks up the interface the mpls
> packet was received on, but it's always called by the interface
> that the packet was receieved on.
>
> on a related note, does anyone have an opinion on what a representative
> mpls test setup looks like?
>
> anyway, ok?

OK bluhm@

> Index: net/if.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if.c,v
> retrieving revision 1.534
> diff -u -p -r1.534 if.c
> --- net/if.c 4 Jan 2018 10:48:02 -0000 1.534
> +++ net/if.c 8 Jan 2018 01:43:50 -0000
> @@ -756,7 +756,7 @@ if_input_local(struct ifnet *ifp, struct
>  #endif /* INET6 */
>  #ifdef MPLS
>   case AF_MPLS:
> - mpls_input(m);
> + mpls_input(ifp, m);
>   break;
>  #endif /* MPLS */
>   default:
> Index: net/if_ethersubr.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_ethersubr.c,v
> retrieving revision 1.248
> diff -u -p -r1.248 if_ethersubr.c
> --- net/if_ethersubr.c 4 Jan 2018 00:33:54 -0000 1.248
> +++ net/if_ethersubr.c 8 Jan 2018 01:43:50 -0000
> @@ -434,7 +434,7 @@ ether_input(struct ifnet *ifp, struct mb
>  #ifdef MPLS
>   case ETHERTYPE_MPLS:
>   case ETHERTYPE_MPLS_MCAST:
> - mpls_input(m);
> + mpls_input(ifp, m);
>   return (1);
>  #endif
>   default:
> Index: netinet/ip_ether.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_ether.c,v
> retrieving revision 1.97
> diff -u -p -r1.97 ip_ether.c
> --- netinet/ip_ether.c 20 Nov 2017 10:35:24 -0000 1.97
> +++ netinet/ip_ether.c 8 Jan 2018 01:43:50 -0000
> @@ -130,7 +130,7 @@ mplsip_decap(struct mbuf *m, int iphlen)
>   pf_pkt_addr_changed(m);
>  #endif
>  
> - mpls_input(m);
> + mpls_input(&sc->gif_if, m);
>  }
>  
>  struct gif_softc *
> Index: netinet/ip_gre.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_gre.c,v
> retrieving revision 1.68
> diff -u -p -r1.68 ip_gre.c
> --- netinet/ip_gre.c 20 Nov 2017 10:35:24 -0000 1.68
> +++ netinet/ip_gre.c 8 Jan 2018 01:43:50 -0000
> @@ -175,7 +175,7 @@ gre_input2(struct mbuf *m, int hlen, int
>  #ifdef MPLS
>   case ETHERTYPE_MPLS:
>   case ETHERTYPE_MPLS_MCAST:
> - mpls_input(m);
> + mpls_input(&sc->sc_if, m);
>   return (1);
>  #endif
>   default:   /* others not yet supported */
> Index: netmpls/mpls.h
> ===================================================================
> RCS file: /cvs/src/sys/netmpls/mpls.h,v
> retrieving revision 1.37
> diff -u -p -r1.37 mpls.h
> --- netmpls/mpls.h 28 Feb 2017 07:07:07 -0000 1.37
> +++ netmpls/mpls.h 8 Jan 2018 01:43:50 -0000
> @@ -185,6 +185,6 @@ struct mbuf *mpls_shim_push(struct mbuf
>  
>  int mpls_output(struct ifnet *, struct mbuf *, struct sockaddr *,
>      struct rtentry *);
> -void mpls_input(struct mbuf *);
> +void mpls_input(struct ifnet *, struct mbuf *);
>  
>  #endif /* _KERNEL */
> Index: netmpls/mpls_input.c
> ===================================================================
> RCS file: /cvs/src/sys/netmpls/mpls_input.c,v
> retrieving revision 1.65
> diff -u -p -r1.65 mpls_input.c
> --- netmpls/mpls_input.c 8 Dec 2017 22:10:34 -0000 1.65
> +++ netmpls/mpls_input.c 8 Jan 2018 01:43:50 -0000
> @@ -53,36 +53,32 @@ struct mbuf *mpls_ip6_adjttl(struct mbuf
>  struct mbuf *mpls_do_error(struct mbuf *, int, int, int);
>  
>  void
> -mpls_input(struct mbuf *m)
> +mpls_input(struct ifnet *ifp, struct mbuf *m)
>  {
>   struct sockaddr_mpls *smpls;
>   struct sockaddr_mpls sa_mpls;
>   struct shim_hdr *shim;
>   struct rtentry *rt;
>   struct rt_mpls *rt_mpls;
> - struct ifnet   *ifp;
>   u_int8_t ttl;
>   int hasbos;
>  
> - if ((ifp = if_get(m->m_pkthdr.ph_ifidx)) == NULL ||
> -    !ISSET(ifp->if_xflags, IFXF_MPLS)) {
> + if (!ISSET(ifp->if_xflags, IFXF_MPLS)) {
>   m_freem(m);
> - if_put(ifp);
>   return;
>   }
>  
>   /* drop all broadcast and multicast packets */
>   if (m->m_flags & (M_BCAST | M_MCAST)) {
>   m_freem(m);
> - if_put(ifp);
>   return;
>   }
>  
> - if (m->m_len < sizeof(*shim))
> - if ((m = m_pullup(m, sizeof(*shim))) == NULL) {
> - if_put(ifp);
> + if (m->m_len < sizeof(*shim)) {
> + m = m_pullup(m, sizeof(*shim));
> + if (m == NULL)
>   return;
> - }
> + }
>  
>   shim = mtod(m, struct shim_hdr *);
>  
> @@ -98,10 +94,9 @@ mpls_input(struct mbuf *m)
>   if (ttl-- <= 1) {
>   /* TTL exceeded */
>   m = mpls_do_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0);
> - if (m == NULL) {
> - if_put(ifp);
> + if (m == NULL)
>   return;
> - }
> +
>   shim = mtod(m, struct shim_hdr *);
>   ttl = ntohl(shim->shim_label & MPLS_TTL_MASK);
>   }
> @@ -116,10 +111,8 @@ mpls_input(struct mbuf *m)
>  
>   if (ntohl(smpls->smpls_label) < MPLS_LABEL_RESERVED_MAX) {
>   m = mpls_shim_pop(m);
> - if (m == NULL) {
> - if_put(ifp);
> + if (m == NULL)
>   return;
> - }
>   if (!hasbos) {
>   /*
>   * RFC 4182 relaxes the position of the
> @@ -135,30 +128,22 @@ mpls_input(struct mbuf *m)
>   switch (ntohl(smpls->smpls_label)) {
>   case MPLS_LABEL_IPV4NULL:
>  do_v4:
> - if ((m = mpls_ip_adjttl(m, ttl)) == NULL) {
> - if_put(ifp);
> + if ((m = mpls_ip_adjttl(m, ttl)) == NULL)
>   return;
> - }
>   ipv4_input(ifp, m);
> - if_put(ifp);
>   return;
>  #ifdef INET6
>   case MPLS_LABEL_IPV6NULL:
>  do_v6:
> - if ((m = mpls_ip6_adjttl(m, ttl)) == NULL) {
> - if_put(ifp);
> + if ((m = mpls_ip6_adjttl(m, ttl)) == NULL)
>   return;
> - }
>   ipv6_input(ifp, m);
> - if_put(ifp);
>   return;
>  #endif /* INET6 */
>   case MPLS_LABEL_IMPLNULL:
>   if (m->m_len < sizeof(u_char) &&
> -    (m = m_pullup(m, sizeof(u_char))) == NULL) {
> - if_put(ifp);
> +    (m = m_pullup(m, sizeof(u_char))) == NULL)
>   return;
> - }
>   switch (*mtod(m, u_char *) >> 4) {
>   case IPVERSION:
>   goto do_v4;
> @@ -168,18 +153,16 @@ do_v6:
>  #endif
>   default:
>   m_freem(m);
> - if_put(ifp);
>   return;
>   }
>   default:
>   /* Other cases are not handled for now */
>   m_freem(m);
> - if_put(ifp);
>   return;
>   }
>   }
>   }
> - if_put(ifp);
> +
>   ifp = NULL;
>  
>   rt = rtalloc(smplstosa(smpls), RT_RESOLVE, m->m_pkthdr.ph_rtableid);

Reply | Threaded
Open this post in threaded view
|

Re: make mpls_input take struct ifnet *ifp as an argument

Claudio Jeker
On Mon, Jan 08, 2018 at 11:50:54AM +0100, Alexander Bluhm wrote:

> On Mon, Jan 08, 2018 at 11:49:05AM +1000, David Gwynne wrote:
> > i want this so it makes mpls_input have the same function signature
> > as all the other protocol input functions we care about.
> >
> > it also helps mpls_input because it looks up the interface the mpls
> > packet was received on, but it's always called by the interface
> > that the packet was receieved on.
> >
> > on a related note, does anyone have an opinion on what a representative
> > mpls test setup looks like?
> >
> > anyway, ok?
>
> OK bluhm@

This is also fine by me.

As a simple test setup I would use static mpls routes. Need to dig out the
commands to do that easily.
 

> > Index: net/if.c
> > ===================================================================
> > RCS file: /cvs/src/sys/net/if.c,v
> > retrieving revision 1.534
> > diff -u -p -r1.534 if.c
> > --- net/if.c 4 Jan 2018 10:48:02 -0000 1.534
> > +++ net/if.c 8 Jan 2018 01:43:50 -0000
> > @@ -756,7 +756,7 @@ if_input_local(struct ifnet *ifp, struct
> >  #endif /* INET6 */
> >  #ifdef MPLS
> >   case AF_MPLS:
> > - mpls_input(m);
> > + mpls_input(ifp, m);
> >   break;
> >  #endif /* MPLS */
> >   default:
> > Index: net/if_ethersubr.c
> > ===================================================================
> > RCS file: /cvs/src/sys/net/if_ethersubr.c,v
> > retrieving revision 1.248
> > diff -u -p -r1.248 if_ethersubr.c
> > --- net/if_ethersubr.c 4 Jan 2018 00:33:54 -0000 1.248
> > +++ net/if_ethersubr.c 8 Jan 2018 01:43:50 -0000
> > @@ -434,7 +434,7 @@ ether_input(struct ifnet *ifp, struct mb
> >  #ifdef MPLS
> >   case ETHERTYPE_MPLS:
> >   case ETHERTYPE_MPLS_MCAST:
> > - mpls_input(m);
> > + mpls_input(ifp, m);
> >   return (1);
> >  #endif
> >   default:
> > Index: netinet/ip_ether.c
> > ===================================================================
> > RCS file: /cvs/src/sys/netinet/ip_ether.c,v
> > retrieving revision 1.97
> > diff -u -p -r1.97 ip_ether.c
> > --- netinet/ip_ether.c 20 Nov 2017 10:35:24 -0000 1.97
> > +++ netinet/ip_ether.c 8 Jan 2018 01:43:50 -0000
> > @@ -130,7 +130,7 @@ mplsip_decap(struct mbuf *m, int iphlen)
> >   pf_pkt_addr_changed(m);
> >  #endif
> >  
> > - mpls_input(m);
> > + mpls_input(&sc->gif_if, m);
> >  }
> >  
> >  struct gif_softc *
> > Index: netinet/ip_gre.c
> > ===================================================================
> > RCS file: /cvs/src/sys/netinet/ip_gre.c,v
> > retrieving revision 1.68
> > diff -u -p -r1.68 ip_gre.c
> > --- netinet/ip_gre.c 20 Nov 2017 10:35:24 -0000 1.68
> > +++ netinet/ip_gre.c 8 Jan 2018 01:43:50 -0000
> > @@ -175,7 +175,7 @@ gre_input2(struct mbuf *m, int hlen, int
> >  #ifdef MPLS
> >   case ETHERTYPE_MPLS:
> >   case ETHERTYPE_MPLS_MCAST:
> > - mpls_input(m);
> > + mpls_input(&sc->sc_if, m);
> >   return (1);
> >  #endif
> >   default:   /* others not yet supported */
> > Index: netmpls/mpls.h
> > ===================================================================
> > RCS file: /cvs/src/sys/netmpls/mpls.h,v
> > retrieving revision 1.37
> > diff -u -p -r1.37 mpls.h
> > --- netmpls/mpls.h 28 Feb 2017 07:07:07 -0000 1.37
> > +++ netmpls/mpls.h 8 Jan 2018 01:43:50 -0000
> > @@ -185,6 +185,6 @@ struct mbuf *mpls_shim_push(struct mbuf
> >  
> >  int mpls_output(struct ifnet *, struct mbuf *, struct sockaddr *,
> >      struct rtentry *);
> > -void mpls_input(struct mbuf *);
> > +void mpls_input(struct ifnet *, struct mbuf *);
> >  
> >  #endif /* _KERNEL */
> > Index: netmpls/mpls_input.c
> > ===================================================================
> > RCS file: /cvs/src/sys/netmpls/mpls_input.c,v
> > retrieving revision 1.65
> > diff -u -p -r1.65 mpls_input.c
> > --- netmpls/mpls_input.c 8 Dec 2017 22:10:34 -0000 1.65
> > +++ netmpls/mpls_input.c 8 Jan 2018 01:43:50 -0000
> > @@ -53,36 +53,32 @@ struct mbuf *mpls_ip6_adjttl(struct mbuf
> >  struct mbuf *mpls_do_error(struct mbuf *, int, int, int);
> >  
> >  void
> > -mpls_input(struct mbuf *m)
> > +mpls_input(struct ifnet *ifp, struct mbuf *m)
> >  {
> >   struct sockaddr_mpls *smpls;
> >   struct sockaddr_mpls sa_mpls;
> >   struct shim_hdr *shim;
> >   struct rtentry *rt;
> >   struct rt_mpls *rt_mpls;
> > - struct ifnet   *ifp;
> >   u_int8_t ttl;
> >   int hasbos;
> >  
> > - if ((ifp = if_get(m->m_pkthdr.ph_ifidx)) == NULL ||
> > -    !ISSET(ifp->if_xflags, IFXF_MPLS)) {
> > + if (!ISSET(ifp->if_xflags, IFXF_MPLS)) {
> >   m_freem(m);
> > - if_put(ifp);
> >   return;
> >   }
> >  
> >   /* drop all broadcast and multicast packets */
> >   if (m->m_flags & (M_BCAST | M_MCAST)) {
> >   m_freem(m);
> > - if_put(ifp);
> >   return;
> >   }
> >  
> > - if (m->m_len < sizeof(*shim))
> > - if ((m = m_pullup(m, sizeof(*shim))) == NULL) {
> > - if_put(ifp);
> > + if (m->m_len < sizeof(*shim)) {
> > + m = m_pullup(m, sizeof(*shim));
> > + if (m == NULL)
> >   return;
> > - }
> > + }
> >  
> >   shim = mtod(m, struct shim_hdr *);
> >  
> > @@ -98,10 +94,9 @@ mpls_input(struct mbuf *m)
> >   if (ttl-- <= 1) {
> >   /* TTL exceeded */
> >   m = mpls_do_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0);
> > - if (m == NULL) {
> > - if_put(ifp);
> > + if (m == NULL)
> >   return;
> > - }
> > +
> >   shim = mtod(m, struct shim_hdr *);
> >   ttl = ntohl(shim->shim_label & MPLS_TTL_MASK);
> >   }
> > @@ -116,10 +111,8 @@ mpls_input(struct mbuf *m)
> >  
> >   if (ntohl(smpls->smpls_label) < MPLS_LABEL_RESERVED_MAX) {
> >   m = mpls_shim_pop(m);
> > - if (m == NULL) {
> > - if_put(ifp);
> > + if (m == NULL)
> >   return;
> > - }
> >   if (!hasbos) {
> >   /*
> >   * RFC 4182 relaxes the position of the
> > @@ -135,30 +128,22 @@ mpls_input(struct mbuf *m)
> >   switch (ntohl(smpls->smpls_label)) {
> >   case MPLS_LABEL_IPV4NULL:
> >  do_v4:
> > - if ((m = mpls_ip_adjttl(m, ttl)) == NULL) {
> > - if_put(ifp);
> > + if ((m = mpls_ip_adjttl(m, ttl)) == NULL)
> >   return;
> > - }
> >   ipv4_input(ifp, m);
> > - if_put(ifp);
> >   return;
> >  #ifdef INET6
> >   case MPLS_LABEL_IPV6NULL:
> >  do_v6:
> > - if ((m = mpls_ip6_adjttl(m, ttl)) == NULL) {
> > - if_put(ifp);
> > + if ((m = mpls_ip6_adjttl(m, ttl)) == NULL)
> >   return;
> > - }
> >   ipv6_input(ifp, m);
> > - if_put(ifp);
> >   return;
> >  #endif /* INET6 */
> >   case MPLS_LABEL_IMPLNULL:
> >   if (m->m_len < sizeof(u_char) &&
> > -    (m = m_pullup(m, sizeof(u_char))) == NULL) {
> > - if_put(ifp);
> > +    (m = m_pullup(m, sizeof(u_char))) == NULL)
> >   return;
> > - }
> >   switch (*mtod(m, u_char *) >> 4) {
> >   case IPVERSION:
> >   goto do_v4;
> > @@ -168,18 +153,16 @@ do_v6:
> >  #endif
> >   default:
> >   m_freem(m);
> > - if_put(ifp);
> >   return;
> >   }
> >   default:
> >   /* Other cases are not handled for now */
> >   m_freem(m);
> > - if_put(ifp);
> >   return;
> >   }
> >   }
> >   }
> > - if_put(ifp);
> > +
> >   ifp = NULL;
> >  
> >   rt = rtalloc(smplstosa(smpls), RT_RESOLVE, m->m_pkthdr.ph_rtableid);
>

--
:wq Claudio

Reply | Threaded
Open this post in threaded view
|

Re: make mpls_input take struct ifnet *ifp as an argument

Bijan Ebrahimi
In reply to this post by David Gwynne-5
(forwarded from misc@) Hi, while reading the changes in OpenBSD source
code (hopefully to learn more), I've notice the usage of Uninitialized
variable. Looks like the latest commit unintentionally removed the
assignment line (sorry for the github link):

https://github.com/openbsd/src/commit/5c53b9324545b7febab2dcf52402199d72b231d3?diff=split#diff-3efc580dfa272b2173162f5950c92484R86 


The following should bring back (the possibly) unwanted change.s Hope it
helps unless I missed something


diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c
index 34fe7314d..fff3564c8 100644
--- a/sys/netmpls/mpls_input.c
+++ b/sys/netmpls/mpls_input.c
@@ -76,13 +76,15 @@ mpls_input(struct ifnet *ifp, struct mbuf *m)
         }

         shim = mtod(m, struct shim_hdr *);
-
  #ifdef MPLS_DEBUG
         printf("mpls_input: iface %s label=%d, ttl=%d BoS %d\n",
-           ifp->if_xname, MPLS_LABEL_GET(shim->shim_label), ttls, hasbos);
+           ifp->if_xname, MPLS_LABEL_GET(shim->shim_label),
+           MPLS_LABEL_GET(shim->shim_label),
+           MPLS_BOS_ISSET(shim->shim_label));
  #endif

         /* check and decrement TTL */
+       ttl = MPLS_LABEL_GET(shim->shim_label);
         if (--ttl == 0) {
                 /* TTL exceeded */
                 m = mpls_do_error(m, ICMP_TIMXCEED,
ICMP_TIMXCEED_INTRANS, 0);