diff options
-rw-r--r-- | include/net/inet_sock.h | 37 | ||||
-rw-r--r-- | include/net/sock.h | 38 | ||||
-rw-r--r-- | net/ipv4/af_inet.c | 8 | ||||
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 2 | ||||
-rw-r--r-- | net/ipv4/udp.c | 4 |
5 files changed, 45 insertions, 44 deletions
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index c1d42957b86b..1653de515cee 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h | |||
@@ -102,7 +102,6 @@ struct rtable; | |||
102 | * @uc_ttl - Unicast TTL | 102 | * @uc_ttl - Unicast TTL |
103 | * @inet_sport - Source port | 103 | * @inet_sport - Source port |
104 | * @inet_id - ID counter for DF pkts | 104 | * @inet_id - ID counter for DF pkts |
105 | * @rxhash - flow hash received from netif layer | ||
106 | * @tos - TOS | 105 | * @tos - TOS |
107 | * @mc_ttl - Multicasting TTL | 106 | * @mc_ttl - Multicasting TTL |
108 | * @is_icsk - is this an inet_connection_sock? | 107 | * @is_icsk - is this an inet_connection_sock? |
@@ -126,9 +125,6 @@ struct inet_sock { | |||
126 | __u16 cmsg_flags; | 125 | __u16 cmsg_flags; |
127 | __be16 inet_sport; | 126 | __be16 inet_sport; |
128 | __u16 inet_id; | 127 | __u16 inet_id; |
129 | #ifdef CONFIG_RPS | ||
130 | __u32 rxhash; | ||
131 | #endif | ||
132 | 128 | ||
133 | struct ip_options *opt; | 129 | struct ip_options *opt; |
134 | __u8 tos; | 130 | __u8 tos; |
@@ -224,37 +220,4 @@ static inline __u8 inet_sk_flowi_flags(const struct sock *sk) | |||
224 | return inet_sk(sk)->transparent ? FLOWI_FLAG_ANYSRC : 0; | 220 | return inet_sk(sk)->transparent ? FLOWI_FLAG_ANYSRC : 0; |
225 | } | 221 | } |
226 | 222 | ||
227 | static inline void inet_rps_record_flow(const struct sock *sk) | ||
228 | { | ||
229 | #ifdef CONFIG_RPS | ||
230 | struct rps_sock_flow_table *sock_flow_table; | ||
231 | |||
232 | rcu_read_lock(); | ||
233 | sock_flow_table = rcu_dereference(rps_sock_flow_table); | ||
234 | rps_record_sock_flow(sock_flow_table, inet_sk(sk)->rxhash); | ||
235 | rcu_read_unlock(); | ||
236 | #endif | ||
237 | } | ||
238 | |||
239 | static inline void inet_rps_reset_flow(const struct sock *sk) | ||
240 | { | ||
241 | #ifdef CONFIG_RPS | ||
242 | struct rps_sock_flow_table *sock_flow_table; | ||
243 | |||
244 | rcu_read_lock(); | ||
245 | sock_flow_table = rcu_dereference(rps_sock_flow_table); | ||
246 | rps_reset_sock_flow(sock_flow_table, inet_sk(sk)->rxhash); | ||
247 | rcu_read_unlock(); | ||
248 | #endif | ||
249 | } | ||
250 | |||
251 | static inline void inet_rps_save_rxhash(struct sock *sk, u32 rxhash) | ||
252 | { | ||
253 | #ifdef CONFIG_RPS | ||
254 | if (unlikely(inet_sk(sk)->rxhash != rxhash)) { | ||
255 | inet_rps_reset_flow(sk); | ||
256 | inet_sk(sk)->rxhash = rxhash; | ||
257 | } | ||
258 | #endif | ||
259 | } | ||
260 | #endif /* _INET_SOCK_H */ | 223 | #endif /* _INET_SOCK_H */ |
diff --git a/include/net/sock.h b/include/net/sock.h index 4081db86a352..07822280d953 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -198,6 +198,7 @@ struct sock_common { | |||
198 | * @sk_rcvlowat: %SO_RCVLOWAT setting | 198 | * @sk_rcvlowat: %SO_RCVLOWAT setting |
199 | * @sk_rcvtimeo: %SO_RCVTIMEO setting | 199 | * @sk_rcvtimeo: %SO_RCVTIMEO setting |
200 | * @sk_sndtimeo: %SO_SNDTIMEO setting | 200 | * @sk_sndtimeo: %SO_SNDTIMEO setting |
201 | * @sk_rxhash: flow hash received from netif layer | ||
201 | * @sk_filter: socket filtering instructions | 202 | * @sk_filter: socket filtering instructions |
202 | * @sk_protinfo: private area, net family specific, when not using slab | 203 | * @sk_protinfo: private area, net family specific, when not using slab |
203 | * @sk_timer: sock cleanup timer | 204 | * @sk_timer: sock cleanup timer |
@@ -279,6 +280,9 @@ struct sock { | |||
279 | int sk_gso_type; | 280 | int sk_gso_type; |
280 | unsigned int sk_gso_max_size; | 281 | unsigned int sk_gso_max_size; |
281 | int sk_rcvlowat; | 282 | int sk_rcvlowat; |
283 | #ifdef CONFIG_RPS | ||
284 | __u32 sk_rxhash; | ||
285 | #endif | ||
282 | unsigned long sk_flags; | 286 | unsigned long sk_flags; |
283 | unsigned long sk_lingertime; | 287 | unsigned long sk_lingertime; |
284 | struct sk_buff_head sk_error_queue; | 288 | struct sk_buff_head sk_error_queue; |
@@ -620,6 +624,40 @@ static inline int sk_backlog_rcv(struct sock *sk, struct sk_buff *skb) | |||
620 | return sk->sk_backlog_rcv(sk, skb); | 624 | return sk->sk_backlog_rcv(sk, skb); |
621 | } | 625 | } |
622 | 626 | ||
627 | static inline void sock_rps_record_flow(const struct sock *sk) | ||
628 | { | ||
629 | #ifdef CONFIG_RPS | ||
630 | struct rps_sock_flow_table *sock_flow_table; | ||
631 | |||
632 | rcu_read_lock(); | ||
633 | sock_flow_table = rcu_dereference(rps_sock_flow_table); | ||
634 | rps_record_sock_flow(sock_flow_table, sk->sk_rxhash); | ||
635 | rcu_read_unlock(); | ||
636 | #endif | ||
637 | } | ||
638 | |||
639 | static inline void sock_rps_reset_flow(const struct sock *sk) | ||
640 | { | ||
641 | #ifdef CONFIG_RPS | ||
642 | struct rps_sock_flow_table *sock_flow_table; | ||
643 | |||
644 | rcu_read_lock(); | ||
645 | sock_flow_table = rcu_dereference(rps_sock_flow_table); | ||
646 | rps_reset_sock_flow(sock_flow_table, sk->sk_rxhash); | ||
647 | rcu_read_unlock(); | ||
648 | #endif | ||
649 | } | ||
650 | |||
651 | static inline void sock_rps_save_rxhash(struct sock *sk, u32 rxhash) | ||
652 | { | ||
653 | #ifdef CONFIG_RPS | ||
654 | if (unlikely(sk->sk_rxhash != rxhash)) { | ||
655 | sock_rps_reset_flow(sk); | ||
656 | sk->sk_rxhash = rxhash; | ||
657 | } | ||
658 | #endif | ||
659 | } | ||
660 | |||
623 | #define sk_wait_event(__sk, __timeo, __condition) \ | 661 | #define sk_wait_event(__sk, __timeo, __condition) \ |
624 | ({ int __rc; \ | 662 | ({ int __rc; \ |
625 | release_sock(__sk); \ | 663 | release_sock(__sk); \ |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 9f52880fae10..c6c43bcd1c6f 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -419,7 +419,7 @@ int inet_release(struct socket *sock) | |||
419 | if (sk) { | 419 | if (sk) { |
420 | long timeout; | 420 | long timeout; |
421 | 421 | ||
422 | inet_rps_reset_flow(sk); | 422 | sock_rps_reset_flow(sk); |
423 | 423 | ||
424 | /* Applications forget to leave groups before exiting */ | 424 | /* Applications forget to leave groups before exiting */ |
425 | ip_mc_drop_socket(sk); | 425 | ip_mc_drop_socket(sk); |
@@ -722,7 +722,7 @@ int inet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
722 | { | 722 | { |
723 | struct sock *sk = sock->sk; | 723 | struct sock *sk = sock->sk; |
724 | 724 | ||
725 | inet_rps_record_flow(sk); | 725 | sock_rps_record_flow(sk); |
726 | 726 | ||
727 | /* We may need to bind the socket. */ | 727 | /* We may need to bind the socket. */ |
728 | if (!inet_sk(sk)->inet_num && inet_autobind(sk)) | 728 | if (!inet_sk(sk)->inet_num && inet_autobind(sk)) |
@@ -737,7 +737,7 @@ static ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset, | |||
737 | { | 737 | { |
738 | struct sock *sk = sock->sk; | 738 | struct sock *sk = sock->sk; |
739 | 739 | ||
740 | inet_rps_record_flow(sk); | 740 | sock_rps_record_flow(sk); |
741 | 741 | ||
742 | /* We may need to bind the socket. */ | 742 | /* We may need to bind the socket. */ |
743 | if (!inet_sk(sk)->inet_num && inet_autobind(sk)) | 743 | if (!inet_sk(sk)->inet_num && inet_autobind(sk)) |
@@ -755,7 +755,7 @@ int inet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
755 | int addr_len = 0; | 755 | int addr_len = 0; |
756 | int err; | 756 | int err; |
757 | 757 | ||
758 | inet_rps_record_flow(sk); | 758 | sock_rps_record_flow(sk); |
759 | 759 | ||
760 | err = sk->sk_prot->recvmsg(iocb, sk, msg, size, flags & MSG_DONTWAIT, | 760 | err = sk->sk_prot->recvmsg(iocb, sk, msg, size, flags & MSG_DONTWAIT, |
761 | flags & ~MSG_DONTWAIT, &addr_len); | 761 | flags & ~MSG_DONTWAIT, &addr_len); |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 4d6717d1e61c..771f8146a2e5 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -1672,7 +1672,7 @@ process: | |||
1672 | 1672 | ||
1673 | skb->dev = NULL; | 1673 | skb->dev = NULL; |
1674 | 1674 | ||
1675 | inet_rps_save_rxhash(sk, skb->rxhash); | 1675 | sock_rps_save_rxhash(sk, skb->rxhash); |
1676 | 1676 | ||
1677 | bh_lock_sock_nested(sk); | 1677 | bh_lock_sock_nested(sk); |
1678 | ret = 0; | 1678 | ret = 0; |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 1e18f9cc9247..fa3d2874db41 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1217,7 +1217,7 @@ int udp_disconnect(struct sock *sk, int flags) | |||
1217 | sk->sk_state = TCP_CLOSE; | 1217 | sk->sk_state = TCP_CLOSE; |
1218 | inet->inet_daddr = 0; | 1218 | inet->inet_daddr = 0; |
1219 | inet->inet_dport = 0; | 1219 | inet->inet_dport = 0; |
1220 | inet_rps_save_rxhash(sk, 0); | 1220 | sock_rps_save_rxhash(sk, 0); |
1221 | sk->sk_bound_dev_if = 0; | 1221 | sk->sk_bound_dev_if = 0; |
1222 | if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) | 1222 | if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) |
1223 | inet_reset_saddr(sk); | 1223 | inet_reset_saddr(sk); |
@@ -1262,7 +1262,7 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
1262 | int rc; | 1262 | int rc; |
1263 | 1263 | ||
1264 | if (inet_sk(sk)->inet_daddr) | 1264 | if (inet_sk(sk)->inet_daddr) |
1265 | inet_rps_save_rxhash(sk, skb->rxhash); | 1265 | sock_rps_save_rxhash(sk, skb->rxhash); |
1266 | 1266 | ||
1267 | rc = sock_queue_rcv_skb(sk, skb); | 1267 | rc = sock_queue_rcv_skb(sk, skb); |
1268 | if (rc < 0) { | 1268 | if (rc < 0) { |