summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/mta.c
AgeCommit message (Collapse)Author
2010-10-09backout the "new" queue code commited 4 months ago. it has many good ideas,Gilles Chehade
is way more optimized than what we had earlier and there's definitely stuff we want to keep, however it is early optimization that doesn't account for many features and makes them hard (if not impossible) to write without ugly workarounds that ruin the purpose of the optimizations. the backout goes to 30 May's right before the commit and catches up on all the non-queue related commits that happened since then. i'll work on reintroducing the ideas from this queue when the basic features we expect from a MTA are implemented. suggested on tech@ about a week ago, no objections, several "please make smtpd move forward" mails from hackers and tech readers.
2010-06-02check event_dispatch() return valueCharles Longeau
ok jacekm@
2010-06-01new queue, again; gcc2 compile tested by deraadtJacek Masiulaniec
2010-06-01New queue doesn't compile on gcc2, back out. Spotted by deraadt@Jacek Masiulaniec
2010-06-01Better errors.Jacek Masiulaniec
2010-05-31Rewrite entire queue code.Jacek Masiulaniec
Major goals: 1) Fix bad performance caused by the runner process doing full queue read in 1s intervals. My Soekris can now happily accept >50 msg/s while having multi-thousand queue; before, one hundred queue would bring the system to its knees. 2) Introduce Qmail-like scheduler that doesn't write as much to the disk so that it needs less code for servicing error conditions, which in some places can be tricky to get right. 3) Introduce separation between the scheduler and the backend; these two queue aspects shouldn't be too tied too each other. This means that eg. storing queue in SQL requires rewrite of just queue_backend.c. 4) Make on-disk queue format architecture independent, and more easily extensible, to reduce number of flag days in the future. Minor goals: ENOSPC no longer prevents delivery attempts, fixed session limiting for relayed mail, improved batching of "relay via" mails, human-readable mailq output, "show queue raw" command, clearer logging, sending of single bounce about multiple recipients, exact delay= computation, zero delay between deliveries while within session limit (currently 1s delay between re-scheduling is enforced), mta no longer requests content fd, corrected session limit for bounce submissions, tiny <100B queue files instead of multi-KB, detect loops before accepting mail, reduce traffic on imsg channels by killing enormous struct submit_status.
2010-04-21Runner process is just a helper for queue, so tear down its imsgJacek Masiulaniec
channels to parent, mda, mta, lka, smtp, and control. This leaves just the channel to queue, which forwards imsgs on runner's behalf and redirects any replies back to it. OK gilles@
2010-04-21Remove unusable ifdef DEBUG code.Jacek Masiulaniec
2010-04-20Kill *2400* lines of code by abstracting common bits of the imsg handlers.Jacek Masiulaniec
2010-01-03Implement "log verbose" and "log brief" to enable or disable verbose debugCharles Longeau
logging on runtime. Based on claudio@'s work on ripd, ospfd, ospf6d, dvmrpd, ldpd, bgpd. With help/ideas/testing from gilles@ jacekm@ todd@ ok jacekm@
2009-12-23Implementation of RFC 2920 PIPELINING extension, client side only for now.Jacek Masiulaniec
This restructures the client_* API internals significantly. The code becomes pipelining in nature. All SMTP commands are put on the output queue and dequeued as quickly as possible. Once dequeued, they're moved to the receive queue so that replies can be matched with previous commands. Dequeuing commands from the output queue halts when the count of commands currently in-pipeline (``cmdi'') is equal to the command send window (``cmdw''). There are three cmdw values useful in practice: 0 clear pipeline, ie. inhibit all future sends 1 disable pipelining, ie. use old ``one-request-one-reply`` mode SIZE_T_MAX enable pipelining, ie. dequeue as many commands as possible At the beginning of session cmdw is 1. When it is found that peer supports PIPELINING, it grows to SIZE_T_MAX. After dequeing DATA it is again 1. After sending QUIT it is 0. Each command dequeued from the output queue becomes a buf in a msgbuf. The act of combining multiple commands into a single send operation did not need to be implemented: buf_write() already combines bufs using iovec and sends them at once using sendmsg(2). Tested by todd@ and oga@ "looks good" to gilles@
2009-12-14Impose sessions limit on the delivery sessions (mta and mda).Jacek Masiulaniec
2009-12-12When acting as a client do content reads from the disk progressivelyJacek Masiulaniec
as the remote accepts more data instead of doing one big read into the memory in the beginning of session.
2009-12-12Simplify client_* api, mainly by making fatal conditions result in immediateJacek Masiulaniec
fatals instead of passing the error up (kills ~300 lines). Implement sending of the QUIT command which replaces crude close(2). tested by gilles@, todd@
2009-12-10Fix a case when 2yz status would not override existing 4yz one.Jacek Masiulaniec
Reported by jsing@
2009-12-07Avoid dereferencing a null pointer when logging a DNS lookup failure.Joel Sing
ok gilles@
2009-11-16Minimize the delay between receiving response to "." and removing the queueJacek Masiulaniec
entry in order to avoid the risk of sending duplicate mail.
2009-11-13Log FQDN and IP of the server we handed mail to. As a bonus, don't delayJacek Masiulaniec
logging of successful deliveries until all MXs were tried, plus add logging of 5yz replies. tested by todd@, "reads ok" gilles@
2009-11-11add missing headers needed by time()Charles Longeau
ok jacekm@
2009-11-05Consider DNS lookups that result in NXDOMAIN to be a permanent failure.Joel Sing
ok gilles@ jacekm@
2009-11-05Introduce a 6yz status code, used internally to report permanent errors.Joel Sing
The 1yz and 6yz status codes are now removed prior to reporting the status message in bounce messages, which provides an easy way to distinguish between local and remote status messages. Initial diff from jacekm@ ok gilles@ jacekm@
2009-09-15Extend SMTP client_* API to support SSL+AUTH, and use it in the mtaJacek Masiulaniec
process to relay mails. ok gilles@
2009-09-08Cope with remote host sending '452 Insufficient system storage'.Landry Breuil
Committing on behalf of gilles@ who doesn't have access to a safe box.
2009-09-03imsg_get sets errno so use fatal instead of fatalx.Jacek Masiulaniec
2009-08-26fix previousJacek Masiulaniec
2009-08-26Do not add Delivered-To to outgoing mail. It will result in prematureJacek Masiulaniec
bounce as soon as it hits mx2 in mx1 -> mx2 -> mx3 relay chain. hint by sthen@, ok gilles@
2009-08-08- simplify a bit queue_message_update()Gilles Chehade
- make sure queue_message_update() creates bounces using bounce_record() - when mta sends update to queue and it sees that batch is flagged with F_BATCH_PERMFAIL, only update the envelope error message if it doesn't have F_MESSAGE_PERMFAIL set, otherwise we may lose the real reason why we failed for that recipient. There's cleanup to do around that old code, i'm sure we can get it simpler. this commit fixes a bug pea@ spotted where a bounce message would not display the reason of a failure when we generated it after failing to deliver a relayed message.
2009-08-07in mta: ssl/ssl.h -> openssl/ssl.h, consistent with other filesGilles Chehade
2009-08-06fix a crash in mta when forwarding a bounce, caused by a null derefGilles Chehade
2009-08-06replace X-OpenSMPTD-Loop with Delivered-ToGilles Chehade
idea by jacekm@ a few weeks ago, discussed with pyr
2009-08-06- introduce message_set_errormsg() to set the error description that willGilles Chehade
appear in a bounce message, and message_get_errormsg() to retrieve that message. - when loop is detected, call message_set_errormsg() - in mta, call message_set_errormsg() for each recipient failure - in mta, call message_set_errormsg() to copy batch errors to recipients if we failed to deliver for a session related error - when bouncing, add the recipient and error reason to the bounce message
2009-08-06This commit reworks the entire mailer daemon support to actually make itGilles Chehade
work for real. As an added bonus, it simplifies it, makes it follow the same code path as regular messages and kills quite some code from mta, mda and store. There's still some work needed but the most painful part is behind us now ;) ok jacekm@
2009-06-20Allocate memory for env->sc_ssl like in smtp; ok gilles@Jacek Masiulaniec
From: Josh Elsasser <josh@elsasser.org>
2009-06-07Change the way fds passed over a socket are retreived on the receiving side.Eric Faurot
Currently the receiver fetches an imsg via imsg_get() and if he expects an fd, he then calls imsg_get_fd() to fetch the next fd queued on the imsgbuf from which the imsg came. This changes hides the fd queueing mechanism to the API user. When closing an imsg with an fd, the message is flagged so that the receiving end knows it must dequeue the fd in imsg_get() and return it with the imsg structure. This way there is no (less) possible screw up from imsg_get_fd() not being called directly after imsg_get() by the user. The retreived imsg is self-contained. ok pyr@, "I like that" henning@
2009-06-06Sync with relayd:Pierre-Yves Ritschard
Stop pushing event handling in the imsg framework. Instead, provide a small glue layer on top of both imsg and libevent. This finally clearly separates event handling and imsg construction. Sidetrack bonus: remove the mega-ugly hack of having a dummy imsg_event_add stub in smtpctl. ok jaceckm@
2009-06-05make smtpd's imsg lib ready, just like relayd and ospfd.Pierre-Yves Ritschard
ok gilles@, jacekm@
2009-06-03simplify struct batch; ok gilles@Jacek Masiulaniec
2009-06-02make env->sc_listeners and env->sc_ssl pointers, one step further towardGilles Chehade
configuration reloading without killing active sessions; ok jacekm@
2009-06-01Fix EV_READ/EV_WRITE testing inside IMSG handlers. Based on similar changeJacek Masiulaniec
to the routing daemons by claudio@; ok gilles@
2009-05-31when entering mta_connect() reset session fd to -1Gilles Chehade
when connect timesout and we close the fd, reset session fd to -1 in session_destroy(), only attempt to close session fd if != -1 fixes a fatal in session_destroy() which happened because we closed a fd after a timeout, but the session still assumed the fd to be opened.
2009-05-30It is now possible to specify a certificate to use when relaying to anotherGilles Chehade
host which requests client certificates: accept [...] relay via [...] ssl certificate "mycert" diff from Josh Elsasser <josh@elsasser.org>, tested and okayed by me with no change but the addition of status 554 to the state machine to deal with remote host telling us it doesn't like our certificate.
2009-05-30increment mta.sessions in when we allocate a new session in mtaGilles Chehade
2009-05-30- increment stats.mta.sessions_active when session is allocated in mtaGilles Chehade
- reorder alphabetically and add mta to the statistics
2009-05-27Insert Received: at receive time instead of delivery time; ok gilles@Jacek Masiulaniec
2009-05-24Parent process forks 3 types of processes, track them all in a single treeJacek Masiulaniec
using newly introduced child struct. Manage process titles centrally in struct smtpd. ok gilles@
2009-05-19Verify the amount of IMSG payload is exactly as expected; ok gilles@Jacek Masiulaniec
2009-05-14use the nitems() macro where appropriateEric Faurot
ok gilles@, jacekm@
2009-05-13do MX lookups in both "relay" and "relay via" case; ok gilles@Jacek Masiulaniec
2009-05-09- New API to handle all DNS query types (A, MX, PTR) asynchronously.Jacek Masiulaniec
- Improve RFC compliance: CNAMEs are resolved, equal preference MXs are randomized, relaying via MX that has equal/lower preference than local server is prevented, decision on when to treat domain name as implicit MX is better. ok gilles@
2009-04-28in mta, change the batch status to S_BATCH_TEMPFAILURE by default so thatGilles Chehade
we need to explicitely set success and permanent failures, this way if we hit any condition that we don't explicitely flag as permanent failure the delivery will be rescheduled later. while at it, made various checks more strict to prevent hiding bugs and a bit of knr cleanups discussed with and "reads good" jacekm@