-/* $OpenBSD: ip_input.c,v 1.379 2022/08/15 16:15:36 bluhm Exp $ */
+/* $OpenBSD: ip_input.c,v 1.380 2022/08/21 14:15:55 bluhm Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
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 **);
/* 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;
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);
}
}
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;
-}
-
int
ip_fragcheck(struct mbuf **mp, int *offp)
{
-/* $OpenBSD: ip6_input.c,v 1.253 2022/08/15 16:15:37 bluhm Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.254 2022/08/21 14:15:55 bluhm Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
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 *);
/* 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)) {
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);
}
}
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;
-}
-
/* On error free mbuf and return IPPROTO_DONE. */
int
ip6_hbhchcheck(struct mbuf **mp, int *offp, int *oursp)