From owner-freebsd-net@FreeBSD.ORG Thu Mar 21 16:44:05 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id F0597A8F for ; Thu, 21 Mar 2013 16:44:05 +0000 (UTC) (envelope-from sonsechang@gmail.com) Received: from mail-da0-x234.google.com (mail-da0-x234.google.com [IPv6:2607:f8b0:400e:c00::234]) by mx1.freebsd.org (Postfix) with ESMTP id D0214A7C for ; Thu, 21 Mar 2013 16:44:05 +0000 (UTC) Received: by mail-da0-f52.google.com with SMTP id f10so1748774dak.39 for ; Thu, 21 Mar 2013 09:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding:x-mailer:thread-index :content-language; bh=q4f5nxVRO64jcM6CIs/Ix520gYdStlVG6CFsSPNAyx0=; b=FAHOn5KL+qJqAds0RBmhfIynClJhj21r/fGQtDe7qT9NehlU4TDZuTfyA9Ve8iNZLk nY7oOd/iQQuBEaQ9P3lGgqwMf3wk5z6MWyTUxP3fqRJ0UDYXFo4oALmXgROWYXcuKFcr Qsl2Vu2jOuugnPuxYOtvElu9yZTHeJvw0j9hxaxWEyDZOYCYh7plz3LrRYMsR43fgAX9 LooRtuKGsfc/bXA0G0ildOrCDBBvZwS82Y9hrpFheEiFG3WCYA/W927rH7T8GutEDZPm odE3yE2garWg73S/OC3MYSwEU8aEp6LHPnjVJQp8VQu7+yPe4OMEMhXplyfStabO4NZ7 CTkQ== X-Received: by 10.66.170.44 with SMTP id aj12mr15742707pac.31.1363884245566; Thu, 21 Mar 2013 09:44:05 -0700 (PDT) Received: from sson1XP ([198.95.226.240]) by mx.google.com with ESMTPS id 1sm6672703pba.32.2013.03.21.09.44.03 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 21 Mar 2013 09:44:04 -0700 (PDT) From: "Sechang Son" To: "'freebsd-net'" Subject: Accessing/modifying route without lock in ip_output Date: Thu, 21 Mar 2013 09:44:02 -0700 Message-ID: <01e701ce2653$4c23f8d0$e46bea70$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: Ac4mUa/Pa3aW7F7VQ+CUqZd+FJEYkA== Content-Language: en-us X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Mar 2013 16:44:06 -0000 Hi, It seems that route entry (i.e. ro->ro_rt) is read/modified without lock in ip_output. The code snippet below is from FreeBSD 10 and other releases are similar to this. Can somebody tell me why it is okay or a design decision of doing this? Appreciated in advance... 114 int 115 ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, 116 struct ip_moptions *imo, struct inpcb *inp) 117 { ... 268 if (rte == NULL) { 269 #ifdef RADIX_MPATH 270 rtalloc_mpath_fib(ro, 271 ntohl(ip->ip_src.s_addr ^ ip->ip_dst.s_addr), 272 inp ? inp->inp_inc.inc_fibnum : M_GETFIB(m)); 273 #else 274 in_rtalloc_ign(ro, 0, 275 inp ? inp->inp_inc.inc_fibnum : M_GETFIB(m)); 276 #endif 277 rte = ro->ro_rt; <====== Note that ro->ro_rt is not locked here... ... 310 if (rte != NULL && (rte->rt_flags & (RTF_UP|RTF_HOST))) { 311 /* 312 * This case can happen if the user changed the MTU 313 * of an interface after enabling IP on it. Because 314 * most netifs don't keep track of routes pointing to 315 * them, there is no way for one to update all its 316 * routes when the MTU is changed. 317 */ 318 if (rte->rt_rmx.rmx_mtu > ifp->if_mtu) 319 rte->rt_rmx.rmx_mtu = ifp->if_mtu; 320 mtu = rte->rt_rmx.rmx_mtu; - Sonny