From 03cb782bcb569e7e085e4736acf89c1e4289f42a Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Mon, 15 Jan 2024 16:33:04 +0100 Subject: [PATCH] MINOR: hlua: Rename set_{tos, mark} to set_fc_{tos, mark} This is a complementary patch to "MINOR: tcp-act: Rename "set-{mark,tos}" to "set-fc-{mark,tos}"", but for the Lua API. set_mark and set_tos were kept as aliases for set_fc_mark and set_fc_tos but they were marked as deprecated. Using this opportunity to reorder set_mark and set_tos by alphabetical order. --- doc/lua-api/index.rst | 40 ++++++++++++++++++++--------- src/hlua.c | 58 ++++++++++++++++++++++--------------------- 2 files changed, 58 insertions(+), 40 deletions(-) diff --git a/doc/lua-api/index.rst b/doc/lua-api/index.rst index a48afd2bb..05b0c636b 100644 --- a/doc/lua-api/index.rst +++ b/doc/lua-api/index.rst @@ -2870,6 +2870,22 @@ TXN class :see: :js:func:`TXN.reply`, :js:class:`Reply` +.. js:function:: TXN.set_fc_tos(txn, tos) + + Is used to set the TOS or DSCP field value of packets sent to the client to + the value passed in "tos" on platforms which support this. + + :param class_txn txn: The class txn object containing the data. + :param integer tos: The new TOS os DSCP. + +.. js:function:: TXN.set_fc_mark(txn, mark) + + Is used to set the Netfilter MARK on all packets sent to the client to the + value passed in "mark" on platforms which support it. + + :param class_txn txn: The class txn object containing the data. + :param integer mark: The mark value. + .. js:function:: TXN.set_loglevel(txn, loglevel) Is used to change the log level of the current request. The "loglevel" must @@ -2881,21 +2897,21 @@ TXN class :js:attr:`core.err`, :js:attr:`core.warning`, :js:attr:`core.notice`, :js:attr:`core.info`, :js:attr:`core.debug` (log level definitions) -.. js:function:: TXN.set_tos(txn, tos) - - Is used to set the TOS or DSCP field value of packets sent to the client to - the value passed in "tos" on platforms which support this. - - :param class_txn txn: The class txn object containing the data. - :param integer tos: The new TOS os DSCP. - .. js:function:: TXN.set_mark(txn, mark) - Is used to set the Netfilter MARK on all packets sent to the client to the - value passed in "mark" on platforms which support it. + Alias for :js:func:`TXN.set_fc_mark()`. - :param class_txn txn: The class txn object containing the data. - :param integer mark: The mark value. + .. warning:: + This function is deprecated. :js:func:`TXN.set_fc_mark()` must be used + instead. + +.. js:function:: TXN.set_tos(txn, tos) + + Alias for :js:func:`TXN.set_fc_tos()`. + + .. warning:: + This function is deprecated. :js:func:`TXN.set_fc_tos()` must be used + instead. .. js:function:: TXN.set_priority_class(txn, prio) diff --git a/src/hlua.c b/src/hlua.c index 780043131..b0abf5fa5 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -8192,6 +8192,32 @@ __LJMP static int hlua_txn_log_alert(lua_State *L) return 0; } +__LJMP static int hlua_txn_set_fc_mark(lua_State *L) +{ + struct hlua_txn *htxn; + int mark; + + MAY_LJMP(check_args(L, 2, "set_fc_mark")); + htxn = MAY_LJMP(hlua_checktxn(L, 1)); + mark = MAY_LJMP(luaL_checkinteger(L, 2)); + + conn_set_mark(objt_conn(htxn->s->sess->origin), mark); + return 0; +} + +__LJMP static int hlua_txn_set_fc_tos(lua_State *L) +{ + struct hlua_txn *htxn; + int tos; + + MAY_LJMP(check_args(L, 2, "set_fc_tos")); + htxn = MAY_LJMP(hlua_checktxn(L, 1)); + tos = MAY_LJMP(luaL_checkinteger(L, 2)); + + conn_set_tos(objt_conn(htxn->s->sess->origin), tos); + return 0; +} + __LJMP static int hlua_txn_set_loglevel(lua_State *L) { struct hlua_txn *htxn; @@ -8208,32 +8234,6 @@ __LJMP static int hlua_txn_set_loglevel(lua_State *L) return 0; } -__LJMP static int hlua_txn_set_tos(lua_State *L) -{ - struct hlua_txn *htxn; - int tos; - - MAY_LJMP(check_args(L, 2, "set_tos")); - htxn = MAY_LJMP(hlua_checktxn(L, 1)); - tos = MAY_LJMP(luaL_checkinteger(L, 2)); - - conn_set_tos(objt_conn(htxn->s->sess->origin), tos); - return 0; -} - -__LJMP static int hlua_txn_set_mark(lua_State *L) -{ - struct hlua_txn *htxn; - int mark; - - MAY_LJMP(check_args(L, 2, "set_mark")); - htxn = MAY_LJMP(hlua_checktxn(L, 1)); - mark = MAY_LJMP(luaL_checkinteger(L, 2)); - - conn_set_mark(objt_conn(htxn->s->sess->origin), mark); - return 0; -} - __LJMP static int hlua_txn_set_priority_class(lua_State *L) { struct hlua_txn *htxn; @@ -13776,9 +13776,11 @@ lua_State *hlua_init_state(int thread_num) hlua_class_function(L, "get_var", hlua_get_var); hlua_class_function(L, "done", hlua_txn_done); hlua_class_function(L, "reply", hlua_txn_reply_new); + hlua_class_function(L, "set_fc_mark", hlua_txn_set_fc_mark); + hlua_class_function(L, "set_fc_tos", hlua_txn_set_fc_tos); hlua_class_function(L, "set_loglevel", hlua_txn_set_loglevel); - hlua_class_function(L, "set_tos", hlua_txn_set_tos); - hlua_class_function(L, "set_mark", hlua_txn_set_mark); + hlua_class_function(L, "set_mark", hlua_txn_set_fc_mark); // DEPRECATED, use set_fc_mark + hlua_class_function(L, "set_tos", hlua_txn_set_fc_tos); // DEPRECATED, use set_fc_tos hlua_class_function(L, "set_priority_class", hlua_txn_set_priority_class); hlua_class_function(L, "set_priority_offset", hlua_txn_set_priority_offset); hlua_class_function(L, "deflog", hlua_txn_deflog);