Skip to content

Commit

Permalink
net: Allow setting sock flow hash without a sock
Browse files Browse the repository at this point in the history
This patch adds sock_rps_record_flow_hash and sock_rps_reset_flow_hash
which take a hash value as an argument and sets the sock_flow_table
accordingly.  This allows the table to be populated in cases where flow
is being tracked outside of a sock structure.

sock_rps_record_flow and sock_rps_reset_flow call this function
where the hash is taken from sk_rxhash.

Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tom Herbert authored and David S. Miller committed Dec 31, 2013
1 parent 84a6a0a commit fe47755
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -820,30 +820,40 @@ static inline int sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)
return sk->sk_backlog_rcv(sk, skb);
}

static inline void sock_rps_record_flow(const struct sock *sk)
static inline void sock_rps_record_flow_hash(__u32 hash)
{
#ifdef CONFIG_RPS
struct rps_sock_flow_table *sock_flow_table;

rcu_read_lock();
sock_flow_table = rcu_dereference(rps_sock_flow_table);
rps_record_sock_flow(sock_flow_table, sk->sk_rxhash);
rps_record_sock_flow(sock_flow_table, hash);
rcu_read_unlock();
#endif
}

static inline void sock_rps_reset_flow(const struct sock *sk)
static inline void sock_rps_reset_flow_hash(__u32 hash)
{
#ifdef CONFIG_RPS
struct rps_sock_flow_table *sock_flow_table;

rcu_read_lock();
sock_flow_table = rcu_dereference(rps_sock_flow_table);
rps_reset_sock_flow(sock_flow_table, sk->sk_rxhash);
rps_reset_sock_flow(sock_flow_table, hash);
rcu_read_unlock();
#endif
}

static inline void sock_rps_record_flow(const struct sock *sk)
{
sock_rps_record_flow_hash(sk->sk_rxhash);
}

static inline void sock_rps_reset_flow(const struct sock *sk)
{
sock_rps_reset_flow_hash(sk->sk_rxhash);
}

static inline void sock_rps_save_rxhash(struct sock *sk,
const struct sk_buff *skb)
{
Expand Down

0 comments on commit fe47755

Please sign in to comment.