[DCCP]: Use sk->sk_prot->max_header consistently for non-data packets
Using this also provides opportunities for introducing inet_csk_alloc_skb that would call alloc_skb, account it to the sock and skb_reserve(max_header), but I'll leave this for later, for now using sk_prot->max_header consistently is enough. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e5a6de915b
commit
118b2c9532
|
@ -201,7 +201,7 @@ static void dccp_v4_ctl_send_ack(struct sk_buff *rxskb)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
|
struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
|
||||||
const int dccp_hdr_ack_len = sizeof(struct dccp_hdr) +
|
const u32 dccp_hdr_ack_len = sizeof(struct dccp_hdr) +
|
||||||
sizeof(struct dccp_hdr_ext) +
|
sizeof(struct dccp_hdr_ext) +
|
||||||
sizeof(struct dccp_hdr_ack_bits);
|
sizeof(struct dccp_hdr_ack_bits);
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
@ -209,12 +209,12 @@ static void dccp_v4_ctl_send_ack(struct sk_buff *rxskb)
|
||||||
if (((struct rtable *)rxskb->dst)->rt_type != RTN_LOCAL)
|
if (((struct rtable *)rxskb->dst)->rt_type != RTN_LOCAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
skb = alloc_skb(MAX_DCCP_HEADER + 15, GFP_ATOMIC);
|
skb = alloc_skb(dccp_v4_ctl_socket->sk->sk_prot->max_header, GFP_ATOMIC);
|
||||||
if (skb == NULL)
|
if (skb == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Reserve space for headers. */
|
/* Reserve space for headers. */
|
||||||
skb_reserve(skb, MAX_DCCP_HEADER);
|
skb_reserve(skb, dccp_v4_ctl_socket->sk->sk_prot->max_header);
|
||||||
|
|
||||||
skb->dst = dst_clone(rxskb->dst);
|
skb->dst = dst_clone(rxskb->dst);
|
||||||
|
|
||||||
|
@ -715,12 +715,13 @@ static void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
|
||||||
if (dst == NULL)
|
if (dst == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
skb = alloc_skb(MAX_DCCP_HEADER + 15, GFP_ATOMIC);
|
skb = alloc_skb(dccp_v4_ctl_socket->sk->sk_prot->max_header,
|
||||||
|
GFP_ATOMIC);
|
||||||
if (skb == NULL)
|
if (skb == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Reserve space for headers. */
|
/* Reserve space for headers. */
|
||||||
skb_reserve(skb, MAX_DCCP_HEADER);
|
skb_reserve(skb, dccp_v4_ctl_socket->sk->sk_prot->max_header);
|
||||||
skb->dst = dst_clone(dst);
|
skb->dst = dst_clone(dst);
|
||||||
|
|
||||||
skb->h.raw = skb_push(skb, dccp_hdr_reset_len);
|
skb->h.raw = skb_push(skb, dccp_hdr_reset_len);
|
||||||
|
|
|
@ -514,7 +514,7 @@ static void dccp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb)
|
||||||
static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
|
static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
|
||||||
{
|
{
|
||||||
struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
|
struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
|
||||||
const int dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
|
const u32 dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
|
||||||
sizeof(struct dccp_hdr_ext) +
|
sizeof(struct dccp_hdr_ext) +
|
||||||
sizeof(struct dccp_hdr_reset);
|
sizeof(struct dccp_hdr_reset);
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
@ -527,18 +527,12 @@ static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
|
||||||
if (!ipv6_unicast_destination(rxskb))
|
if (!ipv6_unicast_destination(rxskb))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
skb = alloc_skb(dccp_v6_ctl_socket->sk->sk_prot->max_header,
|
||||||
* We need to grab some memory, and put together an RST,
|
GFP_ATOMIC);
|
||||||
* and then put it into the queue to be sent.
|
|
||||||
*/
|
|
||||||
|
|
||||||
skb = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) +
|
|
||||||
dccp_hdr_reset_len, GFP_ATOMIC);
|
|
||||||
if (skb == NULL)
|
if (skb == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr) +
|
skb_reserve(skb, dccp_v6_ctl_socket->sk->sk_prot->max_header);
|
||||||
dccp_hdr_reset_len);
|
|
||||||
|
|
||||||
skb->h.raw = skb_push(skb, dccp_hdr_reset_len);
|
skb->h.raw = skb_push(skb, dccp_hdr_reset_len);
|
||||||
dh = dccp_hdr(skb);
|
dh = dccp_hdr(skb);
|
||||||
|
@ -590,18 +584,17 @@ static void dccp_v6_ctl_send_ack(struct sk_buff *rxskb)
|
||||||
{
|
{
|
||||||
struct flowi fl;
|
struct flowi fl;
|
||||||
struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
|
struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
|
||||||
const int dccp_hdr_ack_len = sizeof(struct dccp_hdr) +
|
const u32 dccp_hdr_ack_len = sizeof(struct dccp_hdr) +
|
||||||
sizeof(struct dccp_hdr_ext) +
|
sizeof(struct dccp_hdr_ext) +
|
||||||
sizeof(struct dccp_hdr_ack_bits);
|
sizeof(struct dccp_hdr_ack_bits);
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
|
||||||
skb = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) +
|
skb = alloc_skb(dccp_v6_ctl_socket->sk->sk_prot->max_header,
|
||||||
dccp_hdr_ack_len, GFP_ATOMIC);
|
GFP_ATOMIC);
|
||||||
if (skb == NULL)
|
if (skb == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr) +
|
skb_reserve(skb, dccp_v6_ctl_socket->sk->sk_prot->max_header);
|
||||||
dccp_hdr_ack_len);
|
|
||||||
|
|
||||||
skb->h.raw = skb_push(skb, dccp_hdr_ack_len);
|
skb->h.raw = skb_push(skb, dccp_hdr_ack_len);
|
||||||
dh = dccp_hdr(skb);
|
dh = dccp_hdr(skb);
|
||||||
|
|
|
@ -49,7 +49,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
|
||||||
struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
|
struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
|
||||||
struct dccp_hdr *dh;
|
struct dccp_hdr *dh;
|
||||||
/* XXX For now we're using only 48 bits sequence numbers */
|
/* XXX For now we're using only 48 bits sequence numbers */
|
||||||
const int dccp_header_size = sizeof(*dh) +
|
const u32 dccp_header_size = sizeof(*dh) +
|
||||||
sizeof(struct dccp_hdr_ext) +
|
sizeof(struct dccp_hdr_ext) +
|
||||||
dccp_packet_hdr_len(dcb->dccpd_type);
|
dccp_packet_hdr_len(dcb->dccpd_type);
|
||||||
int err, set_ack = 1;
|
int err, set_ack = 1;
|
||||||
|
@ -279,17 +279,16 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
|
||||||
{
|
{
|
||||||
struct dccp_hdr *dh;
|
struct dccp_hdr *dh;
|
||||||
struct dccp_request_sock *dreq;
|
struct dccp_request_sock *dreq;
|
||||||
const int 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, MAX_HEADER + DCCP_MAX_OPT_LEN +
|
struct sk_buff *skb = sock_wmalloc(sk, sk->sk_prot->max_header, 1,
|
||||||
dccp_header_size, 1,
|
|
||||||
GFP_ATOMIC);
|
GFP_ATOMIC);
|
||||||
if (skb == NULL)
|
if (skb == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Reserve space for headers. */
|
/* Reserve space for headers. */
|
||||||
skb_reserve(skb, MAX_HEADER + DCCP_MAX_OPT_LEN + dccp_header_size);
|
skb_reserve(skb, sk->sk_prot->max_header);
|
||||||
|
|
||||||
skb->dst = dst_clone(dst);
|
skb->dst = dst_clone(dst);
|
||||||
skb->csum = 0;
|
skb->csum = 0;
|
||||||
|
@ -326,17 +325,16 @@ static struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
|
||||||
{
|
{
|
||||||
struct dccp_hdr *dh;
|
struct dccp_hdr *dh;
|
||||||
struct dccp_sock *dp = dccp_sk(sk);
|
struct dccp_sock *dp = dccp_sk(sk);
|
||||||
const int 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_reset);
|
sizeof(struct dccp_hdr_reset);
|
||||||
struct sk_buff *skb = sock_wmalloc(sk, MAX_HEADER + DCCP_MAX_OPT_LEN +
|
struct sk_buff *skb = sock_wmalloc(sk, sk->sk_prot->max_header, 1,
|
||||||
dccp_header_size, 1,
|
|
||||||
GFP_ATOMIC);
|
GFP_ATOMIC);
|
||||||
if (skb == NULL)
|
if (skb == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Reserve space for headers. */
|
/* Reserve space for headers. */
|
||||||
skb_reserve(skb, MAX_HEADER + DCCP_MAX_OPT_LEN + dccp_header_size);
|
skb_reserve(skb, sk->sk_prot->max_header);
|
||||||
|
|
||||||
skb->dst = dst_clone(dst);
|
skb->dst = dst_clone(dst);
|
||||||
skb->csum = 0;
|
skb->csum = 0;
|
||||||
|
@ -426,12 +424,12 @@ int dccp_connect(struct sock *sk)
|
||||||
|
|
||||||
dccp_connect_init(sk);
|
dccp_connect_init(sk);
|
||||||
|
|
||||||
skb = alloc_skb(MAX_DCCP_HEADER + 15, sk->sk_allocation);
|
skb = alloc_skb(sk->sk_prot->max_header, sk->sk_allocation);
|
||||||
if (unlikely(skb == NULL))
|
if (unlikely(skb == NULL))
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
|
|
||||||
/* Reserve space for headers. */
|
/* Reserve space for headers. */
|
||||||
skb_reserve(skb, MAX_DCCP_HEADER);
|
skb_reserve(skb, sk->sk_prot->max_header);
|
||||||
|
|
||||||
DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST;
|
DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST;
|
||||||
skb->csum = 0;
|
skb->csum = 0;
|
||||||
|
@ -452,7 +450,8 @@ void dccp_send_ack(struct sock *sk)
|
||||||
{
|
{
|
||||||
/* If we have been reset, we may not send again. */
|
/* If we have been reset, we may not send again. */
|
||||||
if (sk->sk_state != DCCP_CLOSED) {
|
if (sk->sk_state != DCCP_CLOSED) {
|
||||||
struct sk_buff *skb = alloc_skb(MAX_DCCP_HEADER, GFP_ATOMIC);
|
struct sk_buff *skb = alloc_skb(sk->sk_prot->max_header,
|
||||||
|
GFP_ATOMIC);
|
||||||
|
|
||||||
if (skb == NULL) {
|
if (skb == NULL) {
|
||||||
inet_csk_schedule_ack(sk);
|
inet_csk_schedule_ack(sk);
|
||||||
|
@ -464,7 +463,7 @@ void dccp_send_ack(struct sock *sk)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reserve space for headers */
|
/* Reserve space for headers */
|
||||||
skb_reserve(skb, MAX_DCCP_HEADER);
|
skb_reserve(skb, sk->sk_prot->max_header);
|
||||||
skb->csum = 0;
|
skb->csum = 0;
|
||||||
DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_ACK;
|
DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_ACK;
|
||||||
dccp_transmit_skb(sk, skb);
|
dccp_transmit_skb(sk, skb);
|
||||||
|
@ -511,14 +510,14 @@ void dccp_send_sync(struct sock *sk, const u64 seq,
|
||||||
* dccp_transmit_skb() will set the ownership to this
|
* dccp_transmit_skb() will set the ownership to this
|
||||||
* sock.
|
* sock.
|
||||||
*/
|
*/
|
||||||
struct sk_buff *skb = alloc_skb(MAX_DCCP_HEADER, GFP_ATOMIC);
|
struct sk_buff *skb = alloc_skb(sk->sk_prot->max_header, GFP_ATOMIC);
|
||||||
|
|
||||||
if (skb == NULL)
|
if (skb == NULL)
|
||||||
/* FIXME: how to make sure the sync is sent? */
|
/* FIXME: how to make sure the sync is sent? */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Reserve space for headers and prepare control bits. */
|
/* Reserve space for headers and prepare control bits. */
|
||||||
skb_reserve(skb, MAX_DCCP_HEADER);
|
skb_reserve(skb, sk->sk_prot->max_header);
|
||||||
skb->csum = 0;
|
skb->csum = 0;
|
||||||
DCCP_SKB_CB(skb)->dccpd_type = pkt_type;
|
DCCP_SKB_CB(skb)->dccpd_type = pkt_type;
|
||||||
DCCP_SKB_CB(skb)->dccpd_seq = seq;
|
DCCP_SKB_CB(skb)->dccpd_seq = seq;
|
||||||
|
|
Loading…
Reference in a new issue