Page MenuHomeFreeBSD

D28232.id83592.diff
No OneTemporary

D28232.id83592.diff

Index: sys/netinet/udp_usrreq.c
===================================================================
--- sys/netinet/udp_usrreq.c
+++ sys/netinet/udp_usrreq.c
@@ -603,16 +603,18 @@
if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) !=
NULL) {
if (proto == IPPROTO_UDPLITE)
- UDPLITE_PROBE(receive, NULL, last, ip,
- last, uh);
+ UDPLITE_PROBE(receive, NULL,
+ last, ip, last, uh);
else
- UDP_PROBE(receive, NULL, last, ip, last,
- uh);
+ UDP_PROBE(receive, NULL, last,
+ ip, last, uh);
if (udp_append(last, ip, n, iphlen,
udp_in)) {
- goto inp_lost;
+ INP_RUNLOCK(inp);
+ goto badunlocked;
}
}
+ /* Release PCB lock taken on previous pass. */
INP_RUNLOCK(last);
}
last = inp;
@@ -635,9 +637,11 @@
* to send an ICMP Port Unreachable for a broadcast
* or multicast datgram.)
*/
- UDPSTAT_INC(udps_noportbcast);
- if (inp)
- INP_RUNLOCK(inp);
+ UDPSTAT_INC(udps_noport);
+ if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)))
+ UDPSTAT_INC(udps_noportmcast);
+ else
+ UDPSTAT_INC(udps_noportbcast);
goto badunlocked;
}
if (proto == IPPROTO_UDPLITE)
@@ -646,7 +650,6 @@
UDP_PROBE(receive, NULL, last, ip, last, uh);
if (udp_append(last, ip, m, iphlen, udp_in) == 0)
INP_RUNLOCK(last);
- inp_lost:
return (IPPROTO_DONE);
}
Index: sys/netinet6/udp6_usrreq.c
===================================================================
--- sys/netinet6/udp6_usrreq.c
+++ sys/netinet6/udp6_usrreq.c
@@ -353,6 +353,13 @@
continue;
}
+ INP_RLOCK(inp);
+
+ if (__predict_false(inp->inp_flags2 & INP_FREED)) {
+ INP_RUNLOCK(inp);
+ continue;
+ }
+
/*
* XXXRW: Because we weren't holding either the inpcb
* or the hash lock when we checked for a match
@@ -365,16 +372,10 @@
* and source-specific multicast. [RFC3678]
*/
imo = inp->in6p_moptions;
- if (imo && IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
+ if (imo != NULL) {
struct sockaddr_in6 mcaddr;
int blocked;
- INP_RLOCK(inp);
- if (__predict_false(inp->inp_flags2 & INP_FREED)) {
- INP_RUNLOCK(inp);
- continue;
- }
-
bzero(&mcaddr, sizeof(struct sockaddr_in6));
mcaddr.sin6_len = sizeof(struct sockaddr_in6);
mcaddr.sin6_family = AF_INET6;
@@ -389,33 +390,30 @@
if (blocked == MCAST_NOTSMEMBER ||
blocked == MCAST_MUTED)
UDPSTAT_INC(udps_filtermcast);
- INP_RUNLOCK(inp); /* XXX */
+ INP_RUNLOCK(inp);
continue;
}
-
- INP_RUNLOCK(inp);
}
+
if (last != NULL) {
struct mbuf *n;
if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) !=
NULL) {
- INP_RLOCK(last);
- if (__predict_true(last->inp_flags2 & INP_FREED) == 0) {
- if (nxt == IPPROTO_UDPLITE)
- UDPLITE_PROBE(receive, NULL, last,
- ip6, last, uh);
- else
- UDP_PROBE(receive, NULL, last,
- ip6, last, uh);
- if (udp6_append(last, n, off, fromsa)) {
- /* XXX-BZ do we leak m here? */
- *mp = NULL;
- return (IPPROTO_DONE);
- }
+ if (nxt == IPPROTO_UDPLITE)
+ UDPLITE_PROBE(receive, NULL,
+ last, ip6, last, uh);
+ else
+ UDP_PROBE(receive, NULL, last,
+ ip6, last, uh);
+ if (udp6_append(last, n, off,
+ fromsa)) {
+ INP_RUNLOCK(inp);
+ goto badunlocked;
}
- INP_RUNLOCK(last);
}
+ /* Release PCB lock taken on previous pass. */
+ INP_RUNLOCK(last);
}
last = inp;
/*
@@ -441,15 +439,12 @@
UDPSTAT_INC(udps_noportmcast);
goto badunlocked;
}
- INP_RLOCK(last);
- if (__predict_true(last->inp_flags2 & INP_FREED) == 0) {
- if (nxt == IPPROTO_UDPLITE)
- UDPLITE_PROBE(receive, NULL, last, ip6, last, uh);
- else
- UDP_PROBE(receive, NULL, last, ip6, last, uh);
- if (udp6_append(last, m, off, fromsa) == 0)
- INP_RUNLOCK(last);
- } else
+
+ if (nxt == IPPROTO_UDPLITE)
+ UDPLITE_PROBE(receive, NULL, last, ip6, last, uh);
+ else
+ UDP_PROBE(receive, NULL, last, ip6, last, uh);
+ if (udp6_append(last, m, off, fromsa) == 0)
INP_RUNLOCK(last);
*mp = NULL;
return (IPPROTO_DONE);

File Metadata

Mime Type
text/plain
Expires
Tue, Jul 28, 2:51 PM (4 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35657758
Default Alt Text
D28232.id83592.diff (4 KB)

Event Timeline