ok mvs@

> On 21 Aug 2022, at 16:04, Alexander Bluhm <[email protected]> wrote:
> 
> Hi,
> 
> After moving the IPv4 fragment reassembly and IPv6 hob-by-hob header
> chain processing out of ip_local() and ip6_local(), we can remove
> these almost empty stubs.  No functional change intended.
> 
> ok?
> 
> bluhm
> 
> Index: netinet/ip_input.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_input.c,v
> retrieving revision 1.379
> diff -u -p -r1.379 ip_input.c
> --- netinet/ip_input.c        15 Aug 2022 16:15:36 -0000      1.379
> +++ netinet/ip_input.c        21 Aug 2022 12:49:13 -0000
> @@ -138,7 +138,6 @@ static struct mbuf_queue  ipsendraw_mq;
> extern struct niqueue         arpinq;
> 
> int   ip_ours(struct mbuf **, int *, int, int);
> -int  ip_local(struct mbuf **, int *, int, int);
> int   ip_dooptions(struct mbuf *, struct ifnet *);
> int   in_ouraddr(struct mbuf *, struct ifnet *, struct rtentry **);
> 
> @@ -245,7 +244,7 @@ ip_ours(struct mbuf **mp, int *offp, int
> 
>       /* We are already in a IPv4/IPv6 local deliver loop. */
>       if (af != AF_UNSPEC)
> -             return ip_local(mp, offp, nxt, af);
> +             return nxt;
> 
>       niq_enqueue(&ipintrq, *mp);
>       *mp = NULL;
> @@ -260,15 +259,20 @@ void
> ipintr(void)
> {
>       struct mbuf *m;
> -     int off, nxt;
> 
>       while ((m = niq_dequeue(&ipintrq)) != NULL) {
> +             struct ip *ip;
> +             int off, nxt;
> +
> #ifdef DIAGNOSTIC
>               if ((m->m_flags & M_PKTHDR) == 0)
>                       panic("ipintr no HDR");
> #endif
> -             off = 0;
> -             nxt = ip_local(&m, &off, IPPROTO_IPV4, AF_UNSPEC);
> +             ip = mtod(m, struct ip *);
> +             off = ip->ip_hl << 2;
> +             nxt = ip->ip_p;
> +
> +             nxt = ip_deliver(&m, &off, nxt, AF_INET);
>               KASSERT(nxt == IPPROTO_DONE);
>       }
> }
> @@ -549,28 +553,6 @@ ip_input_if(struct mbuf **mp, int *offp,
>       m_freemp(mp);
>  out:
>       rtfree(rt);
> -     return nxt;
> -}
> -
> -/*
> - * IPv4 local-delivery routine.
> - *
> - * If fragmented try to reassemble.  Pass to next level.
> - */
> -int
> -ip_local(struct mbuf **mp, int *offp, int nxt, int af)
> -{
> -     if (*offp == 0) {
> -             struct ip *ip;
> -
> -             ip = mtod(*mp, struct ip *);
> -             *offp = ip->ip_hl << 2;
> -             nxt = ip->ip_p;
> -     }
> -
> -     /* Check whether we are already in a IPv4/IPv6 local deliver loop. */
> -     if (af == AF_UNSPEC)
> -             nxt = ip_deliver(mp, offp, nxt, AF_INET);
>       return nxt;
> }
> 
> Index: netinet6/ip6_input.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_input.c,v
> retrieving revision 1.253
> diff -u -p -r1.253 ip6_input.c
> --- netinet6/ip6_input.c      15 Aug 2022 16:15:37 -0000      1.253
> +++ netinet6/ip6_input.c      21 Aug 2022 12:55:04 -0000
> @@ -120,7 +120,6 @@ struct cpumem *ip6counters;
> uint8_t ip6_soiikey[IP6_SOIIKEY_LEN];
> 
> int ip6_ours(struct mbuf **, int *, int, int);
> -int ip6_local(struct mbuf **, int *, int, int);
> int ip6_check_rh0hdr(struct mbuf *, int *);
> int ip6_hbhchcheck(struct mbuf **, int *, int *);
> int ip6_hopopts_input(struct mbuf **, int *, u_int32_t *, u_int32_t *);
> @@ -189,7 +188,7 @@ ip6_ours(struct mbuf **mp, int *offp, in
> 
>       /* We are already in a IPv4/IPv6 local deliver loop. */
>       if (af != AF_UNSPEC)
> -             return ip6_local(mp, offp, nxt, af);
> +             return nxt;
> 
>       /* save values for later, use after dequeue */
>       if (*offp != sizeof(struct ip6_hdr)) {
> @@ -224,15 +223,32 @@ void
> ip6intr(void)
> {
>       struct mbuf *m;
> -     int off, nxt;
> 
>       while ((m = niq_dequeue(&ip6intrq)) != NULL) {
> +             struct m_tag *mtag;
> +             int off, nxt;
> +
> #ifdef DIAGNOSTIC
>               if ((m->m_flags & M_PKTHDR) == 0)
>                       panic("ip6intr no HDR");
> #endif
> -             off = 0;
> -             nxt = ip6_local(&m, &off, IPPROTO_IPV6, AF_UNSPEC);
> +             mtag = m_tag_find(m, PACKET_TAG_IP6_OFFNXT, NULL);
> +             if (mtag != NULL) {
> +                     struct ip6_offnxt *ion;
> +
> +                     ion = (struct ip6_offnxt *)(mtag + 1);
> +                     off = ion->ion_off;
> +                     nxt = ion->ion_nxt;
> +
> +                     m_tag_delete(m, mtag);
> +             } else {
> +                     struct ip6_hdr *ip6;
> +
> +                     ip6 = mtod(m, struct ip6_hdr *);
> +                     off = sizeof(struct ip6_hdr);
> +                     nxt = ip6->ip6_nxt;
> +             }
> +             nxt = ip_deliver(&m, &off, nxt, AF_INET6);
>               KASSERT(nxt == IPPROTO_DONE);
>       }
> }
> @@ -610,37 +626,6 @@ ip6_input_if(struct mbuf **mp, int *offp
>       m_freemp(mp);
>  out:
>       rtfree(rt);
> -     return nxt;
> -}
> -
> -int
> -ip6_local(struct mbuf **mp, int *offp, int nxt, int af)
> -{
> -     if (*offp == 0) {
> -             struct m_tag *mtag;
> -
> -             mtag = m_tag_find(*mp, PACKET_TAG_IP6_OFFNXT, NULL);
> -             if (mtag != NULL) {
> -                     struct ip6_offnxt *ion;
> -
> -                     ion = (struct ip6_offnxt *)(mtag + 1);
> -                     *offp = ion->ion_off;
> -                     nxt = ion->ion_nxt;
> -
> -                     m_tag_delete(*mp, mtag);
> -             } else {
> -                     struct ip6_hdr *ip6;
> -
> -                     ip6 = mtod(*mp, struct ip6_hdr *);
> -                     *offp = sizeof(struct ip6_hdr);
> -                     nxt = ip6->ip6_nxt;
> -                     
> -             }
> -     }
> -
> -     /* Check whether we are already in a IPv4/IPv6 local deliver loop. */
> -     if (af == AF_UNSPEC)
> -             nxt = ip_deliver(mp, offp, nxt, AF_INET6);
>       return nxt;
> }
> 
> 

Reply via email to