diff options
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/flow.h | 10 | ||||
-rw-r--r-- | include/net/netprio_cgroup.h | 48 | ||||
-rw-r--r-- | include/net/route.h | 4 | ||||
-rw-r--r-- | include/net/sch_generic.h | 9 | ||||
-rw-r--r-- | include/net/tcp.h | 14 |
5 files changed, 72 insertions, 13 deletions
diff --git a/include/net/flow.h b/include/net/flow.h index 9b582437fbea..6c469dbdb917 100644 --- a/include/net/flow.h +++ b/include/net/flow.h | |||
@@ -93,6 +93,16 @@ static inline void flowi4_init_output(struct flowi4 *fl4, int oif, | |||
93 | fl4->fl4_dport = dport; | 93 | fl4->fl4_dport = dport; |
94 | fl4->fl4_sport = sport; | 94 | fl4->fl4_sport = sport; |
95 | } | 95 | } |
96 | |||
97 | /* Reset some input parameters after previous lookup */ | ||
98 | static inline void flowi4_update_output(struct flowi4 *fl4, int oif, __u8 tos, | ||
99 | __be32 daddr, __be32 saddr) | ||
100 | { | ||
101 | fl4->flowi4_oif = oif; | ||
102 | fl4->flowi4_tos = tos; | ||
103 | fl4->daddr = daddr; | ||
104 | fl4->saddr = saddr; | ||
105 | } | ||
96 | 106 | ||
97 | 107 | ||
98 | struct flowi6 { | 108 | struct flowi6 { |
diff --git a/include/net/netprio_cgroup.h b/include/net/netprio_cgroup.h index 7b2d43139c8e..d58fdec47597 100644 --- a/include/net/netprio_cgroup.h +++ b/include/net/netprio_cgroup.h | |||
@@ -37,19 +37,51 @@ extern int net_prio_subsys_id; | |||
37 | 37 | ||
38 | extern void sock_update_netprioidx(struct sock *sk); | 38 | extern void sock_update_netprioidx(struct sock *sk); |
39 | 39 | ||
40 | static inline struct cgroup_netprio_state | 40 | #if IS_BUILTIN(CONFIG_NETPRIO_CGROUP) |
41 | *task_netprio_state(struct task_struct *p) | 41 | |
42 | static inline u32 task_netprioidx(struct task_struct *p) | ||
42 | { | 43 | { |
43 | #if IS_ENABLED(CONFIG_NETPRIO_CGROUP) | 44 | struct cgroup_netprio_state *state; |
44 | return container_of(task_subsys_state(p, net_prio_subsys_id), | 45 | u32 idx; |
45 | struct cgroup_netprio_state, css); | 46 | |
46 | #else | 47 | rcu_read_lock(); |
47 | return NULL; | 48 | state = container_of(task_subsys_state(p, net_prio_subsys_id), |
48 | #endif | 49 | struct cgroup_netprio_state, css); |
50 | idx = state->prioidx; | ||
51 | rcu_read_unlock(); | ||
52 | return idx; | ||
53 | } | ||
54 | |||
55 | #elif IS_MODULE(CONFIG_NETPRIO_CGROUP) | ||
56 | |||
57 | static inline u32 task_netprioidx(struct task_struct *p) | ||
58 | { | ||
59 | struct cgroup_netprio_state *state; | ||
60 | int subsys_id; | ||
61 | u32 idx = 0; | ||
62 | |||
63 | rcu_read_lock(); | ||
64 | subsys_id = rcu_dereference_index_check(net_prio_subsys_id, | ||
65 | rcu_read_lock_held()); | ||
66 | if (subsys_id >= 0) { | ||
67 | state = container_of(task_subsys_state(p, subsys_id), | ||
68 | struct cgroup_netprio_state, css); | ||
69 | idx = state->prioidx; | ||
70 | } | ||
71 | rcu_read_unlock(); | ||
72 | return idx; | ||
49 | } | 73 | } |
50 | 74 | ||
51 | #else | 75 | #else |
52 | 76 | ||
77 | static inline u32 task_netprioidx(struct task_struct *p) | ||
78 | { | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | #endif /* CONFIG_NETPRIO_CGROUP */ | ||
83 | |||
84 | #else | ||
53 | #define sock_update_netprioidx(sk) | 85 | #define sock_update_netprioidx(sk) |
54 | #endif | 86 | #endif |
55 | 87 | ||
diff --git a/include/net/route.h b/include/net/route.h index 91855d185b53..b1c0d5b564c2 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
@@ -270,6 +270,7 @@ static inline struct rtable *ip_route_connect(struct flowi4 *fl4, | |||
270 | if (IS_ERR(rt)) | 270 | if (IS_ERR(rt)) |
271 | return rt; | 271 | return rt; |
272 | ip_rt_put(rt); | 272 | ip_rt_put(rt); |
273 | flowi4_update_output(fl4, oif, tos, fl4->daddr, fl4->saddr); | ||
273 | } | 274 | } |
274 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); | 275 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); |
275 | return ip_route_output_flow(net, fl4, sk); | 276 | return ip_route_output_flow(net, fl4, sk); |
@@ -284,6 +285,9 @@ static inline struct rtable *ip_route_newports(struct flowi4 *fl4, struct rtable | |||
284 | fl4->fl4_dport = dport; | 285 | fl4->fl4_dport = dport; |
285 | fl4->fl4_sport = sport; | 286 | fl4->fl4_sport = sport; |
286 | ip_rt_put(rt); | 287 | ip_rt_put(rt); |
288 | flowi4_update_output(fl4, sk->sk_bound_dev_if, | ||
289 | RT_CONN_FLAGS(sk), fl4->daddr, | ||
290 | fl4->saddr); | ||
287 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); | 291 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); |
288 | return ip_route_output_flow(sock_net(sk), fl4, sk); | 292 | return ip_route_output_flow(sock_net(sk), fl4, sk); |
289 | } | 293 | } |
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index f6bb08b73ca4..55ce96b53b09 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h | |||
@@ -220,9 +220,16 @@ struct tcf_proto { | |||
220 | 220 | ||
221 | struct qdisc_skb_cb { | 221 | struct qdisc_skb_cb { |
222 | unsigned int pkt_len; | 222 | unsigned int pkt_len; |
223 | long data[]; | 223 | unsigned char data[24]; |
224 | }; | 224 | }; |
225 | 225 | ||
226 | static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) | ||
227 | { | ||
228 | struct qdisc_skb_cb *qcb; | ||
229 | BUILD_BUG_ON(sizeof(skb->cb) < sizeof(unsigned int) + sz); | ||
230 | BUILD_BUG_ON(sizeof(qcb->data) < sz); | ||
231 | } | ||
232 | |||
226 | static inline int qdisc_qlen(const struct Qdisc *q) | 233 | static inline int qdisc_qlen(const struct Qdisc *q) |
227 | { | 234 | { |
228 | return q->q.qlen; | 235 | return q->q.qlen; |
diff --git a/include/net/tcp.h b/include/net/tcp.h index d49db0113a06..42c29bfbcee3 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -273,6 +273,14 @@ static inline int between(__u32 seq1, __u32 seq2, __u32 seq3) | |||
273 | return seq3 - seq2 >= seq1 - seq2; | 273 | return seq3 - seq2 >= seq1 - seq2; |
274 | } | 274 | } |
275 | 275 | ||
276 | static inline bool tcp_out_of_memory(struct sock *sk) | ||
277 | { | ||
278 | if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && | ||
279 | sk_memory_allocated(sk) > sk_prot_mem_limits(sk, 2)) | ||
280 | return true; | ||
281 | return false; | ||
282 | } | ||
283 | |||
276 | static inline bool tcp_too_many_orphans(struct sock *sk, int shift) | 284 | static inline bool tcp_too_many_orphans(struct sock *sk, int shift) |
277 | { | 285 | { |
278 | struct percpu_counter *ocp = sk->sk_prot->orphan_count; | 286 | struct percpu_counter *ocp = sk->sk_prot->orphan_count; |
@@ -283,13 +291,11 @@ static inline bool tcp_too_many_orphans(struct sock *sk, int shift) | |||
283 | if (orphans << shift > sysctl_tcp_max_orphans) | 291 | if (orphans << shift > sysctl_tcp_max_orphans) |
284 | return true; | 292 | return true; |
285 | } | 293 | } |
286 | |||
287 | if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && | ||
288 | sk_memory_allocated(sk) > sk_prot_mem_limits(sk, 2)) | ||
289 | return true; | ||
290 | return false; | 294 | return false; |
291 | } | 295 | } |
292 | 296 | ||
297 | extern bool tcp_check_oom(struct sock *sk, int shift); | ||
298 | |||
293 | /* syncookies: remember time of last synqueue overflow */ | 299 | /* syncookies: remember time of last synqueue overflow */ |
294 | static inline void tcp_synq_overflow(struct sock *sk) | 300 | static inline void tcp_synq_overflow(struct sock *sk) |
295 | { | 301 | { |