mirror of https://gitee.com/openkylin/linux.git
[DCCP]: Simplify skb_set_owner_w semantics
While we're at it let's reorganise the set_owner_w calls a little so that: 1) dccp_transmit_skb sets the owner for all packets except data packets. 2) Add dccp_skb_entail to set owner for packets queued for retransmission. 3) Make dccp_transmit_skb static. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
parent
9d17f21893
commit
48918a4dbd
|
@ -118,7 +118,6 @@ DECLARE_SNMP_STAT(struct dccp_mib, dccp_statistics);
|
||||||
#define DCCP_ADD_STATS_USER(field, val) \
|
#define DCCP_ADD_STATS_USER(field, val) \
|
||||||
SNMP_ADD_STATS_USER(dccp_statistics, field, val)
|
SNMP_ADD_STATS_USER(dccp_statistics, field, val)
|
||||||
|
|
||||||
extern int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb);
|
|
||||||
extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb);
|
extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb);
|
||||||
|
|
||||||
extern int dccp_send_response(struct sock *sk);
|
extern int dccp_send_response(struct sock *sk);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <linux/config.h>
|
#include <linux/config.h>
|
||||||
#include <linux/dccp.h>
|
#include <linux/dccp.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
|
|
||||||
#include <net/sock.h>
|
#include <net/sock.h>
|
||||||
|
@ -25,13 +26,20 @@ static inline void dccp_event_ack_sent(struct sock *sk)
|
||||||
inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
|
inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void dccp_skb_entail(struct sock *sk, struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
skb_set_owner_w(skb, sk);
|
||||||
|
WARN_ON(sk->sk_send_head);
|
||||||
|
sk->sk_send_head = skb;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All SKB's seen here are completely headerless. It is our
|
* All SKB's seen here are completely headerless. It is our
|
||||||
* job to build the DCCP header, and pass the packet down to
|
* job to build the DCCP header, and pass the packet down to
|
||||||
* IP so it can do the same plus pass the packet off to the
|
* IP so it can do the same plus pass the packet off to the
|
||||||
* device.
|
* device.
|
||||||
*/
|
*/
|
||||||
int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
|
static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
if (likely(skb != NULL)) {
|
if (likely(skb != NULL)) {
|
||||||
const struct inet_sock *inet = inet_sk(sk);
|
const struct inet_sock *inet = inet_sk(sk);
|
||||||
|
@ -63,6 +71,9 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
|
||||||
skb->h.raw = skb_push(skb, dccp_header_size);
|
skb->h.raw = skb_push(skb, dccp_header_size);
|
||||||
dh = dccp_hdr(skb);
|
dh = dccp_hdr(skb);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only data packets should come through with skb->sk set.
|
||||||
|
*/
|
||||||
if (!skb->sk)
|
if (!skb->sk)
|
||||||
skb_set_owner_w(skb, sk);
|
skb_set_owner_w(skb, sk);
|
||||||
|
|
||||||
|
@ -393,10 +404,8 @@ int dccp_connect(struct sock *sk)
|
||||||
|
|
||||||
DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST;
|
DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST;
|
||||||
skb->csum = 0;
|
skb->csum = 0;
|
||||||
skb_set_owner_w(skb, sk);
|
|
||||||
|
|
||||||
BUG_TRAP(sk->sk_send_head == NULL);
|
dccp_skb_entail(sk, skb);
|
||||||
sk->sk_send_head = skb;
|
|
||||||
dccp_transmit_skb(sk, skb_clone(skb, GFP_KERNEL));
|
dccp_transmit_skb(sk, skb_clone(skb, GFP_KERNEL));
|
||||||
DCCP_INC_STATS(DCCP_MIB_ACTIVEOPENS);
|
DCCP_INC_STATS(DCCP_MIB_ACTIVEOPENS);
|
||||||
|
|
||||||
|
@ -425,7 +434,6 @@ void dccp_send_ack(struct sock *sk)
|
||||||
skb_reserve(skb, MAX_DCCP_HEADER);
|
skb_reserve(skb, MAX_DCCP_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;
|
||||||
skb_set_owner_w(skb, sk);
|
|
||||||
dccp_transmit_skb(sk, skb);
|
dccp_transmit_skb(sk, skb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,7 +490,6 @@ void dccp_send_sync(struct sock *sk, const u64 seq,
|
||||||
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;
|
||||||
|
|
||||||
skb_set_owner_w(skb, sk);
|
|
||||||
dccp_transmit_skb(sk, skb);
|
dccp_transmit_skb(sk, skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,10 +514,8 @@ void dccp_send_close(struct sock *sk, const int active)
|
||||||
DCCP_SKB_CB(skb)->dccpd_type = dp->dccps_role == DCCP_ROLE_CLIENT ?
|
DCCP_SKB_CB(skb)->dccpd_type = dp->dccps_role == DCCP_ROLE_CLIENT ?
|
||||||
DCCP_PKT_CLOSE : DCCP_PKT_CLOSEREQ;
|
DCCP_PKT_CLOSE : DCCP_PKT_CLOSEREQ;
|
||||||
|
|
||||||
skb_set_owner_w(skb, sk);
|
|
||||||
if (active) {
|
if (active) {
|
||||||
BUG_TRAP(sk->sk_send_head == NULL);
|
dccp_skb_entail(sk, skb);
|
||||||
sk->sk_send_head = skb;
|
|
||||||
dccp_transmit_skb(sk, skb_clone(skb, prio));
|
dccp_transmit_skb(sk, skb_clone(skb, prio));
|
||||||
} else
|
} else
|
||||||
dccp_transmit_skb(sk, skb);
|
dccp_transmit_skb(sk, skb);
|
||||||
|
|
Loading…
Reference in New Issue