aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/sock.h26
-rw-r--r--net/core/sock.c5
2 files changed, 30 insertions, 1 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 1364428f53f2..55de3bd719a5 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -107,6 +107,7 @@ struct net;
107 * @skc_node: main hash linkage for various protocol lookup tables 107 * @skc_node: main hash linkage for various protocol lookup tables
108 * @skc_nulls_node: main hash linkage for UDP/UDP-Lite protocol 108 * @skc_nulls_node: main hash linkage for UDP/UDP-Lite protocol
109 * @skc_refcnt: reference count 109 * @skc_refcnt: reference count
110 * @skc_tx_queue_mapping: tx queue number for this connection
110 * @skc_hash: hash value used with various protocol lookup tables 111 * @skc_hash: hash value used with various protocol lookup tables
111 * @skc_family: network address family 112 * @skc_family: network address family
112 * @skc_state: Connection state 113 * @skc_state: Connection state
@@ -128,6 +129,7 @@ struct sock_common {
128 struct hlist_nulls_node skc_nulls_node; 129 struct hlist_nulls_node skc_nulls_node;
129 }; 130 };
130 atomic_t skc_refcnt; 131 atomic_t skc_refcnt;
132 int skc_tx_queue_mapping;
131 133
132 unsigned int skc_hash; 134 unsigned int skc_hash;
133 unsigned short skc_family; 135 unsigned short skc_family;
@@ -215,6 +217,7 @@ struct sock {
215#define sk_node __sk_common.skc_node 217#define sk_node __sk_common.skc_node
216#define sk_nulls_node __sk_common.skc_nulls_node 218#define sk_nulls_node __sk_common.skc_nulls_node
217#define sk_refcnt __sk_common.skc_refcnt 219#define sk_refcnt __sk_common.skc_refcnt
220#define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping
218 221
219#define sk_copy_start __sk_common.skc_hash 222#define sk_copy_start __sk_common.skc_hash
220#define sk_hash __sk_common.skc_hash 223#define sk_hash __sk_common.skc_hash
@@ -1094,8 +1097,29 @@ static inline void sock_put(struct sock *sk)
1094extern int sk_receive_skb(struct sock *sk, struct sk_buff *skb, 1097extern int sk_receive_skb(struct sock *sk, struct sk_buff *skb,
1095 const int nested); 1098 const int nested);
1096 1099
1100static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
1101{
1102 sk->sk_tx_queue_mapping = tx_queue;
1103}
1104
1105static inline void sk_tx_queue_clear(struct sock *sk)
1106{
1107 sk->sk_tx_queue_mapping = -1;
1108}
1109
1110static inline int sk_tx_queue_get(const struct sock *sk)
1111{
1112 return sk->sk_tx_queue_mapping;
1113}
1114
1115static inline bool sk_tx_queue_recorded(const struct sock *sk)
1116{
1117 return (sk && sk->sk_tx_queue_mapping >= 0);
1118}
1119
1097static inline void sk_set_socket(struct sock *sk, struct socket *sock) 1120static inline void sk_set_socket(struct sock *sk, struct socket *sock)
1098{ 1121{
1122 sk_tx_queue_clear(sk);
1099 sk->sk_socket = sock; 1123 sk->sk_socket = sock;
1100} 1124}
1101 1125
@@ -1152,6 +1176,7 @@ __sk_dst_set(struct sock *sk, struct dst_entry *dst)
1152{ 1176{
1153 struct dst_entry *old_dst; 1177 struct dst_entry *old_dst;
1154 1178
1179 sk_tx_queue_clear(sk);
1155 old_dst = sk->sk_dst_cache; 1180 old_dst = sk->sk_dst_cache;
1156 sk->sk_dst_cache = dst; 1181 sk->sk_dst_cache = dst;
1157 dst_release(old_dst); 1182 dst_release(old_dst);
@@ -1170,6 +1195,7 @@ __sk_dst_reset(struct sock *sk)
1170{ 1195{
1171 struct dst_entry *old_dst; 1196 struct dst_entry *old_dst;
1172 1197
1198 sk_tx_queue_clear(sk);
1173 old_dst = sk->sk_dst_cache; 1199 old_dst = sk->sk_dst_cache;
1174 sk->sk_dst_cache = NULL; 1200 sk->sk_dst_cache = NULL;
1175 dst_release(old_dst); 1201 dst_release(old_dst);
diff --git a/net/core/sock.c b/net/core/sock.c
index 38713aa3faf2..934d9673f084 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -357,6 +357,7 @@ struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie)
357 struct dst_entry *dst = sk->sk_dst_cache; 357 struct dst_entry *dst = sk->sk_dst_cache;
358 358
359 if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) { 359 if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
360 sk_tx_queue_clear(sk);
360 sk->sk_dst_cache = NULL; 361 sk->sk_dst_cache = NULL;
361 dst_release(dst); 362 dst_release(dst);
362 return NULL; 363 return NULL;
@@ -953,7 +954,8 @@ static void sock_copy(struct sock *nsk, const struct sock *osk)
953 void *sptr = nsk->sk_security; 954 void *sptr = nsk->sk_security;
954#endif 955#endif
955 BUILD_BUG_ON(offsetof(struct sock, sk_copy_start) != 956 BUILD_BUG_ON(offsetof(struct sock, sk_copy_start) !=
956 sizeof(osk->sk_node) + sizeof(osk->sk_refcnt)); 957 sizeof(osk->sk_node) + sizeof(osk->sk_refcnt) +
958 sizeof(osk->sk_tx_queue_mapping));
957 memcpy(&nsk->sk_copy_start, &osk->sk_copy_start, 959 memcpy(&nsk->sk_copy_start, &osk->sk_copy_start,
958 osk->sk_prot->obj_size - offsetof(struct sock, sk_copy_start)); 960 osk->sk_prot->obj_size - offsetof(struct sock, sk_copy_start));
959#ifdef CONFIG_SECURITY_NETWORK 961#ifdef CONFIG_SECURITY_NETWORK
@@ -997,6 +999,7 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
997 999
998 if (!try_module_get(prot->owner)) 1000 if (!try_module_get(prot->owner))
999 goto out_free_sec; 1001 goto out_free_sec;
1002 sk_tx_queue_clear(sk);
1000 } 1003 }
1001 1004
1002 return sk; 1005 return sk;