diff options
author | Patrick McHardy <kaber@trash.net> | 2010-02-10 09:38:33 -0500 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2010-02-10 09:38:33 -0500 |
commit | d0b0268fddea3235a8df35e52167c3b206bf2f5a (patch) | |
tree | 16669d6e575b919b792c1cffc34015ffbed091c1 /net/netfilter | |
parent | 42107f5009da223daa800d6da6904d77297ae829 (diff) |
netfilter: ctnetlink: add missing netlink attribute policies
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 327c5174440..5c103b8c7df 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -708,6 +708,11 @@ ctnetlink_parse_tuple_proto(struct nlattr *attr, | |||
708 | return ret; | 708 | return ret; |
709 | } | 709 | } |
710 | 710 | ||
711 | static const struct nla_policy tuple_nla_policy[CTA_TUPLE_MAX+1] = { | ||
712 | [CTA_TUPLE_IP] = { .type = NLA_NESTED }, | ||
713 | [CTA_TUPLE_PROTO] = { .type = NLA_NESTED }, | ||
714 | }; | ||
715 | |||
711 | static int | 716 | static int |
712 | ctnetlink_parse_tuple(const struct nlattr * const cda[], | 717 | ctnetlink_parse_tuple(const struct nlattr * const cda[], |
713 | struct nf_conntrack_tuple *tuple, | 718 | struct nf_conntrack_tuple *tuple, |
@@ -718,7 +723,7 @@ ctnetlink_parse_tuple(const struct nlattr * const cda[], | |||
718 | 723 | ||
719 | memset(tuple, 0, sizeof(*tuple)); | 724 | memset(tuple, 0, sizeof(*tuple)); |
720 | 725 | ||
721 | nla_parse_nested(tb, CTA_TUPLE_MAX, cda[type], NULL); | 726 | nla_parse_nested(tb, CTA_TUPLE_MAX, cda[type], tuple_nla_policy); |
722 | 727 | ||
723 | if (!tb[CTA_TUPLE_IP]) | 728 | if (!tb[CTA_TUPLE_IP]) |
724 | return -EINVAL; | 729 | return -EINVAL; |
@@ -745,12 +750,16 @@ ctnetlink_parse_tuple(const struct nlattr * const cda[], | |||
745 | return 0; | 750 | return 0; |
746 | } | 751 | } |
747 | 752 | ||
753 | static const struct nla_policy help_nla_policy[CTA_HELP_MAX+1] = { | ||
754 | [CTA_HELP_NAME] = { .type = NLA_NUL_STRING }, | ||
755 | }; | ||
756 | |||
748 | static inline int | 757 | static inline int |
749 | ctnetlink_parse_help(const struct nlattr *attr, char **helper_name) | 758 | ctnetlink_parse_help(const struct nlattr *attr, char **helper_name) |
750 | { | 759 | { |
751 | struct nlattr *tb[CTA_HELP_MAX+1]; | 760 | struct nlattr *tb[CTA_HELP_MAX+1]; |
752 | 761 | ||
753 | nla_parse_nested(tb, CTA_HELP_MAX, attr, NULL); | 762 | nla_parse_nested(tb, CTA_HELP_MAX, attr, help_nla_policy); |
754 | 763 | ||
755 | if (!tb[CTA_HELP_NAME]) | 764 | if (!tb[CTA_HELP_NAME]) |
756 | return -EINVAL; | 765 | return -EINVAL; |
@@ -761,11 +770,17 @@ ctnetlink_parse_help(const struct nlattr *attr, char **helper_name) | |||
761 | } | 770 | } |
762 | 771 | ||
763 | static const struct nla_policy ct_nla_policy[CTA_MAX+1] = { | 772 | static const struct nla_policy ct_nla_policy[CTA_MAX+1] = { |
773 | [CTA_TUPLE_ORIG] = { .type = NLA_NESTED }, | ||
774 | [CTA_TUPLE_REPLY] = { .type = NLA_NESTED }, | ||
764 | [CTA_STATUS] = { .type = NLA_U32 }, | 775 | [CTA_STATUS] = { .type = NLA_U32 }, |
776 | [CTA_PROTOINFO] = { .type = NLA_NESTED }, | ||
777 | [CTA_HELP] = { .type = NLA_NESTED }, | ||
778 | [CTA_NAT_SRC] = { .type = NLA_NESTED }, | ||
765 | [CTA_TIMEOUT] = { .type = NLA_U32 }, | 779 | [CTA_TIMEOUT] = { .type = NLA_U32 }, |
766 | [CTA_MARK] = { .type = NLA_U32 }, | 780 | [CTA_MARK] = { .type = NLA_U32 }, |
767 | [CTA_USE] = { .type = NLA_U32 }, | ||
768 | [CTA_ID] = { .type = NLA_U32 }, | 781 | [CTA_ID] = { .type = NLA_U32 }, |
782 | [CTA_NAT_DST] = { .type = NLA_NESTED }, | ||
783 | [CTA_TUPLE_MASTER] = { .type = NLA_NESTED }, | ||
769 | }; | 784 | }; |
770 | 785 | ||
771 | static int | 786 | static int |
@@ -1053,6 +1068,12 @@ ctnetlink_change_timeout(struct nf_conn *ct, const struct nlattr * const cda[]) | |||
1053 | return 0; | 1068 | return 0; |
1054 | } | 1069 | } |
1055 | 1070 | ||
1071 | static const struct nla_policy protoinfo_policy[CTA_PROTOINFO_MAX+1] = { | ||
1072 | [CTA_PROTOINFO_TCP] = { .type = NLA_NESTED }, | ||
1073 | [CTA_PROTOINFO_DCCP] = { .type = NLA_NESTED }, | ||
1074 | [CTA_PROTOINFO_SCTP] = { .type = NLA_NESTED }, | ||
1075 | }; | ||
1076 | |||
1056 | static inline int | 1077 | static inline int |
1057 | ctnetlink_change_protoinfo(struct nf_conn *ct, const struct nlattr * const cda[]) | 1078 | ctnetlink_change_protoinfo(struct nf_conn *ct, const struct nlattr * const cda[]) |
1058 | { | 1079 | { |
@@ -1061,7 +1082,7 @@ ctnetlink_change_protoinfo(struct nf_conn *ct, const struct nlattr * const cda[] | |||
1061 | struct nf_conntrack_l4proto *l4proto; | 1082 | struct nf_conntrack_l4proto *l4proto; |
1062 | int err = 0; | 1083 | int err = 0; |
1063 | 1084 | ||
1064 | nla_parse_nested(tb, CTA_PROTOINFO_MAX, attr, NULL); | 1085 | nla_parse_nested(tb, CTA_PROTOINFO_MAX, attr, protoinfo_policy); |
1065 | 1086 | ||
1066 | rcu_read_lock(); | 1087 | rcu_read_lock(); |
1067 | l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct)); | 1088 | l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct)); |
@@ -1073,12 +1094,18 @@ ctnetlink_change_protoinfo(struct nf_conn *ct, const struct nlattr * const cda[] | |||
1073 | } | 1094 | } |
1074 | 1095 | ||
1075 | #ifdef CONFIG_NF_NAT_NEEDED | 1096 | #ifdef CONFIG_NF_NAT_NEEDED |
1097 | static const struct nla_policy nat_seq_policy[CTA_NAT_SEQ_MAX+1] = { | ||
1098 | [CTA_NAT_SEQ_CORRECTION_POS] = { .type = NLA_U32 }, | ||
1099 | [CTA_NAT_SEQ_OFFSET_BEFORE] = { .type = NLA_U32 }, | ||
1100 | [CTA_NAT_SEQ_OFFSET_AFTER] = { .type = NLA_U32 }, | ||
1101 | }; | ||
1102 | |||
1076 | static inline int | 1103 | static inline int |
1077 | change_nat_seq_adj(struct nf_nat_seq *natseq, const struct nlattr * const attr) | 1104 | change_nat_seq_adj(struct nf_nat_seq *natseq, const struct nlattr * const attr) |
1078 | { | 1105 | { |
1079 | struct nlattr *cda[CTA_NAT_SEQ_MAX+1]; | 1106 | struct nlattr *cda[CTA_NAT_SEQ_MAX+1]; |
1080 | 1107 | ||
1081 | nla_parse_nested(cda, CTA_NAT_SEQ_MAX, attr, NULL); | 1108 | nla_parse_nested(cda, CTA_NAT_SEQ_MAX, attr, nat_seq_policy); |
1082 | 1109 | ||
1083 | if (!cda[CTA_NAT_SEQ_CORRECTION_POS]) | 1110 | if (!cda[CTA_NAT_SEQ_CORRECTION_POS]) |
1084 | return -EINVAL; | 1111 | return -EINVAL; |
@@ -1648,8 +1675,12 @@ out: | |||
1648 | } | 1675 | } |
1649 | 1676 | ||
1650 | static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = { | 1677 | static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = { |
1678 | [CTA_EXPECT_MASTER] = { .type = NLA_NESTED }, | ||
1679 | [CTA_EXPECT_TUPLE] = { .type = NLA_NESTED }, | ||
1680 | [CTA_EXPECT_MASK] = { .type = NLA_NESTED }, | ||
1651 | [CTA_EXPECT_TIMEOUT] = { .type = NLA_U32 }, | 1681 | [CTA_EXPECT_TIMEOUT] = { .type = NLA_U32 }, |
1652 | [CTA_EXPECT_ID] = { .type = NLA_U32 }, | 1682 | [CTA_EXPECT_ID] = { .type = NLA_U32 }, |
1683 | [CTA_EXPECT_HELP_NAME] = { .type = NLA_NUL_STRING }, | ||
1653 | }; | 1684 | }; |
1654 | 1685 | ||
1655 | static int | 1686 | static int |