netfilter: enable CONFIG_NF_CONNTRACK_MARK from kmod-nf-conntrack
[openwrt/openwrt.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 @@ -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 @@ -88,11 +88,11 @@ lua_tg(struct sk_buff *pskb, const struc
26 /* push the lua_packet_segment as a parameter */
27 p = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
28 if (pskb->mac_header)
29 - p->start = pskb->mac_header;
30 + p->start = skb_mac_header(pskb);
31 else if (pskb->network_header)
32 - p->start = pskb->network_header;
33 + p->start = skb_network_header(pskb);
34 else if (pskb->transport_header)
35 - p->start = pskb->transport_header;
36 + p->start = skb_transport_header(pskb);
37 p->offset = 0;
38 p->length = (unsigned long)pskb->tail - (unsigned long)p->start;
39 p->changes = NULL;
40 @@ -208,16 +208,16 @@ static bool load_script_into_state(uint3
41 * some workqueue initialization. So far this is done each time this function
42 * is called, subject to change.
43 */
44 -static bool
45 +static int
46 lua_tg_checkentry(const struct xt_tgchk_param *par)
47 {
48 const struct xt_lua_tginfo *info = par->targinfo;
49
50 if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) {
51 lua_state_refs[info->state_id]++;
52 - return true;
53 + return 0;
54 }
55 - return false;
56 + return -EINVAL;
57 }
58
59 /*::*
60 --- a/extensions/LUA/lua/llimits.h
61 +++ b/extensions/LUA/lua/llimits.h
62 @@ -8,7 +8,6 @@
63 #define llimits_h
64
65 #include <stddef.h>
66 -#include <limits.h>
67
68 #include "lua.h"
69
70 --- a/extensions/LUA/lua/lapi.c
71 +++ b/extensions/LUA/lua/lapi.c
72 @@ -4,9 +4,6 @@
73 ** See Copyright Notice in lua.h
74 */
75
76 -#include <stdarg.h>
77 -#include <math.h>
78 -#include <assert.h>
79 #include <string.h>
80
81 #define lapi_c
82 --- a/extensions/LUA/lua/ltable.c
83 +++ b/extensions/LUA/lua/ltable.c
84 @@ -18,7 +18,6 @@
85 ** Hence even when the load factor reaches 100%, performance remains good.
86 */
87
88 -#include <math.h>
89 #include <string.h>
90
91 #define ltable_c
92 --- a/extensions/LUA/lua/luaconf.h
93 +++ b/extensions/LUA/lua/luaconf.h
94 @@ -13,8 +13,12 @@
95 #if !defined(__KERNEL__)
96 #include <limits.h>
97 #else
98 +#include <linux/kernel.h>
99 +
100 +#undef UCHAR_MAX
101 +#undef BUFSIZ
102 +#undef NO_FPU
103 #define UCHAR_MAX 255
104 -#define SHRT_MAX 32767
105 #define BUFSIZ 8192
106 #define NO_FPU
107 #endif
108 @@ -637,6 +641,8 @@ union luai_Cast { double l_d; long l_l;
109 */
110 #if defined(__KERNEL__)
111 #undef LUA_USE_ULONGJMP
112 +#define setjmp __builtin_setjmp
113 +#define longjmp __builtin_longjmp
114 #endif
115
116 #if defined(__cplusplus)
117 --- a/extensions/LUA/lua/llex.h
118 +++ b/extensions/LUA/lua/llex.h
119 @@ -10,6 +10,8 @@
120 #include "lobject.h"
121 #include "lzio.h"
122
123 +/* prevent conflict with definition from asm/current.h */
124 +#undef current
125
126 #define FIRST_RESERVED 257
127