summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2022-03-22 18:27:22 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2022-03-22 18:27:22 +0000
commit3f6b52b1f3f99569c39dbdbe3e3e45d3484eaa33 (patch)
tree1e3b3dd0917b58fdf2b1a0883f4b67f06968512b
parentefc3101a722ac647497a9d79674ebcb74141053b (diff)
Extract the type from the ICMP6 header before looping over Raw IPv6
PCBs. This make mutex and error handling easier. OK claudio@
-rw-r--r--sys/netinet6/raw_ip6.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index b5bb3bf6907..6d882f6dcc5 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip6.c,v 1.145 2022/03/21 09:12:34 bluhm Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.146 2022/03/22 18:27:21 bluhm Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
@@ -125,10 +125,19 @@ rip6_input(struct mbuf **mp, int *offp, int proto, int af)
struct in6_addr *key;
struct sockaddr_in6 rip6src;
struct mbuf *opts = NULL;
+ uint8_t type;
KASSERT(af == AF_INET6);
- if (proto != IPPROTO_ICMPV6)
+ if (proto == IPPROTO_ICMPV6) {
+ struct icmp6_hdr *icmp6;
+
+ IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, *offp,
+ sizeof(*icmp6));
+ if (icmp6 == NULL)
+ return IPPROTO_DONE;
+ type = icmp6->icmp6_type;
+ } else
rip6stat_inc(rip6s_ipackets);
bzero(&rip6src, sizeof(rip6src));
@@ -177,16 +186,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto, int af)
!IN6_ARE_ADDR_EQUAL(&in6p->inp_faddr6, &ip6->ip6_src))
continue;
if (proto == IPPROTO_ICMPV6 && in6p->inp_icmp6filt) {
- struct icmp6_hdr *icmp6;
-
- IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, *offp,
- sizeof(*icmp6));
- if (icmp6 == NULL) {
- mtx_leave(&rawin6pcbtable.inpt_mtx);
- return IPPROTO_DONE;
- }
- if (ICMP6_FILTER_WILLBLOCK(icmp6->icmp6_type,
- in6p->inp_icmp6filt))
+ if (ICMP6_FILTER_WILLBLOCK(type, in6p->inp_icmp6filt))
continue;
}
if (proto != IPPROTO_ICMPV6 && in6p->inp_cksum6 != -1) {