From: Aurelien DARRAGON Date: Mon, 15 Jan 2024 15:33:04 +0000 (+0100) Subject: MINOR: hlua: Rename set_{tos, mark} to set_fc_{tos, mark} X-Git-Tag: v3.0-dev3~117 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=03cb782bcb569e7e085e4736acf89c1e4289f42a;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/doc/lua-api/index.rst b/doc/lua-api/index.rst index a48afd2bb1..05b0c636b9 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) +.. js:function:: TXN.set_mark(txn, mark) - 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. + Alias for :js:func:`TXN.set_fc_mark()`. - :param class_txn txn: The class txn object containing the data. - :param integer tos: The new TOS os DSCP. + .. warning:: + This function is deprecated. :js:func:`TXN.set_fc_mark()` must be used + instead. -.. js:function:: TXN.set_mark(txn, mark) +.. js:function:: TXN.set_tos(txn, tos) - 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_tos()`. - :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_tos()` must be used + instead. .. js:function:: TXN.set_priority_class(txn, prio) diff --git a/src/hlua.c b/src/hlua.c index 7800431312..b0abf5fa5a 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -8192,28 +8192,25 @@ __LJMP static int hlua_txn_log_alert(lua_State *L) return 0; } -__LJMP static int hlua_txn_set_loglevel(lua_State *L) +__LJMP static int hlua_txn_set_fc_mark(lua_State *L) { struct hlua_txn *htxn; - int ll; + int mark; - MAY_LJMP(check_args(L, 2, "set_loglevel")); + MAY_LJMP(check_args(L, 2, "set_fc_mark")); htxn = MAY_LJMP(hlua_checktxn(L, 1)); - ll = MAY_LJMP(luaL_checkinteger(L, 2)); - - if (ll < 0 || ll > 7) - WILL_LJMP(luaL_argerror(L, 2, "Bad log level. It must be between 0 and 7")); + mark = MAY_LJMP(luaL_checkinteger(L, 2)); - htxn->s->logs.level = ll; + conn_set_mark(objt_conn(htxn->s->sess->origin), mark); return 0; } -__LJMP static int hlua_txn_set_tos(lua_State *L) +__LJMP static int hlua_txn_set_fc_tos(lua_State *L) { struct hlua_txn *htxn; int tos; - MAY_LJMP(check_args(L, 2, "set_tos")); + MAY_LJMP(check_args(L, 2, "set_fc_tos")); htxn = MAY_LJMP(hlua_checktxn(L, 1)); tos = MAY_LJMP(luaL_checkinteger(L, 2)); @@ -8221,16 +8218,19 @@ __LJMP static int hlua_txn_set_tos(lua_State *L) return 0; } -__LJMP static int hlua_txn_set_mark(lua_State *L) +__LJMP static int hlua_txn_set_loglevel(lua_State *L) { struct hlua_txn *htxn; - int mark; + int ll; - MAY_LJMP(check_args(L, 2, "set_mark")); + MAY_LJMP(check_args(L, 2, "set_loglevel")); htxn = MAY_LJMP(hlua_checktxn(L, 1)); - mark = MAY_LJMP(luaL_checkinteger(L, 2)); + ll = MAY_LJMP(luaL_checkinteger(L, 2)); - conn_set_mark(objt_conn(htxn->s->sess->origin), mark); + if (ll < 0 || ll > 7) + WILL_LJMP(luaL_argerror(L, 2, "Bad log level. It must be between 0 and 7")); + + htxn->s->logs.level = ll; return 0; } @@ -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);