svn commit: r269227 - projects/ipfw/sys/netpfil/ipfw
Alexander V. Chernikov
melifaro at FreeBSD.org
Tue Jul 29 08:00:14 UTC 2014
Author: melifaro
Date: Tue Jul 29 08:00:13 2014
New Revision: 269227
URL: http://svnweb.freebsd.org/changeset/base/269227
Log:
* Change algorthm names to "type:algo" (e.g. "iface:array", "cidr:radix") format.
* Pass number of items changed in add/del hooks to permit adding/deleting
multiple values at once.
Modified:
projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c
projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h
projects/ipfw/sys/netpfil/ipfw/ip_fw_table_algo.c
Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c
==============================================================================
--- projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c Tue Jul 29 07:40:14 2014 (r269226)
+++ projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c Tue Jul 29 08:00:13 2014 (r269227)
@@ -139,6 +139,7 @@ add_table_entry(struct ip_fw_chain *ch,
struct namedobj_instance *ni;
uint16_t kidx;
int error;
+ uint32_t num;
uint64_t aflags;
char ta_buf[128];
@@ -222,16 +223,16 @@ add_table_entry(struct ip_fw_chain *ch,
/* We've got valid table in @tc. Let's add data */
kidx = tc->no.kidx;
ta = tc->ta;
+ num = 0;
IPFW_WLOCK(ch);
-
- error = ta->add(tc->astate, KIDX_TO_TI(ch, kidx), tei, &ta_buf, &aflags);
-
+ error = ta->add(tc->astate, KIDX_TO_TI(ch, kidx), tei, &ta_buf,
+ &aflags, &num);
IPFW_WUNLOCK(ch);
/* Update number of records. */
- if (error == 0 && (tei->flags & TEI_FLAGS_UPDATED) == 0)
- tc->count++;
+ if (error == 0)
+ tc->count += num;
tc->flags = aflags;
@@ -252,6 +253,7 @@ del_table_entry(struct ip_fw_chain *ch,
struct namedobj_instance *ni;
uint16_t kidx;
int error;
+ uint32_t num;
uint64_t aflags;
char ta_buf[128];
@@ -302,13 +304,15 @@ del_table_entry(struct ip_fw_chain *ch,
}
kidx = tc->no.kidx;
+ num = 0;
IPFW_WLOCK(ch);
- error = ta->del(tc->astate, KIDX_TO_TI(ch, kidx), tei, &ta_buf,&aflags);
+ error = ta->del(tc->astate, KIDX_TO_TI(ch, kidx), tei, &ta_buf,
+ &aflags, &num);
IPFW_WUNLOCK(ch);
if (error == 0)
- tc->count--;
+ tc->count -= num;
tc->flags = aflags;
IPFW_UH_WUNLOCK(ch);
Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h
==============================================================================
--- projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h Tue Jul 29 07:40:14 2014 (r269226)
+++ projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h Tue Jul 29 08:00:13 2014 (r269227)
@@ -70,9 +70,9 @@ typedef int (ta_prepare_add)(struct ip_f
typedef int (ta_prepare_del)(struct ip_fw_chain *ch, struct tentry_info *tei,
void *ta_buf);
typedef int (ta_add)(void *ta_state, struct table_info *ti,
- struct tentry_info *tei, void *ta_buf, uint64_t *pflags);
+ struct tentry_info *tei, void *ta_buf, uint64_t *pflags, uint32_t *pnum);
typedef int (ta_del)(void *ta_state, struct table_info *ti,
- struct tentry_info *tei, void *ta_buf, uint64_t *pflags);
+ struct tentry_info *tei, void *ta_buf, uint64_t *pflags, uint32_t *pnum);
typedef void (ta_flush_entry)(struct ip_fw_chain *ch, struct tentry_info *tei,
void *ta_buf);
Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_table_algo.c
==============================================================================
--- projects/ipfw/sys/netpfil/ipfw/ip_fw_table_algo.c Tue Jul 29 07:40:14 2014 (r269226)
+++ projects/ipfw/sys/netpfil/ipfw/ip_fw_table_algo.c Tue Jul 29 08:00:13 2014 (r269227)
@@ -365,8 +365,8 @@ ta_prepare_add_cidr(struct ip_fw_chain *
}
static int
-ta_add_cidr(void *ta_state, struct table_info *ti,
- struct tentry_info *tei, void *ta_buf, uint64_t *pflags)
+ta_add_cidr(void *ta_state, struct table_info *ti, struct tentry_info *tei,
+ void *ta_buf, uint64_t *pflags, uint32_t *pnum)
{
struct radix_node_head *rnh;
struct radix_node *rn;
@@ -408,11 +408,13 @@ ta_add_cidr(void *ta_state, struct table
/* Indicate that update has happened instead of addition */
tei->flags |= TEI_FLAGS_UPDATED;
+ *pnum = 0;
return (0);
}
tb->ent_ptr = NULL;
+ *pnum = 1;
return (0);
}
@@ -474,8 +476,8 @@ ta_prepare_del_cidr(struct ip_fw_chain *
}
static int
-ta_del_cidr(void *ta_state, struct table_info *ti,
- struct tentry_info *tei, void *ta_buf, uint64_t *pflags)
+ta_del_cidr(void *ta_state, struct table_info *ti, struct tentry_info *tei,
+ void *ta_buf, uint64_t *pflags, uint32_t *pnum)
{
struct radix_node_head *rnh;
struct radix_node *rn;
@@ -495,6 +497,8 @@ ta_del_cidr(void *ta_state, struct table
if (rn == NULL)
return (ENOENT);
+ *pnum = 1;
+
return (0);
}
@@ -511,7 +515,7 @@ ta_flush_cidr_entry(struct ip_fw_chain *
}
struct table_algo radix_cidr = {
- .name = "radix_cidr",
+ .name = "cidr:radix",
.lookup = ta_lookup_radix,
.init = ta_init_radix,
.destroy = ta_destroy_radix,
@@ -808,8 +812,8 @@ ta_prepare_add_ifidx(struct ip_fw_chain
}
static int
-ta_add_ifidx(void *ta_state, struct table_info *ti,
- struct tentry_info *tei, void *ta_buf, uint64_t *pflags)
+ta_add_ifidx(void *ta_state, struct table_info *ti, struct tentry_info *tei,
+ void *ta_buf, uint64_t *pflags, uint32_t *pnum)
{
struct iftable_cfg *icfg;
struct ifentry *ife, *tmp;
@@ -843,6 +847,7 @@ ta_add_ifidx(void *ta_state, struct tabl
/* Indicate that update has happened instead of addition */
tei->flags |= TEI_FLAGS_UPDATED;
+ *pnum = 0;
return (0);
}
@@ -859,6 +864,7 @@ ta_add_ifidx(void *ta_state, struct tabl
}
tb->ife = NULL;
+ *pnum = 1;
return (0);
}
@@ -890,8 +896,8 @@ ta_prepare_del_ifidx(struct ip_fw_chain
* runtime array. Removed interface notification.
*/
static int
-ta_del_ifidx(void *ta_state, struct table_info *ti,
- struct tentry_info *tei, void *ta_buf, uint64_t *pflags)
+ta_del_ifidx(void *ta_state, struct table_info *ti, struct tentry_info *tei,
+ void *ta_buf, uint64_t *pflags, uint32_t *pnum)
{
struct iftable_cfg *icfg;
struct ifentry *ife;
@@ -931,6 +937,7 @@ ta_del_ifidx(void *ta_state, struct tabl
icfg->count--;
tb->ife = ife;
+ *pnum = 1;
return (0);
}
@@ -1161,7 +1168,7 @@ ta_foreach_ifidx(void *ta_state, struct
}
struct table_algo idx_iface = {
- .name = "idx_iface",
+ .name = "iface:array",
.lookup = ta_lookup_ifidx,
.init = ta_init_ifidx,
.destroy = ta_destroy_ifidx,
More information about the svn-src-projects
mailing list