Skip to content

Commit 6b7d31f

Browse files
laf0rgeArnaldo Carvalho de Melo
authored andcommitted
[NETFILTER]: Add "revision" support to arp_tables and ip6_tables
Like ip_tables already has it for some time, this adds support for having multiple revisions for each match/target. We steal one byte from the name in order to accomodate a 8 bit version number. Signed-off-by: Harald Welte <laforge@netfilter.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
1 parent 6ede246 commit 6b7d31f

5 files changed

Lines changed: 362 additions & 192 deletions

File tree

‎include/linux/netfilter_arp/arp_tables.h‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ struct arpt_entry_target
6868
u_int16_t target_size;
6969

7070
/* Used by userspace */
71-
char name[ARPT_FUNCTION_MAXNAMELEN];
71+
char name[ARPT_FUNCTION_MAXNAMELEN-1];
72+
u_int8_t revision;
7273
} user;
7374
struct {
7475
u_int16_t target_size;
@@ -148,7 +149,9 @@ struct arpt_entry
148149

149150
#define ARPT_SO_GET_INFO (ARPT_BASE_CTL)
150151
#define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1)
151-
#define ARPT_SO_GET_MAX ARPT_SO_GET_ENTRIES
152+
/* #define ARPT_SO_GET_REVISION_MATCH (ARPT_BASE_CTL + 2)*/
153+
#define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3)
154+
#define ARPT_SO_GET_MAX ARPT_SO_GET_REVISION_TARGET
152155

153156
/* CONTINUE verdict for targets */
154157
#define ARPT_CONTINUE 0xFFFFFFFF
@@ -236,6 +239,15 @@ struct arpt_get_entries
236239
struct arpt_entry entrytable[0];
237240
};
238241

242+
/* The argument to ARPT_SO_GET_REVISION_*. Returns highest revision
243+
* kernel supports, if >= revision. */
244+
struct arpt_get_revision
245+
{
246+
char name[ARPT_FUNCTION_MAXNAMELEN-1];
247+
248+
u_int8_t revision;
249+
};
250+
239251
/* Standard return verdict, or do jump. */
240252
#define ARPT_STANDARD_TARGET ""
241253
/* Error verdict. */
@@ -274,7 +286,9 @@ struct arpt_target
274286
{
275287
struct list_head list;
276288

277-
const char name[ARPT_FUNCTION_MAXNAMELEN];
289+
const char name[ARPT_FUNCTION_MAXNAMELEN-1];
290+
291+
u_int8_t revision;
278292

279293
/* Returns verdict. */
280294
unsigned int (*target)(struct sk_buff **pskb,

‎include/linux/netfilter_ipv6/ip6_tables.h‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ struct ip6t_entry_match
5757
u_int16_t match_size;
5858

5959
/* Used by userspace */
60-
char name[IP6T_FUNCTION_MAXNAMELEN];
60+
char name[IP6T_FUNCTION_MAXNAMELEN-1];
61+
u_int8_t revision;
6162
} user;
6263
struct {
6364
u_int16_t match_size;
@@ -80,7 +81,8 @@ struct ip6t_entry_target
8081
u_int16_t target_size;
8182

8283
/* Used by userspace */
83-
char name[IP6T_FUNCTION_MAXNAMELEN];
84+
char name[IP6T_FUNCTION_MAXNAMELEN-1];
85+
u_int8_t revision;
8486
} user;
8587
struct {
8688
u_int16_t target_size;
@@ -161,7 +163,9 @@ struct ip6t_entry
161163

162164
#define IP6T_SO_GET_INFO (IP6T_BASE_CTL)
163165
#define IP6T_SO_GET_ENTRIES (IP6T_BASE_CTL + 1)
164-
#define IP6T_SO_GET_MAX IP6T_SO_GET_ENTRIES
166+
#define IP6T_SO_GET_REVISION_MATCH (IP6T_BASE_CTL + 2)
167+
#define IP6T_SO_GET_REVISION_TARGET (IP6T_BASE_CTL + 3)
168+
#define IP6T_SO_GET_MAX IP6T_SO_GET_REVISION_TARGET
165169

166170
/* CONTINUE verdict for targets */
167171
#define IP6T_CONTINUE 0xFFFFFFFF
@@ -291,6 +295,15 @@ struct ip6t_get_entries
291295
struct ip6t_entry entrytable[0];
292296
};
293297

298+
/* The argument to IP6T_SO_GET_REVISION_*. Returns highest revision
299+
* kernel supports, if >= revision. */
300+
struct ip6t_get_revision
301+
{
302+
char name[IP6T_FUNCTION_MAXNAMELEN-1];
303+
304+
u_int8_t revision;
305+
};
306+
294307
/* Standard return verdict, or do jump. */
295308
#define IP6T_STANDARD_TARGET ""
296309
/* Error verdict. */
@@ -352,7 +365,9 @@ struct ip6t_match
352365
{
353366
struct list_head list;
354367

355-
const char name[IP6T_FUNCTION_MAXNAMELEN];
368+
const char name[IP6T_FUNCTION_MAXNAMELEN-1];
369+
370+
u_int8_t revision;
356371

357372
/* Return true or false: return FALSE and set *hotdrop = 1 to
358373
force immediate packet drop. */
@@ -387,7 +402,9 @@ struct ip6t_target
387402
{
388403
struct list_head list;
389404

390-
const char name[IP6T_FUNCTION_MAXNAMELEN];
405+
const char name[IP6T_FUNCTION_MAXNAMELEN-1];
406+
407+
u_int8_t revision;
391408

392409
/* Returns verdict. Argument order changed since 2.6.9, as this
393410
must now handle non-linear skbs, using skb_copy_bits and

0 commit comments

Comments
 (0)