modparam("tm", "reparse_on_dns_failover", 0)
...
</programlisting>
- </example>
+ </example>
+ </section>
+
+ <section id="on_sl_reply">
+ <title><varname>on_sl_reply</varname> (string)</title>
+ <para>
+ Sets reply route block, to which control is passed when a
+ reply is received that has no associated transaction.
+ The reply is passed to the core for stateless forwarding after
+ the route block execution unless it returns 0.
+ </para>
+ <example>
+ <title>Set <varname>on_sl_reply</varname> parameter</title>
+ <programlisting>
+...
+modparam("tm", "on_sl_reply", "stateless_replies")
+...
+
+onreply_route["stateless_replies"] {
+ # do not allow stateless replies to be forwarded
+ return 0;
+}
+ </programlisting>
+ </example>
</section>
</section>
static int goto_on_negative=0;
/* where to go on receipt of reply */
static int goto_on_reply=0;
+/* where to go on receipt of reply without transaction context */
+int goto_on_sl_reply=0;
/* responses priority (used by t_pick_branch)
/* make sure we know the associated transaction ... */
if (t_check( p_msg , &branch )==-1)
- return 1;
+ goto trans_not_found;
/*... if there is none, tell the core router to fwd statelessly */
t=get_t();
- if ( (t==0)||(t==T_UNDEFINED)) return 1;
+ if ( (t==0)||(t==T_UNDEFINED))
+ goto trans_not_found;
cancel_bitmap=0;
msg_status=p_msg->REPLY_STATUS;
simply do nothing; that will make the other party to
retransmit; hopefuly, we'll then be better off */
return 0;
+
+trans_not_found:
+ /* transaction context was not found */
+ if (goto_on_sl_reply) {
+ /* the script writer has a chance to decide whether to
+ forward the reply or not */
+ init_run_actions_ctx(&ra_ctx);
+ return run_actions(&ra_ctx, onreply_rt.rlist[goto_on_sl_reply], p_msg);
+ } else {
+ /* let the core forward the reply */
+ return 1;
+ }
}
extern char tm_tags[TOTAG_VALUE_LEN];
extern char *tm_tag_suffix;
+extern int goto_on_sl_reply;
+
enum route_mode { MODE_REQUEST=1, MODE_ONREPLY, MODE_ONFAILURE };
extern enum route_mode rmode;
static int fixup_on_reply(void** param, int param_no);
static int fixup_on_branch(void** param, int param_no);
static int fixup_t_reply(void** param, int param_no);
-
+static int fixup_on_sl_reply(modparam_t type, void* val);
/* init functions */
static int mod_init(void);
{"blst_methods_lookup", PARAM_INT, &default_tm_cfg.tm_blst_methods_lookup},
{"cancel_b_method", PARAM_INT, &default_tm_cfg.cancel_b_flags},
{"reparse_on_dns_failover", PARAM_INT, &default_tm_cfg.reparse_on_dns_failover},
+ {"on_sl_reply", PARAM_STRING|PARAM_USE_FUNC, fixup_on_sl_reply },
{0,0,0}
};
return 0;
}
+static int fixup_on_sl_reply(modparam_t type, void* val)
+{
+ if ((type & PARAM_STRING) == 0) {
+ LOG(L_ERR, "ERROR: tm: fixup_on_sl_reply: not a string parameter\n");
+ return -1;
+ }
+
+ if (fixup_routes("on_sl_reply", &onreply_rt, &val))
+ return -1;
+
+ goto_on_sl_reply = (int)(long)val;
+ return 0;
+}
+
/* (char *hostname, char *port_nr) ==> (struct proxy_l *, -) */