From 65b1ea7e2f36e86175cd3402ffab809bdbc8199d Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Fri, 21 Dec 2007 13:17:51 +0000 Subject: [PATCH] - All inpcb related operations are now CPU localized, so there is no need to protect them with critical secion. - Clean up div_bind() a little bit. # divert(4) is CPU localized; I don't think a system will open more than # one divert(4) socket. --- sys/netinet/ip_divert.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 7adae33c1d..53caef8591 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netinet/ip_divert.c,v 1.42.2.6 2003/01/23 21:06:45 sam Exp $ - * $DragonFly: src/sys/netinet/ip_divert.c,v 1.34 2007/12/21 12:51:51 sephe Exp $ + * $DragonFly: src/sys/netinet/ip_divert.c,v 1.35 2007/12/21 13:17:51 sephe Exp $ */ #include "opt_inet.h" @@ -441,9 +441,7 @@ div_attach(struct socket *so, int proto, struct pru_attach_info *ai) error = soreserve(so, div_sendspace, div_recvspace, ai->sb_rlimit); if (error) return error; - crit_enter(); error = in_pcballoc(so, &divcbinfo); - crit_exit(); if (error) return error; inp = (struct inpcb *)so->so_pcb; @@ -488,25 +486,22 @@ div_disconnect(struct socket *so) static int div_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { - struct inpcb *inp; int error; - crit_enter(); - inp = so->so_pcb; - /* in_pcbbind assumes that nam is a sockaddr_in + /* + * in_pcbbind assumes that nam is a sockaddr_in * and in_pcbbind requires a valid address. Since divert * sockets don't we need to make sure the address is * filled in properly. * XXX -- divert should not be abusing in_pcbind * and should probably have its own family. */ - if (nam->sa_family != AF_INET) + if (nam->sa_family != AF_INET) { error = EAFNOSUPPORT; - else { + } else { ((struct sockaddr_in *)nam)->sin_addr.s_addr = INADDR_ANY; - error = in_pcbbind(inp, nam, td); + error = in_pcbbind(so->so_pcb, nam, td); } - crit_exit(); return error; } -- 2.41.0