On Tue, May 30, 2017 at 09:27:28AM +0200, Martin Pieuchot wrote:
> Here's a simple refactoring diff to simplify the next one. The upcoming
> diff will be unlocking IP forwarding paths, so I want to keep it as
> small as possible.
>
> The idea of the refactoring below is to introduce two wrappers functions
> around IP queues. In the next iteration they will call the protocol
> function directly.
>
> ok?
Totally, makes switching a lot easier. Go for it.
> Index: dev/usb/if_umb.c
> ===
> RCS file: /cvs/src/sys/dev/usb/if_umb.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 if_umb.c
> --- dev/usb/if_umb.c 18 May 2017 14:48:27 - 1.13
> +++ dev/usb/if_umb.c 30 May 2017 07:23:02 -
> @@ -768,7 +768,6 @@ umb_output(struct ifnet *ifp, struct mbu
> int
> umb_input(struct ifnet *ifp, struct mbuf *m, void *cookie)
> {
> - struct niqueue *inq;
> uint8_t ipv;
>
> if ((ifp->if_flags & IFF_UP) == 0) {
> @@ -789,12 +788,12 @@ umb_input(struct ifnet *ifp, struct mbuf
> ifp->if_ibytes += m->m_pkthdr.len;
> switch (ipv) {
> case 4:
> - inq = &ipintrq;
> - break;
> + ipv4_input(ifp, m);
> + return 1;
> #ifdef INET6
> case 6:
> - inq = &ip6intrq;
> - break;
> + ipv6_input(ifp, m);
> + return 1;
> #endif /* INET6 */
> default:
> ifp->if_ierrors++;
> @@ -803,7 +802,6 @@ umb_input(struct ifnet *ifp, struct mbuf
> m_freem(m);
> return 1;
> }
> - niq_enqueue(inq, m);
> return 1;
> }
>
> Index: net/if.c
> ===
> RCS file: /cvs/src/sys/net/if.c,v
> retrieving revision 1.501
> diff -u -p -r1.501 if.c
> --- net/if.c 30 May 2017 06:42:13 - 1.501
> +++ net/if.c 30 May 2017 07:23:02 -
> @@ -734,8 +734,6 @@ if_input(struct ifnet *ifp, struct mbuf_
> int
> if_input_local(struct ifnet *ifp, struct mbuf *m, sa_family_t af)
> {
> - struct niqueue *ifq = NULL;
> -
> #if NBPFILTER > 0
> /*
>* Only send packets to bpf if they are destinated to local
> @@ -758,33 +756,28 @@ if_input_local(struct ifnet *ifp, struct
> ifp->if_opackets++;
> ifp->if_obytes += m->m_pkthdr.len;
>
> + ifp->if_ipackets++;
> + ifp->if_ibytes += m->m_pkthdr.len;
> +
> switch (af) {
> case AF_INET:
> - ifq = &ipintrq;
> + ipv4_input(ifp, m);
> break;
> #ifdef INET6
> case AF_INET6:
> - ifq = &ip6intrq;
> + ipv6_input(ifp, m);
> break;
> #endif /* INET6 */
> #ifdef MPLS
> case AF_MPLS:
> - ifp->if_ipackets++;
> - ifp->if_ibytes += m->m_pkthdr.len;
> mpls_input(m);
> - return (0);
> + break;
> #endif /* MPLS */
> default:
> printf("%s: can't handle af%d\n", ifp->if_xname, af);
> m_freem(m);
> return (EAFNOSUPPORT);
> }
> -
> - if (niq_enqueue(ifq, m) != 0)
> - return (ENOBUFS);
> -
> - ifp->if_ipackets++;
> - ifp->if_ibytes += m->m_pkthdr.len;
>
> return (0);
> }
> Index: net/if_ethersubr.c
> ===
> RCS file: /cvs/src/sys/net/if_ethersubr.c,v
> retrieving revision 1.244
> diff -u -p -r1.244 if_ethersubr.c
> --- net/if_ethersubr.c28 May 2017 12:51:34 - 1.244
> +++ net/if_ethersubr.c30 May 2017 07:23:02 -
> @@ -374,8 +374,8 @@ ether_input(struct ifnet *ifp, struct mb
> decapsulate:
> switch (etype) {
> case ETHERTYPE_IP:
> - inq = &ipintrq;
> - break;
> + ipv4_input(ifp, m);
> + return (1);
>
> case ETHERTYPE_ARP:
> if (ifp->if_flags & IFF_NOARP)
> @@ -394,8 +394,8 @@ decapsulate:
>* Schedule IPv6 software interrupt for incoming IPv6 packet.
>*/
> case ETHERTYPE_IPV6:
> - inq = &ip6intrq;
> - break;
> + ipv6_input(ifp, m);
> + return (1);
> #endif /* INET6 */
> #if NPPPOE > 0 || defined(PIPEX)
> case ETHERTYPE_PPPOEDISC:
> Index: net/if_mpe.c
> ===
> RCS file: /cvs/src/sys/net/if_mpe.c,v
> retrieving revision 1.59
> diff -u -p -r1.59 if_mpe.c
> --- net/if_mpe.c 4 May 2017 15:00:24 - 1.59
> +++ net/if_mpe.c 30 May 2017 07:23:02 -
> @@ -396,7 +396,7 @@ mpe_input(struct mbuf *m, struct ifnet *
> bpf_mtap_af(ifp->if_bpf, AF_INET, m, BPF_DIRECTION_IN);
> #endif
>
> - niq_enqueue(&ipintrq, m);
> + ipv4_input(ifp, m);
> }
>
> #ifdef INET6
> @@ -428,6 +428,6 @@ mpe_input6(struct mbuf *m, struct ifnet
> bpf_mtap_af(ifp->if_bpf, AF_INET6, m, BPF_DIREC