提交 4259cb25 编写于 作者: L Linus Torvalds

Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (32 commits)
  [NETPOLL]: Fix local_bh_enable() warning.
  [IPVS]: Make ip_vs_sync.c <= 80col wide.
  [IPVS]: Use msleep_interruptable() instead of ssleep() aka msleep()
  [HAMRADIO]: Fix baycom_epp.c compile failure.
  [DCCP]: Whitespace cleanups
  [DCCP] ccid3: Fixup some type conversions related to rtts
  [DCCP] ccid3: BUG-FIX - conversion errors
  [DCCP] ccid3: Reorder packet history source file
  [DCCP] ccid3: Reorder packet history header file
  [DCCP] ccid3: Make debug output consistent
  [DCCP] ccid3: Perform history operations only after packet has been sent
  [DCCP] ccid3: TX history - remove unused field
  [DCCP] ccid3: Shift window counter computation
  [DCCP] ccid3: Sanity-check RTT samples
  [DCCP] ccid3: Initialise RTT values
  [DCCP] ccid: Deprecate ccid_hc_tx_insert_options
  [DCCP]: Warn when discarding packet due to internal errors
  [DCCP]: Only deliver to the CCID rx side in charge
  [DCCP]: Simplify TFRC calculation
  [DCCP]: Debug timeval operations
  ...
