aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-12-18 01:26:24 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:58:47 -0500
commit41acd975b954ad6ec4943d77e5920f2eeaf54518 (patch)
tree9b7572b6bb264dc4130b974bed52f01b400e49c9 /net
parent27e2c26b85b6b234411d94127201436c1ec9c002 (diff)
[NETFILTER]: arp_tables: move ARPT_SO_GET_INFO handling to seperate function
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/netfilter/arp_tables.c88
1 files changed, 46 insertions, 42 deletions
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index eaca06eace03..33e8d53eebf8 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -782,6 +782,49 @@ static int copy_entries_to_user(unsigned int total_size,
782 return ret; 782 return ret;
783} 783}
784 784
785static int get_info(void __user *user, int *len)
786{
787 char name[ARPT_TABLE_MAXNAMELEN];
788 struct arpt_table *t;
789 int ret;
790
791 if (*len != sizeof(struct arpt_getinfo)) {
792 duprintf("length %u != %Zu\n", *len,
793 sizeof(struct arpt_getinfo));
794 return -EINVAL;
795 }
796
797 if (copy_from_user(name, user, sizeof(name)) != 0)
798 return -EFAULT;
799
800 name[ARPT_TABLE_MAXNAMELEN-1] = '\0';
801
802 t = try_then_request_module(xt_find_table_lock(NF_ARP, name),
803 "arptable_%s", name);
804 if (t && !IS_ERR(t)) {
805 struct arpt_getinfo info;
806 struct xt_table_info *private = t->private;
807
808 info.valid_hooks = t->valid_hooks;
809 memcpy(info.hook_entry, private->hook_entry,
810 sizeof(info.hook_entry));
811 memcpy(info.underflow, private->underflow,
812 sizeof(info.underflow));
813 info.num_entries = private->number;
814 info.size = private->size;
815 strcpy(info.name, name);
816
817 if (copy_to_user(user, &info, *len) != 0)
818 ret = -EFAULT;
819 else
820 ret = 0;
821 xt_table_unlock(t);
822 module_put(t->me);
823 } else
824 ret = t ? PTR_ERR(t) : -ENOENT;
825 return ret;
826}
827
785static int get_entries(const struct arpt_get_entries *entries, 828static int get_entries(const struct arpt_get_entries *entries,
786 struct arpt_get_entries __user *uptr) 829 struct arpt_get_entries __user *uptr)
787{ 830{
@@ -1008,48 +1051,9 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
1008 return -EPERM; 1051 return -EPERM;
1009 1052
1010 switch (cmd) { 1053 switch (cmd) {
1011 case ARPT_SO_GET_INFO: { 1054 case ARPT_SO_GET_INFO:
1012 char name[ARPT_TABLE_MAXNAMELEN]; 1055 ret = get_info(user, len);
1013 struct arpt_table *t; 1056 break;
1014
1015 if (*len != sizeof(struct arpt_getinfo)) {
1016 duprintf("length %u != %Zu\n", *len,
1017 sizeof(struct arpt_getinfo));
1018 ret = -EINVAL;
1019 break;
1020 }
1021
1022 if (copy_from_user(name, user, sizeof(name)) != 0) {
1023 ret = -EFAULT;
1024 break;
1025 }
1026 name[ARPT_TABLE_MAXNAMELEN-1] = '\0';
1027
1028 t = try_then_request_module(xt_find_table_lock(NF_ARP, name),
1029 "arptable_%s", name);
1030 if (t && !IS_ERR(t)) {
1031 struct arpt_getinfo info;
1032 struct xt_table_info *private = t->private;
1033
1034 info.valid_hooks = t->valid_hooks;
1035 memcpy(info.hook_entry, private->hook_entry,
1036 sizeof(info.hook_entry));
1037 memcpy(info.underflow, private->underflow,
1038 sizeof(info.underflow));
1039 info.num_entries = private->number;
1040 info.size = private->size;
1041 strcpy(info.name, name);
1042
1043 if (copy_to_user(user, &info, *len) != 0)
1044 ret = -EFAULT;
1045 else
1046 ret = 0;
1047 xt_table_unlock(t);
1048 module_put(t->me);
1049 } else
1050 ret = t ? PTR_ERR(t) : -ENOENT;
1051 }
1052 break;
1053 1057
1054 case ARPT_SO_GET_ENTRIES: { 1058 case ARPT_SO_GET_ENTRIES: {
1055 struct arpt_get_entries get; 1059 struct arpt_get_entries get;