From d3bec59eb93a64e803307b9a2ce0b7aad9be5555 Mon Sep 17 00:00:00 2001 From: Rich Fought Date: Tue, 9 Oct 2012 15:16:00 -0700 Subject: [PATCH] bugfixes --- include/netlink/cli/exp.h | 1 + lib/netfilter/exp.c | 8 ++++---- lib/netfilter/exp_obj.c | 12 +++++++----- src/lib/exp.c | 6 ++++++ src/nf-exp-list.c | 4 ++++ 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/netlink/cli/exp.h b/include/netlink/cli/exp.h index 94609d7..cbe9649 100644 --- a/include/netlink/cli/exp.h +++ b/include/netlink/cli/exp.h @@ -21,6 +21,7 @@ extern struct nl_cache *nl_cli_exp_alloc_cache(struct nl_sock *); extern void nl_cli_exp_parse_family(struct nfnl_exp *, char *); extern void nl_cli_exp_parse_timeout(struct nfnl_exp *, char *); extern void nl_cli_exp_parse_id(struct nfnl_exp *, char *); +extern void nl_cli_exp_parse_helper_name(struct nfnl_exp *, char *); extern void nl_cli_exp_parse_src(struct nfnl_exp *, int, char *); extern void nl_cli_exp_parse_dst(struct nfnl_exp *, int, char *); extern void nl_cli_exp_parse_l4protonum(struct nfnl_exp *, int, char *); diff --git a/lib/netfilter/exp.c b/lib/netfilter/exp.c index c6479f6..dbdc278 100644 --- a/lib/netfilter/exp.c +++ b/lib/netfilter/exp.c @@ -505,8 +505,8 @@ static struct nl_af_group exp_groups[] = { #define NFNLMSG_EXP_TYPE(type) NFNLMSG_TYPE(NFNL_SUBSYS_CTNETLINK_EXP, (type)) static struct nl_cache_ops nfnl_exp_ops = { - .co_name = "netfilter/exp", - .co_hdrsize = NFNL_HDRLEN, + .co_name = "netfilter/exp", + .co_hdrsize = NFNL_HDRLEN, .co_msgtypes = { { NFNLMSG_EXP_TYPE(IPCTNL_MSG_EXP_NEW), NL_ACT_NEW, "new" }, { NFNLMSG_EXP_TYPE(IPCTNL_MSG_EXP_GET), NL_ACT_GET, "get" }, @@ -514,10 +514,10 @@ static struct nl_cache_ops nfnl_exp_ops = { END_OF_MSGTYPES_LIST, }, .co_protocol = NETLINK_NETFILTER, - .co_groups = exp_groups, + .co_groups = exp_groups, .co_request_update = exp_request_update, .co_msg_parser = exp_msg_parser, - .co_obj_ops = &exp_obj_ops, + .co_obj_ops = &exp_obj_ops, }; static void __init exp_init(void) diff --git a/lib/netfilter/exp_obj.c b/lib/netfilter/exp_obj.c index 41ac214..61b12e1 100644 --- a/lib/netfilter/exp_obj.c +++ b/lib/netfilter/exp_obj.c @@ -58,7 +58,6 @@ #define EXP_ATTR_NAT_L4PROTO_NUM (1UL << 25) // contains l4proto # + PORT attrs or ICMP attrs #define EXP_ATTR_NAT_L4PROTO_PORTS (1UL << 26) #define EXP_ATTR_NAT_L4PROTO_ICMP (1UL << 27) - #define EXP_ATTR_NAT_DIR (1UL << 28) // 8-bit /** @endcond */ @@ -184,14 +183,16 @@ static void dump_icmp(struct nl_dump_params *p, struct nfnl_exp *exp, int tuple) static void exp_dump_tuples(struct nfnl_exp *exp, struct nl_dump_params *p) { - struct nl_addr *tuple_src = NULL, *tuple_dst = NULL; + struct nl_addr *tuple_src, *tuple_dst; int tuple_sport = 0, tuple_dport = 0; int i = 0; char buf[64]; for (i = NFNL_EXP_TUPLE_EXPECT; i <= NFNL_EXP_TUPLE_NAT; i++) { + tuple_src = NULL; + tuple_dst = NULL; - // Test needed for NAT case + // Test needed for NAT case if (nfnl_exp_test_src(exp, i)) tuple_src = nfnl_exp_get_src(exp, i); if (nfnl_exp_test_dst(exp, i)) @@ -207,6 +208,7 @@ static void exp_dump_tuples(struct nfnl_exp *exp, struct nl_dump_params *p) tuple_sport = nfnl_exp_get_src_port(exp, i); tuple_dport = nfnl_exp_get_dst_port(exp, i); } + dump_addr(p, tuple_src, tuple_sport); dump_addr(p, tuple_dst, tuple_dport); dump_icmp(p, exp, 0); @@ -636,9 +638,9 @@ uint8_t nfnl_exp_get_nat_dir(const struct nfnl_exp *exp) #define EXP_GET_TUPLE(e, t) \ (t == NFNL_EXP_TUPLE_MASTER) ? \ &(e->exp_master) : \ - (t == NFNL_EXP_TUPLE_MASK) ?\ + (t == NFNL_EXP_TUPLE_MASK) ? \ &(e->exp_mask) : \ - (t == NFNL_EXP_TUPLE_NAT) ?\ + (t == NFNL_EXP_TUPLE_NAT) ? \ &(e->exp_nat) : &(exp->exp_expect) static int exp_get_src_attr(int tuple) diff --git a/src/lib/exp.c b/src/lib/exp.c index 01aae01..82820f9 100644 --- a/src/lib/exp.c +++ b/src/lib/exp.c @@ -59,6 +59,12 @@ void nl_cli_exp_parse_id(struct nfnl_exp *exp, char *arg) nfnl_exp_set_id(exp, id); } +void nl_cli_exp_parse_helper_name(struct nfnl_exp *exp, char *arg) +{ + int err; + nfnl_exp_set_helper_name(exp, arg); +} + void nl_cli_exp_parse_src(struct nfnl_exp *exp, int tuple, char *arg) { int err; diff --git a/src/nf-exp-list.c b/src/nf-exp-list.c index 5a29b4a..3bdb6c5 100644 --- a/src/nf-exp-list.c +++ b/src/nf-exp-list.c @@ -36,6 +36,7 @@ static void print_usage(void) " --master-dport=PORT Master conntrack destination port\n" " -F, --family=FAMILY Address family\n" " --timeout=NUM Timeout value\n" + " --helper=STRING Helper Name\n" //" --flags Flags\n" ); exit(0); @@ -69,6 +70,7 @@ int main(int argc, char *argv[]) ARG_MASTER_DST, ARG_MASTER_DPORT, ARG_TIMEOUT, + ARG_HELPER_NAME, //ARG_FLAGS, }; static struct option long_opts[] = { @@ -88,6 +90,7 @@ int main(int argc, char *argv[]) { "master-dport", 1, 0, ARG_MASTER_DPORT }, { "family", 1, 0, 'F' }, { "timeout", 1, 0, ARG_TIMEOUT }, + { "helper", 1, 0, ARG_HELPER_NAME }, //{ "flags", 1, 0, ARG_FLAGS}, { 0, 0, 0, 0 } }; @@ -116,6 +119,7 @@ int main(int argc, char *argv[]) case ARG_MASTER_DPORT: nl_cli_exp_parse_dst_port(exp, NFNL_EXP_TUPLE_MASTER, optarg); break; case 'F': nl_cli_exp_parse_family(exp, optarg); break; case ARG_TIMEOUT: nl_cli_exp_parse_timeout(exp, optarg); break; + case ARG_HELPER_NAME: nl_cli_exp_parse_helper_name(exp, optarg); break; //case ARG_FLAGS: nl_cli_exp_parse_flags(exp, optarg); break; } } -- 2.40.0