...@@ -19,7 +19,8 @@ for real time and multimedia traffic. ...@@ -19,7 +19,8 @@ for real time and multimedia traffic.
It has a base protocol and pluggable congestion control IDs (CCIDs). It has a base protocol and pluggable congestion control IDs (CCIDs).
It is at experimental RFC status and the homepage for DCCP as a protocol is at: It is at proposed standard RFC status and the homepage for DCCP as a protocol
is at:
http://www.read.cs.ucla.edu/dccp/ http://www.read.cs.ucla.edu/dccp/
Missing features Missing features
...@@ -34,9 +35,6 @@ The known bugs are at: ...@@ -34,9 +35,6 @@ The known bugs are at:
Socket options Socket options
============== ==============
DCCP_SOCKOPT_PACKET_SIZE is used for CCID3 to set default packet size for
calculations.
DCCP_SOCKOPT_SERVICE sets the service. The specification mandates use of DCCP_SOCKOPT_SERVICE sets the service. The specification mandates use of
service codes (RFC 4340, sec. 8.1.2); if this socket option is not set, service codes (RFC 4340, sec. 8.1.2); if this socket option is not set,
the socket will fall back to 0 (which means that no meaningful service code the socket will fall back to 0 (which means that no meaningful service code
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#define SHA384_DIGEST_SIZE 48 #define SHA384_DIGEST_SIZE 48
#define SHA512_DIGEST_SIZE 64 #define SHA512_DIGEST_SIZE 64
#define SHA384_HMAC_BLOCK_SIZE 96 #define SHA384_HMAC_BLOCK_SIZE 128
#define SHA512_HMAC_BLOCK_SIZE 128 #define SHA512_HMAC_BLOCK_SIZE 128
struct sha512_ctx { struct sha512_ctx {
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
fore200e_mkfirm fore200e_mkfirm
fore200e_pca_fw.c fore200e_pca_fw.c
pca200e.bin pca200e.bin
pca200e_ecd.bin2
...@@ -1177,7 +1177,7 @@ static void baycom_probe(struct net_device *dev) ...@@ -1177,7 +1177,7 @@ static void baycom_probe(struct net_device *dev)
dev->mtu = AX25_DEF_PACLEN; /* eth_mtu is the default */ dev->mtu = AX25_DEF_PACLEN; /* eth_mtu is the default */
dev->addr_len = AX25_ADDR_LEN; /* sizeof an ax.25 address */ dev->addr_len = AX25_ADDR_LEN; /* sizeof an ax.25 address */
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, &ax25_nocall, AX25_ADDR_LEN); memcpy(dev->dev_addr, &null_ax25_address, AX25_ADDR_LEN);
dev->tx_queue_len = 16; dev->tx_queue_len = 16;
/* New style flags */ /* New style flags */
......
...@@ -382,7 +382,7 @@ config SDLA ...@@ -382,7 +382,7 @@ config SDLA
# Wan router core. # Wan router core.
config WAN_ROUTER_DRIVERS config WAN_ROUTER_DRIVERS
bool "WAN router drivers" tristate "WAN router drivers"
depends on WAN && WAN_ROUTER depends on WAN && WAN_ROUTER
---help--- ---help---
Connect LAN to WAN via Linux box. Connect LAN to WAN via Linux box.
...@@ -393,7 +393,8 @@ config WAN_ROUTER_DRIVERS ...@@ -393,7 +393,8 @@ config WAN_ROUTER_DRIVERS
<file:Documentation/networking/wan-router.txt>. <file:Documentation/networking/wan-router.txt>.
Note that the answer to this question won't directly affect the Note that the answer to this question won't directly affect the
kernel: saying N will just cause the configurator to skip all kernel except for how subordinate drivers may be built:
saying N will just cause the configurator to skip all
the questions about WAN router drivers. the questions about WAN router drivers.
If unsure, say N. If unsure, say N.
......
...@@ -176,20 +176,20 @@ enum { ...@@ -176,20 +176,20 @@ enum {
}; };
/* DCCP features (RFC 4340 section 6.4) */ /* DCCP features (RFC 4340 section 6.4) */
enum { enum {
DCCPF_RESERVED = 0, DCCPF_RESERVED = 0,
DCCPF_CCID = 1, DCCPF_CCID = 1,
DCCPF_SHORT_SEQNOS = 2, /* XXX: not yet implemented */ DCCPF_SHORT_SEQNOS = 2, /* XXX: not yet implemented */
DCCPF_SEQUENCE_WINDOW = 3, DCCPF_SEQUENCE_WINDOW = 3,
DCCPF_ECN_INCAPABLE = 4, /* XXX: not yet implemented */ DCCPF_ECN_INCAPABLE = 4, /* XXX: not yet implemented */
DCCPF_ACK_RATIO = 5, DCCPF_ACK_RATIO = 5,
DCCPF_SEND_ACK_VECTOR = 6, DCCPF_SEND_ACK_VECTOR = 6,
DCCPF_SEND_NDP_COUNT = 7, DCCPF_SEND_NDP_COUNT = 7,
DCCPF_MIN_CSUM_COVER = 8, DCCPF_MIN_CSUM_COVER = 8,
DCCPF_DATA_CHECKSUM = 9, /* XXX: not yet implemented */ DCCPF_DATA_CHECKSUM = 9, /* XXX: not yet implemented */
/* 10-127 reserved */ /* 10-127 reserved */
DCCPF_MIN_CCID_SPECIFIC = 128, DCCPF_MIN_CCID_SPECIFIC = 128,
DCCPF_MAX_CCID_SPECIFIC = 255, DCCPF_MAX_CCID_SPECIFIC = 255,
}; };
/* this structure is argument to DCCP_SOCKOPT_CHANGE_X */ /* this structure is argument to DCCP_SOCKOPT_CHANGE_X */
...@@ -427,7 +427,7 @@ struct dccp_service_list { ...@@ -427,7 +427,7 @@ struct dccp_service_list {
}; };
#define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1) #define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1)
#define DCCP_SERVICE_CODE_IS_ABSENT 0 #define DCCP_SERVICE_CODE_IS_ABSENT 0
static inline int dccp_list_has_service(const struct dccp_service_list *sl, static inline int dccp_list_has_service(const struct dccp_service_list *sl,
const __be32 service) const __be32 service)
...@@ -436,7 +436,7 @@ static inline int dccp_list_has_service(const struct dccp_service_list *sl, ...@@ -436,7 +436,7 @@ static inline int dccp_list_has_service(const struct dccp_service_list *sl,
u32 i = sl->dccpsl_nr; u32 i = sl->dccpsl_nr;
while (i--) while (i--)
if (sl->dccpsl_list[i] == service) if (sl->dccpsl_list[i] == service)
return 1; return 1;
} }
return 0; return 0;
} }
...@@ -511,7 +511,7 @@ struct dccp_sock { ...@@ -511,7 +511,7 @@ struct dccp_sock {
__u8 dccps_hc_tx_insert_options:1; __u8 dccps_hc_tx_insert_options:1;
struct timer_list dccps_xmit_timer; struct timer_list dccps_xmit_timer;
}; };
static inline struct dccp_sock *dccp_sk(const struct sock *sk) static inline struct dccp_sock *dccp_sk(const struct sock *sk)
{ {
return (struct dccp_sock *)sk; return (struct dccp_sock *)sk;
......
...@@ -37,10 +37,14 @@ struct tfrc_rx_info { ...@@ -37,10 +37,14 @@ struct tfrc_rx_info {
* @tfrctx_p: current loss event rate (5.4) * @tfrctx_p: current loss event rate (5.4)
* @tfrctx_rto: estimate of RTO, equals 4*RTT (4.3) * @tfrctx_rto: estimate of RTO, equals 4*RTT (4.3)
* @tfrctx_ipi: inter-packet interval (4.6) * @tfrctx_ipi: inter-packet interval (4.6)
*
* Note: X and X_recv are both maintained in units of 64 * bytes/second. This
* enables a finer resolution of sending rates and avoids problems with
* integer arithmetic; u32 is not sufficient as scaling consumes 6 bits.
*/ */
struct tfrc_tx_info { struct tfrc_tx_info {
__u32 tfrctx_x; __u64 tfrctx_x;
__u32 tfrctx_x_recv; __u64 tfrctx_x_recv;
__u32 tfrctx_x_calc; __u32 tfrctx_x_calc;
__u32 tfrctx_rtt; __u32 tfrctx_rtt;
__u32 tfrctx_p; __u32 tfrctx_p;
......
...@@ -285,6 +285,8 @@ extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *); ...@@ -285,6 +285,8 @@ extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *);
extern const ax25_address ax25_bcast; extern const ax25_address ax25_bcast;
extern const ax25_address ax25_defaddr; extern const ax25_address ax25_defaddr;
extern const ax25_address null_ax25_address; extern const ax25_address null_ax25_address;
extern char *ax2asc(char *buf, const ax25_address *);
extern void asc2ax(ax25_address *addr, const char *callsign);
extern int ax25cmp(const ax25_address *, const ax25_address *); extern int ax25cmp(const ax25_address *, const ax25_address *);
extern int ax25digicmp(const ax25_digi *, const ax25_digi *); extern int ax25digicmp(const ax25_digi *, const ax25_digi *);
extern const unsigned char *ax25_addr_parse(const unsigned char *, int, extern const unsigned char *ax25_addr_parse(const unsigned char *, int,
......
...@@ -83,7 +83,7 @@ EXPORT_SYMBOL(ax2asc); ...@@ -83,7 +83,7 @@ EXPORT_SYMBOL(ax2asc);
*/ */
void asc2ax(ax25_address *addr, const char *callsign) void asc2ax(ax25_address *addr, const char *callsign)
{ {
char *s; const char *s;
int n; int n;
for (s = callsign, n = 0; n < 6; n++) { for (s = callsign, n = 0; n < 6; n++) {
......
...@@ -242,22 +242,28 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) ...@@ -242,22 +242,28 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
/* don't get messages out of order, and no recursion */ /* don't get messages out of order, and no recursion */
if (skb_queue_len(&npinfo->txq) == 0 && if (skb_queue_len(&npinfo->txq) == 0 &&
npinfo->poll_owner != smp_processor_id() && npinfo->poll_owner != smp_processor_id()) {
netif_tx_trylock(dev)) { unsigned long flags;
/* try until next clock tick */
for (tries = jiffies_to_usecs(1)/USEC_PER_POLL; tries > 0; --tries) {
if (!netif_queue_stopped(dev))
status = dev->hard_start_xmit(skb, dev);
if (status == NETDEV_TX_OK) local_irq_save(flags);
break; if (netif_tx_trylock(dev)) {
/* try until next clock tick */
for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
tries > 0; --tries) {
if (!netif_queue_stopped(dev))
status = dev->hard_start_xmit(skb, dev);
/* tickle device maybe there is some cleanup */ if (status == NETDEV_TX_OK)
netpoll_poll(np); break;
udelay(USEC_PER_POLL); /* tickle device maybe there is some cleanup */
netpoll_poll(np);
udelay(USEC_PER_POLL);
}
netif_tx_unlock(dev);
} }
netif_tx_unlock(dev); local_irq_restore(flags);
} }
if (status != NETDEV_TX_OK) { if (status != NETDEV_TX_OK) {
......
...@@ -223,7 +223,7 @@ static inline int dccp_ackvec_set_buf_head_state(struct dccp_ackvec *av, ...@@ -223,7 +223,7 @@ static inline int dccp_ackvec_set_buf_head_state(struct dccp_ackvec *av,
gap = -new_head; gap = -new_head;
} }
new_head += DCCP_MAX_ACKVEC_LEN; new_head += DCCP_MAX_ACKVEC_LEN;
} }
av->dccpav_buf_head = new_head; av->dccpav_buf_head = new_head;
...@@ -336,7 +336,7 @@ int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, ...@@ -336,7 +336,7 @@ int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len) void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len)
{ {
dccp_pr_debug_cat("ACK vector len=%d, ackno=%llu |", len, dccp_pr_debug_cat("ACK vector len=%d, ackno=%llu |", len,
(unsigned long long)ackno); (unsigned long long)ackno);
while (len--) { while (len--) {
const u8 state = (*vector & DCCP_ACKVEC_STATE_MASK) >> 6; const u8 state = (*vector & DCCP_ACKVEC_STATE_MASK) >> 6;
......
...@@ -43,8 +43,6 @@ struct ccid_operations { ...@@ -43,8 +43,6 @@ struct ccid_operations {
unsigned char* value); unsigned char* value);
int (*ccid_hc_rx_insert_options)(struct sock *sk, int (*ccid_hc_rx_insert_options)(struct sock *sk,
struct sk_buff *skb); struct sk_buff *skb);
int (*ccid_hc_tx_insert_options)(struct sock *sk,
struct sk_buff *skb);
void (*ccid_hc_tx_packet_recv)(struct sock *sk, void (*ccid_hc_tx_packet_recv)(struct sock *sk,
struct sk_buff *skb); struct sk_buff *skb);
int (*ccid_hc_tx_parse_options)(struct sock *sk, int (*ccid_hc_tx_parse_options)(struct sock *sk,
...@@ -146,14 +144,6 @@ static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk, ...@@ -146,14 +144,6 @@ static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
return rc; return rc;
} }
static inline int ccid_hc_tx_insert_options(struct ccid *ccid, struct sock *sk,
struct sk_buff *skb)
{
if (ccid->ccid_ops->ccid_hc_tx_insert_options != NULL)
return ccid->ccid_ops->ccid_hc_tx_insert_options(sk, skb);
return 0;
}
static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk, static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
struct sk_buff *skb) struct sk_buff *skb)
{ {
......
...@@ -351,7 +351,7 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len) ...@@ -351,7 +351,7 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
while (seqp != hctx->ccid2hctx_seqh) { while (seqp != hctx->ccid2hctx_seqh) {
ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n", ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n",
(unsigned long long)seqp->ccid2s_seq, (unsigned long long)seqp->ccid2s_seq,
seqp->ccid2s_acked, seqp->ccid2s_sent); seqp->ccid2s_acked, seqp->ccid2s_sent);
seqp = seqp->ccid2s_next; seqp = seqp->ccid2s_next;
} }
...@@ -473,7 +473,7 @@ static inline void ccid2_new_ack(struct sock *sk, ...@@ -473,7 +473,7 @@ static inline void ccid2_new_ack(struct sock *sk,
/* first measurement */ /* first measurement */
if (hctx->ccid2hctx_srtt == -1) { if (hctx->ccid2hctx_srtt == -1) {
ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n", ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n",
r, jiffies, r, jiffies,
(unsigned long long)seqp->ccid2s_seq); (unsigned long long)seqp->ccid2s_seq);
ccid2_change_srtt(hctx, r); ccid2_change_srtt(hctx, r);
hctx->ccid2hctx_rttvar = r >> 1; hctx->ccid2hctx_rttvar = r >> 1;
...@@ -518,8 +518,8 @@ static inline void ccid2_new_ack(struct sock *sk, ...@@ -518,8 +518,8 @@ static inline void ccid2_new_ack(struct sock *sk,
hctx->ccid2hctx_lastrtt = jiffies; hctx->ccid2hctx_lastrtt = jiffies;
ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n", ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n",
hctx->ccid2hctx_srtt, hctx->ccid2hctx_rttvar, hctx->ccid2hctx_srtt, hctx->ccid2hctx_rttvar,
hctx->ccid2hctx_rto, HZ, r); hctx->ccid2hctx_rto, HZ, r);
hctx->ccid2hctx_sent = 0; hctx->ccid2hctx_sent = 0;
} }
...@@ -667,9 +667,9 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -667,9 +667,9 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
/* new packet received or marked */ /* new packet received or marked */
if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED && if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED &&
!seqp->ccid2s_acked) { !seqp->ccid2s_acked) {
if (state == if (state ==
DCCP_ACKVEC_STATE_ECN_MARKED) { DCCP_ACKVEC_STATE_ECN_MARKED) {
ccid2_congestion_event(hctx, ccid2_congestion_event(hctx,
seqp); seqp);
} else } else
ccid2_new_ack(sk, seqp, ccid2_new_ack(sk, seqp,
......
此差异已折叠。
...@@ -51,6 +51,16 @@ ...@@ -51,6 +51,16 @@
/* Parameter t_mbi from [RFC 3448, 4.3]: backoff interval in seconds */ /* Parameter t_mbi from [RFC 3448, 4.3]: backoff interval in seconds */
#define TFRC_T_MBI 64 #define TFRC_T_MBI 64
/* What we think is a reasonable upper limit on RTT values */
#define CCID3_SANE_RTT_MAX ((suseconds_t)(4 * USEC_PER_SEC))
#define CCID3_RTT_SANITY_CHECK(rtt) do { \
if (rtt > CCID3_SANE_RTT_MAX) { \
DCCP_CRIT("RTT (%d) too large, substituting %d", \
(int)rtt, (int)CCID3_SANE_RTT_MAX); \
rtt = CCID3_SANE_RTT_MAX; \
} } while (0)
enum ccid3_options { enum ccid3_options {
TFRC_OPT_LOSS_EVENT_RATE = 192, TFRC_OPT_LOSS_EVENT_RATE = 192,
TFRC_OPT_LOSS_INTERVALS = 193, TFRC_OPT_LOSS_INTERVALS = 193,
...@@ -67,7 +77,7 @@ struct ccid3_options_received { ...@@ -67,7 +77,7 @@ struct ccid3_options_received {
/* TFRC sender states */ /* TFRC sender states */
enum ccid3_hc_tx_states { enum ccid3_hc_tx_states {
TFRC_SSTATE_NO_SENT = 1, TFRC_SSTATE_NO_SENT = 1,
TFRC_SSTATE_NO_FBACK, TFRC_SSTATE_NO_FBACK,
TFRC_SSTATE_FBACK, TFRC_SSTATE_FBACK,
TFRC_SSTATE_TERM, TFRC_SSTATE_TERM,
...@@ -75,23 +85,23 @@ enum ccid3_hc_tx_states { ...@@ -75,23 +85,23 @@ enum ccid3_hc_tx_states {
/** struct ccid3_hc_tx_sock - CCID3 sender half-connection socket /** struct ccid3_hc_tx_sock - CCID3 sender half-connection socket
* *
* @ccid3hctx_x - Current sending rate * @ccid3hctx_x - Current sending rate in 64 * bytes per second
* @ccid3hctx_x_recv - Receive rate * @ccid3hctx_x_recv - Receive rate in 64 * bytes per second
* @ccid3hctx_x_calc - Calculated send rate (RFC 3448, 3.1) * @ccid3hctx_x_calc - Calculated rate in bytes per second
* @ccid3hctx_rtt - Estimate of current round trip time in usecs * @ccid3hctx_rtt - Estimate of current round trip time in usecs
* @ccid3hctx_p - Current loss event rate (0-1) scaled by 1000000 * @ccid3hctx_p - Current loss event rate (0-1) scaled by 1000000
* @ccid3hctx_s - Packet size * @ccid3hctx_s - Packet size in bytes
* @ccid3hctx_t_rto - Retransmission Timeout (RFC 3448, 3.1) * @ccid3hctx_t_rto - Nofeedback Timer setting in usecs
* @ccid3hctx_t_ipi - Interpacket (send) interval (RFC 3448, 4.6) * @ccid3hctx_t_ipi - Interpacket (send) interval (RFC 3448, 4.6) in usecs
* @ccid3hctx_state - Sender state, one of %ccid3_hc_tx_states * @ccid3hctx_state - Sender state, one of %ccid3_hc_tx_states
* @ccid3hctx_last_win_count - Last window counter sent * @ccid3hctx_last_win_count - Last window counter sent
* @ccid3hctx_t_last_win_count - Timestamp of earliest packet * @ccid3hctx_t_last_win_count - Timestamp of earliest packet
* with last_win_count value sent * with last_win_count value sent
* @ccid3hctx_no_feedback_timer - Handle to no feedback timer * @ccid3hctx_no_feedback_timer - Handle to no feedback timer
* @ccid3hctx_idle - Flag indicating that sender is idling * @ccid3hctx_idle - Flag indicating that sender is idling
* @ccid3hctx_t_ld - Time last doubled during slow start * @ccid3hctx_t_ld - Time last doubled during slow start
* @ccid3hctx_t_nom - Nominal send time of next packet * @ccid3hctx_t_nom - Nominal send time of next packet
* @ccid3hctx_delta - Send timer delta * @ccid3hctx_delta - Send timer delta (RFC 3448, 4.6) in usecs
* @ccid3hctx_hist - Packet history * @ccid3hctx_hist - Packet history
* @ccid3hctx_options_received - Parsed set of retrieved options * @ccid3hctx_options_received - Parsed set of retrieved options
*/ */
...@@ -105,7 +115,7 @@ struct ccid3_hc_tx_sock { ...@@ -105,7 +115,7 @@ struct ccid3_hc_tx_sock {
#define ccid3hctx_t_rto ccid3hctx_tfrc.tfrctx_rto #define ccid3hctx_t_rto ccid3hctx_tfrc.tfrctx_rto
#define ccid3hctx_t_ipi ccid3hctx_tfrc.tfrctx_ipi #define ccid3hctx_t_ipi ccid3hctx_tfrc.tfrctx_ipi
u16 ccid3hctx_s; u16 ccid3hctx_s;
enum ccid3_hc_tx_states ccid3hctx_state:8; enum ccid3_hc_tx_states ccid3hctx_state:8;
u8 ccid3hctx_last_win_count; u8 ccid3hctx_last_win_count;
u8 ccid3hctx_idle; u8 ccid3hctx_idle;
struct timeval ccid3hctx_t_last_win_count; struct timeval ccid3hctx_t_last_win_count;
...@@ -119,7 +129,7 @@ struct ccid3_hc_tx_sock { ...@@ -119,7 +129,7 @@ struct ccid3_hc_tx_sock {
/* TFRC receiver states */ /* TFRC receiver states */
enum ccid3_hc_rx_states { enum ccid3_hc_rx_states {
TFRC_RSTATE_NO_DATA = 1, TFRC_RSTATE_NO_DATA = 1,
TFRC_RSTATE_DATA, TFRC_RSTATE_DATA,
TFRC_RSTATE_TERM = 127, TFRC_RSTATE_TERM = 127,
}; };
...@@ -147,18 +157,18 @@ struct ccid3_hc_rx_sock { ...@@ -147,18 +157,18 @@ struct ccid3_hc_rx_sock {
#define ccid3hcrx_x_recv ccid3hcrx_tfrc.tfrcrx_x_recv #define ccid3hcrx_x_recv ccid3hcrx_tfrc.tfrcrx_x_recv
#define ccid3hcrx_rtt ccid3hcrx_tfrc.tfrcrx_rtt #define ccid3hcrx_rtt ccid3hcrx_tfrc.tfrcrx_rtt
#define ccid3hcrx_p ccid3hcrx_tfrc.tfrcrx_p #define ccid3hcrx_p ccid3hcrx_tfrc.tfrcrx_p
u64 ccid3hcrx_seqno_nonloss:48, u64 ccid3hcrx_seqno_nonloss:48,
ccid3hcrx_ccval_nonloss:4, ccid3hcrx_ccval_nonloss:4,
ccid3hcrx_ccval_last_counter:4; ccid3hcrx_ccval_last_counter:4;
enum ccid3_hc_rx_states ccid3hcrx_state:8; enum ccid3_hc_rx_states ccid3hcrx_state:8;
u32 ccid3hcrx_bytes_recv; u32 ccid3hcrx_bytes_recv;
struct timeval ccid3hcrx_tstamp_last_feedback; struct timeval ccid3hcrx_tstamp_last_feedback;
struct timeval ccid3hcrx_tstamp_last_ack; struct timeval ccid3hcrx_tstamp_last_ack;
struct list_head ccid3hcrx_hist; struct list_head ccid3hcrx_hist;
struct list_head ccid3hcrx_li_hist; struct list_head ccid3hcrx_li_hist;
u16 ccid3hcrx_s; u16 ccid3hcrx_s;
u32 ccid3hcrx_pinv; u32 ccid3hcrx_pinv;
u32 ccid3hcrx_elapsed_time; u32 ccid3hcrx_elapsed_time;
}; };
static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)
......
...@@ -36,9 +36,100 @@ ...@@ -36,9 +36,100 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/string.h> #include <linux/string.h>
#include "packet_history.h" #include "packet_history.h"
/*
* Transmitter History Routines
*/
struct dccp_tx_hist *dccp_tx_hist_new(const char *name)
{
struct dccp_tx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC);
static const char dccp_tx_hist_mask[] = "tx_hist_%s";
char *slab_name;
if (hist == NULL)
goto out;
slab_name = kmalloc(strlen(name) + sizeof(dccp_tx_hist_mask) - 1,
GFP_ATOMIC);
if (slab_name == NULL)
goto out_free_hist;
sprintf(slab_name, dccp_tx_hist_mask, name);
hist->dccptxh_slab = kmem_cache_create(slab_name,
sizeof(struct dccp_tx_hist_entry),
0, SLAB_HWCACHE_ALIGN,
NULL, NULL);
if (hist->dccptxh_slab == NULL)
goto out_free_slab_name;
out:
return hist;
out_free_slab_name:
kfree(slab_name);
out_free_hist:
kfree(hist);
hist = NULL;
goto out;
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_new);
void dccp_tx_hist_delete(struct dccp_tx_hist *hist)
{
const char* name = kmem_cache_name(hist->dccptxh_slab);
kmem_cache_destroy(hist->dccptxh_slab);
kfree(name);
kfree(hist);
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_delete);
struct dccp_tx_hist_entry *
dccp_tx_hist_find_entry(const struct list_head *list, const u64 seq)
{
struct dccp_tx_hist_entry *packet = NULL, *entry;
list_for_each_entry(entry, list, dccphtx_node)
if (entry->dccphtx_seqno == seq) {
packet = entry;
break;
}
return packet;
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_find_entry);
void dccp_tx_hist_purge(struct dccp_tx_hist *hist, struct list_head *list)
{
struct dccp_tx_hist_entry *entry, *next;
list_for_each_entry_safe(entry, next, list, dccphtx_node) {
list_del_init(&entry->dccphtx_node);
dccp_tx_hist_entry_delete(hist, entry);
}
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_purge);
void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
struct list_head *list,
struct dccp_tx_hist_entry *packet)
{
struct dccp_tx_hist_entry *next;
list_for_each_entry_safe_continue(packet, next, list, dccphtx_node) {
list_del_init(&packet->dccphtx_node);
dccp_tx_hist_entry_delete(hist, packet);
}
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_purge_older);
/*
* Receiver History Routines
*/
struct dccp_rx_hist *dccp_rx_hist_new(const char *name) struct dccp_rx_hist *dccp_rx_hist_new(const char *name)
{ {
struct dccp_rx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC); struct dccp_rx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC);
...@@ -83,18 +174,24 @@ void dccp_rx_hist_delete(struct dccp_rx_hist *hist) ...@@ -83,18 +174,24 @@ void dccp_rx_hist_delete(struct dccp_rx_hist *hist)
EXPORT_SYMBOL_GPL(dccp_rx_hist_delete); EXPORT_SYMBOL_GPL(dccp_rx_hist_delete);
void dccp_rx_hist_purge(struct dccp_rx_hist *hist, struct list_head *list) int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq,
u8 *ccval)
{ {
struct dccp_rx_hist_entry *entry, *next; struct dccp_rx_hist_entry *packet = NULL, *entry;
list_for_each_entry_safe(entry, next, list, dccphrx_node) { list_for_each_entry(entry, list, dccphrx_node)
list_del_init(&entry->dccphrx_node); if (entry->dccphrx_seqno == seq) {
kmem_cache_free(hist->dccprxh_slab, entry); packet = entry;
} break;
} }
EXPORT_SYMBOL_GPL(dccp_rx_hist_purge); if (packet)
*ccval = packet->dccphrx_ccval;
return packet != NULL;
}
EXPORT_SYMBOL_GPL(dccp_rx_hist_find_entry);
struct dccp_rx_hist_entry * struct dccp_rx_hist_entry *
dccp_rx_hist_find_data_packet(const struct list_head *list) dccp_rx_hist_find_data_packet(const struct list_head *list)
{ {
...@@ -184,110 +281,18 @@ void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist, ...@@ -184,110 +281,18 @@ void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist,
EXPORT_SYMBOL_GPL(dccp_rx_hist_add_packet); EXPORT_SYMBOL_GPL(dccp_rx_hist_add_packet);
struct dccp_tx_hist *dccp_tx_hist_new(const char *name) void dccp_rx_hist_purge(struct dccp_rx_hist *hist, struct list_head *list)
{
struct dccp_tx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC);
static const char dccp_tx_hist_mask[] = "tx_hist_%s";
char *slab_name;
if (hist == NULL)
goto out;
slab_name = kmalloc(strlen(name) + sizeof(dccp_tx_hist_mask) - 1,
GFP_ATOMIC);
if (slab_name == NULL)
goto out_free_hist;
sprintf(slab_name, dccp_tx_hist_mask, name);
hist->dccptxh_slab = kmem_cache_create(slab_name,
sizeof(struct dccp_tx_hist_entry),
0, SLAB_HWCACHE_ALIGN,
NULL, NULL);
if (hist->dccptxh_slab == NULL)
goto out_free_slab_name;
out:
return hist;
out_free_slab_name:
kfree(slab_name);
out_free_hist:
kfree(hist);
hist = NULL;
goto out;
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_new);
void dccp_tx_hist_delete(struct dccp_tx_hist *hist)
{
const char* name = kmem_cache_name(hist->dccptxh_slab);
kmem_cache_destroy(hist->dccptxh_slab);
kfree(name);
kfree(hist);
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_delete);
struct dccp_tx_hist_entry *
dccp_tx_hist_find_entry(const struct list_head *list, const u64 seq)
{
struct dccp_tx_hist_entry *packet = NULL, *entry;
list_for_each_entry(entry, list, dccphtx_node)
if (entry->dccphtx_seqno == seq) {
packet = entry;
break;
}
return packet;
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_find_entry);
int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq,
u8 *ccval)
{
struct dccp_rx_hist_entry *packet = NULL, *entry;
list_for_each_entry(entry, list, dccphrx_node)
if (entry->dccphrx_seqno == seq) {
packet = entry;
break;
}
if (packet)
*ccval = packet->dccphrx_ccval;
return packet != NULL;
}
EXPORT_SYMBOL_GPL(dccp_rx_hist_find_entry);
void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
struct list_head *list,
struct dccp_tx_hist_entry *packet)
{ {
struct dccp_tx_hist_entry *next; struct dccp_rx_hist_entry *entry, *next;
list_for_each_entry_safe_continue(packet, next, list, dccphtx_node) { list_for_each_entry_safe(entry, next, list, dccphrx_node) {
list_del_init(&packet->dccphtx_node); list_del_init(&entry->dccphrx_node);
dccp_tx_hist_entry_delete(hist, packet); kmem_cache_free(hist->dccprxh_slab, entry);
} }
} }
EXPORT_SYMBOL_GPL(dccp_tx_hist_purge_older); EXPORT_SYMBOL_GPL(dccp_rx_hist_purge);
void dccp_tx_hist_purge(struct dccp_tx_hist *hist, struct list_head *list)
{
struct dccp_tx_hist_entry *entry, *next;
list_for_each_entry_safe(entry, next, list, dccphtx_node) {
list_del_init(&entry->dccphtx_node);
dccp_tx_hist_entry_delete(hist, entry);
}
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_purge);
MODULE_AUTHOR("Ian McDonald <ian.mcdonald@jandi.co.nz>, " MODULE_AUTHOR("Ian McDonald <ian.mcdonald@jandi.co.nz>, "
"Arnaldo Carvalho de Melo <acme@ghostprotocols.net>"); "Arnaldo Carvalho de Melo <acme@ghostprotocols.net>");
......
...@@ -49,43 +49,27 @@ ...@@ -49,43 +49,27 @@
#define TFRC_WIN_COUNT_PER_RTT 4 #define TFRC_WIN_COUNT_PER_RTT 4
#define TFRC_WIN_COUNT_LIMIT 16 #define TFRC_WIN_COUNT_LIMIT 16
/*
* Transmitter History data structures and declarations
*/
struct dccp_tx_hist_entry { struct dccp_tx_hist_entry {
struct list_head dccphtx_node; struct list_head dccphtx_node;
u64 dccphtx_seqno:48, u64 dccphtx_seqno:48,
dccphtx_ccval:4,
dccphtx_sent:1; dccphtx_sent:1;
u32 dccphtx_rtt; u32 dccphtx_rtt;
struct timeval dccphtx_tstamp; struct timeval dccphtx_tstamp;
}; };
struct dccp_rx_hist_entry {
struct list_head dccphrx_node;
u64 dccphrx_seqno:48,
dccphrx_ccval:4,
dccphrx_type:4;
u32 dccphrx_ndp; /* In fact it is from 8 to 24 bits */
struct timeval dccphrx_tstamp;
};
struct dccp_tx_hist { struct dccp_tx_hist {
struct kmem_cache *dccptxh_slab; struct kmem_cache *dccptxh_slab;
}; };
extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name); extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name);
extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist); extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist);
struct dccp_rx_hist {
struct kmem_cache *dccprxh_slab;
};
extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name);
extern void dccp_rx_hist_delete(struct dccp_rx_hist *hist);
extern struct dccp_rx_hist_entry *
dccp_rx_hist_find_data_packet(const struct list_head *list);
static inline struct dccp_tx_hist_entry * static inline struct dccp_tx_hist_entry *
dccp_tx_hist_entry_new(struct dccp_tx_hist *hist, dccp_tx_hist_entry_new(struct dccp_tx_hist *hist,
const gfp_t prio) const gfp_t prio)
{ {
struct dccp_tx_hist_entry *entry = kmem_cache_alloc(hist->dccptxh_slab, struct dccp_tx_hist_entry *entry = kmem_cache_alloc(hist->dccptxh_slab,
prio); prio);
...@@ -96,18 +80,20 @@ static inline struct dccp_tx_hist_entry * ...@@ -96,18 +80,20 @@ static inline struct dccp_tx_hist_entry *
return entry; return entry;
} }
static inline void dccp_tx_hist_entry_delete(struct dccp_tx_hist *hist, static inline struct dccp_tx_hist_entry *
struct dccp_tx_hist_entry *entry) dccp_tx_hist_head(struct list_head *list)
{ {
if (entry != NULL) struct dccp_tx_hist_entry *head = NULL;
kmem_cache_free(hist->dccptxh_slab, entry);
if (!list_empty(list))
head = list_entry(list->next, struct dccp_tx_hist_entry,
dccphtx_node);
return head;
} }
extern struct dccp_tx_hist_entry * extern struct dccp_tx_hist_entry *
dccp_tx_hist_find_entry(const struct list_head *list, dccp_tx_hist_find_entry(const struct list_head *list,
const u64 seq); const u64 seq);
extern int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq,
u8 *ccval);
static inline void dccp_tx_hist_add_entry(struct list_head *list, static inline void dccp_tx_hist_add_entry(struct list_head *list,
struct dccp_tx_hist_entry *entry) struct dccp_tx_hist_entry *entry)
...@@ -115,30 +101,45 @@ static inline void dccp_tx_hist_add_entry(struct list_head *list, ...@@ -115,30 +101,45 @@ static inline void dccp_tx_hist_add_entry(struct list_head *list,
list_add(&entry->dccphtx_node, list); list_add(&entry->dccphtx_node, list);
} }
static inline void dccp_tx_hist_entry_delete(struct dccp_tx_hist *hist,
struct dccp_tx_hist_entry *entry)
{
if (entry != NULL)
kmem_cache_free(hist->dccptxh_slab, entry);
}
extern void dccp_tx_hist_purge(struct dccp_tx_hist *hist,
struct list_head *list);
extern void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist, extern void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
struct list_head *list, struct list_head *list,
struct dccp_tx_hist_entry *next); struct dccp_tx_hist_entry *next);
extern void dccp_tx_hist_purge(struct dccp_tx_hist *hist, /*
struct list_head *list); * Receiver History data structures and declarations
*/
struct dccp_rx_hist_entry {
struct list_head dccphrx_node;
u64 dccphrx_seqno:48,
dccphrx_ccval:4,
dccphrx_type:4;
u32 dccphrx_ndp; /* In fact it is from 8 to 24 bits */
struct timeval dccphrx_tstamp;
};
static inline struct dccp_tx_hist_entry * struct dccp_rx_hist {
dccp_tx_hist_head(struct list_head *list) struct kmem_cache *dccprxh_slab;
{ };
struct dccp_tx_hist_entry *head = NULL;
if (!list_empty(list)) extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name);
head = list_entry(list->next, struct dccp_tx_hist_entry, extern void dccp_rx_hist_delete(struct dccp_rx_hist *hist);
dccphtx_node);
return head;
}
static inline struct dccp_rx_hist_entry * static inline struct dccp_rx_hist_entry *
dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, dccp_rx_hist_entry_new(struct dccp_rx_hist *hist,
const struct sock *sk, const struct sock *sk,
const u32 ndp, const u32 ndp,
const struct sk_buff *skb, const struct sk_buff *skb,
const gfp_t prio) const gfp_t prio)
{ {
struct dccp_rx_hist_entry *entry = kmem_cache_alloc(hist->dccprxh_slab, struct dccp_rx_hist_entry *entry = kmem_cache_alloc(hist->dccprxh_slab,
prio); prio);
...@@ -156,18 +157,8 @@ static inline struct dccp_rx_hist_entry * ...@@ -156,18 +157,8 @@ static inline struct dccp_rx_hist_entry *
return entry; return entry;
} }
static inline void dccp_rx_hist_entry_delete(struct dccp_rx_hist *hist,
struct dccp_rx_hist_entry *entry)
{
if (entry != NULL)
kmem_cache_free(hist->dccprxh_slab, entry);
}
extern void dccp_rx_hist_purge(struct dccp_rx_hist *hist,
struct list_head *list);
static inline struct dccp_rx_hist_entry * static inline struct dccp_rx_hist_entry *
dccp_rx_hist_head(struct list_head *list) dccp_rx_hist_head(struct list_head *list)
{ {
struct dccp_rx_hist_entry *head = NULL; struct dccp_rx_hist_entry *head = NULL;
...@@ -177,6 +168,27 @@ static inline struct dccp_rx_hist_entry * ...@@ -177,6 +168,27 @@ static inline struct dccp_rx_hist_entry *
return head; return head;
} }
extern int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq,
u8 *ccval);
extern struct dccp_rx_hist_entry *
dccp_rx_hist_find_data_packet(const struct list_head *list);
extern void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist,
struct list_head *rx_list,
struct list_head *li_list,
struct dccp_rx_hist_entry *packet,
u64 nonloss_seqno);
static inline void dccp_rx_hist_entry_delete(struct dccp_rx_hist *hist,
struct dccp_rx_hist_entry *entry)
{
if (entry != NULL)
kmem_cache_free(hist->dccprxh_slab, entry);
}
extern void dccp_rx_hist_purge(struct dccp_rx_hist *hist,
struct list_head *list);
static inline int static inline int
dccp_rx_hist_entry_data_packet(const struct dccp_rx_hist_entry *entry) dccp_rx_hist_entry_data_packet(const struct dccp_rx_hist_entry *entry)
{ {
...@@ -184,12 +196,6 @@ static inline int ...@@ -184,12 +196,6 @@ static inline int
entry->dccphrx_type == DCCP_PKT_DATAACK; entry->dccphrx_type == DCCP_PKT_DATAACK;
} }
extern void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist,
struct list_head *rx_list,
struct list_head *li_list,
struct dccp_rx_hist_entry *packet,
u64 nonloss_seqno);
extern u64 dccp_rx_hist_detect_loss(struct list_head *rx_list, extern u64 dccp_rx_hist_detect_loss(struct list_head *rx_list,
struct list_head *li_list, u8 *win_loss); struct list_head *li_list, u8 *win_loss);
......
...@@ -13,8 +13,29 @@ ...@@ -13,8 +13,29 @@
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
*/ */
#include <linux/types.h> #include <linux/types.h>
#include <asm/div64.h>
/* integer-arithmetic divisions of type (a * 1000000)/b */
static inline u64 scaled_div(u64 a, u32 b)
{
BUG_ON(b==0);
a *= 1000000;
do_div(a, b);
return a;
}
static inline u32 scaled_div32(u64 a, u32 b)
{
u64 result = scaled_div(a, b);
if (result > UINT_MAX) {
DCCP_CRIT("Overflow: a(%llu)/b(%u) > ~0U",
(unsigned long long)a, b);
return UINT_MAX;
}
return result;
}
extern u32 tfrc_calc_x(u16 s, u32 R, u32 p); extern u32 tfrc_calc_x(u16 s, u32 R, u32 p);
extern u32 tfrc_calc_x_reverse_lookup(u32 fvalue); extern u32 tfrc_calc_x_reverse_lookup(u32 fvalue);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <asm/div64.h>
#include "../../dccp.h" #include "../../dccp.h"
#include "tfrc.h" #include "tfrc.h"
...@@ -616,15 +615,12 @@ static inline u32 tfrc_binsearch(u32 fval, u8 small) ...@@ -616,15 +615,12 @@ static inline u32 tfrc_binsearch(u32 fval, u8 small)
* @R: RTT scaled by 1000000 (i.e., microseconds) * @R: RTT scaled by 1000000 (i.e., microseconds)
* @p: loss ratio estimate scaled by 1000000 * @p: loss ratio estimate scaled by 1000000
* Returns X_calc in bytes per second (not scaled). * Returns X_calc in bytes per second (not scaled).
*
* Note: DO NOT alter this code unless you run test cases against it,
* as the code has been optimized to stop underflow/overflow.
*/ */
u32 tfrc_calc_x(u16 s, u32 R, u32 p) u32 tfrc_calc_x(u16 s, u32 R, u32 p)
{ {
int index; u16 index;
u32 f; u32 f;
u64 tmp1, tmp2; u64 result;
/* check against invalid parameters and divide-by-zero */ /* check against invalid parameters and divide-by-zero */
BUG_ON(p > 1000000); /* p must not exceed 100% */ BUG_ON(p > 1000000); /* p must not exceed 100% */
...@@ -650,15 +646,17 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p) ...@@ -650,15 +646,17 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p)
f = tfrc_calc_x_lookup[index][0]; f = tfrc_calc_x_lookup[index][0];
} }
/* The following computes X = s/(R*f(p)) in bytes per second. Since f(p) /*
* and R are both scaled by 1000000, we need to multiply by 1000000^2. * Compute X = s/(R*f(p)) in bytes per second.
* ==> DO NOT alter this unless you test against overflow on 32 bit */ * Since f(p) and R are both scaled by 1000000, we need to multiply by
tmp1 = ((u64)s * 100000000); * 1000000^2. To avoid overflow, the result is computed in two stages.
tmp2 = ((u64)R * (u64)f); * This works under almost all reasonable operational conditions, for a
do_div(tmp2, 10000); * wide range of parameters. Yet, should some strange combination of
do_div(tmp1, tmp2); * parameters result in overflow, the use of scaled_div32 will catch
* this and return UINT_MAX - which is a logically adequate consequence.
return (u32)tmp1; */
result = scaled_div(s, R);
return scaled_div32(result, f);
} }
EXPORT_SYMBOL_GPL(tfrc_calc_x); EXPORT_SYMBOL_GPL(tfrc_calc_x);
......
...@@ -80,8 +80,6 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo); ...@@ -80,8 +80,6 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo);
#define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */ #define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */
#define DCCP_XMIT_TIMEO 30000 /* Time/msecs for blocking transmit per packet */
/* sysctl variables for DCCP */ /* sysctl variables for DCCP */
extern int sysctl_dccp_request_retries; extern int sysctl_dccp_request_retries;
extern int sysctl_dccp_retries1; extern int sysctl_dccp_retries1;
...@@ -434,6 +432,7 @@ static inline void timeval_sub_usecs(struct timeval *tv, ...@@ -434,6 +432,7 @@ static inline void timeval_sub_usecs(struct timeval *tv,
tv->tv_sec--; tv->tv_sec--;
tv->tv_usec += USEC_PER_SEC; tv->tv_usec += USEC_PER_SEC;
} }
DCCP_BUG_ON(tv->tv_sec < 0);
} }
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
......
...@@ -329,7 +329,7 @@ static void dccp_feat_empty_confirm(struct dccp_minisock *dmsk, ...@@ -329,7 +329,7 @@ static void dccp_feat_empty_confirm(struct dccp_minisock *dmsk,
switch (type) { switch (type) {
case DCCPO_CHANGE_L: opt->dccpop_type = DCCPO_CONFIRM_R; break; case DCCPO_CHANGE_L: opt->dccpop_type = DCCPO_CONFIRM_R; break;
case DCCPO_CHANGE_R: opt->dccpop_type = DCCPO_CONFIRM_L; break; case DCCPO_CHANGE_R: opt->dccpop_type = DCCPO_CONFIRM_L; break;
default: DCCP_WARN("invalid type %d\n", type); return; default: DCCP_WARN("invalid type %d\n", type); return;
} }
opt->dccpop_feat = feature; opt->dccpop_feat = feature;
...@@ -427,7 +427,7 @@ int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature, ...@@ -427,7 +427,7 @@ int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
switch (type) { switch (type) {
case DCCPO_CONFIRM_L: t = DCCPO_CHANGE_R; break; case DCCPO_CONFIRM_L: t = DCCPO_CHANGE_R; break;
case DCCPO_CONFIRM_R: t = DCCPO_CHANGE_L; break; case DCCPO_CONFIRM_R: t = DCCPO_CHANGE_L; break;
default: DCCP_WARN("invalid type %d\n", type); default: DCCP_WARN("invalid type %d\n", type);
return 1; return 1;
} }
...@@ -610,7 +610,7 @@ const char *dccp_feat_typename(const u8 type) ...@@ -610,7 +610,7 @@ const char *dccp_feat_typename(const u8 type)
case DCCPO_CHANGE_R: return("ChangeR"); case DCCPO_CHANGE_R: return("ChangeR");
case DCCPO_CONFIRM_R: return("ConfirmR"); case DCCPO_CONFIRM_R: return("ConfirmR");
/* the following case must not appear in feature negotation */ /* the following case must not appear in feature negotation */
default: dccp_pr_debug("unknown type %d [BUG!]\n", type); default: dccp_pr_debug("unknown type %d [BUG!]\n", type);
} }
return NULL; return NULL;
} }
......
/* /*
* net/dccp/input.c * net/dccp/input.c
* *
* An implementation of the DCCP protocol * An implementation of the DCCP protocol
* Arnaldo Carvalho de Melo <acme@conectiva.com.br> * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* *
...@@ -82,7 +82,7 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb) ...@@ -82,7 +82,7 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
* Otherwise, * Otherwise,
* Drop packet and return * Drop packet and return
*/ */
if (dh->dccph_type == DCCP_PKT_SYNC || if (dh->dccph_type == DCCP_PKT_SYNC ||
dh->dccph_type == DCCP_PKT_SYNCACK) { dh->dccph_type == DCCP_PKT_SYNCACK) {
if (between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, if (between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
dp->dccps_awl, dp->dccps_awh) && dp->dccps_awl, dp->dccps_awh) &&
...@@ -185,8 +185,8 @@ static int __dccp_rcv_established(struct sock *sk, struct sk_buff *skb, ...@@ -185,8 +185,8 @@ static int __dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
dccp_rcv_close(sk, skb); dccp_rcv_close(sk, skb);
return 0; return 0;
case DCCP_PKT_REQUEST: case DCCP_PKT_REQUEST:
/* Step 7 /* Step 7
* or (S.is_server and P.type == Response) * or (S.is_server and P.type == Response)
* or (S.is_client and P.type == Request) * or (S.is_client and P.type == Request)
* or (S.state >= OPEN and P.type == Request * or (S.state >= OPEN and P.type == Request
* and P.seqno >= S.OSR) * and P.seqno >= S.OSR)
...@@ -248,8 +248,18 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, ...@@ -248,8 +248,18 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
DCCP_ACKVEC_STATE_RECEIVED)) DCCP_ACKVEC_STATE_RECEIVED))
goto discard; goto discard;
ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); /*
ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); * Deliver to the CCID module in charge.
* FIXME: Currently DCCP operates one-directional only, i.e. a listening
* server is not at the same time a connecting client. There is
* not much sense in delivering to both rx/tx sides at the moment
* (only one is active at a time); when moving to bidirectional
* service, this needs to be revised.
*/
if (dccp_sk(sk)->dccps_role == DCCP_ROLE_SERVER)
ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
else
ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb);
return __dccp_rcv_established(sk, skb, dh, len); return __dccp_rcv_established(sk, skb, dh, len);
discard: discard:
...@@ -264,7 +274,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, ...@@ -264,7 +274,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
const struct dccp_hdr *dh, const struct dccp_hdr *dh,
const unsigned len) const unsigned len)
{ {
/* /*
* Step 4: Prepare sequence numbers in REQUEST * Step 4: Prepare sequence numbers in REQUEST
* If S.state == REQUEST, * If S.state == REQUEST,
* If (P.type == Response or P.type == Reset) * If (P.type == Response or P.type == Reset)
...@@ -332,7 +342,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, ...@@ -332,7 +342,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
* from the Response * / * from the Response * /
* S.state := PARTOPEN * S.state := PARTOPEN
* Set PARTOPEN timer * Set PARTOPEN timer
* Continue with S.state == PARTOPEN * Continue with S.state == PARTOPEN
* / * Step 12 will send the Ack completing the * / * Step 12 will send the Ack completing the
* three-way handshake * / * three-way handshake * /
*/ */
...@@ -363,7 +373,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, ...@@ -363,7 +373,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
*/ */
__kfree_skb(skb); __kfree_skb(skb);
return 0; return 0;
} }
dccp_send_ack(sk); dccp_send_ack(sk);
return -1; return -1;
} }
...@@ -371,7 +381,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, ...@@ -371,7 +381,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
out_invalid_packet: out_invalid_packet:
/* dccp_v4_do_rcv will send a reset */ /* dccp_v4_do_rcv will send a reset */
DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_PACKET_ERROR; DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_PACKET_ERROR;
return 1; return 1;
} }
static int dccp_rcv_respond_partopen_state_process(struct sock *sk, static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
...@@ -478,14 +488,17 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, ...@@ -478,14 +488,17 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
if (dcb->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) if (dcb->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
dccp_event_ack_recv(sk, skb); dccp_event_ack_recv(sk, skb);
if (dccp_msk(sk)->dccpms_send_ack_vector && if (dccp_msk(sk)->dccpms_send_ack_vector &&
dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk,
DCCP_SKB_CB(skb)->dccpd_seq, DCCP_SKB_CB(skb)->dccpd_seq,
DCCP_ACKVEC_STATE_RECEIVED)) DCCP_ACKVEC_STATE_RECEIVED))
goto discard; goto discard;
ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); /* XXX see the comments in dccp_rcv_established about this */
ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); if (dccp_sk(sk)->dccps_role == DCCP_ROLE_SERVER)
ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
else
ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb);
} }
/* /*
...@@ -567,7 +580,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, ...@@ -567,7 +580,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
} }
} }
if (!queued) { if (!queued) {
discard: discard:
__kfree_skb(skb); __kfree_skb(skb);
} }
......
...@@ -157,7 +157,7 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk, ...@@ -157,7 +157,7 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk,
/* We don't check in the destentry if pmtu discovery is forbidden /* We don't check in the destentry if pmtu discovery is forbidden
* on this route. We just assume that no packet_to_big packets * on this route. We just assume that no packet_to_big packets
* are send back when pmtu discovery is not active. * are send back when pmtu discovery is not active.
* There is a small race when the user changes this flag in the * There is a small race when the user changes this flag in the
* route, but I think that's acceptable. * route, but I think that's acceptable.
*/ */
if ((dst = __sk_dst_check(sk, 0)) == NULL) if ((dst = __sk_dst_check(sk, 0)) == NULL)
...@@ -467,7 +467,7 @@ static struct dst_entry* dccp_v4_route_skb(struct sock *sk, ...@@ -467,7 +467,7 @@ static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
.uli_u = { .ports = .uli_u = { .ports =
{ .sport = dccp_hdr(skb)->dccph_dport, { .sport = dccp_hdr(skb)->dccph_dport,
.dport = dccp_hdr(skb)->dccph_sport } .dport = dccp_hdr(skb)->dccph_sport }
} }
}; };
security_skb_classify_flow(skb, &fl); security_skb_classify_flow(skb, &fl);
...@@ -595,7 +595,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) ...@@ -595,7 +595,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
struct inet_request_sock *ireq; struct inet_request_sock *ireq;
struct request_sock *req; struct request_sock *req;
struct dccp_request_sock *dreq; struct dccp_request_sock *dreq;
const __be32 service = dccp_hdr_request(skb)->dccph_req_service; const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
__u8 reset_code = DCCP_RESET_CODE_TOO_BUSY; __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
...@@ -609,7 +609,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) ...@@ -609,7 +609,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
if (dccp_bad_service_code(sk, service)) { if (dccp_bad_service_code(sk, service)) {
reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE; reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
goto drop; goto drop;
} }
/* /*
* TW buckets are converted to open requests without * TW buckets are converted to open requests without
* limitations, they conserve resources and peer is * limitations, they conserve resources and peer is
...@@ -644,7 +644,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) ...@@ -644,7 +644,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
ireq->rmt_addr = skb->nh.iph->saddr; ireq->rmt_addr = skb->nh.iph->saddr;
ireq->opt = NULL; ireq->opt = NULL;
/* /*
* Step 3: Process LISTEN state * Step 3: Process LISTEN state
* *
* Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
...@@ -846,15 +846,15 @@ static int dccp_v4_rcv(struct sk_buff *skb) ...@@ -846,15 +846,15 @@ static int dccp_v4_rcv(struct sk_buff *skb)
} }
/* Step 2: /* Step 2:
* Look up flow ID in table and get corresponding socket */ * Look up flow ID in table and get corresponding socket */
sk = __inet_lookup(&dccp_hashinfo, sk = __inet_lookup(&dccp_hashinfo,
skb->nh.iph->saddr, dh->dccph_sport, skb->nh.iph->saddr, dh->dccph_sport,
skb->nh.iph->daddr, dh->dccph_dport, skb->nh.iph->daddr, dh->dccph_dport,
inet_iif(skb)); inet_iif(skb));
/* /*
* Step 2: * Step 2:
* If no socket ... * If no socket ...
*/ */
if (sk == NULL) { if (sk == NULL) {
dccp_pr_debug("failed to look up flow ID in table and " dccp_pr_debug("failed to look up flow ID in table and "
...@@ -862,9 +862,9 @@ static int dccp_v4_rcv(struct sk_buff *skb) ...@@ -862,9 +862,9 @@ static int dccp_v4_rcv(struct sk_buff *skb)
goto no_dccp_socket; goto no_dccp_socket;
} }
/* /*
* Step 2: * Step 2:
* ... or S.state == TIMEWAIT, * ... or S.state == TIMEWAIT,
* Generate Reset(No Connection) unless P.type == Reset * Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return * Drop packet and return
*/ */
...@@ -876,8 +876,8 @@ static int dccp_v4_rcv(struct sk_buff *skb) ...@@ -876,8 +876,8 @@ static int dccp_v4_rcv(struct sk_buff *skb)
/* /*
* RFC 4340, sec. 9.2.1: Minimum Checksum Coverage * RFC 4340, sec. 9.2.1: Minimum Checksum Coverage
* o if MinCsCov = 0, only packets with CsCov = 0 are accepted * o if MinCsCov = 0, only packets with CsCov = 0 are accepted
* o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov * o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov
*/ */
min_cov = dccp_sk(sk)->dccps_pcrlen; min_cov = dccp_sk(sk)->dccps_pcrlen;
if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) { if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {
...@@ -900,7 +900,7 @@ static int dccp_v4_rcv(struct sk_buff *skb) ...@@ -900,7 +900,7 @@ static int dccp_v4_rcv(struct sk_buff *skb)
goto discard_it; goto discard_it;
/* /*
* Step 2: * Step 2:
* If no socket ... * If no socket ...
* Generate Reset(No Connection) unless P.type == Reset * Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return * Drop packet and return
*/ */
......
...@@ -77,7 +77,7 @@ static inline void dccp_v6_send_check(struct sock *sk, int unused_value, ...@@ -77,7 +77,7 @@ static inline void dccp_v6_send_check(struct sock *sk, int unused_value,
} }
static inline __u32 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr, static inline __u32 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr,
__be16 sport, __be16 dport ) __be16 sport, __be16 dport )
{ {
return secure_tcpv6_sequence_number(saddr, daddr, sport, dport); return secure_tcpv6_sequence_number(saddr, daddr, sport, dport);
} }
...@@ -329,7 +329,7 @@ static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb) ...@@ -329,7 +329,7 @@ static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
skb = alloc_skb(dccp_v6_ctl_socket->sk->sk_prot->max_header, skb = alloc_skb(dccp_v6_ctl_socket->sk->sk_prot->max_header,
GFP_ATOMIC); GFP_ATOMIC);
if (skb == NULL) if (skb == NULL)
return; return;
skb_reserve(skb, dccp_v6_ctl_socket->sk->sk_prot->max_header); skb_reserve(skb, dccp_v6_ctl_socket->sk->sk_prot->max_header);
...@@ -353,7 +353,7 @@ static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb) ...@@ -353,7 +353,7 @@ static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
dccp_csum_outgoing(skb); dccp_csum_outgoing(skb);
dh->dccph_checksum = dccp_v6_csum_finish(skb, &rxskb->nh.ipv6h->saddr, dh->dccph_checksum = dccp_v6_csum_finish(skb, &rxskb->nh.ipv6h->saddr,
&rxskb->nh.ipv6h->daddr); &rxskb->nh.ipv6h->daddr);
memset(&fl, 0, sizeof(fl)); memset(&fl, 0, sizeof(fl));
ipv6_addr_copy(&fl.fl6_dst, &rxskb->nh.ipv6h->saddr); ipv6_addr_copy(&fl.fl6_dst, &rxskb->nh.ipv6h->saddr);
...@@ -424,7 +424,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) ...@@ -424,7 +424,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
struct dccp_request_sock *dreq; struct dccp_request_sock *dreq;
struct inet6_request_sock *ireq6; struct inet6_request_sock *ireq6;
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
const __be32 service = dccp_hdr_request(skb)->dccph_req_service; const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
__u8 reset_code = DCCP_RESET_CODE_TOO_BUSY; __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
...@@ -437,7 +437,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) ...@@ -437,7 +437,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
if (dccp_bad_service_code(sk, service)) { if (dccp_bad_service_code(sk, service)) {
reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE; reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
goto drop; goto drop;
} }
/* /*
* There are no SYN attacks on IPv6, yet... * There are no SYN attacks on IPv6, yet...
*/ */
...@@ -787,7 +787,7 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -787,7 +787,7 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
* otherwise we just shortcircuit this and continue with * otherwise we just shortcircuit this and continue with
* the new socket.. * the new socket..
*/ */
if (nsk != sk) { if (nsk != sk) {
if (dccp_child_process(sk, nsk, skb)) if (dccp_child_process(sk, nsk, skb))
goto reset; goto reset;
if (opt_skb != NULL) if (opt_skb != NULL)
...@@ -843,14 +843,14 @@ static int dccp_v6_rcv(struct sk_buff **pskb) ...@@ -843,14 +843,14 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb); DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
/* Step 2: /* Step 2:
* Look up flow ID in table and get corresponding socket */ * Look up flow ID in table and get corresponding socket */
sk = __inet6_lookup(&dccp_hashinfo, &skb->nh.ipv6h->saddr, sk = __inet6_lookup(&dccp_hashinfo, &skb->nh.ipv6h->saddr,
dh->dccph_sport, dh->dccph_sport,
&skb->nh.ipv6h->daddr, ntohs(dh->dccph_dport), &skb->nh.ipv6h->daddr, ntohs(dh->dccph_dport),
inet6_iif(skb)); inet6_iif(skb));
/* /*
* Step 2: * Step 2:
* If no socket ... * If no socket ...
*/ */
if (sk == NULL) { if (sk == NULL) {
dccp_pr_debug("failed to look up flow ID in table and " dccp_pr_debug("failed to look up flow ID in table and "
...@@ -860,7 +860,7 @@ static int dccp_v6_rcv(struct sk_buff **pskb) ...@@ -860,7 +860,7 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
/* /*
* Step 2: * Step 2:
* ... or S.state == TIMEWAIT, * ... or S.state == TIMEWAIT,
* Generate Reset(No Connection) unless P.type == Reset * Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return * Drop packet and return
*/ */
...@@ -872,8 +872,8 @@ static int dccp_v6_rcv(struct sk_buff **pskb) ...@@ -872,8 +872,8 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
/* /*
* RFC 4340, sec. 9.2.1: Minimum Checksum Coverage * RFC 4340, sec. 9.2.1: Minimum Checksum Coverage
* o if MinCsCov = 0, only packets with CsCov = 0 are accepted * o if MinCsCov = 0, only packets with CsCov = 0 are accepted
* o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov * o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov
*/ */
min_cov = dccp_sk(sk)->dccps_pcrlen; min_cov = dccp_sk(sk)->dccps_pcrlen;
if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) { if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {
...@@ -893,7 +893,7 @@ static int dccp_v6_rcv(struct sk_buff **pskb) ...@@ -893,7 +893,7 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
goto discard_it; goto discard_it;
/* /*
* Step 2: * Step 2:
* If no socket ... * If no socket ...
* Generate Reset(No Connection) unless P.type == Reset * Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return * Drop packet and return
*/ */
......
...@@ -182,7 +182,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk, ...@@ -182,7 +182,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
EXPORT_SYMBOL_GPL(dccp_create_openreq_child); EXPORT_SYMBOL_GPL(dccp_create_openreq_child);
/* /*
* Process an incoming packet for RESPOND sockets represented * Process an incoming packet for RESPOND sockets represented
* as an request_sock. * as an request_sock.
*/ */
......
...@@ -557,11 +557,6 @@ int dccp_insert_options(struct sock *sk, struct sk_buff *skb) ...@@ -557,11 +557,6 @@ int dccp_insert_options(struct sock *sk, struct sk_buff *skb)
return -1; return -1;
dp->dccps_hc_rx_insert_options = 0; dp->dccps_hc_rx_insert_options = 0;
} }
if (dp->dccps_hc_tx_insert_options) {
if (ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb))
return -1;
dp->dccps_hc_tx_insert_options = 0;
}
/* Feature negotiation */ /* Feature negotiation */
/* Data packets can't do feat negotiation */ /* Data packets can't do feat negotiation */
......
/* /*
* net/dccp/output.c * net/dccp/output.c
* *
* An implementation of the DCCP protocol * An implementation of the DCCP protocol
* Arnaldo Carvalho de Melo <acme@conectiva.com.br> * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* *
...@@ -175,14 +175,12 @@ void dccp_write_space(struct sock *sk) ...@@ -175,14 +175,12 @@ void dccp_write_space(struct sock *sk)
/** /**
* dccp_wait_for_ccid - Wait for ccid to tell us we can send a packet * dccp_wait_for_ccid - Wait for ccid to tell us we can send a packet
* @sk: socket to wait for * @sk: socket to wait for
* @timeo: for how long
*/ */
static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb, static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb)
long *timeo)
{ {
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
long delay; unsigned long delay;
int rc; int rc;
while (1) { while (1) {
...@@ -190,8 +188,6 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb, ...@@ -190,8 +188,6 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
if (sk->sk_err) if (sk->sk_err)
goto do_error; goto do_error;
if (!*timeo)
goto do_nonblock;
if (signal_pending(current)) if (signal_pending(current))
goto do_interrupted; goto do_interrupted;
...@@ -199,12 +195,9 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb, ...@@ -199,12 +195,9 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
if (rc <= 0) if (rc <= 0)
break; break;
delay = msecs_to_jiffies(rc); delay = msecs_to_jiffies(rc);
if (delay > *timeo || delay < 0)
goto do_nonblock;
sk->sk_write_pending++; sk->sk_write_pending++;
release_sock(sk); release_sock(sk);
*timeo -= schedule_timeout(delay); schedule_timeout(delay);
lock_sock(sk); lock_sock(sk);
sk->sk_write_pending--; sk->sk_write_pending--;
} }
...@@ -215,11 +208,8 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb, ...@@ -215,11 +208,8 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
do_error: do_error:
rc = -EPIPE; rc = -EPIPE;
goto out; goto out;
do_nonblock:
rc = -EAGAIN;
goto out;
do_interrupted: do_interrupted:
rc = sock_intr_errno(*timeo); rc = -EINTR;
goto out; goto out;
} }
...@@ -240,8 +230,6 @@ void dccp_write_xmit(struct sock *sk, int block) ...@@ -240,8 +230,6 @@ void dccp_write_xmit(struct sock *sk, int block)
{ {
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
struct sk_buff *skb; struct sk_buff *skb;
long timeo = DCCP_XMIT_TIMEO; /* If a packet is taking longer than
this we have other issues */
while ((skb = skb_peek(&sk->sk_write_queue))) { while ((skb = skb_peek(&sk->sk_write_queue))) {
int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb); int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb);
...@@ -251,11 +239,9 @@ void dccp_write_xmit(struct sock *sk, int block) ...@@ -251,11 +239,9 @@ void dccp_write_xmit(struct sock *sk, int block)
sk_reset_timer(sk, &dp->dccps_xmit_timer, sk_reset_timer(sk, &dp->dccps_xmit_timer,
msecs_to_jiffies(err)+jiffies); msecs_to_jiffies(err)+jiffies);
break; break;
} else { } else
err = dccp_wait_for_ccid(sk, skb, &timeo); err = dccp_wait_for_ccid(sk, skb);
timeo = DCCP_XMIT_TIMEO; if (err && err != -EINTR)
}
if (err)
DCCP_BUG("err=%d after dccp_wait_for_ccid", err); DCCP_BUG("err=%d after dccp_wait_for_ccid", err);
} }
...@@ -281,8 +267,10 @@ void dccp_write_xmit(struct sock *sk, int block) ...@@ -281,8 +267,10 @@ void dccp_write_xmit(struct sock *sk, int block)
if (err) if (err)
DCCP_BUG("err=%d after ccid_hc_tx_packet_sent", DCCP_BUG("err=%d after ccid_hc_tx_packet_sent",
err); err);
} else } else {
dccp_pr_debug("packet discarded\n");
kfree(skb); kfree(skb);
}
} }
} }
...@@ -350,7 +338,6 @@ EXPORT_SYMBOL_GPL(dccp_make_response); ...@@ -350,7 +338,6 @@ EXPORT_SYMBOL_GPL(dccp_make_response);
static struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst, static struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
const enum dccp_reset_codes code) const enum dccp_reset_codes code)
{ {
struct dccp_hdr *dh; struct dccp_hdr *dh;
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
...@@ -431,14 +418,14 @@ static inline void dccp_connect_init(struct sock *sk) ...@@ -431,14 +418,14 @@ static inline void dccp_connect_init(struct sock *sk)
dccp_sync_mss(sk, dst_mtu(dst)); dccp_sync_mss(sk, dst_mtu(dst));
/* /*
* SWL and AWL are initially adjusted so that they are not less than * SWL and AWL are initially adjusted so that they are not less than
* the initial Sequence Numbers received and sent, respectively: * the initial Sequence Numbers received and sent, respectively:
* SWL := max(GSR + 1 - floor(W/4), ISR), * SWL := max(GSR + 1 - floor(W/4), ISR),
* AWL := max(GSS - W' + 1, ISS). * AWL := max(GSS - W' + 1, ISS).
* These adjustments MUST be applied only at the beginning of the * These adjustments MUST be applied only at the beginning of the
* connection. * connection.
*/ */
dccp_update_gss(sk, dp->dccps_iss); dccp_update_gss(sk, dp->dccps_iss);
dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss)); dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss));
......
...@@ -196,7 +196,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized) ...@@ -196,7 +196,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
sk, GFP_KERNEL); sk, GFP_KERNEL);
dp->dccps_hc_tx_ccid = ccid_hc_tx_new(dmsk->dccpms_tx_ccid, dp->dccps_hc_tx_ccid = ccid_hc_tx_new(dmsk->dccpms_tx_ccid,
sk, GFP_KERNEL); sk, GFP_KERNEL);
if (unlikely(dp->dccps_hc_rx_ccid == NULL || if (unlikely(dp->dccps_hc_rx_ccid == NULL ||
dp->dccps_hc_tx_ccid == NULL)) { dp->dccps_hc_tx_ccid == NULL)) {
ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
...@@ -390,7 +390,7 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service, ...@@ -390,7 +390,7 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service,
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
struct dccp_service_list *sl = NULL; struct dccp_service_list *sl = NULL;
if (service == DCCP_SERVICE_INVALID_VALUE || if (service == DCCP_SERVICE_INVALID_VALUE ||
optlen > DCCP_SERVICE_LIST_MAX_LEN * sizeof(u32)) optlen > DCCP_SERVICE_LIST_MAX_LEN * sizeof(u32))
return -EINVAL; return -EINVAL;
...@@ -830,7 +830,7 @@ EXPORT_SYMBOL_GPL(inet_dccp_listen); ...@@ -830,7 +830,7 @@ EXPORT_SYMBOL_GPL(inet_dccp_listen);
static const unsigned char dccp_new_state[] = { static const unsigned char dccp_new_state[] = {
/* current state: new state: action: */ /* current state: new state: action: */
[0] = DCCP_CLOSED, [0] = DCCP_CLOSED,
[DCCP_OPEN] = DCCP_CLOSING | DCCP_ACTION_FIN, [DCCP_OPEN] = DCCP_CLOSING | DCCP_ACTION_FIN,
[DCCP_REQUESTING] = DCCP_CLOSED, [DCCP_REQUESTING] = DCCP_CLOSED,
[DCCP_PARTOPEN] = DCCP_CLOSING | DCCP_ACTION_FIN, [DCCP_PARTOPEN] = DCCP_CLOSING | DCCP_ACTION_FIN,
[DCCP_LISTEN] = DCCP_CLOSED, [DCCP_LISTEN] = DCCP_CLOSED,
......
/* /*
* net/dccp/timer.c * net/dccp/timer.c
* *
* An implementation of the DCCP protocol * An implementation of the DCCP protocol
* Arnaldo Carvalho de Melo <acme@conectiva.com.br> * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* *
...@@ -102,13 +102,13 @@ static void dccp_retransmit_timer(struct sock *sk) ...@@ -102,13 +102,13 @@ static void dccp_retransmit_timer(struct sock *sk)
* sk->sk_send_head has to have one skb with * sk->sk_send_head has to have one skb with
* DCCP_SKB_CB(skb)->dccpd_type set to one of the retransmittable DCCP * DCCP_SKB_CB(skb)->dccpd_type set to one of the retransmittable DCCP
* packet types. The only packets eligible for retransmission are: * packet types. The only packets eligible for retransmission are:
* -- Requests in client-REQUEST state (sec. 8.1.1) * -- Requests in client-REQUEST state (sec. 8.1.1)
* -- Acks in client-PARTOPEN state (sec. 8.1.5) * -- Acks in client-PARTOPEN state (sec. 8.1.5)
* -- CloseReq in server-CLOSEREQ state (sec. 8.3) * -- CloseReq in server-CLOSEREQ state (sec. 8.3)
* -- Close in node-CLOSING state (sec. 8.3) */ * -- Close in node-CLOSING state (sec. 8.3) */
BUG_TRAP(sk->sk_send_head != NULL); BUG_TRAP(sk->sk_send_head != NULL);
/* /*
* More than than 4MSL (8 minutes) has passed, a RESET(aborted) was * More than than 4MSL (8 minutes) has passed, a RESET(aborted) was
* sent, no need to retransmit, this sock is dead. * sent, no need to retransmit, this sock is dead.
*/ */
...@@ -200,7 +200,7 @@ static void dccp_keepalive_timer(unsigned long data) ...@@ -200,7 +200,7 @@ static void dccp_keepalive_timer(unsigned long data)
/* Only process if socket is not in use. */ /* Only process if socket is not in use. */
bh_lock_sock(sk); bh_lock_sock(sk);
if (sock_owned_by_user(sk)) { if (sock_owned_by_user(sk)) {
/* Try again later. */ /* Try again later. */
inet_csk_reset_keepalive_timer(sk, HZ / 20); inet_csk_reset_keepalive_timer(sk, HZ / 20);
goto out; goto out;
} }
......
...@@ -657,7 +657,7 @@ static void sync_master_loop(void) ...@@ -657,7 +657,7 @@ static void sync_master_loop(void)
if (stop_master_sync) if (stop_master_sync)
break; break;
ssleep(1); msleep_interruptible(1000);
} }
/* clean up the sync_buff queue */ /* clean up the sync_buff queue */
...@@ -714,7 +714,7 @@ static void sync_backup_loop(void) ...@@ -714,7 +714,7 @@ static void sync_backup_loop(void)
if (stop_backup_sync) if (stop_backup_sync)
break; break;
ssleep(1); msleep_interruptible(1000);
} }
/* release the sending multicast socket */ /* release the sending multicast socket */
...@@ -826,7 +826,7 @@ static int fork_sync_thread(void *startup) ...@@ -826,7 +826,7 @@ static int fork_sync_thread(void *startup)
if ((pid = kernel_thread(sync_thread, startup, 0)) < 0) { if ((pid = kernel_thread(sync_thread, startup, 0)) < 0) {
IP_VS_ERR("could not create sync_thread due to %d... " IP_VS_ERR("could not create sync_thread due to %d... "
"retrying.\n", pid); "retrying.\n", pid);
ssleep(1); msleep_interruptible(1000);
goto repeat; goto repeat;
} }
...@@ -849,10 +849,12 @@ int start_sync_thread(int state, char *mcast_ifn, __u8 syncid) ...@@ -849,10 +849,12 @@ int start_sync_thread(int state, char *mcast_ifn, __u8 syncid)
ip_vs_sync_state |= state; ip_vs_sync_state |= state;
if (state == IP_VS_STATE_MASTER) { if (state == IP_VS_STATE_MASTER) {
strlcpy(ip_vs_master_mcast_ifn, mcast_ifn, sizeof(ip_vs_master_mcast_ifn)); strlcpy(ip_vs_master_mcast_ifn, mcast_ifn,
sizeof(ip_vs_master_mcast_ifn));
ip_vs_master_syncid = syncid; ip_vs_master_syncid = syncid;
} else { } else {
strlcpy(ip_vs_backup_mcast_ifn, mcast_ifn, sizeof(ip_vs_backup_mcast_ifn)); strlcpy(ip_vs_backup_mcast_ifn, mcast_ifn,
sizeof(ip_vs_backup_mcast_ifn));
ip_vs_backup_syncid = syncid; ip_vs_backup_syncid = syncid;
} }
...@@ -860,7 +862,7 @@ int start_sync_thread(int state, char *mcast_ifn, __u8 syncid) ...@@ -860,7 +862,7 @@ int start_sync_thread(int state, char *mcast_ifn, __u8 syncid)
if ((pid = kernel_thread(fork_sync_thread, &startup, 0)) < 0) { if ((pid = kernel_thread(fork_sync_thread, &startup, 0)) < 0) {
IP_VS_ERR("could not create fork_sync_thread due to %d... " IP_VS_ERR("could not create fork_sync_thread due to %d... "
"retrying.\n", pid); "retrying.\n", pid);
ssleep(1); msleep_interruptible(1000);
goto repeat; goto repeat;
} }
...@@ -880,7 +882,8 @@ int stop_sync_thread(int state) ...@@ -880,7 +882,8 @@ int stop_sync_thread(int state)
IP_VS_DBG(7, "%s: pid %d\n", __FUNCTION__, current->pid); IP_VS_DBG(7, "%s: pid %d\n", __FUNCTION__, current->pid);
IP_VS_INFO("stopping sync thread %d ...\n", IP_VS_INFO("stopping sync thread %d ...\n",
(state == IP_VS_STATE_MASTER) ? sync_master_pid : sync_backup_pid); (state == IP_VS_STATE_MASTER) ?
sync_master_pid : sync_backup_pid);
__set_current_state(TASK_UNINTERRUPTIBLE); __set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&stop_sync_wait, &wait); add_wait_queue(&stop_sync_wait, &wait);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册