b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | --- a/extensions/LUA/xt_LUA_target.c |
| 2 | +++ b/extensions/LUA/xt_LUA_target.c |
| 3 | @@ -19,7 +19,7 @@ |
| 4 | #include <linux/kernel.h> |
| 5 | #include <linux/slab.h> |
| 6 | #include <linux/module.h> |
| 7 | -#include <asm/uaccess.h> |
| 8 | +#include <linux/uaccess.h> |
| 9 | #include <net/ip.h> |
| 10 | #include <linux/netfilter/x_tables.h> |
| 11 | #include "xt_LUA.h" |
| 12 | @@ -64,10 +64,10 @@ uint32_t lua_state_refs[LUA_STATE_ARRAY |
| 13 | * XT_CONTINUE inside the *register_lua_packet_lib* function. |
| 14 | */ |
| 15 | |
| 16 | -spinlock_t lock = SPIN_LOCK_UNLOCKED; |
| 17 | +DEFINE_SPINLOCK(lock); |
| 18 | |
| 19 | static uint32_t |
| 20 | -lua_tg(struct sk_buff *pskb, const struct xt_target_param *par) |
| 21 | +lua_tg(struct sk_buff *pskb, const struct xt_action_param *par) |
| 22 | { |
| 23 | uint32_t verdict; |
| 24 | lua_packet_segment *p; |
| 25 | @@ -79,7 +79,7 @@ lua_tg(struct sk_buff *pskb, const struc |
| 26 | |
| 27 | L = lua_envs[info->state_id]->L; |
| 28 | |
| 29 | - if (!skb_make_writable(pskb, pskb->len)) |
| 30 | + if (skb_ensure_writable(pskb, pskb->len)) |
| 31 | return NF_DROP; |
| 32 | |
| 33 | /* call the function provided by --function parameter or the default 'process_packet' defined in Lua */ |
| 34 | @@ -88,11 +88,11 @@ lua_tg(struct sk_buff *pskb, const struc |
| 35 | /* push the lua_packet_segment as a parameter */ |
| 36 | p = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment)); |
| 37 | if (pskb->mac_header) |
| 38 | - p->start = pskb->mac_header; |
| 39 | + p->start = skb_mac_header(pskb); |
| 40 | else if (pskb->network_header) |
| 41 | - p->start = pskb->network_header; |
| 42 | + p->start = skb_network_header(pskb); |
| 43 | else if (pskb->transport_header) |
| 44 | - p->start = pskb->transport_header; |
| 45 | + p->start = skb_transport_header(pskb); |
| 46 | p->offset = 0; |
| 47 | p->length = (unsigned long)pskb->tail - (unsigned long)p->start; |
| 48 | p->changes = NULL; |
| 49 | @@ -208,16 +208,16 @@ static bool load_script_into_state(uint3 |
| 50 | * some workqueue initialization. So far this is done each time this function |
| 51 | * is called, subject to change. |
| 52 | */ |
| 53 | -static bool |
| 54 | +static int |
| 55 | lua_tg_checkentry(const struct xt_tgchk_param *par) |
| 56 | { |
| 57 | const struct xt_lua_tginfo *info = par->targinfo; |
| 58 | |
| 59 | if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) { |
| 60 | lua_state_refs[info->state_id]++; |
| 61 | - return true; |
| 62 | + return 0; |
| 63 | } |
| 64 | - return false; |
| 65 | + return -EINVAL; |
| 66 | } |
| 67 | |
| 68 | /*::* |
| 69 | --- a/extensions/LUA/lua/llimits.h |
| 70 | +++ b/extensions/LUA/lua/llimits.h |
| 71 | @@ -8,7 +8,6 @@ |
| 72 | #define llimits_h |
| 73 | |
| 74 | #include <stddef.h> |
| 75 | -#include <limits.h> |
| 76 | |
| 77 | #include "lua.h" |
| 78 | |
| 79 | --- a/extensions/LUA/lua/lapi.c |
| 80 | +++ b/extensions/LUA/lua/lapi.c |
| 81 | @@ -4,9 +4,6 @@ |
| 82 | ** See Copyright Notice in lua.h |
| 83 | */ |
| 84 | |
| 85 | -#include <stdarg.h> |
| 86 | -#include <math.h> |
| 87 | -#include <assert.h> |
| 88 | #include <string.h> |
| 89 | |
| 90 | #define lapi_c |
| 91 | --- a/extensions/LUA/lua/ltable.c |
| 92 | +++ b/extensions/LUA/lua/ltable.c |
| 93 | @@ -18,7 +18,6 @@ |
| 94 | ** Hence even when the load factor reaches 100%, performance remains good. |
| 95 | */ |
| 96 | |
| 97 | -#include <math.h> |
| 98 | #include <string.h> |
| 99 | |
| 100 | #define ltable_c |
| 101 | --- a/extensions/LUA/lua/luaconf.h |
| 102 | +++ b/extensions/LUA/lua/luaconf.h |
| 103 | @@ -13,8 +13,12 @@ |
| 104 | #if !defined(__KERNEL__) |
| 105 | #include <limits.h> |
| 106 | #else |
| 107 | +#include <linux/kernel.h> |
| 108 | + |
| 109 | +#undef UCHAR_MAX |
| 110 | +#undef BUFSIZ |
| 111 | +#undef NO_FPU |
| 112 | #define UCHAR_MAX 255 |
| 113 | -#define SHRT_MAX 32767 |
| 114 | #define BUFSIZ 8192 |
| 115 | #define NO_FPU |
| 116 | #endif |
| 117 | @@ -637,6 +641,8 @@ union luai_Cast { double l_d; long l_l; |
| 118 | */ |
| 119 | #if defined(__KERNEL__) |
| 120 | #undef LUA_USE_ULONGJMP |
| 121 | +#define setjmp __builtin_setjmp |
| 122 | +#define longjmp __builtin_longjmp |
| 123 | #endif |
| 124 | |
| 125 | #if defined(__cplusplus) |
| 126 | --- a/extensions/LUA/lua/llex.h |
| 127 | +++ b/extensions/LUA/lua/llex.h |
| 128 | @@ -10,6 +10,8 @@ |
| 129 | #include "lobject.h" |
| 130 | #include "lzio.h" |
| 131 | |
| 132 | +/* prevent conflict with definition from asm/current.h */ |
| 133 | +#undef current |
| 134 | |
| 135 | #define FIRST_RESERVED 257 |
| 136 | |