Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/rmind-smpnet]: src/sys Eliminate some of the splsoftnet() calls, misc cl...
details: https://anonhg.NetBSD.org/src/rev/6d936548104e
branches: rmind-smpnet
changeset: 787710:6d936548104e
user: rmind <rmind%NetBSD.org@localhost>
date: Thu Oct 17 23:52:18 2013 +0000
description:
Eliminate some of the splsoftnet() calls, misc clean up.
diffstat:
sys/kern/uipc_socket2.c | 6 +-
sys/netinet/ip_output.c | 28 ++++++++-------
sys/netinet/tcp_usrreq.c | 6 +-
sys/netinet/udp_usrreq.c | 87 ++++++++++++++++++-----------------------------
4 files changed, 54 insertions(+), 73 deletions(-)
diffs (truncated from 412 to 300 lines):
diff -r 7aed2419406b -r 6d936548104e sys/kern/uipc_socket2.c
--- a/sys/kern/uipc_socket2.c Mon Sep 23 00:57:53 2013 +0000
+++ b/sys/kern/uipc_socket2.c Thu Oct 17 23:52:18 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket2.c,v 1.112.2.2 2013/09/23 00:57:53 rmind Exp $ */
+/* $NetBSD: uipc_socket2.c,v 1.112.2.3 2013/10/17 23:52:18 rmind Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.112.2.2 2013/09/23 00:57:53 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.112.2.3 2013/10/17 23:52:18 rmind Exp $");
#include "opt_mbuftrace.h"
#include "opt_sb_max.h"
@@ -299,7 +299,7 @@
so->so_snd.sb_flags |= head->so_snd.sb_flags & (SB_AUTOSIZE | SB_ASYNC);
/*
- * Share the lock the listening-socket, it may get unshared
+ * Share the lock with the listening-socket, it may get unshared
* once the connection is complete.
*/
mutex_obj_hold(head->so_lock);
diff -r 7aed2419406b -r 6d936548104e sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c Mon Sep 23 00:57:53 2013 +0000
+++ b/sys/netinet/ip_output.c Thu Oct 17 23:52:18 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_output.c,v 1.223.2.2 2013/08/28 23:59:36 rmind Exp $ */
+/* $NetBSD: ip_output.c,v 1.223.2.3 2013/10/17 23:52:18 rmind Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.223.2.2 2013/08/28 23:59:36 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.223.2.3 2013/10/17 23:52:18 rmind Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -191,6 +191,7 @@
MCLAIM(m, &ip_tx_mowner);
+ KASSERT(solocked(so));
KASSERT((m->m_flags & M_PKTHDR) != 0);
KASSERT((m->m_pkthdr.csum_flags & (M_CSUM_TCPv6|M_CSUM_UDPv6)) == 0);
KASSERT((m->m_pkthdr.csum_flags & (M_CSUM_TCPv4|M_CSUM_UDPv4)) !=
@@ -202,6 +203,7 @@
hlen = len;
}
ip = mtod(m, struct ip *);
+
/*
* Fill in IP header.
*/
@@ -214,6 +216,7 @@
} else {
hlen = ip->ip_hl << 2;
}
+
/*
* Route packet.
*/
@@ -222,17 +225,15 @@
ro = &iproute;
sockaddr_in_init(&u.dst4, &ip->ip_dst, 0);
dst = satocsin(rtcache_getdst(ro));
+
/*
- * If there is a cached route,
- * check that it is to the same destination
- * and is still up. If not, free it and try again.
- * The address family should also be checked in case of sharing the
- * cache with IPv6.
+ * If there is a cached route, check that it is to the same
+ * destination and is still up. If not, free it and try again.
+ * The address family should also be checked in case of sharing
+ * the cache with IPv6.
*/
- if (dst == NULL)
- ;
- else if (dst->sin_family != AF_INET ||
- !in_hosteq(dst->sin_addr, ip->ip_dst))
+ if (dst && (dst->sin_family != AF_INET ||
+ !in_hosteq(dst->sin_addr, ip->ip_dst)))
rtcache_free(ro);
if ((rt = rtcache_validate(ro)) == NULL &&
@@ -240,9 +241,9 @@
dst = &u.dst4;
rtcache_setdst(ro, &u.dst);
}
+
/*
- * If routing to interface only,
- * short circuit routing lookup.
+ * If routing to interface only, short circuit routing lookup.
*/
if (flags & IP_ROUTETOIF) {
if ((ia = ifatoia(ifa_ifwithladdr(sintocsa(dst)))) == NULL) {
@@ -275,6 +276,7 @@
if (rt->rt_flags & RTF_GATEWAY)
dst = satosin(rt->rt_gateway);
}
+
if (IN_MULTICAST(ip->ip_dst.s_addr) ||
(ip->ip_dst.s_addr == INADDR_BROADCAST)) {
struct in_multi *inm;
diff -r 7aed2419406b -r 6d936548104e sys/netinet/tcp_usrreq.c
--- a/sys/netinet/tcp_usrreq.c Mon Sep 23 00:57:53 2013 +0000
+++ b/sys/netinet/tcp_usrreq.c Thu Oct 17 23:52:18 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_usrreq.c,v 1.166.4.3 2013/09/23 00:57:53 rmind Exp $ */
+/* $NetBSD: tcp_usrreq.c,v 1.166.4.4 2013/10/17 23:52:18 rmind Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -95,7 +95,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.166.4.3 2013/09/23 00:57:53 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.166.4.4 2013/10/17 23:52:18 rmind Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -1984,7 +1984,7 @@
PR_WRAP_USRREQ(tcp_usrreq)
-#define tcp_usrreq tcp_usrreq_wrapper
+#define tcp_usrreq tcp_usrreq_wrapper
const struct pr_usrreqs tcp_usrreqs = {
.pr_attach = tcp_attach,
diff -r 7aed2419406b -r 6d936548104e sys/netinet/udp_usrreq.c
--- a/sys/netinet/udp_usrreq.c Mon Sep 23 00:57:53 2013 +0000
+++ b/sys/netinet/udp_usrreq.c Thu Oct 17 23:52:18 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udp_usrreq.c,v 1.190.2.3 2013/09/23 00:57:53 rmind Exp $ */
+/* $NetBSD: udp_usrreq.c,v 1.190.2.4 2013/10/17 23:52:18 rmind Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.190.2.3 2013/09/23 00:57:53 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.190.2.4 2013/10/17 23:52:18 rmind Exp $");
#include "opt_inet.h"
#include "opt_compat_netbsd.h"
@@ -305,10 +305,8 @@
struct sockaddr_in src, dst;
struct ip *ip;
struct udphdr *uh;
- int iphlen;
- int len;
- int n;
- u_int16_t ip_len;
+ int iphlen, len, n;
+ uint16_t ip_len;
va_start(ap, m);
iphlen = va_arg(ap, int);
@@ -329,7 +327,7 @@
}
KASSERT(UDP_HDR_ALIGNED_P(uh));
- /* destination port of 0 is illegal, based on RFC768. */
+ /* Destination port of 0 is illegal, based on RFC 768. */
if (uh->uh_dport == 0)
goto bad;
@@ -338,7 +336,7 @@
* If not enough data to reflect UDP length, drop.
*/
ip_len = ntohs(ip->ip_len);
- len = ntohs((u_int16_t)uh->uh_ulen);
+ len = ntohs((uint16_t)uh->uh_ulen);
if (ip_len != iphlen + len) {
if (ip_len < iphlen + len || len < sizeof(struct udphdr)) {
UDP_STATINC(UDP_STAT_BADLEN);
@@ -351,7 +349,7 @@
* Checksum extended UDP header and data.
*/
if (udp4_input_checksum(m, uh, iphlen, len))
- goto badcsum;
+ goto bad;
/* construct source and dst sockaddrs. */
sockaddr_in_init(&src, &ip->ip_src, uh->uh_sport);
@@ -412,14 +410,11 @@
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
m = NULL;
}
-
bad:
- if (m)
+ if (m) {
m_freem(m);
+ }
return;
-
-badcsum:
- m_freem(m);
}
static void
@@ -676,32 +671,30 @@
int
udp_ctloutput(int op, struct socket *so, struct sockopt *sopt)
{
- int s, family, optval, inpflags, error = 0;
+ int family, optval, inpflags, error = 0;
inpcb_t *inp;
+ KASSERT(solocked(so));
+
family = so->so_proto->pr_domain->dom_family;
- s = splsoftnet();
switch (family) {
#ifdef INET
case PF_INET:
if (sopt->sopt_level != IPPROTO_UDP) {
- error = ip_ctloutput(op, so, sopt);
- goto end;
+ return ip_ctloutput(op, so, sopt);
}
break;
#endif
#ifdef INET6
case PF_INET6:
if (sopt->sopt_level != IPPROTO_UDP) {
- error = ip6_ctloutput(op, so, sopt);
- goto end;
+ return ip6_ctloutput(op, so, sopt);
}
break;
#endif
default:
- error = EAFNOSUPPORT;
- goto end;
+ return EAFNOSUPPORT;
}
switch (op) {
@@ -747,8 +740,6 @@
break;
}
-end:
- splx(s);
return error;
}
@@ -792,8 +783,6 @@
inpcb_get_ports(inp, &ui->ui_sport, &ui->ui_dport);
ui->ui_ulen = htons((uint16_t)len + sizeof(struct udphdr));
- ro = inpcb_get_route(inp);
-
/*
* Set up checksum and output datagram.
*/
@@ -818,9 +807,10 @@
ui_ip->ip_tos = inp_ip->ip_tos; /* XXX */
UDP_STATINC(UDP_STAT_OPACKETS);
- return (ip_output(m, inpcb_get_options(inp), ro,
+ ro = inpcb_get_route(inp);
+ return ip_output(m, inpcb_get_options(inp), ro,
so->so_options & (SO_DONTROUTE | SO_BROADCAST),
- inpcb_get_moptions(inp), so));
+ inpcb_get_moptions(inp), so);
release:
m_freem(m);
@@ -832,11 +822,11 @@
{
inpcb_t *inp;
struct ip *ip;
- int s, error;
+ int error;
KASSERT(sotoinpcb(so) == NULL);
- s = splsoftnet();
+ /* Assign the lock (must happen if we will error out). */
sosetlock(so);
#ifdef MBUFTRACE
Home |
Main Index |
Thread Index |
Old Index