acassis commented on code in PR #12156:
URL: https://github.com/apache/nuttx/pull/12156#discussion_r1568961705
##########
net/nat/ipv4_nat_entry.c:
##########
@@ -195,39 +195,47 @@ static void ipv4_nat_entry_delete(FAR ipv4_nat_entry_t
*entry)
****************************************************************************/
#if CONFIG_NET_NAT_ENTRY_RECLAIM_SEC > 0
+static void ipv4_nat_reclaim_entry_cb(FAR ipv4_nat_entry_t *entry,
+ FAR void *arg)
+{
+ int32_t current_time = *(FAR int32_t *)arg;
+
+ if (entry->expire_time - current_time <= 0)
+ {
+ ipv4_nat_entry_delete(entry);
+ }
+}
+
static void ipv4_nat_reclaim_entry(int32_t current_time)
{
static int32_t next_reclaim_time = CONFIG_NET_NAT_ENTRY_RECLAIM_SEC;
if (next_reclaim_time - current_time <= 0)
{
- FAR hash_node_t *p;
- FAR hash_node_t *tmp;
- int count = 0;
- int i;
-
ninfo("INFO: Reclaiming all expired NAT44 entries.\n");
-
- hashtable_for_every_safe(g_nat44_inbound, p, tmp, i)
- {
- FAR ipv4_nat_entry_t *entry =
- container_of(p, ipv4_nat_entry_t, hash_inbound);
-
- if (entry->expire_time - current_time <= 0)
- {
- ipv4_nat_entry_delete(entry);
- count++;
- }
- }
-
- ninfo("INFO: %d expired NAT44 entries reclaimed.\n", count);
+ ipv4_nat_entry_foreach(ipv4_nat_reclaim_entry_cb, ¤t_time);
next_reclaim_time = current_time + CONFIG_NET_NAT_ENTRY_RECLAIM_SEC;
}
}
#else
# define ipv4_nat_reclaim_entry(t)
#endif
+/****************************************************************************
+ * Name: ipv4_nat_entry_clear_cb
Review Comment:
Please include description
##########
net/nat/ipv6_nat_entry.c:
##########
@@ -188,39 +188,47 @@ static void ipv6_nat_entry_delete(FAR ipv6_nat_entry_t
*entry)
****************************************************************************/
#if CONFIG_NET_NAT_ENTRY_RECLAIM_SEC > 0
+static void ipv6_nat_reclaim_entry_cb(FAR ipv6_nat_entry_t *entry,
+ FAR void *arg)
+{
+ int32_t current_time = *(FAR int32_t *)arg;
+
+ if (entry->expire_time - current_time <= 0)
+ {
+ ipv6_nat_entry_delete(entry);
+ }
+}
+
static void ipv6_nat_reclaim_entry(int32_t current_time)
{
static int32_t next_reclaim_time = CONFIG_NET_NAT_ENTRY_RECLAIM_SEC;
if (next_reclaim_time - current_time <= 0)
{
- FAR hash_node_t *p;
- FAR hash_node_t *tmp;
- int count = 0;
- int i;
-
ninfo("INFO: Reclaiming all expired NAT66 entries.\n");
-
- hashtable_for_every_safe(g_nat66_inbound, p, tmp, i)
- {
- FAR ipv6_nat_entry_t *entry =
- container_of(p, ipv6_nat_entry_t, hash_inbound);
-
- if (entry->expire_time - current_time <= 0)
- {
- ipv6_nat_entry_delete(entry);
- count++;
- }
- }
-
- ninfo("INFO: %d expired NAT66 entries reclaimed.\n", count);
+ ipv6_nat_entry_foreach(ipv6_nat_reclaim_entry_cb, ¤t_time);
next_reclaim_time = current_time + CONFIG_NET_NAT_ENTRY_RECLAIM_SEC;
}
}
#else
# define ipv6_nat_reclaim_entry(t)
#endif
+/****************************************************************************
+ * Name: ipv6_nat_entry_clear_cb
Review Comment:
Ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]