Now that the filter code path has been short-circuited, start removing stub
smtp_filter_*() indirections. I'm doing this one function at a time to keep
the diffs simple, starting with smtp_filter_connect().

Eric.

Index: smtp_session.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtp_session.c,v
retrieving revision 1.305
diff -u -p -r1.305 smtp_session.c
--- smtp_session.c      13 Aug 2017 11:10:30 -0000      1.305
+++ smtp_session.c      29 Aug 2017 08:03:49 -0000
@@ -189,7 +189,6 @@ static void smtp_queue_open_message(stru
 static void smtp_queue_commit(struct smtp_session *);
 static void smtp_queue_rollback(struct smtp_session *);
 
-static void smtp_filter_connect(struct smtp_session *, struct sockaddr *);
 static void smtp_filter_eom(struct smtp_session *);
 static void smtp_filter_helo(struct smtp_session *);
 static void smtp_filter_mail(struct smtp_session *);
@@ -1005,7 +1004,6 @@ smtp_filter_response(uint64_t id, int qu
     const char *line)
 {
        struct smtp_session     *s;
-       struct ca_cert_req_msg   req_ca_cert;
 
        s = tree_xpop(&wait_filter, id);
 
@@ -1019,35 +1017,6 @@ smtp_filter_response(uint64_t id, int qu
 
        switch (query) {
 
-       case QUERY_CONNECT:
-               if (status != FILTER_OK) {
-                       log_info("%016"PRIx64" smtp "
-                           "event=closed address=%s host=%s 
reason=filter-reject",
-                           s->id, ss_to_text(&s->ss), s->hostname);
-                       smtp_free(s, "rejected by filter");
-                       return;
-               }
-
-               if (s->listener->flags & F_SMTPS) {
-                       req_ca_cert.reqid = s->id;
-                       if (s->listener->pki_name[0]) {
-                               (void)strlcpy(req_ca_cert.name, 
s->listener->pki_name,
-                                   sizeof req_ca_cert.name);
-                               req_ca_cert.fallback = 0;
-                       }
-                       else {
-                               (void)strlcpy(req_ca_cert.name, s->smtpname,
-                                   sizeof req_ca_cert.name);
-                               req_ca_cert.fallback = 1;
-                       }
-                       m_compose(p_lka, IMSG_SMTP_TLS_INIT, 0, 0, -1,
-                           &req_ca_cert, sizeof(req_ca_cert));
-                       tree_xset(&wait_ssl_init, s->id, s);
-                       return;
-               }
-               smtp_send_banner(s);
-               return;
-
        case QUERY_HELO:
                if (status != FILTER_OK) {
                        code = code ? code : 530;
@@ -2023,6 +1992,7 @@ smtp_lookup_servername(struct smtp_sessi
 static void
 smtp_connected(struct smtp_session *s)
 {
+       struct ca_cert_req_msg  req_ca_cert;
        struct sockaddr_storage ss;
        socklen_t               sl;
 
@@ -2037,7 +2007,25 @@ smtp_connected(struct smtp_session *s)
                return;
        }
 
-       smtp_filter_connect(s, (struct sockaddr *)&ss);
+       if (s->listener->flags & F_SMTPS) {
+               req_ca_cert.reqid = s->id;
+               if (s->listener->pki_name[0]) {
+                       (void)strlcpy(req_ca_cert.name, s->listener->pki_name,
+                           sizeof req_ca_cert.name);
+                       req_ca_cert.fallback = 0;
+               }
+               else {
+                       (void)strlcpy(req_ca_cert.name, s->smtpname,
+                           sizeof req_ca_cert.name);
+                       req_ca_cert.fallback = 1;
+               }
+               m_compose(p_lka, IMSG_SMTP_TLS_INIT, 0, 0, -1,
+                   &req_ca_cert, sizeof(req_ca_cert));
+               tree_xset(&wait_ssl_init, s->id, s);
+               return;
+       }
+
+       smtp_send_banner(s);
 }
 
 static void
@@ -2416,13 +2404,6 @@ smtp_queue_rollback(struct smtp_session 
        m_create(p_queue, IMSG_SMTP_MESSAGE_ROLLBACK, 0, 0, -1);
        m_add_msgid(p_queue, s->tx->msgid);
        m_close(p_queue);
-}
-
-static void
-smtp_filter_connect(struct smtp_session *s, struct sockaddr *sa)
-{
-       tree_xset(&wait_filter, s->id, s);
-       smtp_filter_response(s->id, QUERY_CONNECT, FILTER_OK, 0, NULL);
 }
 
 static void

Reply via email to