Skip to content

Commit 1e2e011

Browse files
edumazetdavem330
authored andcommitted
inet: add rsk_refcnt/ireq_refcnt to request socks
When request socks will be in ehash, they'll need to be refcounted. This patch adds rsk_refcnt/ireq_refcnt macros, and adds reqsk_put() function, but nothing yet use them. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d34ac51 commit 1e2e011

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎include/net/inet_sock.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct inet_request_sock {
8181
#define ir_cookie req.__req_common.skc_cookie
8282
#define ireq_net req.__req_common.skc_net
8383
#define ireq_state req.__req_common.skc_state
84+
#define ireq_refcnt req.__req_common.skc_refcnt
8485

8586
kmemcheck_bitfield_begin(flags);
8687
u16 snd_wscale : 4,

‎include/net/request_sock.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ int inet_rtx_syn_ack(struct sock *parent, struct request_sock *req);
4949
*/
5050
struct request_sock {
5151
struct sock_common __req_common;
52+
#define rsk_refcnt __req_common.skc_refcnt
53+
5254
struct request_sock *dl_next;
5355
u16 mss;
5456
u8 num_retrans; /* number of retransmits */
@@ -86,6 +88,12 @@ static inline void reqsk_free(struct request_sock *req)
8688
__reqsk_free(req);
8789
}
8890

91+
static inline void reqsk_put(struct request_sock *req)
92+
{
93+
if (atomic_dec_and_test(&req->rsk_refcnt))
94+
reqsk_free(req);
95+
}
96+
8997
extern int sysctl_max_syn_backlog;
9098

9199
/** struct listen_sock - listen state

0 commit comments

Comments
 (0)