svn commit: r271056 - projects/ipfw/sys/netpfil/ipfw
Alexander V. Chernikov
melifaro at FreeBSD.org
Wed Sep 3 21:57:07 UTC 2014
Author: melifaro
Date: Wed Sep 3 21:57:06 2014
New Revision: 271056
URL: http://svnweb.freebsd.org/changeset/base/271056
Log:
Be consistent and use same arguments for ctl3 opcodes.
Move legacy IP_FW_TABLE_XGETSIZE handling to separate function.
Modified:
projects/ipfw/sys/netpfil/ipfw/ip_fw_iface.c
projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h
projects/ipfw/sys/netpfil/ipfw/ip_fw_sockopt.c
projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c
projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h
Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_iface.c
==============================================================================
--- projects/ipfw/sys/netpfil/ipfw/ip_fw_iface.c Wed Sep 3 21:45:39 2014 (r271055)
+++ projects/ipfw/sys/netpfil/ipfw/ip_fw_iface.c Wed Sep 3 21:57:06 2014 (r271056)
@@ -484,7 +484,8 @@ export_iface_internal(struct namedobj_in
* Returns 0 on success
*/
int
-ipfw_list_ifaces(struct ip_fw_chain *ch, struct sockopt_data *sd)
+ipfw_list_ifaces(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
+ struct sockopt_data *sd)
{
struct namedobj_instance *ii;
struct _ipfw_obj_lheader *olh;
Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h
==============================================================================
--- projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h Wed Sep 3 21:45:39 2014 (r271055)
+++ projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h Wed Sep 3 21:57:06 2014 (r271056)
@@ -520,7 +520,8 @@ int ipfw_iface_ref(struct ip_fw_chain *c
void ipfw_iface_unref(struct ip_fw_chain *ch, struct ipfw_ifc *ic);
void ipfw_iface_add_notify(struct ip_fw_chain *ch, struct ipfw_ifc *ic);
void ipfw_iface_del_notify(struct ip_fw_chain *ch, struct ipfw_ifc *ic);
-int ipfw_list_ifaces(struct ip_fw_chain *ch, struct sockopt_data *sd);
+int ipfw_list_ifaces(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
+ struct sockopt_data *sd);
/* In ip_fw_sockopt.c */
void ipfw_init_skipto_cache(struct ip_fw_chain *chain);
Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_sockopt.c
==============================================================================
--- projects/ipfw/sys/netpfil/ipfw/ip_fw_sockopt.c Wed Sep 3 21:45:39 2014 (r271055)
+++ projects/ipfw/sys/netpfil/ipfw/ip_fw_sockopt.c Wed Sep 3 21:57:06 2014 (r271056)
@@ -1926,7 +1926,8 @@ dump_static_rules(struct ip_fw_chain *ch
* Returns 0 on success.
*/
static int
-dump_config(struct ip_fw_chain *chain, struct sockopt_data *sd)
+dump_config(struct ip_fw_chain *chain, ip_fw3_opheader *op3,
+ struct sockopt_data *sd)
{
ipfw_cfg_lheader *hdr;
struct ip_fw *rule;
@@ -2436,7 +2437,7 @@ ipfw_ctl3(struct sockopt *sopt)
switch (opt) {
case IP_FW_XGET:
- error = dump_config(chain, &sdata);
+ error = dump_config(chain, op3, &sdata);
break;
case IP_FW_XADD:
@@ -2463,7 +2464,7 @@ ipfw_ctl3(struct sockopt *sopt)
break;
case IP_FW_XIFLIST:
- error = ipfw_list_ifaces(chain, &sdata);
+ error = ipfw_list_ifaces(chain, op3, &sdata);
break;
/*--- TABLE opcodes ---*/
@@ -2481,11 +2482,11 @@ ipfw_ctl3(struct sockopt *sopt)
break;
case IP_FW_TABLE_XINFO:
- error = ipfw_describe_table(chain, &sdata);
+ error = ipfw_describe_table(chain, op3, &sdata);
break;
case IP_FW_TABLES_XLIST:
- error = ipfw_list_tables(chain, &sdata);
+ error = ipfw_list_tables(chain, op3, &sdata);
break;
case IP_FW_TABLE_XLIST:
@@ -2506,7 +2507,7 @@ ipfw_ctl3(struct sockopt *sopt)
break;
case IP_FW_TABLES_ALIST:
- error = ipfw_list_table_algo(chain, &sdata);
+ error = ipfw_list_table_algo(chain, op3, &sdata);
break;
case IP_FW_TABLE_VLIST:
@@ -2514,26 +2515,7 @@ ipfw_ctl3(struct sockopt *sopt)
break;
case IP_FW_TABLE_XGETSIZE:
- {
- uint32_t *tbl;
- struct tid_info ti;
-
- if (IP_FW3_OPLENGTH(sopt) < sizeof(uint32_t)) {
- error = EINVAL;
- break;
- }
-
- tbl = (uint32_t *)(op3 + 1);
-
- memset(&ti, 0, sizeof(ti));
- ti.uidx = *tbl;
- IPFW_UH_RLOCK(chain);
- error = ipfw_count_xtable(chain, &ti, tbl);
- IPFW_UH_RUNLOCK(chain);
- if (error)
- break;
- error = sooptcopyout(sopt, op3, sopt->sopt_valsize);
- }
+ error = ipfw_get_table_size(chain, op3, &sdata);
break;
default:
Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c
==============================================================================
--- projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c Wed Sep 3 21:45:39 2014 (r271055)
+++ projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c Wed Sep 3 21:57:06 2014 (r271056)
@@ -1754,7 +1754,8 @@ ipfw_lookup_table_extended(struct ip_fw_
* Returns 0 on success
*/
int
-ipfw_list_tables(struct ip_fw_chain *ch, struct sockopt_data *sd)
+ipfw_list_tables(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
+ struct sockopt_data *sd)
{
struct _ipfw_obj_lheader *olh;
int error;
@@ -1781,7 +1782,8 @@ ipfw_list_tables(struct ip_fw_chain *ch,
* Returns 0 on success.
*/
int
-ipfw_describe_table(struct ip_fw_chain *ch, struct sockopt_data *sd)
+ipfw_describe_table(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
+ struct sockopt_data *sd)
{
struct _ipfw_obj_header *oh;
struct table_config *tc;
@@ -2390,6 +2392,32 @@ ipfw_dump_table_v0(struct ip_fw_chain *c
}
/*
+ * Legacy function to retrieve number of items in table.
+ */
+int
+ipfw_get_table_size(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
+ struct sockopt_data *sd)
+{
+ uint32_t *tbl;
+ struct tid_info ti;
+ size_t sz;
+ int error;
+
+ sz = sizeof(*op3) + sizeof(uint32_t);
+ op3 = (ip_fw3_opheader *)ipfw_get_sopt_header(sd, sz);
+ if (op3 == NULL)
+ return (EINVAL);
+
+ tbl = (uint32_t *)(op3 + 1);
+ memset(&ti, 0, sizeof(ti));
+ ti.uidx = *tbl;
+ IPFW_UH_RLOCK(ch);
+ error = ipfw_count_xtable(ch, &ti, tbl);
+ IPFW_UH_RUNLOCK(ch);
+ return (error);
+}
+
+/*
* Legacy IP_FW_TABLE_GETSIZE handler
*/
int
@@ -2773,7 +2801,8 @@ ipfw_del_table_algo(struct ip_fw_chain *
* Returns 0 on success
*/
int
-ipfw_list_table_algo(struct ip_fw_chain *ch, struct sockopt_data *sd)
+ipfw_list_table_algo(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
+ struct sockopt_data *sd)
{
struct _ipfw_obj_lheader *olh;
struct tables_config *tcfg;
Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h
==============================================================================
--- projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h Wed Sep 3 21:45:39 2014 (r271055)
+++ projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h Wed Sep 3 21:57:06 2014 (r271056)
@@ -163,10 +163,12 @@ void ipfw_table_algo_destroy(struct ip_f
/* direct ipfw_ctl handlers */
-int ipfw_list_tables(struct ip_fw_chain *ch, struct sockopt_data *sd);
+int ipfw_list_tables(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
+ struct sockopt_data *sd);
int ipfw_dump_table(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
struct sockopt_data *sd);
-int ipfw_describe_table(struct ip_fw_chain *ch, struct sockopt_data *sd);
+int ipfw_describe_table(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
+ struct sockopt_data *sd);
int ipfw_find_table_entry(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
struct sockopt_data *sd);
@@ -178,7 +180,8 @@ int ipfw_manage_table_ent(struct ip_fw_c
struct sockopt_data *sd);
int ipfw_flush_table(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
struct sockopt_data *sd);
-int ipfw_list_table_algo(struct ip_fw_chain *ch, struct sockopt_data *sd);
+int ipfw_list_table_algo(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
+ struct sockopt_data *sd);
int ipfw_swap_table(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
struct sockopt_data *sd);
/* Exported to support legacy opcodes */
@@ -189,6 +192,8 @@ int del_table_entry(struct ip_fw_chain *
int flush_table(struct ip_fw_chain *ch, struct tid_info *ti);
void ipfw_import_table_value_legacy(uint32_t value, struct table_value *v);
uint32_t ipfw_export_table_value_legacy(struct table_value *v);
+int ipfw_get_table_size(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
+ struct sockopt_data *sd);
/* ipfw_table_value.c functions */
int ipfw_list_table_values(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
More information about the svn-src-projects
mailing list