xtables-addons: Fix Lua packet script implementation
[openwrt/staging/yousong.git] / package / network / utils / xtables-addons / patches / 201-fix-lua-packetscript.patch
1 --- a/extensions/LUA/xt_LUA_target.c
2 +++ b/extensions/LUA/xt_LUA_target.c
3 @@ -64,10 +64,10 @@ uint32_t lua_state_refs[LUA_STATE_ARRAY
4 * XT_CONTINUE inside the *register_lua_packet_lib* function.
5 */
6
7 -spinlock_t lock = SPIN_LOCK_UNLOCKED;
8 +DEFINE_SPINLOCK(lock);
9
10 static uint32_t
11 -lua_tg(struct sk_buff *pskb, const struct xt_target_param *par)
12 +lua_tg(struct sk_buff *pskb, const struct xt_action_param *par)
13 {
14 uint32_t verdict;
15 lua_packet_segment *p;
16 @@ -88,11 +88,11 @@ lua_tg(struct sk_buff *pskb, const struc
17 /* push the lua_packet_segment as a parameter */
18 p = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
19 if (pskb->mac_header)
20 - p->start = pskb->mac_header;
21 + p->start = skb_mac_header(pskb);
22 else if (pskb->network_header)
23 - p->start = pskb->network_header;
24 + p->start = skb_network_header(pskb);
25 else if (pskb->transport_header)
26 - p->start = pskb->transport_header;
27 + p->start = skb_transport_header(pskb);
28 p->offset = 0;
29 p->length = (unsigned long)pskb->tail - (unsigned long)p->start;
30 p->changes = NULL;
31 @@ -208,16 +208,16 @@ static bool load_script_into_state(uint3
32 * some workqueue initialization. So far this is done each time this function
33 * is called, subject to change.
34 */
35 -static bool
36 +static int
37 lua_tg_checkentry(const struct xt_tgchk_param *par)
38 {
39 const struct xt_lua_tginfo *info = par->targinfo;
40
41 if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) {
42 lua_state_refs[info->state_id]++;
43 - return true;
44 + return 0;
45 }
46 - return false;
47 + return -EINVAL;
48 }
49
50 /*::*
51 --- a/extensions/LUA/lua/llimits.h
52 +++ b/extensions/LUA/lua/llimits.h
53 @@ -8,7 +8,6 @@
54 #define llimits_h
55
56 #include <stddef.h>
57 -#include <limits.h>
58
59 #include "lua.h"
60
61 --- a/extensions/LUA/lua/lapi.c
62 +++ b/extensions/LUA/lua/lapi.c
63 @@ -4,9 +4,6 @@
64 ** See Copyright Notice in lua.h
65 */
66
67 -#include <stdarg.h>
68 -#include <math.h>
69 -#include <assert.h>
70 #include <string.h>
71
72 #define lapi_c
73 --- a/extensions/LUA/lua/ltable.c
74 +++ b/extensions/LUA/lua/ltable.c
75 @@ -18,7 +18,6 @@
76 ** Hence even when the load factor reaches 100%, performance remains good.
77 */
78
79 -#include <math.h>
80 #include <string.h>
81
82 #define ltable_c
83 --- a/extensions/LUA/lua/luaconf.h
84 +++ b/extensions/LUA/lua/luaconf.h
85 @@ -13,6 +13,10 @@
86 #if !defined(__KERNEL__)
87 #include <limits.h>
88 #else
89 +#undef UCHAR_MAX
90 +#undef SHRT_MAX
91 +#undef BUFSIZ
92 +#undef NO_FPU
93 #define UCHAR_MAX 255
94 #define SHRT_MAX 32767
95 #define BUFSIZ 8192
96 @@ -637,6 +641,8 @@ union luai_Cast { double l_d; long l_l;
97 */
98 #if defined(__KERNEL__)
99 #undef LUA_USE_ULONGJMP
100 +#define setjmp __builtin_setjmp
101 +#define longjmp __builtin_longjmp
102 #endif
103
104 #if defined(__cplusplus)