Skip to content

Commit

Permalink
inet: add rsk_refcnt/ireq_refcnt to request socks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Mar 13, 2015
1 parent d34ac51 commit 1e2e011
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/net/inet_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct inet_request_sock {
#define ir_cookie req.__req_common.skc_cookie
#define ireq_net req.__req_common.skc_net
#define ireq_state req.__req_common.skc_state
#define ireq_refcnt req.__req_common.skc_refcnt

kmemcheck_bitfield_begin(flags);
u16 snd_wscale : 4,
Expand Down
8 changes: 8 additions & 0 deletions include/net/request_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ int inet_rtx_syn_ack(struct sock *parent, struct request_sock *req);
*/
struct request_sock {
struct sock_common __req_common;
#define rsk_refcnt __req_common.skc_refcnt

struct request_sock *dl_next;
u16 mss;
u8 num_retrans; /* number of retransmits */
Expand Down Expand Up @@ -86,6 +88,12 @@ static inline void reqsk_free(struct request_sock *req)
__reqsk_free(req);
}

static inline void reqsk_put(struct request_sock *req)
{
if (atomic_dec_and_test(&req->rsk_refcnt))
reqsk_free(req);
}

extern int sysctl_max_syn_backlog;

/** struct listen_sock - listen state
Expand Down

0 comments on commit 1e2e011

Please sign in to comment.