-static int
-ldp_fd_alloc (u32 sid)
-{
- ldp_fd_entry_t *fde;
-
- clib_rwlock_writer_lock (&ldp->fd_table_lock);
- if (pool_elts (ldp->fd_pool) >= (1ULL << 32) - ldp->sid_bit_val)
- {
- clib_rwlock_writer_unlock (&ldp->fd_table_lock);
- return -1;
- }
- pool_get (ldp->fd_pool, fde);
- fde->session_index = vppcom_session_index (sid);
- fde->fd_index = fde - ldp->fd_pool;
- fde->fd = fde->fd_index + ldp->sid_bit_val;
- hash_set (ldp->session_index_to_fd_table, fde->session_index, fde->fd);
- clib_rwlock_writer_unlock (&ldp->fd_table_lock);
- return fde->fd;
-}
-
-static ldp_fd_entry_t *
-ldp_fd_entry_get_w_lock (u32 fd_index)
-{
- clib_rwlock_reader_lock (&ldp->fd_table_lock);
- if (pool_is_free_index (ldp->fd_pool, fd_index))
- return 0;
-
- return pool_elt_at_index (ldp->fd_pool, fd_index);
-}
-
-static inline int
-ldp_fd_from_sid (u32 sid)
-{
- uword *fdp;
- int fd;
-
- clib_rwlock_reader_lock (&ldp->fd_table_lock);
- fdp = hash_get (ldp->session_index_to_fd_table, vppcom_session_index (sid));
- fd = fdp ? *fdp : -EMFILE;
- clib_rwlock_reader_unlock (&ldp->fd_table_lock);
-
- return fd;
-}
-