⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 早期freebsd实现
💻
字号:
         XLA - Extended Load Average design for Sendmail R6         --------------------------------------------------          Christophe Wolfhugel - Herve Schauer Consultants              wolf@grasp.insa-lyon.fr, wolf@hsc-sec.frWARNING:  this extension is supplied as a contribution to Sendmail.Should you have trouble, questions, please contact me directly, and*not* the Sendmail development team.ABSTRACTSendmail currently furnishes a limitation mecanism which is based onthe system load average, when available.  Experience has prooven thatthis was not sufficiant for some particular situations, for exampleif you have slow and/or overloaded links. This can easily cause bothsystem and network congestions with Sendmail having to handle a largenumber of simultaneous sessions on the same overloaded link, causingmost of the SMTP sessions to timeout after a long time.  The systemload average is also generally too slow to react when your systemgets a burst of incoming or outgoing SMTP sessions which on somestations can easily cause system unavailabilities.The extended load average module has been designed in order to furnisha way of limitation the load generated by Sendmail to both yoursystem and your network. This design can be used either alone or ascomplementary to the system load average if your system supports it.Limitation is based on the number of incoming/outgoing SMTP sessions,and remote hosts are classified in classes. The system administratorwill define a maximum number of incoming SMTP sessions as well asa maximum total (incoming + outgoing) sessions for each class ofhosts. A class can be either an individual machine or a network.When the limit is reached for a given class, all incoming SMTPconnections will be politely refused. When the limit is reached forall classes, the SMTP connections will be refused by the system(which one could consider as less politely :)).On outgoing mail, messages will be queued for delayed processing.The extended load average parameters are given in the Sendmailconfiguration file, and when not present, Sendmail behaves theusual way.COMPILATIONCopy the xla.c module in the src sub-directory, edit the Makefilein order to define XLA (-DXLA). Also add the xla.[co] module namein the list of files so that it gets compiled.Regenerate sendmail by removing all objects, or at least thosecontaining references to XLA (this list may vary, so use grep toget the module list).  This will generate a new sendmail executablecontaining the xla code.Debugging level 59 has been assigned to this module and when usedit provides some output (sendmail -d59.x).  Please check the sourcecode to see which levels are supported.CONFIGURATIONThe extended average uses a new set of configuration lines in thesendmail.cf file.  All newly introduced line begin with the letter L(capital L).Before detailling the syntax, first an example (this can be placedat any section of the sendmail.cf file, note that the order isimportant). Fields are separated by (one or more) tabs/spaces.# File name used to store the countersL/etc/sendmail.la# Classes definition# Lname            #queue #rejectL*.insa-lyon.fr         8       3L*.univ-lyon1.fr        6       4L*                     15      16The first line defines the working file which will be used in orderto have the occurences of Sendmail read and update the counters. Theformat of this file is described in the "Design" section.This line is mandatory and the specified file must be absolute (iebegin with a slash).Then you can specify one or more classes. The last class (*) is alsomandatory and should be in last position as the first match will stopthe search and if there is no match the behavior of Sendmail is unknown.Each class has three fields separated by one or more tabs/spaces.L{mask}         {queue_#}      {refuse_#}The {mask} is a simple mask. It can be either an explicit host name(like grasp.insa-lyon.fr) or a mask starting with "*." or just "*".No other variants are allowed.Lgrasp.insa-lyon.fr  will match exactely any session to/from this host.L*.insa-lyon.fr      will match any session to/from any machine in the                     insa-lyon.fr domain as well as from the machine                     named "insa-lyon.fr" if it exists.L*                   will match any session, and thus should also be                     last in the list to act as a catchup line.The {queue_#} is the maximum number of SMTP sessions in the given classfor both incoming and outgoing messages. The {refuse_#} indicates whento refuse incoming messages for this class. The interaction betweenthose counters is somewhat subtle. It seems logical that a standardconfiguration has {queue_#} >= {refuse_#}, and in fact in mostconfigurations they can be equal (that's why what I use in my environment).Thus, this is not mandatory. If {queue_#} < {refuse_#} outgoing messageswill be lower priority than incoming messages and once a class gets loadedthe outgoing messages are blocked first.I use very low values in some situations, for example I have a customerconnected to the Internet via a 9600 bps line, they also have internalusers sending burst of messages (10, 20 small messages coming in justone or two seconds).  Both situations were unsupportable. The line istoo slow to handle many simultaneous connections and the mail serverdoes not have the ressources to handle such a heavy load (it's a 12 MegsSun 3 also doing Usenet news).I have defined following section in the configuration file, and experienceshows the benefits for everyone. Fake domain for the example: customer.fr.L/etc/sendmail.laL*.customer.fr          8       8L*                      3       3This means that there might not be more than 8 simultaneous SMTP sessionsbetween the mail server and any other internal host. This is to protectthe station from heavy loads like users (or applications !) sendingseveral tenths of messages in just a few seconds).No more than 3 SMTP sessions are authorized with any other host, this isto save the load of the slow 9600 line to the Internet.Drawback is that is you have 3 * 2 Megs sessions established from/to theoutside, all your mail will be held until one slot gets available, ona 9600 bps line just make your counts, il blocks your line during overone hour.DESIGNSendmail will analyze the "L" lines in the configuration file duringstartup (or read the initialized structure from the frozen file).When started in daemon mode (and only there), any existing working filewill be cleared and a new one is created. Each class gets a record inthe sendmail.la work file. The size of this record is a short integer(generally two bytes) and represents the count of active sessions inthe given class.  Read/Write operations in this file are done inone operation (as anyway the size is far below one disk sector). Thefile is locked with Sendmail's lockfile() function priori to anyaccess.Handling incoming SMTP sessions.There is interaction is two points in the Sendmail source code. Firston the listen system call: if all slots in all classes are in use,a listen(0) is done so that the system rejects any incoming SMTP session.This avois to fork and then reject the connexion.If there are some free slots, nothing better than accepting theconnection, then forking can be done. The child process then checks ifthe adequate class is full or not. If full, it rejects the connectionwith a "421 Too many sessions" diagnostic to the sender (which shouldthen appear when the remote users do a mailq). If the treshold {reject_#}is not reached, the connection is accepted and the counter is sendmail.lais updated.Handling outgoing SMTP sessions.As soon as Sendmail needs to connect to a distant host, the adequate classis checked against {queue_#} and if no slots are available, the message isqueued for further processing.Sendmail's connection caching.Sendmail-R6 introduces a new design: connection caching, ie several SMTPsessions can be opened at the same time.  This could cause some problemswhen sending mail, as after having a few connections opened, all slotscould be in use and generate a partial delivery of the message.  Inorder to deal with this, xla.c uses following design "for a givensendmail process, only the first connection in a given class is counted".This can be done because sendmail does not do parralel message sendingon the different channels.End of connection.As soon as a connection is closed, the counters will be automaticallyupdated.Please look at the code to understand of all this works. Comments,suggestions, questions welcome.                                        Christophe Wolfhugel                                        Herve Schauer Consultants                                        Paris, France                                        May 23, 1993

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -