From 931d388ff33dee589bc00e4f9033be5ca7c43786 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 9 Jun 2011 15:24:49 +0200 Subject: doc: include matches/targets in manpage again Evil sed did not throw any warning whatsoever when it cannot find the file. Signed-off-by: Jan Engelhardt --- iptables/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iptables/Makefile.am b/iptables/Makefile.am index 13cca9c6..a0682788 100644 --- a/iptables/Makefile.am +++ b/iptables/Makefile.am @@ -51,10 +51,10 @@ v6_sbin_links = ip6tables ip6tables-restore ip6tables-save endif iptables.8: ${srcdir}/iptables.8.in ../extensions/matches4.man ../extensions/targets4.man - ${AM_VERBOSE_GEN} sed -e 's/@PACKAGE_AND_VERSION@/${PACKAGE} ${PACKAGE_VERSION}/g' -e '/@MATCH@/ r extensions/matches4.man' -e '/@TARGET@/ r extensions/targets4.man' $< >$@; + ${AM_VERBOSE_GEN} sed -e 's/@PACKAGE_AND_VERSION@/${PACKAGE} ${PACKAGE_VERSION}/g' -e '/@MATCH@/ r ../extensions/matches4.man' -e '/@TARGET@/ r ../extensions/targets4.man' $< >$@; ip6tables.8: ${srcdir}/ip6tables.8.in ../extensions/matches6.man ../extensions/targets6.man - ${AM_VERBOSE_GEN} sed -e 's/@PACKAGE_AND_VERSION@/${PACKAGE} ${PACKAGE_VERSION}/g' -e '/@MATCH@/ r extensions/matches6.man' -e '/@TARGET@/ r extensions/targets6.man' $< >$@; + ${AM_VERBOSE_GEN} sed -e 's/@PACKAGE_AND_VERSION@/${PACKAGE} ${PACKAGE_VERSION}/g' -e '/@MATCH@/ r ../extensions/matches6.man' -e '/@TARGET@/ r ../extensions/targets6.man' $< >$@; pkgconfig_DATA = xtables.pc -- cgit v1.2.3 From 4e98e81ecdcc321d232edc42fac168d257e712ff Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 21 Jun 2011 17:00:45 +0200 Subject: libipt_LOG: fix ignoring all but last flags Signed-off-by: Jan Engelhardt --- extensions/libip6t_LOG.c | 10 +++++----- extensions/libipt_LOG.c | 10 +++++----- tests/options-most.rules | 2 ++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/extensions/libip6t_LOG.c b/extensions/libip6t_LOG.c index a419ec91..2b1ae289 100644 --- a/extensions/libip6t_LOG.c +++ b/extensions/libip6t_LOG.c @@ -87,19 +87,19 @@ static void LOG_parse(struct xt_option_call *cb) "Newlines not allowed in --log-prefix"); break; case O_LOG_TCPSEQ: - info->logflags = IP6T_LOG_TCPSEQ; + info->logflags |= IP6T_LOG_TCPSEQ; break; case O_LOG_TCPOPTS: - info->logflags = IP6T_LOG_TCPOPT; + info->logflags |= IP6T_LOG_TCPOPT; break; case O_LOG_IPOPTS: - info->logflags = IP6T_LOG_IPOPT; + info->logflags |= IP6T_LOG_IPOPT; break; case O_LOG_UID: - info->logflags = IP6T_LOG_UID; + info->logflags |= IP6T_LOG_UID; break; case O_LOG_MAC: - info->logflags = IP6T_LOG_MACDECODE; + info->logflags |= IP6T_LOG_MACDECODE; break; } } diff --git a/extensions/libipt_LOG.c b/extensions/libipt_LOG.c index b270bcf6..77f16d19 100644 --- a/extensions/libipt_LOG.c +++ b/extensions/libipt_LOG.c @@ -87,19 +87,19 @@ static void LOG_parse(struct xt_option_call *cb) "Newlines not allowed in --log-prefix"); break; case O_LOG_TCPSEQ: - info->logflags = IPT_LOG_TCPSEQ; + info->logflags |= IPT_LOG_TCPSEQ; break; case O_LOG_TCPOPTS: - info->logflags = IPT_LOG_TCPOPT; + info->logflags |= IPT_LOG_TCPOPT; break; case O_LOG_IPOPTS: - info->logflags = IPT_LOG_IPOPT; + info->logflags |= IPT_LOG_IPOPT; break; case O_LOG_UID: - info->logflags = IPT_LOG_UID; + info->logflags |= IPT_LOG_UID; break; case O_LOG_MAC: - info->logflags = IPT_LOG_MACDECODE; + info->logflags |= IPT_LOG_MACDECODE; break; } } diff --git a/tests/options-most.rules b/tests/options-most.rules index 6c4a8313..13ee9873 100644 --- a/tests/options-most.rules +++ b/tests/options-most.rules @@ -146,6 +146,8 @@ -A matches -A matches -m rt --rt-segsleft 5:4294967295 -A matches +-A ntarg -j LOG --log-tcp-sequence --log-tcp-options --log-ip-options +-A ntarg -A ntarg -j NFQUEUE --queue-num 1 -A ntarg -A ntarg -j NFQUEUE --queue-balance 8:99 -- cgit v1.2.3 From 68818f746bf9c68de04a75fbe756bf2c73e0fb32 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 21 Jun 2011 14:20:15 +0200 Subject: libxt_RATEEST: use guided option parser Signed-off-by: Jan Engelhardt --- extensions/libxt_RATEEST.c | 94 +++++++++++++++------------------------------- 1 file changed, 30 insertions(+), 64 deletions(-) diff --git a/extensions/libxt_RATEEST.c b/extensions/libxt_RATEEST.c index 6369e9e4..b928b339 100644 --- a/extensions/libxt_RATEEST.c +++ b/extensions/libxt_RATEEST.c @@ -1,9 +1,6 @@ -#include #include #include #include -#include -#include #include #include @@ -11,7 +8,6 @@ #include /* hack to pass raw values to final_check */ -static struct xt_rateest_target_info *RATEEST_info; static unsigned int interval; static unsigned int ewma_log; @@ -25,18 +21,23 @@ RATEEST_help(void) " --rateest-ewmalog value Rate measurement averaging time constant\n"); } -enum RATEEST_options { - RATEEST_OPT_NAME, - RATEEST_OPT_INTERVAL, - RATEEST_OPT_EWMALOG, +enum { + O_NAME = 0, + O_INTERVAL, + O_EWMALOG, }; -static const struct option RATEEST_opts[] = { - {.name = "rateest-name", .has_arg = true, .val = RATEEST_OPT_NAME}, - {.name = "rateest-interval", .has_arg = true, .val = RATEEST_OPT_INTERVAL}, - {.name = "rateest-ewmalog", .has_arg = true, .val = RATEEST_OPT_EWMALOG}, - XT_GETOPT_TABLEEND, +#define s struct xt_rateest_target_info +static const struct xt_option_entry RATEEST_opts[] = { + {.name = "rateest-name", .id = O_NAME, .type = XTTYPE_STRING, + .flags = XTOPT_MAND | XTOPT_PUT, XTOPT_POINTER(s, name)}, + {.name = "rateest-interval", .id = O_INTERVAL, .type = XTTYPE_STRING, + .flags = XTOPT_MAND}, + {.name = "rateest-ewmalog", .id = O_EWMALOG, .type = XTTYPE_STRING, + .flags = XTOPT_MAND}, + XTOPT_TABLEEND, }; +#undef s /* Copied from iproute */ #define TIME_UNITS_PER_SEC 1000000 @@ -82,63 +83,28 @@ RATEEST_print_time(unsigned int time) printf(" %uus", time); } -static int -RATEEST_parse(int c, char **argv, int invert, unsigned int *flags, - const void *entry, struct xt_entry_target **target) +static void RATEEST_parse(struct xt_option_call *cb) { - struct xt_rateest_target_info *info = (void *)(*target)->data; - - RATEEST_info = info; - - switch (c) { - case RATEEST_OPT_NAME: - if (*flags & (1 << c)) + xtables_option_parse(cb); + switch (cb->entry->id) { + case O_INTERVAL: + if (RATEEST_get_time(&interval, cb->arg) < 0) xtables_error(PARAMETER_PROBLEM, - "RATEEST: can't specify --rateest-name twice"); - *flags |= 1 << c; - - strncpy(info->name, optarg, sizeof(info->name) - 1); + "RATEEST: bad interval value \"%s\"", + cb->arg); break; - - case RATEEST_OPT_INTERVAL: - if (*flags & (1 << c)) + case O_EWMALOG: + if (RATEEST_get_time(&ewma_log, cb->arg) < 0) xtables_error(PARAMETER_PROBLEM, - "RATEEST: can't specify --rateest-interval twice"); - *flags |= 1 << c; - - if (RATEEST_get_time(&interval, optarg) < 0) - xtables_error(PARAMETER_PROBLEM, - "RATEEST: bad interval value `%s'", optarg); - - break; - - case RATEEST_OPT_EWMALOG: - if (*flags & (1 << c)) - xtables_error(PARAMETER_PROBLEM, - "RATEEST: can't specify --rateest-ewmalog twice"); - *flags |= 1 << c; - - if (RATEEST_get_time(&ewma_log, optarg) < 0) - xtables_error(PARAMETER_PROBLEM, - "RATEEST: bad ewmalog value `%s'", optarg); - + "RATEEST: bad ewmalog value \"%s\"", + cb->arg); break; } - - return 1; } -static void -RATEEST_final_check(unsigned int flags) +static void RATEEST_final_check(struct xt_fcheck_call *cb) { - struct xt_rateest_target_info *info = RATEEST_info; - - if (!(flags & (1 << RATEEST_OPT_NAME))) - xtables_error(PARAMETER_PROBLEM, "RATEEST: no name specified"); - if (!(flags & (1 << RATEEST_OPT_INTERVAL))) - xtables_error(PARAMETER_PROBLEM, "RATEEST: no interval specified"); - if (!(flags & (1 << RATEEST_OPT_EWMALOG))) - xtables_error(PARAMETER_PROBLEM, "RATEEST: no ewmalog specified"); + struct xt_rateest_target_info *info = cb->data; for (info->interval = 0; info->interval <= 5; info->interval++) { if (interval <= (1 << info->interval) * (TIME_UNITS_PER_SEC / 4)) @@ -199,11 +165,11 @@ static struct xtables_target rateest_tg_reg = { .size = XT_ALIGN(sizeof(struct xt_rateest_target_info)), .userspacesize = XT_ALIGN(sizeof(struct xt_rateest_target_info)), .help = RATEEST_help, - .parse = RATEEST_parse, - .final_check = RATEEST_final_check, + .x6_parse = RATEEST_parse, + .x6_fcheck = RATEEST_final_check, .print = RATEEST_print, .save = RATEEST_save, - .extra_opts = RATEEST_opts, + .x6_options = RATEEST_opts, }; void _init(void) -- cgit v1.2.3 From 14190986f87301b18bcc473c842bd82d778d87a2 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Sat, 18 Jun 2011 21:18:29 +0200 Subject: iptables: consolidate target/match init call This is useful for the upcoming patch about per-instance auxiliary data. Signed-off-by: Jan Engelhardt --- iptables/ip6tables.c | 9 +++------ iptables/iptables.c | 10 ++++------ iptables/xshared.c | 15 +++++++++++++-- iptables/xshared.h | 2 ++ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c index 4037acfb..d13744ca 100644 --- a/iptables/ip6tables.c +++ b/iptables/ip6tables.c @@ -1288,8 +1288,7 @@ static void command_jump(struct iptables_command_state *cs) cs->target->t->u.target_size = size; strcpy(cs->target->t->u.user.name, cs->jumpto); cs->target->t->u.user.revision = cs->target->revision; - if (cs->target->init != NULL) - cs->target->init(cs->target->t); + xs_init_target(cs->target); if (cs->target->x6_options != NULL) opts = xtables_options_xfrm(ip6tables_globals.orig_opts, opts, cs->target->x6_options, @@ -1317,8 +1316,7 @@ static void command_match(struct iptables_command_state *cs) m->m->u.match_size = size; strcpy(m->m->u.user.name, m->name); m->m->u.user.revision = m->revision; - if (m->init != NULL) - m->init(m->m); + xs_init_match(m); if (m == m->next) return; /* Merge options for non-cloned matches */ @@ -1839,8 +1837,7 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand cs.target->t = xtables_calloc(1, size); cs.target->t->u.target_size = size; strcpy(cs.target->t->u.user.name, cs.jumpto); - if (cs.target->init != NULL) - cs.target->init(cs.target->t); + xs_init_target(cs.target); } if (!cs.target) { diff --git a/iptables/iptables.c b/iptables/iptables.c index 4ae75419..477e8f1d 100644 --- a/iptables/iptables.c +++ b/iptables/iptables.c @@ -1315,8 +1315,8 @@ static void command_jump(struct iptables_command_state *cs) cs->target->t->u.target_size = size; strcpy(cs->target->t->u.user.name, cs->jumpto); cs->target->t->u.user.revision = cs->target->revision; - if (cs->target->init != NULL) - cs->target->init(cs->target->t); + xs_init_target(cs->target); + if (cs->target->x6_options != NULL) opts = xtables_options_xfrm(iptables_globals.orig_opts, opts, cs->target->x6_options, @@ -1344,8 +1344,7 @@ static void command_match(struct iptables_command_state *cs) m->m->u.match_size = size; strcpy(m->m->u.user.name, m->name); m->m->u.user.revision = m->revision; - if (m->init != NULL) - m->init(m->m); + xs_init_match(m); if (m == m->next) return; /* Merge options for non-cloned matches */ @@ -1871,8 +1870,7 @@ int do_command4(int argc, char *argv[], char **table, struct iptc_handle **handl strcpy(cs.target->t->u.user.name, cs.jumpto); if (!iptc_is_chain(cs.jumpto, *handle)) cs.target->t->u.user.revision = cs.target->revision; - if (cs.target->init != NULL) - cs.target->init(cs.target->t); + xs_init_target(cs.target); } if (!cs.target) { diff --git a/iptables/xshared.c b/iptables/xshared.c index 0e3857bb..55ce5504 100644 --- a/iptables/xshared.c +++ b/iptables/xshared.c @@ -145,8 +145,7 @@ int command_default(struct iptables_command_state *cs, m->m->u.match_size = size; strcpy(m->m->u.user.name, m->name); m->m->u.user.revision = m->revision; - if (m->init != NULL) - m->init(m->m); + xs_init_match(m); if (m->x6_options != NULL) gl->opts = xtables_options_xfrm(gl->orig_opts, @@ -207,3 +206,15 @@ int subcmd_main(int argc, char **argv, const struct subcommand *cb) fprintf(stderr, " * %s\n", cb->name); exit(EXIT_FAILURE); } + +void xs_init_target(struct xtables_target *target) +{ + if (target->init != NULL) + target->init(target->t); +} + +void xs_init_match(struct xtables_match *match) +{ + if (match->init != NULL) + match->init(match->m); +} diff --git a/iptables/xshared.h b/iptables/xshared.h index b44a3a35..b804aafe 100644 --- a/iptables/xshared.h +++ b/iptables/xshared.h @@ -81,6 +81,8 @@ extern int command_default(struct iptables_command_state *, struct xtables_globals *); extern struct xtables_match *load_proto(struct iptables_command_state *); extern int subcmd_main(int, char **, const struct subcommand *); +extern void xs_init_target(struct xtables_target *); +extern void xs_init_match(struct xtables_match *); extern const struct xtables_afinfo *afinfo; -- cgit v1.2.3 From 2dba676b68ef842025f3afecba26cb0b2ae4c09b Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Sat, 18 Jun 2011 21:34:25 +0200 Subject: extensions: support for per-extension instance "global" variable space Signed-off-by: Jan Engelhardt --- include/xtables.h.in | 18 +++++++++++++++--- iptables/xshared.c | 18 ++++++++++++++++++ iptables/xtoptions.c | 4 ++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/include/xtables.h.in b/include/xtables.h.in index 2565dd23..0dead268 100644 --- a/include/xtables.h.in +++ b/include/xtables.h.in @@ -137,11 +137,13 @@ struct xt_option_entry { * @arg: input from command line * @ext_name: name of extension currently being processed * @entry: current option being processed - * @data: per-extension data block + * @data: per-extension kernel data block * @xflags: options of the extension that have been used * @invert: whether option was used with ! * @nvals: number of results in uXX_multi * @val: parsed result + * @udata: per-extension private scratch area + * (cf. xtables_{match,target}->udata_size) */ struct xt_option_call { const char *arg, *ext_name; @@ -174,16 +176,19 @@ struct xt_option_call { struct xt_entry_target **target; }; void *xt_entry; + void *udata; }; /** * @ext_name: name of extension currently being processed - * @data: per-extension data block + * @data: per-extension (kernel) data block + * @udata: per-extension private scratch area + * (cf. xtables_{match,target}->udata_size) * @xflags: options of the extension that have been used */ struct xt_fcheck_call { const char *ext_name; - void *data; + void *data, *udata; unsigned int xflags; }; @@ -254,7 +259,11 @@ struct xtables_match void (*x6_fcheck)(struct xt_fcheck_call *); const struct xt_option_entry *x6_options; + /* Size of per-extension instance extra "global" scratch space */ + size_t udata_size; + /* Ignore these men behind the curtain: */ + void *udata; unsigned int option_offset; struct xt_entry_match *m; unsigned int mflags; @@ -318,7 +327,10 @@ struct xtables_target void (*x6_fcheck)(struct xt_fcheck_call *); const struct xt_option_entry *x6_options; + size_t udata_size; + /* Ignore these men behind the curtain: */ + void *udata; unsigned int option_offset; struct xt_entry_target *t; unsigned int tflags; diff --git a/iptables/xshared.c b/iptables/xshared.c index 55ce5504..79da507d 100644 --- a/iptables/xshared.c +++ b/iptables/xshared.c @@ -209,12 +209,30 @@ int subcmd_main(int argc, char **argv, const struct subcommand *cb) void xs_init_target(struct xtables_target *target) { + if (target->udata_size != 0) { + free(target->udata); + target->udata = calloc(1, target->udata_size); + if (target->udata == NULL) + xtables_error(RESOURCE_PROBLEM, "malloc"); + } if (target->init != NULL) target->init(target->t); } void xs_init_match(struct xtables_match *match) { + if (match->udata_size != 0) { + /* + * As soon as a subsequent instance of the same match + * is used, e.g. "-m time -m time", the first instance + * is no longer reachable anyway, so we can free udata. + * Same goes for target. + */ + free(match->udata); + match->udata = calloc(1, match->udata_size); + if (match->udata == NULL) + xtables_error(RESOURCE_PROBLEM, "malloc"); + } if (match->init != NULL) match->init(match->m); } diff --git a/iptables/xtoptions.c b/iptables/xtoptions.c index ac0601f2..1423724b 100644 --- a/iptables/xtoptions.c +++ b/iptables/xtoptions.c @@ -908,6 +908,7 @@ void xtables_option_tpcall(unsigned int c, char **argv, bool invert, cb.xflags = t->tflags; cb.target = &t->t; cb.xt_entry = fw; + cb.udata = t->udata; t->x6_parse(&cb); t->tflags = cb.xflags; } @@ -943,6 +944,7 @@ void xtables_option_mpcall(unsigned int c, char **argv, bool invert, cb.xflags = m->mflags; cb.match = &m->m; cb.xt_entry = fw; + cb.udata = m->udata; m->x6_parse(&cb); m->mflags = cb.xflags; } @@ -1028,6 +1030,7 @@ void xtables_option_tfcall(struct xtables_target *t) cb.ext_name = t->name; cb.data = t->t->data; cb.xflags = t->tflags; + cb.udata = t->udata; t->x6_fcheck(&cb); } else if (t->final_check != NULL) { t->final_check(t->tflags); @@ -1048,6 +1051,7 @@ void xtables_option_mfcall(struct xtables_match *m) cb.ext_name = m->name; cb.data = m->m->data; cb.xflags = m->mflags; + cb.udata = m->udata; m->x6_fcheck(&cb); } else if (m->final_check != NULL) { m->final_check(m->mflags); -- cgit v1.2.3 From 4a96d2e2c9d8c43b58d9490cd1d2ae2d1b3e0bef Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 21 Jun 2011 09:54:31 +0200 Subject: libxt_rateest: abolish global variables Signed-off-by: Jan Engelhardt --- extensions/libxt_rateest.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/extensions/libxt_rateest.c b/extensions/libxt_rateest.c index 509b3e31..5f42a137 100644 --- a/extensions/libxt_rateest.c +++ b/extensions/libxt_rateest.c @@ -8,9 +8,6 @@ #include #include -/* Ugly hack to pass info to final_check function. We should fix the API */ -static struct xt_rateest_match_info *rateest_info; - static void rateest_help(void) { printf( @@ -115,8 +112,6 @@ rateest_parse(int c, char **argv, int invert, unsigned int *flags, struct xt_rateest_match_info *info = (void *)(*match)->data; unsigned int val; - rateest_info = info; - switch (c) { case OPT_RATEEST1: xtables_check_inverse(optarg, &invert, &optind, 0, argv); @@ -302,10 +297,9 @@ rateest_parse(int c, char **argv, int invert, unsigned int *flags, return 1; } -static void -rateest_final_check(unsigned int flags) +static void rateest_final_check(struct xt_fcheck_call *cb) { - struct xt_rateest_match_info *info = rateest_info; + struct xt_rateest_match_info *info = cb->data; if (info == NULL) xtables_error(PARAMETER_PROBLEM, "rateest match: " @@ -439,7 +433,7 @@ static struct xtables_match rateest_mt_reg = { .userspacesize = XT_ALIGN(offsetof(struct xt_rateest_match_info, est1)), .help = rateest_help, .parse = rateest_parse, - .final_check = rateest_final_check, + .x6_fcheck = rateest_final_check, .print = rateest_print, .save = rateest_save, .extra_opts = rateest_opts, -- cgit v1.2.3 From 12bc22a9d3e4ae4a3276dbae1cf3bd50ef5dbe9d Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 21 Jun 2011 14:22:20 +0200 Subject: libxt_RATEEST: abolish global variables Signed-off-by: Jan Engelhardt --- extensions/libxt_RATEEST.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/extensions/libxt_RATEEST.c b/extensions/libxt_RATEEST.c index b928b339..62bcb5e8 100644 --- a/extensions/libxt_RATEEST.c +++ b/extensions/libxt_RATEEST.c @@ -7,9 +7,10 @@ #include #include -/* hack to pass raw values to final_check */ -static unsigned int interval; -static unsigned int ewma_log; +struct rateest_tg_udata { + unsigned int interval; + unsigned int ewma_log; +}; static void RATEEST_help(void) @@ -85,16 +86,18 @@ RATEEST_print_time(unsigned int time) static void RATEEST_parse(struct xt_option_call *cb) { + struct rateest_tg_udata *udata = cb->udata; + xtables_option_parse(cb); switch (cb->entry->id) { case O_INTERVAL: - if (RATEEST_get_time(&interval, cb->arg) < 0) + if (RATEEST_get_time(&udata->interval, cb->arg) < 0) xtables_error(PARAMETER_PROBLEM, "RATEEST: bad interval value \"%s\"", cb->arg); break; case O_EWMALOG: - if (RATEEST_get_time(&ewma_log, cb->arg) < 0) + if (RATEEST_get_time(&udata->ewma_log, cb->arg) < 0) xtables_error(PARAMETER_PROBLEM, "RATEEST: bad ewmalog value \"%s\"", cb->arg); @@ -105,9 +108,10 @@ static void RATEEST_parse(struct xt_option_call *cb) static void RATEEST_final_check(struct xt_fcheck_call *cb) { struct xt_rateest_target_info *info = cb->data; + struct rateest_tg_udata *udata = cb->udata; for (info->interval = 0; info->interval <= 5; info->interval++) { - if (interval <= (1 << info->interval) * (TIME_UNITS_PER_SEC / 4)) + if (udata->interval <= (1 << info->interval) * (TIME_UNITS_PER_SEC / 4)) break; } @@ -118,7 +122,7 @@ static void RATEEST_final_check(struct xt_fcheck_call *cb) for (info->ewma_log = 1; info->ewma_log < 32; info->ewma_log++) { double w = 1.0 - 1.0 / (1 << info->ewma_log); - if (interval / (-log(w)) > ewma_log) + if (udata->interval / (-log(w)) > udata->ewma_log) break; } info->ewma_log--; @@ -170,6 +174,7 @@ static struct xtables_target rateest_tg_reg = { .print = RATEEST_print, .save = RATEEST_save, .x6_options = RATEEST_opts, + .udata_size = sizeof(struct rateest_tg_udata), }; void _init(void) -- cgit v1.2.3 From 017e7b7e1cf4fb63208e46592d06cc030f6d552d Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 22 Jun 2011 10:15:07 +0200 Subject: libip6t_HL: fix option names from ttl -> hl Signed-off-by: Jan Engelhardt --- extensions/libip6t_HL.c | 6 +++--- tests/options-most.rules | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/extensions/libip6t_HL.c b/extensions/libip6t_HL.c index 254b1914..52ca5d3e 100644 --- a/extensions/libip6t_HL.c +++ b/extensions/libip6t_HL.c @@ -20,12 +20,12 @@ enum { #define s struct ip6t_HL_info static const struct xt_option_entry HL_opts[] = { - {.name = "ttl-set", .type = XTTYPE_UINT8, .id = O_HL_SET, + {.name = "hl-set", .type = XTTYPE_UINT8, .id = O_HL_SET, .excl = F_ANY, .flags = XTOPT_PUT, XTOPT_POINTER(s, hop_limit)}, - {.name = "ttl-dec", .type = XTTYPE_UINT8, .id = O_HL_DEC, + {.name = "hl-dec", .type = XTTYPE_UINT8, .id = O_HL_DEC, .excl = F_ANY, .flags = XTOPT_PUT, XTOPT_POINTER(s, hop_limit), .min = 1}, - {.name = "ttl-inc", .type = XTTYPE_UINT8, .id = O_HL_INC, + {.name = "hl-inc", .type = XTTYPE_UINT8, .id = O_HL_INC, .excl = F_ANY, .flags = XTOPT_PUT, XTOPT_POINTER(s, hop_limit), .min = 1}, XTOPT_TABLEEND, diff --git a/tests/options-most.rules b/tests/options-most.rules index 13ee9873..125b5bf3 100644 --- a/tests/options-most.rules +++ b/tests/options-most.rules @@ -1,4 +1,3 @@ -# Generated by ip6tables-save v1.4.10 on Mon Jan 31 02:19:53 2011 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] @@ -171,4 +170,17 @@ #-A zmatches -m rateest --rateest-delta --rateest RE1 --rateest-pps1 8 --rateest-eq --rateest-pps2 9 #-A zmatches -m rateest --rateest-delta --rateest RE1 --rateest-pps1 8 --rateest-gt --rateest-pps2 9 COMMIT -# Completed on Mon Jan 31 02:19:54 2011 +*mangle +:PREROUTING ACCEPT [0:0] +:INPUT ACCEPT [0:0] +:FORWARD ACCEPT [0:0] +:OUTPUT ACCEPT [0:0] +:POSTROUTING ACCEPT [0:0] +:matches - - +:ntarg - - +:zmatches - - +-A INPUT -m u32 --u32 "0x0=0x0&&0x0=0x1" -j ntarg +-A ntarg -j HL --hl-inc 1 +-A ntarg -j HL --hl-dec 1 +-A ntarg +COMMIT -- cgit v1.2.3 From 70cb0a6d3e09f64f9a05870d694ac0160319de9a Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 22 Jun 2011 11:15:34 +0200 Subject: libxt_state: fix regression about inversion of main option Signed-off-by: Jan Engelhardt --- extensions/libxt_state.c | 2 +- tests/options-most.rules | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/libxt_state.c b/extensions/libxt_state.c index 3fc747d8..eff444c8 100644 --- a/extensions/libxt_state.c +++ b/extensions/libxt_state.c @@ -23,7 +23,7 @@ state_help(void) static const struct xt_option_entry state_opts[] = { {.name = "state", .id = O_STATE, .type = XTTYPE_STRING, - .flags = XTOPT_MAND}, + .flags = XTOPT_MAND | XTOPT_INVERT}, XTOPT_TABLEEND, }; diff --git a/tests/options-most.rules b/tests/options-most.rules index 125b5bf3..2b419e57 100644 --- a/tests/options-most.rules +++ b/tests/options-most.rules @@ -75,6 +75,8 @@ -A matches -A matches -m conntrack --ctexpire 5:4294967295 -A matches +-A matches -m conntrack ! --ctstate NEW ! --ctproto tcp ! --ctorigsrc ::1/127 ! --ctorigdst ::2/127 ! --ctreplsrc ::2/127 ! --ctrepldst ::2/127 ! --ctorigsrcport 3 ! --ctorigdstport 4 ! --ctreplsrcport 5 ! --ctrepldstport 6 ! --ctstatus ASSURED ! --ctexpire 8:9 +-A matches -A matches -p esp -m esp --espspi 1 -A matches -A matches -p esp -m esp --espspi :2 -- cgit v1.2.3 From 68146dad91611bd8d6d12c8ba27219130d99607b Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 22 Jun 2011 11:18:19 +0200 Subject: libxt_hashlimit: use a more obvious expiry value by default Due to the previous default expiry of 10 sec, "--hashlimit 1/min" would allow matching up to 6/min if a properly timed. To do what the user expects, the minimum expiry must equal the selected time quantum however. Cc: Jan Rovner Signed-off-by: Jan Engelhardt --- extensions/libxt_hashlimit.c | 57 +++++++++++++++++++++++++++++++------------- tests/options-most.rules | 5 ++++ 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/extensions/libxt_hashlimit.c b/extensions/libxt_hashlimit.c index e683f9ad..a838680c 100644 --- a/extensions/libxt_hashlimit.c +++ b/extensions/libxt_hashlimit.c @@ -25,6 +25,10 @@ #define XT_HASHLIMIT_GCINTERVAL 1000 #define XT_HASHLIMIT_EXPIRE 10000 +struct hashlimit_mt_udata { + uint32_t mult; +}; + static void hashlimit_help(void) { printf( @@ -56,8 +60,9 @@ enum { O_HTABLE_MAX, O_HTABLE_GCINT, O_HTABLE_EXPIRE, - F_UPTO = 1 << O_UPTO, - F_ABOVE = 1 << O_ABOVE, + F_UPTO = 1 << O_UPTO, + F_ABOVE = 1 << O_ABOVE, + F_HTABLE_EXPIRE = 1 << O_HTABLE_EXPIRE, }; static void hashlimit_mt_help(void) @@ -141,25 +146,25 @@ static const struct xt_option_entry hashlimit_mt_opts[] = { #undef s static -int parse_rate(const char *rate, uint32_t *val) +int parse_rate(const char *rate, uint32_t *val, struct hashlimit_mt_udata *ud) { const char *delim; uint32_t r; - uint32_t mult = 1; /* Seconds by default. */ + ud->mult = 1; /* Seconds by default. */ delim = strchr(rate, '/'); if (delim) { if (strlen(delim+1) == 0) return 0; if (strncasecmp(delim+1, "second", strlen(delim+1)) == 0) - mult = 1; + ud->mult = 1; else if (strncasecmp(delim+1, "minute", strlen(delim+1)) == 0) - mult = 60; + ud->mult = 60; else if (strncasecmp(delim+1, "hour", strlen(delim+1)) == 0) - mult = 60*60; + ud->mult = 60*60; else if (strncasecmp(delim+1, "day", strlen(delim+1)) == 0) - mult = 24*60*60; + ud->mult = 24*60*60; else return 0; } @@ -169,10 +174,10 @@ int parse_rate(const char *rate, uint32_t *val) /* This would get mapped to infinite (1/day is minimum they can specify, so we're ok at that end). */ - if (r / mult > XT_HASHLIMIT_SCALE) + if (r / ud->mult > XT_HASHLIMIT_SCALE) xtables_error(PARAMETER_PROBLEM, "Rate too fast \"%s\"\n", rate); - *val = XT_HASHLIMIT_SCALE * mult / r; + *val = XT_HASHLIMIT_SCALE * ud->mult / r; return 1; } @@ -248,14 +253,14 @@ static void hashlimit_parse(struct xt_option_call *cb) case O_UPTO: if (cb->invert) info->cfg.mode |= XT_HASHLIMIT_INVERT; - if (!parse_rate(cb->arg, &info->cfg.avg)) + if (!parse_rate(cb->arg, &info->cfg.avg, cb->udata)) xtables_param_act(XTF_BAD_VALUE, "hashlimit", "--hashlimit-upto", cb->arg); break; case O_ABOVE: if (!cb->invert) info->cfg.mode |= XT_HASHLIMIT_INVERT; - if (!parse_rate(cb->arg, &info->cfg.avg)) + if (!parse_rate(cb->arg, &info->cfg.avg, cb->udata)) xtables_param_act(XTF_BAD_VALUE, "hashlimit", "--hashlimit-above", cb->arg); break; @@ -276,14 +281,14 @@ static void hashlimit_mt_parse(struct xt_option_call *cb) case O_UPTO: if (cb->invert) info->cfg.mode |= XT_HASHLIMIT_INVERT; - if (!parse_rate(cb->arg, &info->cfg.avg)) + if (!parse_rate(cb->arg, &info->cfg.avg, cb->udata)) xtables_param_act(XTF_BAD_VALUE, "hashlimit", "--hashlimit-upto", cb->arg); break; case O_ABOVE: if (!cb->invert) info->cfg.mode |= XT_HASHLIMIT_INVERT; - if (!parse_rate(cb->arg, &info->cfg.avg)) + if (!parse_rate(cb->arg, &info->cfg.avg, cb->udata)) xtables_param_act(XTF_BAD_VALUE, "hashlimit", "--hashlimit-above", cb->arg); break; @@ -303,9 +308,26 @@ static void hashlimit_mt_parse(struct xt_option_call *cb) static void hashlimit_check(struct xt_fcheck_call *cb) { + const struct hashlimit_mt_udata *udata = cb->udata; + struct xt_hashlimit_info *info = cb->data; + if (!(cb->xflags & (F_UPTO | F_ABOVE))) xtables_error(PARAMETER_PROBLEM, "You have to specify --hashlimit"); + if (!(cb->xflags & F_HTABLE_EXPIRE)) + info->cfg.expire = udata->mult; +} + +static void hashlimit_mt_check(struct xt_fcheck_call *cb) +{ + const struct hashlimit_mt_udata *udata = cb->udata; + struct xt_hashlimit_mtinfo1 *info = cb->data; + + if (!(cb->xflags & (F_UPTO | F_ABOVE))) + xtables_error(PARAMETER_PROBLEM, + "You have to specify --hashlimit"); + if (!(cb->xflags & F_HTABLE_EXPIRE)) + info->cfg.expire = udata->mult; } static const struct rates @@ -508,6 +530,7 @@ static struct xtables_match hashlimit_mt_reg[] = { .print = hashlimit_print, .save = hashlimit_save, .x6_options = hashlimit_mt_opts, + .udata_size = sizeof(struct hashlimit_mt_udata), }, { .version = XTABLES_VERSION, @@ -519,10 +542,11 @@ static struct xtables_match hashlimit_mt_reg[] = { .help = hashlimit_mt_help, .init = hashlimit_mt4_init, .x6_parse = hashlimit_mt_parse, - .x6_fcheck = hashlimit_check, + .x6_fcheck = hashlimit_mt_check, .print = hashlimit_mt4_print, .save = hashlimit_mt4_save, .x6_options = hashlimit_mt_opts, + .udata_size = sizeof(struct hashlimit_mt_udata), }, { .version = XTABLES_VERSION, @@ -534,10 +558,11 @@ static struct xtables_match hashlimit_mt_reg[] = { .help = hashlimit_mt_help, .init = hashlimit_mt6_init, .x6_parse = hashlimit_mt_parse, - .x6_fcheck = hashlimit_check, + .x6_fcheck = hashlimit_mt_check, .print = hashlimit_mt6_print, .save = hashlimit_mt6_save, .x6_options = hashlimit_mt_opts, + .udata_size = sizeof(struct hashlimit_mt_udata), }, }; diff --git a/tests/options-most.rules b/tests/options-most.rules index 2b419e57..7298a1f9 100644 --- a/tests/options-most.rules +++ b/tests/options-most.rules @@ -87,6 +87,11 @@ -A matches -A matches -p esp -m esp --espspi 5:4294967295 -A matches +-A matches -m hashlimit --hashlimit-upto 1/sec --hashlimit-burst 1 --hashlimit-name mini1 +-A matches -m hashlimit --hashlimit-upto 1/min --hashlimit-burst 1 --hashlimit-name mini2 +-A matches -m hashlimit --hashlimit-upto 1/hour --hashlimit-burst 1 --hashlimit-name mini3 +-A matches -m hashlimit --hashlimit-upto 1/day --hashlimit-burst 1 --hashlimit-name mini4 +-A matches -A matches -m ipvs --vaddr fe80::/64 --vport 1 --vdir REPLY --vmethod GATE --vportctl 21 -A matches -A matches -m length --length 1 -- cgit v1.2.3 From f6677b5bcae125af28d227b9073426bddbd9190e Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 22 Jun 2011 15:42:48 +0200 Subject: build: bump soversion for recent data structure change Cf. commit v1.4.11.1-5-g2dba676. Signed-off-by: Jan Engelhardt --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e902ab92..b57f542d 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_INIT([iptables], [1.4.11.1]) # See libtool.info "Libtool's versioning system" -libxtables_vcurrent=6 +libxtables_vcurrent=7 libxtables_vage=0 AC_CONFIG_HEADERS([config.h]) -- cgit v1.2.3 From 96d0d0130a9a08803406c5c18681903446088ebf Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Fri, 10 Jun 2011 15:25:55 +0200 Subject: iptables: Coverity: DEADCODE libiptc.c:407: dead_error_condition: On this path, the condition "res > 0" cannot be false. libiptc.c:396: at_least: After this line, the value of "res" is at least 1. libiptc.c:393: equality_cond: Condition "res == 0" is evaluated as false. libiptc.c:396: new_values: Noticing condition "res < 0". libiptc.c:425: new_values: Noticing condition "res < 0". libiptc.c:407: new_values: Noticing condition "res > 0". libiptc.c:435: dead_error_line: Execution cannot reach this statement "return list_pos;". Signed-off-by: Jan Engelhardt --- libiptc/libiptc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c index 0b6d5e3a..42d9784a 100644 --- a/libiptc/libiptc.c +++ b/libiptc/libiptc.c @@ -403,7 +403,7 @@ __iptcc_bsearch_chain_index(const char *name, unsigned int offset, } debug("jump back to pos:%d (end:%d)\n", pos, end); goto loop; - } else if (res > 0 ){ /* Not far enough, jump forward */ + } else { /* res > 0; Not far enough, jump forward */ /* Exit case: Last element of array */ if (pos == handle->chain_index_sz-1) { @@ -430,8 +430,6 @@ __iptcc_bsearch_chain_index(const char *name, unsigned int offset, debug("jump forward to pos:%d (end:%d)\n", pos, end); goto loop; } - - return list_pos; } /* Wrapper for string chain name based bsearch */ -- cgit v1.2.3 From 474c18d7982407246dd724c6fa3939f78466620a Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Fri, 10 Jun 2011 15:25:57 +0200 Subject: iptables: Coverity: NEGATIVE_RETURNS libipq.c:232: var_tested_neg: Variable "h->fd" tests negative. libipq.c:234: negative_returns: "h->fd" is passed to a parameter that cannot be negative. Signed-off-by: Jan Engelhardt --- libipq/libipq.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libipq/libipq.c b/libipq/libipq.c index e3304875..fb65971a 100644 --- a/libipq/libipq.c +++ b/libipq/libipq.c @@ -231,7 +231,6 @@ struct ipq_handle *ipq_create_handle(uint32_t flags, uint32_t protocol) if (h->fd == -1) { ipq_errno = IPQ_ERR_SOCKET; - close(h->fd); free(h); return NULL; } -- cgit v1.2.3 From ee80faf4438102395bc4034894b6468453181be9 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Fri, 10 Jun 2011 15:25:58 +0200 Subject: iptables: Coverity: REVERSE_INULL ip6tables-restore.c:186: deref_ptr_in_call: Dereferencing pointer "in". ip6tables-restore.c:463: check_after_deref: Dereferencing "in" before a null check. iptables-restore.c:192: deref_ptr_in_call: Dereferencing pointer "in". iptables-restore.c:468: check_after_deref: Dereferencing "in" before a null check. iptables-xml.c:671: deref_ptr_in_call: Dereferencing pointer "in". iptables-xml.c:873: check_after_deref: Dereferencing "in" before a null check. Signed-off-by: Jan Engelhardt --- iptables/ip6tables-restore.c | 3 +-- iptables/iptables-restore.c | 3 +-- iptables/iptables-xml.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/iptables/ip6tables-restore.c b/iptables/ip6tables-restore.c index 420bc523..ae147d55 100644 --- a/iptables/ip6tables-restore.c +++ b/iptables/ip6tables-restore.c @@ -460,7 +460,6 @@ int main(int argc, char *argv[]) exit(1); } - if (in != NULL) - fclose(in); + fclose(in); return 0; } diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c index 26245997..1cb833c0 100644 --- a/iptables/iptables-restore.c +++ b/iptables/iptables-restore.c @@ -465,7 +465,6 @@ main(int argc, char *argv[]) exit(1); } - if (in != NULL) - fclose(in); + fclose(in); return 0; } diff --git a/iptables/iptables-xml.c b/iptables/iptables-xml.c index 5aa638c0..502b2d96 100644 --- a/iptables/iptables-xml.c +++ b/iptables/iptables-xml.c @@ -865,8 +865,7 @@ main(int argc, char *argv[]) exit(1); } - if (in != NULL) - fclose(in); + fclose(in); printf("\n"); free_argv(); -- cgit v1.2.3 From d0101690d9ae347d8a8ee9e340c5db72480046a3 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Fri, 10 Jun 2011 15:26:00 +0200 Subject: iptables: Coverity: VARARGS xtables.c:931: va_init: Initializing va_list "args". xtables.c:938: missing_va_end: va_end was not called for "args". xtables.c:947: missing_va_end: va_end was not called for "args". xtables.c:961: missing_va_end: va_end was not called for "args". Signed-off-by: Jan Engelhardt --- iptables/xtables.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/iptables/xtables.c b/iptables/xtables.c index acfcf8bd..db6d079f 100644 --- a/iptables/xtables.c +++ b/iptables/xtables.c @@ -1042,8 +1042,10 @@ void xtables_param_act(unsigned int status, const char *p1, ...) case XTF_ONLY_ONCE: p2 = va_arg(args, const char *); b = va_arg(args, unsigned int); - if (!b) + if (!b) { + va_end(args); return; + } xt_params->exit_err(PARAMETER_PROBLEM, "%s: \"%s\" option may only be specified once", p1, p2); @@ -1051,8 +1053,10 @@ void xtables_param_act(unsigned int status, const char *p1, ...) case XTF_NO_INVERT: p2 = va_arg(args, const char *); b = va_arg(args, unsigned int); - if (!b) + if (!b) { + va_end(args); return; + } xt_params->exit_err(PARAMETER_PROBLEM, "%s: \"%s\" option cannot be inverted", p1, p2); break; @@ -1065,8 +1069,10 @@ void xtables_param_act(unsigned int status, const char *p1, ...) break; case XTF_ONE_ACTION: b = va_arg(args, unsigned int); - if (!b) + if (!b) { + va_end(args); return; + } xt_params->exit_err(PARAMETER_PROBLEM, "%s: At most one action is possible", p1); break; -- cgit v1.2.3 From f53710b16c2bae1843c3f5fee390f496dfa82526 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Fri, 10 Jun 2011 15:26:02 +0200 Subject: iptables: Coverity: RESOURCE_LEAK xtables.c:320: alloc_fn: Calling allocation function "get_modprobe". xtables.c:294: alloc_fn: Storage is returned from allocation function "malloc". xtables.c:294: var_assign: Assigning: "ret" = "malloc(1024UL)". xtables.c:304: return_alloc: Returning allocated memory "ret". xtables.c:320: var_assign: Assigning: "buf" = storage returned from "get_modprobe()". xtables.c:323: var_assign: Assigning: "modprobe" = "buf". xtables.c:348: leaked_storage: Variable "buf" going out of scope leaks the storage it points to. xtables.c:348: leaked_storage: Returning without freeing "modprobe" leaks the storage that it points to. Signed-off-by: Jan Engelhardt --- iptables/xtables.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iptables/xtables.c b/iptables/xtables.c index db6d079f..00c7c066 100644 --- a/iptables/xtables.c +++ b/iptables/xtables.c @@ -362,6 +362,7 @@ int xtables_insmod(const char *modname, const char *modprobe, bool quiet) /* not usually reached */ exit(1); case -1: + free(buf); return -1; default: /* parent */ -- cgit v1.2.3 From 622abc73b097e7e778b432e422fd3c1f035bcfd3 Mon Sep 17 00:00:00 2001 From: Massimo Maggi Date: Wed, 15 Jun 2011 02:52:00 +0200 Subject: libxt_RATEEST: fix userspacesize field I cannot delete a rule by matching it if the target of the rule is RATEEST. Copy-paste from terminal: # iptables -t mangle -A PREROUTING -j RATEEST --rateest-name somename --rateest-interval 250ms --rateest-ewmalog 4s # iptables -t mangle -D PREROUTING -j RATEEST --rateest-name somename --rateest-interval 250ms --rateest-ewmalog 4s iptables: No chain/target/match by that name. I saw in comments of the kernel code that the last part of the struct xt_rateest_target_info is used only by kernel: struct xt_rateest_target_info { char name[IFNAMSIZ]; __s8 interval; __u8 ewma_log; /* Used internally by the kernel */ struct xt_rateest *est __attribute__((aligned(8))); }; but in struct xtables_target, .size and .userspacesize are equal. Simply correcting this solved the problem. References: http://bugzilla.netfilter.org/show_bug.cgi?id=724 Signed-off-by: Jan Engelhardt --- extensions/libxt_RATEEST.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/libxt_RATEEST.c b/extensions/libxt_RATEEST.c index 62bcb5e8..acdefb90 100644 --- a/extensions/libxt_RATEEST.c +++ b/extensions/libxt_RATEEST.c @@ -167,7 +167,7 @@ static struct xtables_target rateest_tg_reg = { .name = "RATEEST", .version = XTABLES_VERSION, .size = XT_ALIGN(sizeof(struct xt_rateest_target_info)), - .userspacesize = XT_ALIGN(sizeof(struct xt_rateest_target_info)), + .userspacesize = offsetof(struct xt_rateest_target_info, est), .help = RATEEST_help, .x6_parse = RATEEST_parse, .x6_fcheck = RATEEST_final_check, -- cgit v1.2.3 From 447ddfbfb3ed16ad0059f4559334670e9b9806ec Mon Sep 17 00:00:00 2001 From: Jakub Zawadzki Date: Mon, 13 Jun 2011 13:54:33 +0200 Subject: doc: fix group range in libxt_NFLOG's man References: http://bugzilla.netfilter.org/show_bug.cgi?id=723 Signed-off-by: Jan Engelhardt --- extensions/libxt_NFLOG.man | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/libxt_NFLOG.man b/extensions/libxt_NFLOG.man index 66f0b973..1b6dbf16 100644 --- a/extensions/libxt_NFLOG.man +++ b/extensions/libxt_NFLOG.man @@ -9,7 +9,7 @@ may subscribe to the group to receive the packets. Like LOG, this is a non-terminating target, i.e. rule traversal continues at the next rule. .TP \fB\-\-nflog\-group\fP \fInlgroup\fP -The netlink group (1 \- 2^32\-1) to which packets are (only applicable for +The netlink group (0 - 2^16\-1) to which packets are (only applicable for nfnetlink_log). The default value is 0. .TP \fB\-\-nflog\-prefix\fP \fIprefix\fP -- cgit v1.2.3 From 3c871010888e1479ef8fca2048485b979ec2661a Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 24 Jun 2011 20:16:48 +0200 Subject: build: attempt to fix building under Linux 2.4 iptables no longer compiles for Linux 2.4 because it uses linux/magic.h. This header and the PROC_SUPER_MAGIC macro are only for Linux 2.6. xtables.c:35:52: error: linux/magic.h: No such file or directory xtables.c: In function 'proc_file_exists': xtables.c:389: error: 'PROC_SUPER_MAGIC' undeclared (first use in this function) xtables.c:389: error: (Each undeclared identifier is reported only once for each function it appears in.) References: http://bugzilla.netfilter.org/show_bug.cgi?id=720 Signed-off-by: Jan Engelhardt --- configure.ac | 4 +--- iptables/xtables.c | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index b57f542d..6c90caaf 100644 --- a/configure.ac +++ b/configure.ac @@ -59,12 +59,10 @@ AC_SUBST([libiptc_LDFLAGS2]) blacklist_modules=""; -AC_CHECK_HEADER([linux/dccp.h]) +AC_CHECK_HEADERS([linux/dccp.h linux/ip_vs.h linux/magic.h linux/proc_fs.h]) if test "$ac_cv_header_linux_dccp_h" != "yes"; then blacklist_modules="$blacklist_modules dccp"; fi; - -AC_CHECK_HEADER([linux/ip_vs.h]) if test "$ac_cv_header_linux_ip_vs_h" != "yes"; then blacklist_modules="$blacklist_modules ipvs"; fi; diff --git a/iptables/xtables.c b/iptables/xtables.c index 00c7c066..c4b1c2a8 100644 --- a/iptables/xtables.c +++ b/iptables/xtables.c @@ -15,6 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" #include #include #include @@ -32,7 +33,11 @@ #include #include #include -#include /* for PROC_SUPER_MAGIC */ +#if defined(HAVE_LINUX_MAGIC_H) +# include /* for PROC_SUPER_MAGIC */ +#elif defined(HAVE_LINUX_PROC_FS_H) +# include /* Linux 2.4 */ +#endif #include #include /* INT_MAX in ip_tables.h/ip6_tables.h */ -- cgit v1.2.3 From 358650c0e280dad8c1292efbf856ac310004a52b Mon Sep 17 00:00:00 2001 From: "Martin F. Krafft" Date: Tue, 22 Sep 2009 21:07:13 +0200 Subject: iptables-apply: select default rule file depending on call name ip6tables-apply points to iptables-apply (which is good). Since iptables/ip6tables rule files are different, the reporter suggests that the DEFAULT_FILE variable should depend on whether iptables-apply or ip6tables-apply is run. References: http://bugs.debian.org/547734 Signed-off-by: Jan Engelhardt --- iptables/iptables-apply | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/iptables/iptables-apply b/iptables/iptables-apply index 5fec76b0..86b8d5a2 100755 --- a/iptables/iptables-apply +++ b/iptables/iptables-apply @@ -11,7 +11,6 @@ PROGNAME="${0##*/}"; VERSION=1.0 TIMEOUT=10 -DEFAULT_FILE=/etc/network/iptables function blurb() { @@ -87,6 +86,19 @@ for opt in $OPTS; do shift done +case "$PROGNAME" in + (*6*) + SAVE=ip6tables-save + RESTORE=ip6tables-restore + DEFAULT_FILE=/etc/network/ip6tables + ;; + (*) + SAVE=iptables-save + RESTORE=iptables-restore + DEFAULT_FILE=/etc/network/iptables + ;; +esac + FILE="${1:-$DEFAULT_FILE}"; if [[ -z "$FILE" ]]; then @@ -99,17 +111,6 @@ if [[ ! -r "$FILE" ]]; then exit 2 fi -case "${0##*/}" in - (*6*) - SAVE=ip6tables-save - RESTORE=ip6tables-restore - ;; - (*) - SAVE=iptables-save - RESTORE=iptables-restore - ;; -esac - COMMANDS=(tempfile "$SAVE" "$RESTORE") for cmd in "${COMMANDS[@]}"; do -- cgit v1.2.3 From 1c9508e1f3f853f33683eb7118e19b193a6c80b7 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 30 Jun 2011 13:19:15 +0200 Subject: doc: mention multiple verbosity flags "-vv" can be used to further increase the verbosity level. Document this. References: http://bugs.debian.org/616037 Signed-off-by: Jan Engelhardt --- iptables/ip6tables.8.in | 3 ++- iptables/iptables.8.in | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/iptables/ip6tables.8.in b/iptables/ip6tables.8.in index 48ba18e1..20e271de 100644 --- a/iptables/ip6tables.8.in +++ b/iptables/ip6tables.8.in @@ -333,7 +333,8 @@ byte counters are also listed, with the suffix 'K', 'M' or 'G' for 1000, 1,000,000 and 1,000,000,000 multipliers respectively (but see the \fB\-x\fP flag to change this). For appending, insertion, deletion and replacement, this causes -detailed information on the rule or rules to be printed. +detailed information on the rule or rules to be printed. \fB\-v\fP may be +specified multiple times to possibly emit more detailed debug statements. .TP \fB\-n\fP, \fB\-\-numeric\fP Numeric output. diff --git a/iptables/iptables.8.in b/iptables/iptables.8.in index d09bf7aa..3b717a11 100644 --- a/iptables/iptables.8.in +++ b/iptables/iptables.8.in @@ -332,7 +332,8 @@ byte counters are also listed, with the suffix 'K', 'M' or 'G' for 1000, 1,000,000 and 1,000,000,000 multipliers respectively (but see the \fB\-x\fP flag to change this). For appending, insertion, deletion and replacement, this causes -detailed information on the rule or rules to be printed. +detailed information on the rule or rules to be printed. \fB\-v\fP may be +specified multiple times to possibly emit more detailed debug statements. .TP \fB\-n\fP, \fB\-\-numeric\fP Numeric output. -- cgit v1.2.3