mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-07 05:05:12 +02:00
condition: use new structure type
Use __u8 for the invert flag instead of int. Reduce CONDITION_NAME_LEN from 32 to 31 so that the entire structure can fit into a cacheline.
This commit is contained in:
@@ -21,7 +21,7 @@ static const struct option condition_opts[] = {
|
||||
static int condition_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||
const void *entry, struct xt_entry_match **match)
|
||||
{
|
||||
struct condition_info *info = (void *)(*match)->data;
|
||||
struct xt_condition_mtinfo *info = (void *)(*match)->data;
|
||||
|
||||
if (c == 'X') {
|
||||
if (*flags)
|
||||
@@ -54,7 +54,7 @@ static void condition_check(unsigned int flags)
|
||||
static void condition_print(const void *ip, const struct xt_entry_match *match,
|
||||
int numeric)
|
||||
{
|
||||
const struct condition_info *info = (const void *)match->data;
|
||||
const struct xt_condition_mtinfo *info = (const void *)match->data;
|
||||
|
||||
printf("condition %s%s ", (info->invert) ? "!" : "", info->name);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ static void condition_print(const void *ip, const struct xt_entry_match *match,
|
||||
|
||||
static void condition_save(const void *ip, const struct xt_entry_match *match)
|
||||
{
|
||||
const struct condition_info *info = (const void *)match->data;
|
||||
const struct xt_condition_mtinfo *info = (const void *)match->data;
|
||||
|
||||
printf("--condition %s\"%s\" ", (info->invert) ? "! " : "", info->name);
|
||||
}
|
||||
@@ -70,8 +70,8 @@ static void condition_save(const void *ip, const struct xt_entry_match *match)
|
||||
static struct xtables_match condition_match = {
|
||||
.name = "condition",
|
||||
.version = XTABLES_VERSION,
|
||||
.size = XT_ALIGN(sizeof(struct condition_info)),
|
||||
.userspacesize = XT_ALIGN(sizeof(struct condition_info)),
|
||||
.size = XT_ALIGN(sizeof(struct xt_condition_mtinfo)),
|
||||
.userspacesize = XT_ALIGN(sizeof(struct xt_condition_mtinfo)),
|
||||
.help = condition_help,
|
||||
.parse = condition_parse,
|
||||
.final_check = condition_check,
|
||||
|
@@ -118,7 +118,7 @@ condition_mt(const struct sk_buff *skb, const struct net_device *in,
|
||||
const void *matchinfo, int offset, unsigned int protoff,
|
||||
bool *hotdrop)
|
||||
{
|
||||
const struct condition_info *info = matchinfo;
|
||||
const struct xt_condition_mtinfo *info = matchinfo;
|
||||
struct condition_variable *var;
|
||||
int condition_status = 0;
|
||||
|
||||
@@ -140,7 +140,7 @@ condition_mt_check(const char *tablename, const void *entry,
|
||||
unsigned int hook_mask)
|
||||
{
|
||||
static const char * const forbidden_names[]={ "", ".", ".." };
|
||||
const struct condition_info *info = matchinfo;
|
||||
const struct xt_condition_mtinfo *info = matchinfo;
|
||||
struct list_head *pos;
|
||||
struct condition_variable *var, *newvar;
|
||||
|
||||
@@ -211,7 +211,7 @@ condition_mt_check(const char *tablename, const void *entry,
|
||||
|
||||
static void condition_mt_destroy(const struct xt_match *match, void *matchinfo)
|
||||
{
|
||||
const struct condition_info *info = matchinfo;
|
||||
const struct xt_condition_mtinfo *info = matchinfo;
|
||||
struct list_head *pos;
|
||||
struct condition_variable *var;
|
||||
|
||||
@@ -241,7 +241,7 @@ static void condition_mt_destroy(const struct xt_match *match, void *matchinfo)
|
||||
static struct xt_match condition_match = {
|
||||
.name = "condition",
|
||||
.family = PF_INET,
|
||||
.matchsize = sizeof(struct condition_info),
|
||||
.matchsize = XT_ALIGN(sizeof(struct xt_condition_mtinfo)),
|
||||
.match = condition_mt,
|
||||
.checkentry = condition_mt_check,
|
||||
.destroy = condition_mt_destroy,
|
||||
@@ -251,7 +251,7 @@ static struct xt_match condition_match = {
|
||||
static struct xt_match condition6_match = {
|
||||
.name = "condition",
|
||||
.family = PF_INET6,
|
||||
.matchsize = sizeof(struct condition_info),
|
||||
.matchsize = XT_ALIGN(sizeof(struct xt_condition_mtinfo)),
|
||||
.match = condition_mt,
|
||||
.checkentry = condition_mt_check,
|
||||
.destroy = condition_mt_destroy,
|
||||
|
@@ -1,11 +1,13 @@
|
||||
#ifndef _XT_CONDITION_H
|
||||
#define _XT_CONDITION_H
|
||||
|
||||
#define CONDITION_NAME_LEN 32
|
||||
enum {
|
||||
CONDITION_NAME_LEN = 31,
|
||||
};
|
||||
|
||||
struct condition_info {
|
||||
struct xt_condition_mtinfo {
|
||||
char name[CONDITION_NAME_LEN];
|
||||
int invert;
|
||||
__u8 invert;
|
||||
};
|
||||
|
||||
#endif /* _XT_CONDITION_H */
|
||||
|
Reference in New Issue
Block a user