···78787979static int ccid3_init(struct sock *sk)8080{8181- ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);8281 return 0;8382}84838584static void ccid3_exit(struct sock *sk)8685{8787- ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);8886}89879088/* TFRC sender states */···285287 long delay;286288 int rc = -ENOTCONN;287289288288- /* Check if pure ACK or Terminating*/290290+ BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM);289291292292+ /* Check if pure ACK or Terminating*/290293 /*291294 * XXX: We only call this function for DATA and DATAACK, on, these292295 * packets can have zero length, but why the comment about "pure ACK"?293296 */294294- if (hctx == NULL || len == 0 ||295295- hctx->ccid3hctx_state == TFRC_SSTATE_TERM)297297+ if (unlikely(len == 0))296298 goto out;297299298300 /* See if last packet allocated was not sent */···302304 SLAB_ATOMIC);303305304306 rc = -ENOBUFS;305305- if (new_packet == NULL) {306306- ccid3_pr_debug("%s, sk=%p, not enough mem to add "307307- "to history, send refused\n",308308- dccp_role(sk), sk);307307+ if (unlikely(new_packet == NULL)) {308308+ LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, not enough "309309+ "mem to add to history, send refused\n",310310+ __FUNCTION__, dccp_role(sk), sk);309311 goto out;310312 }311313···316318317319 switch (hctx->ccid3hctx_state) {318320 case TFRC_SSTATE_NO_SENT:319319- ccid3_pr_debug("%s, sk=%p, first packet(%llu)\n",320320- dccp_role(sk), sk, dp->dccps_gss);321321-322321 hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer;323322 hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk;324323 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,···323328 hctx->ccid3hctx_last_win_count = 0;324329 hctx->ccid3hctx_t_last_win_count = now;325330 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);326326- hctx->ccid3hctx_t_ipi = TFRC_INITIAL_TIMEOUT;331331+ hctx->ccid3hctx_t_ipi = TFRC_INITIAL_IPI;327332328333 /* Set nominal send time for initial packet */329334 hctx->ccid3hctx_t_nom = now;···336341 case TFRC_SSTATE_FBACK:337342 delay = (timeval_delta(&now, &hctx->ccid3hctx_t_nom) -338343 hctx->ccid3hctx_delta);339339- ccid3_pr_debug("send_packet delay=%ld\n", delay);340344 delay /= -1000;341345 /* divide by -1000 is to convert to ms and get sign right */342346 rc = delay > 0 ? delay : 0;···365371 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);366372 struct timeval now;367373368368- BUG_ON(hctx == NULL);369369-370370- if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) {371371- ccid3_pr_debug("%s, sk=%p, while state is TFRC_SSTATE_TERM!\n",372372- dccp_role(sk), sk);373373- return;374374- }374374+ BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM);375375376376 dccp_timestamp(sk, &now);377377···375387 struct dccp_tx_hist_entry *packet;376388377389 packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);378378- if (packet == NULL) {379379- printk(KERN_CRIT "%s: packet doesn't exists in "380380- "history!\n", __FUNCTION__);390390+ if (unlikely(packet == NULL)) {391391+ LIMIT_NETDEBUG(KERN_WARNING "%s: packet doesn't "392392+ "exists in history!\n", __FUNCTION__);381393 return;382394 }383383- if (packet->dccphtx_sent) {384384- printk(KERN_CRIT "%s: no unsent packet in history!\n",385385- __FUNCTION__);395395+ if (unlikely(packet->dccphtx_sent)) {396396+ LIMIT_NETDEBUG(KERN_WARNING "%s: no unsent packet in "397397+ "history!\n", __FUNCTION__);386398 return;387399 }388400 packet->dccphtx_tstamp = now;···453465 u32 x_recv;454466 u32 r_sample;455467456456- if (hctx == NULL)457457- return;458458-459459- if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) {460460- ccid3_pr_debug("%s, sk=%p, received a packet when "461461- "terminating!\n", dccp_role(sk), sk);462462- return;463463- }468468+ BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM);464469465470 /* we are only interested in ACKs */466471 if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK ||···477496 /* get t_recvdata from history */478497 packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist,479498 DCCP_SKB_CB(skb)->dccpd_ack_seq);480480- if (packet == NULL) {481481- ccid3_pr_debug("%s, sk=%p, seqno %llu(%s) does't "482482- "exist in history!\n",483483- dccp_role(sk), sk,484484- DCCP_SKB_CB(skb)->dccpd_ack_seq,485485- dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type));499499+ if (unlikely(packet == NULL)) {500500+ LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, seqno "501501+ "%llu(%s) does't exist in history!\n",502502+ __FUNCTION__, dccp_role(sk), sk,503503+ (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq,504504+ dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type));486505 return;487506 }488507···490509 dccp_timestamp(sk, &now);491510 r_sample = timeval_delta(&now, &packet->dccphtx_tstamp);492511 if (unlikely(r_sample <= t_elapsed))493493- LIMIT_NETDEBUG(KERN_WARNING494494- "%s: r_sample=%uus, t_elapsed=%uus\n",512512+ LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, "513513+ "t_elapsed=%uus\n",495514 __FUNCTION__, r_sample, t_elapsed);496515 else497516 r_sample -= t_elapsed;···587606588607static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb)589608{590590- struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);609609+ const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);591610592592- if (hctx == NULL || !(sk->sk_state == DCCP_OPEN ||593593- sk->sk_state == DCCP_PARTOPEN))611611+ BUG_ON(hctx == NULL);612612+613613+ if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN))594614 return;595615596616 DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count;···606624 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);607625 struct ccid3_options_received *opt_recv;608626609609- if (hctx == NULL)610610- return 0;627627+ BUG_ON(hctx == NULL);611628612629 opt_recv = &hctx->ccid3hctx_options_received;613630···620639621640 switch (option) {622641 case TFRC_OPT_LOSS_EVENT_RATE:623623- if (len != 4) {624624- ccid3_pr_debug("%s, sk=%p, invalid len for "625625- "TFRC_OPT_LOSS_EVENT_RATE\n",626626- dccp_role(sk), sk);642642+ if (unlikely(len != 4)) {643643+ LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid "644644+ "len for TFRC_OPT_LOSS_EVENT_RATE\n",645645+ __FUNCTION__, dccp_role(sk), sk);627646 rc = -EINVAL;628647 } else {629648 opt_recv->ccid3or_loss_event_rate = ntohl(*(u32 *)value);···641660 opt_recv->ccid3or_loss_intervals_len);642661 break;643662 case TFRC_OPT_RECEIVE_RATE:644644- if (len != 4) {645645- ccid3_pr_debug("%s, sk=%p, invalid len for "646646- "TFRC_OPT_RECEIVE_RATE\n",647647- dccp_role(sk), sk);663663+ if (unlikely(len != 4)) {664664+ LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid "665665+ "len for TFRC_OPT_RECEIVE_RATE\n",666666+ __FUNCTION__, dccp_role(sk), sk);648667 rc = -EINVAL;649668 } else {650669 opt_recv->ccid3or_receive_rate = ntohl(*(u32 *)value);···662681{663682 struct dccp_sock *dp = dccp_sk(sk);664683 struct ccid3_hc_tx_sock *hctx;665665-666666- ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);667684668685 dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), gfp_any());669686 if (dp->dccps_hc_tx_ccid_private == NULL)···691712 struct dccp_sock *dp = dccp_sk(sk);692713 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);693714694694- ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);695715 BUG_ON(hctx == NULL);696716697717 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM);···770792 }771793772794 packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist);773773- if (packet == NULL) {774774- printk(KERN_CRIT "%s: %s, sk=%p, no data packet in history!\n",775775- __FUNCTION__, dccp_role(sk), sk);776776- dump_stack();795795+ if (unlikely(packet == NULL)) {796796+ LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, no data packet "797797+ "in history!\n",798798+ __FUNCTION__, dccp_role(sk), sk);777799 return;778800 }779801···795817796818static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)797819{798798- struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);820820+ const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);799821 u32 x_recv, pinv;800822801801- if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN ||802802- sk->sk_state == DCCP_PARTOPEN))823823+ BUG_ON(hcrx == NULL);824824+825825+ if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN))803826 return;804827805828 DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter;···857878 }858879 }859880860860- if (step == 0) {861861- printk(KERN_CRIT "%s: %s, sk=%p, packet history contains no "862862- "data packets!\n",863863- __FUNCTION__, dccp_role(sk), sk);881881+ if (unlikely(step == 0)) {882882+ LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, packet history "883883+ "contains no data packets!\n",884884+ __FUNCTION__, dccp_role(sk), sk);864885 return ~0;865886 }866887867867- if (interval == 0) {868868- ccid3_pr_debug("%s, sk=%p, Could not find a win_count "869869- "interval > 0. Defaulting to 1\n",870870- dccp_role(sk), sk);888888+ if (unlikely(interval == 0)) {889889+ LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Could not find a "890890+ "win_count interval > 0. Defaulting to 1\n",891891+ __FUNCTION__, dccp_role(sk), sk);871892 interval = 1;872893 }873894found:···910931 if (li_tail == NULL)911932 return;912933 li_tail->dccplih_interval = ccid3_hc_rx_calc_first_li(sk);913913- }914914- /* FIXME: find end of interval */934934+ } else935935+ LIMIT_NETDEBUG(KERN_WARNING "%s: FIXME: find end of "936936+ "interval\n", __FUNCTION__);915937}916938917939static void ccid3_hc_rx_detect_loss(struct sock *sk)···936956 u32 p_prev, r_sample, t_elapsed;937957 int ins;938958939939- if (hcrx == NULL)940940- return;941941-942942- BUG_ON(!(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA ||959959+ BUG_ON(hcrx == NULL ||960960+ !(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA ||943961 hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA));944962945963 opt_recv = &dccp_sk(sk)->dccps_options_received;···956978 t_elapsed = opt_recv->dccpor_elapsed_time * 10;957979958980 if (unlikely(r_sample <= t_elapsed))959959- LIMIT_NETDEBUG(KERN_WARNING960960- "%s: r_sample=%uus, t_elapsed=%uus\n",981981+ LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, "982982+ "t_elapsed=%uus\n",961983 __FUNCTION__, r_sample, t_elapsed);962984 else963985 r_sample -= t_elapsed;···975997 break;976998 case DCCP_PKT_DATA:977999 break;978978- default:979979- ccid3_pr_debug("%s, sk=%p, not DATA/DATAACK/ACK packet(%s)\n",980980- dccp_role(sk), sk,981981- dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type));10001000+ default: /* We're not interested in other packet types, move along */9821001 return;9831002 }98410039851004 packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp,9861005 skb, SLAB_ATOMIC);987987- if (packet == NULL) {988988- ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet "989989- "to history (consider it lost)!",990990- dccp_role(sk), sk);10061006+ if (unlikely(packet == NULL)) {10071007+ LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Not enough mem to "10081008+ "add rx packet to history, consider it lost!\n",10091009+ __FUNCTION__, dccp_role(sk), sk);9911010 return;9921011 }9931012···10771102 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);10781103 struct dccp_sock *dp = dccp_sk(sk);1079110410801080- ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);10811081-10821082- if (hcrx == NULL)10831083- return;11051105+ BUG_ON(hcrx == NULL);1084110610851107 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM);10861108···10951123{10961124 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);1097112510981098- if (hcrx == NULL)10991099- return;11261126+ BUG_ON(hcrx == NULL);1100112711011128 info->tcpi_ca_state = hcrx->ccid3hcrx_state;11021129 info->tcpi_options |= TCPI_OPT_TIMESTAMPS;···11061135{11071136 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);1108113711091109- if (hctx == NULL)11101110- return;11381138+ BUG_ON(hctx == NULL);1111113911121140 info->tcpi_rto = hctx->ccid3hctx_t_rto;11131141 info->tcpi_rtt = hctx->ccid3hctx_rtt;
+2
net/dccp/ccids/ccid3.h
···4848/* Two seconds as per CCID3 spec */4949#define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC)50505151+#define TFRC_INITIAL_IPI (USEC_PER_SEC / 4)5252+5153/* In usecs - half the scheduling granularity as per RFC3448 4.6 */5254#define TFRC_OPSYS_HALF_TIME_GRAN (USEC_PER_SEC / (2 * HZ))5355