Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 194557
b: refs/heads/master
c: c58dc01
h: refs/heads/master
i:
  194555: 6329406
v: v3
  • Loading branch information
David S. Miller committed Apr 27, 2010
1 parent e63cd5c commit cf5a34d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c4ee6a5348102b9cea49fb9adf88307445407911
refs/heads/master: c58dc01babfd58ec9e71a6ce080150dc27755d88
37 changes: 0 additions & 37 deletions trunk/include/net/inet_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ struct rtable;
* @uc_ttl - Unicast TTL
* @inet_sport - Source port
* @inet_id - ID counter for DF pkts
* @rxhash - flow hash received from netif layer
* @tos - TOS
* @mc_ttl - Multicasting TTL
* @is_icsk - is this an inet_connection_sock?
Expand All @@ -126,9 +125,6 @@ struct inet_sock {
__u16 cmsg_flags;
__be16 inet_sport;
__u16 inet_id;
#ifdef CONFIG_RPS
__u32 rxhash;
#endif

struct ip_options *opt;
__u8 tos;
Expand Down Expand Up @@ -224,37 +220,4 @@ static inline __u8 inet_sk_flowi_flags(const struct sock *sk)
return inet_sk(sk)->transparent ? FLOWI_FLAG_ANYSRC : 0;
}

static inline void inet_rps_record_flow(const struct sock *sk)
{
#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, inet_sk(sk)->rxhash);
rcu_read_unlock();
#endif
}

static inline void inet_rps_reset_flow(const struct sock *sk)
{
#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, inet_sk(sk)->rxhash);
rcu_read_unlock();
#endif
}

static inline void inet_rps_save_rxhash(struct sock *sk, u32 rxhash)
{
#ifdef CONFIG_RPS
if (unlikely(inet_sk(sk)->rxhash != rxhash)) {
inet_rps_reset_flow(sk);
inet_sk(sk)->rxhash = rxhash;
}
#endif
}
#endif /* _INET_SOCK_H */
38 changes: 38 additions & 0 deletions trunk/include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ struct sock_common {
* @sk_rcvlowat: %SO_RCVLOWAT setting
* @sk_rcvtimeo: %SO_RCVTIMEO setting
* @sk_sndtimeo: %SO_SNDTIMEO setting
* @sk_rxhash: flow hash received from netif layer
* @sk_filter: socket filtering instructions
* @sk_protinfo: private area, net family specific, when not using slab
* @sk_timer: sock cleanup timer
Expand Down Expand Up @@ -279,6 +280,9 @@ struct sock {
int sk_gso_type;
unsigned int sk_gso_max_size;
int sk_rcvlowat;
#ifdef CONFIG_RPS
__u32 sk_rxhash;
#endif
unsigned long sk_flags;
unsigned long sk_lingertime;
struct sk_buff_head sk_error_queue;
Expand Down Expand Up @@ -620,6 +624,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)
{
#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);
rcu_read_unlock();
#endif
}

static inline void sock_rps_reset_flow(const struct sock *sk)
{
#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);
rcu_read_unlock();
#endif
}

static inline void sock_rps_save_rxhash(struct sock *sk, u32 rxhash)
{
#ifdef CONFIG_RPS
if (unlikely(sk->sk_rxhash != rxhash)) {
sock_rps_reset_flow(sk);
sk->sk_rxhash = rxhash;
}
#endif
}

#define sk_wait_event(__sk, __timeo, __condition) \
({ int __rc; \
release_sock(__sk); \
Expand Down
8 changes: 4 additions & 4 deletions trunk/net/ipv4/af_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ int inet_release(struct socket *sock)
if (sk) {
long timeout;

inet_rps_reset_flow(sk);
sock_rps_reset_flow(sk);

/* Applications forget to leave groups before exiting */
ip_mc_drop_socket(sk);
Expand Down Expand Up @@ -722,7 +722,7 @@ int inet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
{
struct sock *sk = sock->sk;

inet_rps_record_flow(sk);
sock_rps_record_flow(sk);

/* We may need to bind the socket. */
if (!inet_sk(sk)->inet_num && inet_autobind(sk))
Expand All @@ -737,7 +737,7 @@ static ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset,
{
struct sock *sk = sock->sk;

inet_rps_record_flow(sk);
sock_rps_record_flow(sk);

/* We may need to bind the socket. */
if (!inet_sk(sk)->inet_num && inet_autobind(sk))
Expand All @@ -755,7 +755,7 @@ int inet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
int addr_len = 0;
int err;

inet_rps_record_flow(sk);
sock_rps_record_flow(sk);

err = sk->sk_prot->recvmsg(iocb, sk, msg, size, flags & MSG_DONTWAIT,
flags & ~MSG_DONTWAIT, &addr_len);
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/ipv4/tcp_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ int tcp_v4_rcv(struct sk_buff *skb)

skb->dev = NULL;

inet_rps_save_rxhash(sk, skb->rxhash);
sock_rps_save_rxhash(sk, skb->rxhash);

bh_lock_sock_nested(sk);
ret = 0;
Expand Down
4 changes: 2 additions & 2 deletions trunk/net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ int udp_disconnect(struct sock *sk, int flags)
sk->sk_state = TCP_CLOSE;
inet->inet_daddr = 0;
inet->inet_dport = 0;
inet_rps_save_rxhash(sk, 0);
sock_rps_save_rxhash(sk, 0);
sk->sk_bound_dev_if = 0;
if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))
inet_reset_saddr(sk);
Expand Down Expand Up @@ -1262,7 +1262,7 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
int rc;

if (inet_sk(sk)->inet_daddr)
inet_rps_save_rxhash(sk, skb->rxhash);
sock_rps_save_rxhash(sk, skb->rxhash);

rc = sock_queue_rcv_skb(sk, skb);
if (rc < 0) {
Expand Down

0 comments on commit cf5a34d

Please sign in to comment.