home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / protocol / tcpip / 5083 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  8.1 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!olivea!spool.mu.edu!umn.edu!mmm.serc.3m.com!mmc.mmmg.com!timbuk.cray.com!shamash!easyaspi.udev.cdc.com!gsa
  2. From: gsa@easyaspi.udev.cdc.com (gary s anderson)
  3. Newsgroups: comp.protocols.tcp-ip
  4. Subject: Re: rpc process chewing up resources
  5. Message-ID: <49395@shamash.cdc.com>
  6. Date: 6 Nov 92 22:08:11 GMT
  7. References: <DERAADT.92Nov5044404@newt.newt.cuc.ab.ca>
  8. Sender: root@shamash.cdc.com
  9. Reply-To: gsa@easyaspi.udev.cdc.com (gary s anderson)
  10. Lines: 165
  11.  
  12. In article <DERAADT.92Nov5044404@newt.newt.cuc.ab.ca>, deraadt@newt.cuc.ab.ca (Theo de Raadt) writes:
  13. |> I'm currently implimenting YP client functionality for 386bsd. So far,
  14. |> it's been an enjoyable and frustrating time....
  15. |> 
  16. |> In article <49256@shamash.cdc.com> gsa@easyaspi.udev.cdc.com (gary s anderson) writes:
  17. |> >  |> > |> > sits within the "yp" library code (you need to ask SUN why "pinging"
  18. |> >  |> > |> > the portmapper from within "yp" is useful).  This has the wonderful
  19. |> >  |> > |> Hmmmph!
  20. |> >  |> > |> What would you do if you wanted to discover if ypbind is running?
  21. |> 
  22. |> Well, on some systems (including my code at the moment) that's exactly
  23. |> why TCP is used. It's faster than UDP.
  24.  
  25. Please explain how TCP is "faster" than UDP.  You are sending one request
  26. and getting one reply.  This is an unfragmented request/reply sequence,
  27. in the case discussed in this thread.  TCP adds an end-to-end
  28. connect sequence besides sending the request and receiving the response.
  29. I'd like to know which systems you use which can create a connection
  30. and send a message faster than you can just send the message.
  31.  
  32. There are many reasons to use TCP but your comment on "faster"
  33. is obviously missing some relevant context information.
  34.  
  35. |> 
  36. |> My first code used UDP to find out if ypbind was running. Well, if you
  37. |> don't get an answer, even in talking to 127.0.0.1, well, the kernel's
  38. |> buffers could just be swamped at the moment. So you have to try a few
  39. |> times. Not pretty.
  40.  
  41. If there are no kernel buffers you can't create a TCP connection
  42. either.  The case where UDP suffers is when concurrent request
  43. information overflows the receive socket.  In the case we are
  44. talking about this isn't a major concern (i.e. small packets and
  45. short think time in server.  Additionally, vendors selling useful
  46. multi-user systems provide reasonable buffer sizes).  Consequently,
  47. overflowing the TCP connect limit would be roughly 
  48. equivalent to the UDP receive buffer limit.
  49.  
  50. NOTE - In case you missed, the TCP connection in question is directed 
  51. to the portmapper not to ypbind.
  52.  
  53. |> 
  54. |> So, I started using TCP. Immediate response yes/no whether YP is
  55. |> running. I had no real concerns with whether the portmapper is
  56. |> running.
  57. |> 
  58. |> I'm have a Sun too. A few minutes ago, I went and looked to see why
  59. |> the file /etc/ypbind.lock exist... a bit of snooping and following a
  60. |> hunch...
  61. |> 
  62. |>   4835 -rw-------  1 root            0 Nov  2 21:46 /etc/ypbind.lock
  63. |>   ^^^^
  64. |>  inode
  65. |> 
  66. |> pstat -i | grep 4835
  67. |>  f23f9a8    R     7,  0  4835 100600   1    0         0   E     2   0   1 VREG
  68. |>                               ^^^
  69. |> That little 'E' is an exclusive lock.
  70. |> 
  71. |> Could someone explain exactly what is going on here? What I suspect
  72. |> follows: ypbind maintains the exclusive lock on /etc/ypbind.lock
  73. |> Processes that are interested can find out if ypbind is running by
  74. |> doing a lockf(fd, F_TEST).  Sun's ypbind also puts an exclusive lock
  75. |> on /var/yp/binding/domainname.2 and /var/yp/binding/domainname.1.  I
  76. |> suspect the 2 is YPBINDVERS.
  77. |> 
  78. |> Just trying to get a flock() on that file seems to work. This is so much
  79. |> easier than what it appears the entire argument here is about.
  80. |> 
  81. |> Here's what happens if I trace a program that needs to check YP.
  82. |> 
  83. |>     open ("/var/yp/binding/cuc.ab.ca.2", 0, 036736173730) = 4
  84. |>     flock (4, 06) = -1 EWOULDBLOCK (Operation would block)
  85. |>     mmap (0x8ab8, 14, 0x1, 0x80000001, 4, 0) = 0xf7710000
  86. |>     close (4) = 0
  87. |> 
  88. |> Aha. The fact that the flock() failed tells us that ypbind is running.
  89. |> Sun places into the binding file the actual (struct sockaddr_in) at
  90. |> which the current ypserver can be found (It could be ypbind's address,
  91. |> but it makes more sense to be ypserv's address). So they mmap() the
  92. |> (struct sockaddr_in) and continue.
  93. |> 
  94. |> >  |> > 
  95. |> >  |> > I would send a UDP RPC request to the portmapper to find out
  96. |> >  |> > if ypbind was registered.  The problem is that there is code
  97. |> >  |> > which creates a "dummy" TCP connection just to see if the
  98. |> >  |> > portmapper is running (i.e. doesn't trust UDP time-outs as 
  99. |> >  |> > sufficient evidence that the portmapper is not running).
  100. |> 
  101. |> I would not trust a UDP timeout on "localhost" as meaning that the
  102. |> portmapper is dead. It might take 5 seconds for a busy portmapper to
  103. |> answer. Someone in Timbuktu, at the end of a very slow link, may have
  104. |> been spraying the portmapper. Packets may have convoyed, and the
  105. |> portmapper may be swamped! How long are you going to wait around?
  106.  
  107. Why do you assume that this same phantom you fear cannot spray the
  108. portmapper with bogus TCP connections?  You will find that the same
  109. quantity of bogus TCP connections are generally worse than bogus UDP 
  110. packets.  People with this level of paranoia typically deploy firewalls.
  111.  
  112. Also, you seem to be disillusioned about what happens when a TCP
  113. packet gets dumped on the ground.  You will note that it has a
  114. regressive back-off timer with the lowest retry level at
  115. approximately one second.  What TCP gives you is a well-respected
  116. retry algorithm which may not always be present in various UDP
  117. applications.
  118.  
  119. The advantage that was hypothesized for TCP (in this particular
  120. thread) is that the UDP/ICMP "port not available" (i.e. no server currently
  121. bound to the specified port) may not be as well supported as the
  122. equivalent TCP RST functionality.  If your application has some
  123. semantical benefit gain from this feature then TCP might be
  124. a better choice. 
  125.  
  126. |> 
  127. |> >  |> > If the connection succeeds, it is immediately closed and then
  128. |> >  |> > the UDP RPC request is made to the portmapper to get the 
  129. |> >  |> > information about ypbind.
  130. |> >  |> 
  131. |> >  |> Perhaps my point was not clear.
  132. |> >  |> 
  133. |> >  |> By using TCP you avoid having to wait for a UDP time-out to expire when
  134. |> >  |> things are not present.  Which would make you more unhappy?  Having an
  135. |> >  |> anonymous TCP port number tied up for a little while or having to wait
  136. |> >  |> a large part of a second (or more if you allow remote access over slow
  137. |> >  |> links) to discover that the portmapper is not running?
  138. |> 
  139. |> With TCP, your connection will succeed immediately, well, as long as
  140. |> the listen queue has room for you....
  141. |> 
  142. |> 
  143. |> Really, I prefer Sun's method of checking for yellow. A flock() on a
  144. |> locked file means you are talking to an inode that is already in the
  145. |> buffer cache. That's got to be faster and more reliable than talking
  146. |> to portmap & ypbind.
  147.  
  148. As long as everything is local you can reliably use files for
  149. interlocking, however, I would not be overly enthused to see rpc.lockd
  150. as the cornerstone for provision of these services (e.g. you ever needed
  151. to solve a remote concurrency issue).
  152.  
  153. |> 
  154. |> Anyways, I'm going to impliment my routines much like Sun's did!
  155. |> 
  156. |> Only one thing bothers me with the RPC programming I am doing. Sun's
  157. |> ypbind is not multithreaded; rather, it forks when it gets a request
  158. |> for a currently unbound domain. I decided to make my ypbind much more
  159. |> multithreaded. What I have come to discover to my disgust is that if
  160. |> you wish to write a properly multithreaded RPC application you have to
  161. |> give up all the juicy RPC and SVC routines and dig right into the XDR
  162. |> level. What a pain. And, boy, I could scream because I have found no
  163. |> way to access msg->msg_xid from the SVC/RPC level! For a proper
  164. |> multi-threaded application, you are going to need to save a copy of
  165. |> that for the later reply!
  166. |>  <tdr.
  167. |> --
  168.  
  169.   
  170. One technique is to use request-only primitives (e.g. use timeout==0) to satisfy
  171. multi-threading needs.  However, since you probably want to interoperate
  172. with existing ypbind entities this probably won't help much.
  173.  
  174.  
  175. |> 
  176. |> This space not left unintentionally unblank.        deraadt@newt.cuc.ab.ca
  177.