Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: lec-bit <[email protected]>
  • Loading branch information
lec-bit committed Oct 23, 2024
1 parent f48c716 commit 1902392
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions bpf/deserialization_to_bpf_map/deserialization_to_bpf_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,7 @@ void inner_map_batch_delete()
int deserial_uninit(bool persist)
{
int ret = 0;
remove(MAP_IN_MAP_MNG_PERSIST_FILE_PATH);
if (persist)
ret = inner_map_mng_persist();

Expand All @@ -1635,8 +1636,6 @@ int deserial_uninit(bool persist)

close(g_inner_map_mng.inner_fd);
close(g_inner_map_mng.outter_fd);
if (!persist || ret < 0)
remove(MAP_IN_MAP_MNG_PERSIST_FILE_PATH);
return ret;
}

Expand Down Expand Up @@ -1730,7 +1729,7 @@ int inner_map_elastic_scaling()

int inner_map_mng_persist()
{
int i, size;
int i, size, map_fd;
FILE *f = NULL;
struct persist_info *p = NULL;

Expand Down Expand Up @@ -1759,13 +1758,15 @@ int inner_map_mng_persist()
kernel will convert it into a bpf_map pointer for storage, so it will
not be affected.*/
for (i = 0; i <= g_inner_map_mng.max_allocated_idx; i++) {
int map_fd = bpf_get_map_id_by_fd(g_inner_map_mng.inner_maps[i].map_fd);
if (map_fd < 0) {
return map_fd;
if (g_inner_map_mng.inner_maps[i].allocated) {
map_fd = bpf_get_map_id_by_fd(g_inner_map_mng.inner_maps[i].map_fd);
if (map_fd < 0) {
return map_fd;
}
p->inner_map_stat[i].map_fd = map_fd;
p->inner_map_stat[i].used = g_inner_map_mng.inner_maps[i].used;
p->inner_map_stat[i].allocated = g_inner_map_mng.inner_maps[i].allocated;
}
p->inner_map_stat[i].map_fd = map_fd;
p->inner_map_stat[i].used = g_inner_map_mng.inner_maps[i].used;
p->inner_map_stat[i].allocated = g_inner_map_mng.inner_maps[i].allocated;
}

f = fopen(MAP_IN_MAP_MNG_PERSIST_FILE_PATH, "wb");
Expand Down

0 comments on commit 1902392

Please sign in to comment.