iproute2: act_ipt fix xtables breakage
Fixes breakage with xtables API starting with version 1.4.10 Signed-off-by: Hasan Chowdhury <shemonc@gmail.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
This commit is contained in:
parent
55eaaeb57a
commit
852d51222d
63
tc/m_xt.c
63
tc/m_xt.c
|
|
@ -118,6 +118,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
struct xtables_target *m = NULL;
|
struct xtables_target *m = NULL;
|
||||||
struct ipt_entry fw;
|
struct ipt_entry fw;
|
||||||
struct rtattr *tail;
|
struct rtattr *tail;
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
int rargc = *argc_p;
|
int rargc = *argc_p;
|
||||||
char **argv = *argv_p;
|
char **argv = *argv_p;
|
||||||
|
|
@ -126,6 +127,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
int size = 0;
|
int size = 0;
|
||||||
int iok = 0, ok = 0;
|
int iok = 0, ok = 0;
|
||||||
__u32 hook = 0, index = 0;
|
__u32 hook = 0, index = 0;
|
||||||
|
struct option *opts = NULL;
|
||||||
|
|
||||||
xtables_init_all(&tcipt_globals, NFPROTO_IPV4);
|
xtables_init_all(&tcipt_globals, NFPROTO_IPV4);
|
||||||
set_lib_dir();
|
set_lib_dir();
|
||||||
|
|
@ -158,14 +160,22 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
printf(" %s error \n", m->name);
|
printf(" %s error \n", m->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tcipt_globals.opts =
|
|
||||||
xtables_merge_options(
|
|
||||||
#if (XTABLES_VERSION_CODE >= 6)
|
#if (XTABLES_VERSION_CODE >= 6)
|
||||||
tcipt_globals.orig_opts,
|
opts = xtables_options_xfrm(tcipt_globals.orig_opts,
|
||||||
|
tcipt_globals.opts,
|
||||||
|
m->x6_options,
|
||||||
|
&m->option_offset);
|
||||||
|
#else
|
||||||
|
opts = xtables_merge_options(tcipt_globals.orig_opts,
|
||||||
|
tcipt_globals.opts,
|
||||||
|
m->extra_opts,
|
||||||
|
&m->option_offset);
|
||||||
#endif
|
#endif
|
||||||
tcipt_globals.opts,
|
if (opts == NULL) {
|
||||||
m->extra_opts,
|
fprintf(stderr, " failed to find aditional options for target %s\n\n", optarg);
|
||||||
&m->option_offset);
|
return -1;
|
||||||
|
} else
|
||||||
|
tcipt_globals.opts = opts;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr," failed to find target %s\n\n", optarg);
|
fprintf(stderr," failed to find target %s\n\n", optarg);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -175,17 +185,21 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
|
|
||||||
default:
|
default:
|
||||||
memset(&fw, 0, sizeof (fw));
|
memset(&fw, 0, sizeof (fw));
|
||||||
if (m) {
|
#if (XTABLES_VERSION_CODE >= 6)
|
||||||
m->parse(c - m->option_offset, argv, 0,
|
if (m != NULL && m->x6_parse != NULL ) {
|
||||||
&m->tflags, NULL, &m->t);
|
xtables_option_tpcall(c, argv, 0 , m, NULL);
|
||||||
|
#else
|
||||||
|
if (m != NULL && m->parse != NULL ) {
|
||||||
|
m->parse(c - m->option_offset, argv, 0, &m->tflags,
|
||||||
|
NULL, &m->t);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr," failed to find target %s\n\n", optarg);
|
fprintf(stderr,"failed to find target %s\n\n", optarg);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
ok++;
|
ok++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,8 +222,13 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check that we passed the correct parameters to the target */
|
/* check that we passed the correct parameters to the target */
|
||||||
|
#if (XTABLES_VERSION_CODE >= 6)
|
||||||
|
if (m)
|
||||||
|
xtables_option_tfcall(m);
|
||||||
|
#else
|
||||||
if (m && m->final_check)
|
if (m && m->final_check)
|
||||||
m->final_check(m->tflags);
|
m->final_check(m->tflags);
|
||||||
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
struct tcmsg *t = NLMSG_DATA(n);
|
struct tcmsg *t = NLMSG_DATA(n);
|
||||||
|
|
@ -271,6 +290,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
{
|
{
|
||||||
struct rtattr *tb[TCA_IPT_MAX + 1];
|
struct rtattr *tb[TCA_IPT_MAX + 1];
|
||||||
struct xt_entry_target *t = NULL;
|
struct xt_entry_target *t = NULL;
|
||||||
|
struct option *opts = NULL;
|
||||||
|
|
||||||
if (arg == NULL)
|
if (arg == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -309,14 +329,22 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcipt_globals.opts =
|
|
||||||
xtables_merge_options(
|
|
||||||
#if (XTABLES_VERSION_CODE >= 6)
|
#if (XTABLES_VERSION_CODE >= 6)
|
||||||
tcipt_globals.orig_opts,
|
opts = xtables_options_xfrm(tcipt_globals.orig_opts,
|
||||||
|
tcipt_globals.opts,
|
||||||
|
m->x6_options,
|
||||||
|
&m->option_offset);
|
||||||
|
#else
|
||||||
|
opts = xtables_merge_options(tcipt_globals.orig_opts,
|
||||||
|
tcipt_globals.opts,
|
||||||
|
m->extra_opts,
|
||||||
|
&m->option_offset);
|
||||||
#endif
|
#endif
|
||||||
tcipt_globals.opts,
|
if (opts == NULL) {
|
||||||
m->extra_opts,
|
fprintf(stderr, " failed to find aditional options for target %s\n\n", optarg);
|
||||||
&m->option_offset);
|
return -1;
|
||||||
|
} else
|
||||||
|
tcipt_globals.opts = opts;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, " failed to find target %s\n\n",
|
fprintf(stderr, " failed to find target %s\n\n",
|
||||||
t->u.user.name);
|
t->u.user.name);
|
||||||
|
|
@ -355,4 +383,3 @@ struct action_util xt_action_util = {
|
||||||
.parse_aopt = parse_ipt,
|
.parse_aopt = parse_ipt,
|
||||||
.print_aopt = print_ipt,
|
.print_aopt = print_ipt,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue