Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add assertions and comments for lock states of socket an...
details: https://anonhg.NetBSD.org/src/rev/81338eabc015
branches: trunk
changeset: 351674:81338eabc015
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Feb 22 07:05:04 2017 +0000
description:
Add assertions and comments for lock states of socket and pcb
diffstat:
sys/netinet/in_pcb.h | 3 ++-
sys/netinet/ip_output.c | 10 ++++++++--
sys/netinet6/in6_pcb.h | 4 +++-
sys/netinet6/ip6_output.c | 9 +++++++--
4 files changed, 20 insertions(+), 6 deletions(-)
diffs (124 lines):
diff -r c3d2e7016d62 -r 81338eabc015 sys/netinet/in_pcb.h
--- a/sys/netinet/in_pcb.h Wed Feb 22 04:44:16 2017 +0000
+++ b/sys/netinet/in_pcb.h Wed Feb 22 07:05:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb.h,v 1.61 2016/12/08 05:16:33 ozaki-r Exp $ */
+/* $NetBSD: in_pcb.h,v 1.62 2017/02/22 07:05:04 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -128,6 +128,7 @@
INP_PKTINFO)
#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
+#define inplocked(inp) solocked((inp)->inp_socket)
#ifdef _KERNEL
void in_losing(struct inpcb *);
diff -r c3d2e7016d62 -r 81338eabc015 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c Wed Feb 22 04:44:16 2017 +0000
+++ b/sys/netinet/ip_output.c Wed Feb 22 07:05:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_output.c,v 1.271 2017/02/17 04:31:34 ozaki-r Exp $ */
+/* $NetBSD: ip_output.c,v 1.272 2017/02/22 07:05:04 ozaki-r 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.271 2017/02/17 04:31:34 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.272 2017/02/22 07:05:04 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1058,6 +1058,8 @@
int inpflags = inp->inp_flags;
int optval = 0, error = 0;
+ KASSERT(solocked(so));
+
if (sopt->sopt_level != IPPROTO_IP) {
if (sopt->sopt_level == SOL_SOCKET && sopt->sopt_name == SO_NOHEADER)
return 0;
@@ -1335,6 +1337,8 @@
u_char *dp;
int cnt;
+ KASSERT(inplocked(inp));
+
/* Turn off any old options. */
if (inp->inp_options) {
m_free(inp->inp_options);
@@ -1773,6 +1777,8 @@
uint8_t optval;
int error = 0;
+ /* imo is protected by solock or refereced only by the caller */
+
switch (sopt->sopt_name) {
case IP_MULTICAST_IF:
if (imo == NULL || imo->imo_multicast_if_index == 0)
diff -r c3d2e7016d62 -r 81338eabc015 sys/netinet6/in6_pcb.h
--- a/sys/netinet6/in6_pcb.h Wed Feb 22 04:44:16 2017 +0000
+++ b/sys/netinet6/in6_pcb.h Wed Feb 22 07:05:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_pcb.h,v 1.47 2016/12/08 05:16:34 ozaki-r Exp $ */
+/* $NetBSD: in6_pcb.h,v 1.48 2017/02/22 07:05:04 ozaki-r Exp $ */
/* $KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $ */
/*
@@ -107,6 +107,8 @@
#define in6p_faddr in6p_ip6.ip6_dst
#define in6p_laddr in6p_ip6.ip6_src
+#define in6plocked(in6p) solocked((in6p)->in6p_socket)
+
/* states in inp_state: */
#define IN6P_ATTACHED INP_ATTACHED
#define IN6P_BOUND INP_BOUND
diff -r c3d2e7016d62 -r 81338eabc015 sys/netinet6/ip6_output.c
--- a/sys/netinet6/ip6_output.c Wed Feb 22 04:44:16 2017 +0000
+++ b/sys/netinet6/ip6_output.c Wed Feb 22 07:05:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_output.c,v 1.184 2017/02/17 03:57:17 ozaki-r Exp $ */
+/* $NetBSD: ip6_output.c,v 1.185 2017/02/22 07:05:04 ozaki-r Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.184 2017/02/17 03:57:17 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.185 2017/02/22 07:05:04 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1359,6 +1359,7 @@
int error, optval;
int level, optname;
+ KASSERT(solocked(so));
KASSERT(sopt != NULL);
level = sopt->sopt_level;
@@ -2073,6 +2074,8 @@
struct mbuf *m;
int error = 0;
+ KASSERT(solocked(so));
+
/* turn off any old options. */
if (opt) {
#ifdef DIAGNOSTIC
@@ -2467,6 +2470,8 @@
struct ip6_moptions *im6o = in6p->in6p_moptions;
struct in6_multi_mship *imm;
+ KASSERT(in6plocked(in6p));
+
if (im6o == NULL) {
/*
* No multicast option buffer attached to the pcb;
Home |
Main Index |
Thread Index |
Old Index