mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 04:31:50 +00:00
dccp: constify dccp_make_response() socket argument
Like tcp_make_synack() the only time we might change the socket is when calling sock_wmalloc(), which is using atomic operation to update sk->sk_wmem_alloc Also use MAX_DCCP_HEADER as both IPv4/IPv6 use this value for max_header. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
0f935dbedc
commit
802885fc04
@ -293,7 +293,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized);
|
|||||||
void dccp_destroy_sock(struct sock *sk);
|
void dccp_destroy_sock(struct sock *sk);
|
||||||
|
|
||||||
void dccp_close(struct sock *sk, long timeout);
|
void dccp_close(struct sock *sk, long timeout);
|
||||||
struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
|
struct sk_buff *dccp_make_response(const struct sock *sk, struct dst_entry *dst,
|
||||||
struct request_sock *req);
|
struct request_sock *req);
|
||||||
|
|
||||||
int dccp_connect(struct sock *sk);
|
int dccp_connect(struct sock *sk);
|
||||||
|
@ -390,7 +390,7 @@ int dccp_retransmit_skb(struct sock *sk)
|
|||||||
return dccp_transmit_skb(sk, skb_clone(sk->sk_send_head, GFP_ATOMIC));
|
return dccp_transmit_skb(sk, skb_clone(sk->sk_send_head, GFP_ATOMIC));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
|
struct sk_buff *dccp_make_response(const struct sock *sk, struct dst_entry *dst,
|
||||||
struct request_sock *req)
|
struct request_sock *req)
|
||||||
{
|
{
|
||||||
struct dccp_hdr *dh;
|
struct dccp_hdr *dh;
|
||||||
@ -398,13 +398,18 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
|
|||||||
const u32 dccp_header_size = sizeof(struct dccp_hdr) +
|
const u32 dccp_header_size = sizeof(struct dccp_hdr) +
|
||||||
sizeof(struct dccp_hdr_ext) +
|
sizeof(struct dccp_hdr_ext) +
|
||||||
sizeof(struct dccp_hdr_response);
|
sizeof(struct dccp_hdr_response);
|
||||||
struct sk_buff *skb = sock_wmalloc(sk, sk->sk_prot->max_header, 1,
|
struct sk_buff *skb;
|
||||||
GFP_ATOMIC);
|
|
||||||
if (skb == NULL)
|
/* sk is marked const to clearly express we dont hold socket lock.
|
||||||
|
* sock_wmalloc() will atomically change sk->sk_wmem_alloc,
|
||||||
|
* it is safe to promote sk to non const.
|
||||||
|
*/
|
||||||
|
skb = sock_wmalloc((struct sock *)sk, MAX_DCCP_HEADER, 1,
|
||||||
|
GFP_ATOMIC);
|
||||||
|
if (!skb)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Reserve space for headers. */
|
skb_reserve(skb, MAX_DCCP_HEADER);
|
||||||
skb_reserve(skb, sk->sk_prot->max_header);
|
|
||||||
|
|
||||||
skb_dst_set(skb, dst_clone(dst));
|
skb_dst_set(skb, dst_clone(dst));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user