Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Mar 2013 09:44:02 -0700
From:      "Sechang Son" <sonsechang@gmail.com>
To:        "'freebsd-net'" <freebsd-net@freebsd.org>
Subject:   Accessing/modifying route without lock in ip_output
Message-ID:  <01e701ce2653$4c23f8d0$e46bea70$@gmail.com>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?01e701ce2653$4c23f8d0$e46bea70$>