aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGreg KH <gregkh@suse.de>2005-09-12 15:45:04 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-12 15:45:04 -0400
commitd58dde0f552a5c5c4485b962d8b6e9dd54fefb30 (patch)
treed9a7e35eb88fea6265d5aadcc3d4ed39122b052a /net
parent877599fdef5ea4a7dd1956e22fa9d6923add97f8 (diff)
parent2ade81473636b33aaac64495f89a7dc572c529f0 (diff)
Merge ../torvalds-2.6/
Diffstat (limited to 'net')
-rw-r--r--net/atm/mpc.c2
-rw-r--r--net/core/dst.c3
-rw-r--r--net/core/netpoll.c4
-rw-r--r--net/core/pktgen.c2
-rw-r--r--net/dccp/ccids/ccid3.c317
-rw-r--r--net/dccp/ccids/ccid3.h16
-rw-r--r--net/dccp/ccids/lib/packet_history.h3
-rw-r--r--net/dccp/dccp.h16
-rw-r--r--net/dccp/input.c4
-rw-r--r--net/dccp/ipv4.c5
-rw-r--r--net/dccp/minisocks.c1
-rw-r--r--net/dccp/options.c90
-rw-r--r--net/dccp/output.c3
-rw-r--r--net/decnet/dn_route.c3
-rw-r--r--net/ipv4/af_inet.c13
-rw-r--r--net/ipv4/fib_trie.c804
-rw-r--r--net/ipv4/inetpeer.c3
-rw-r--r--net/ipv4/netfilter/ipt_owner.c1
-rw-r--r--net/ipv4/tcp_output.c5
-rw-r--r--net/ipv6/addrconf.c3
-rw-r--r--net/ipv6/exthdrs.c3
-rw-r--r--net/ipv6/ip6_fib.c2
-rw-r--r--net/ipv6/ip6_flowlabel.c2
-rw-r--r--net/ipv6/netfilter/ip6t_owner.c1
-rw-r--r--net/ipv6/netfilter/ip6t_rt.c14
-rw-r--r--net/netrom/nr_loopback.c2
-rw-r--r--net/sched/sch_api.c2
27 files changed, 640 insertions, 684 deletions
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index 17a81ebe7e6e..526d9531411f 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -105,7 +105,7 @@ extern void mpc_proc_clean(void);
105 105
106struct mpoa_client *mpcs = NULL; /* FIXME */ 106struct mpoa_client *mpcs = NULL; /* FIXME */
107static struct atm_mpoa_qos *qos_head = NULL; 107static struct atm_mpoa_qos *qos_head = NULL;
108static struct timer_list mpc_timer = TIMER_INITIALIZER(NULL, 0, 0); 108static DEFINE_TIMER(mpc_timer, NULL, 0, 0);
109 109
110 110
111static struct mpoa_client *find_mpc_by_itfnum(int itf) 111static struct mpoa_client *find_mpc_by_itfnum(int itf)
diff --git a/net/core/dst.c b/net/core/dst.c
index 334790da9f16..470c05bc4cb2 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -39,8 +39,7 @@ static unsigned long dst_gc_timer_inc = DST_GC_MAX;
39static void dst_run_gc(unsigned long); 39static void dst_run_gc(unsigned long);
40static void ___dst_free(struct dst_entry * dst); 40static void ___dst_free(struct dst_entry * dst);
41 41
42static struct timer_list dst_gc_timer = 42static DEFINE_TIMER(dst_gc_timer, dst_run_gc, DST_GC_MIN, 0);
43 TIMER_INITIALIZER(dst_run_gc, DST_GC_MIN, 0);
44 43
45static void dst_run_gc(unsigned long dummy) 44static void dst_run_gc(unsigned long dummy)
46{ 45{
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index a1a9a7abff50..5265dfd69928 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -645,10 +645,10 @@ int netpoll_setup(struct netpoll *np)
645 645
646 npinfo->rx_flags = 0; 646 npinfo->rx_flags = 0;
647 npinfo->rx_np = NULL; 647 npinfo->rx_np = NULL;
648 npinfo->poll_lock = SPIN_LOCK_UNLOCKED; 648 spin_lock_init(&npinfo->poll_lock);
649 npinfo->poll_owner = -1; 649 npinfo->poll_owner = -1;
650 npinfo->tries = MAX_RETRIES; 650 npinfo->tries = MAX_RETRIES;
651 npinfo->rx_lock = SPIN_LOCK_UNLOCKED; 651 spin_lock_init(&npinfo->rx_lock);
652 } else 652 } else
653 npinfo = ndev->npinfo; 653 npinfo = ndev->npinfo;
654 654
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8eb083b6041a..b3ad49fa7d78 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -503,7 +503,7 @@ static int pg_delay_d = 0;
503static int pg_clone_skb_d = 0; 503static int pg_clone_skb_d = 0;
504static int debug = 0; 504static int debug = 0;
505 505
506static spinlock_t _thread_lock = SPIN_LOCK_UNLOCKED; 506static DEFINE_SPINLOCK(_thread_lock);
507static struct pktgen_thread *pktgen_threads = NULL; 507static struct pktgen_thread *pktgen_threads = NULL;
508 508
509static char module_fname[128]; 509static char module_fname[128];
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 7bf3b3a91e97..e05f4f955eee 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -43,12 +43,22 @@
43#include "ccid3.h" 43#include "ccid3.h"
44 44
45/* 45/*
46 * Reason for maths with 10 here is to avoid 32 bit overflow when a is big. 46 * Reason for maths here is to avoid 32 bit overflow when a is big.
47 * With this we get close to the limit.
47 */ 48 */
48static inline u32 usecs_div(const u32 a, const u32 b) 49static inline u32 usecs_div(const u32 a, const u32 b)
49{ 50{
50 const u32 tmp = a * (USEC_PER_SEC / 10); 51 const u32 div = a < (UINT_MAX / (USEC_PER_SEC / 10)) ? 10 :
51 return b > 20 ? tmp / (b / 10) : tmp; 52 a < (UINT_MAX / (USEC_PER_SEC / 50)) ? 50 :
53 a < (UINT_MAX / (USEC_PER_SEC / 100)) ? 100 :
54 a < (UINT_MAX / (USEC_PER_SEC / 500)) ? 500 :
55 a < (UINT_MAX / (USEC_PER_SEC / 1000)) ? 1000 :
56 a < (UINT_MAX / (USEC_PER_SEC / 5000)) ? 5000 :
57 a < (UINT_MAX / (USEC_PER_SEC / 10000)) ? 10000 :
58 a < (UINT_MAX / (USEC_PER_SEC / 50000)) ? 50000 :
59 100000;
60 const u32 tmp = a * (USEC_PER_SEC / div);
61 return (b >= 2 * div) ? tmp / (b / div) : tmp;
52} 62}
53 63
54static int ccid3_debug; 64static int ccid3_debug;
@@ -68,13 +78,11 @@ static struct dccp_li_hist *ccid3_li_hist;
68 78
69static int ccid3_init(struct sock *sk) 79static int ccid3_init(struct sock *sk)
70{ 80{
71 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
72 return 0; 81 return 0;
73} 82}
74 83
75static void ccid3_exit(struct sock *sk) 84static void ccid3_exit(struct sock *sk)
76{ 85{
77 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
78} 86}
79 87
80/* TFRC sender states */ 88/* TFRC sender states */
@@ -102,8 +110,7 @@ static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state)
102static inline void ccid3_hc_tx_set_state(struct sock *sk, 110static inline void ccid3_hc_tx_set_state(struct sock *sk,
103 enum ccid3_hc_tx_states state) 111 enum ccid3_hc_tx_states state)
104{ 112{
105 struct dccp_sock *dp = dccp_sk(sk); 113 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
106 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private;
107 enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; 114 enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state;
108 115
109 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", 116 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
@@ -144,8 +151,7 @@ static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx)
144 */ 151 */
145static void ccid3_hc_tx_update_x(struct sock *sk) 152static void ccid3_hc_tx_update_x(struct sock *sk)
146{ 153{
147 struct dccp_sock *dp = dccp_sk(sk); 154 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
148 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private;
149 155
150 /* To avoid large error in calcX */ 156 /* To avoid large error in calcX */
151 if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { 157 if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) {
@@ -159,7 +165,7 @@ static void ccid3_hc_tx_update_x(struct sock *sk)
159 } else { 165 } else {
160 struct timeval now; 166 struct timeval now;
161 167
162 do_gettimeofday(&now); 168 dccp_timestamp(sk, &now);
163 if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= 169 if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >=
164 hctx->ccid3hctx_rtt) { 170 hctx->ccid3hctx_rtt) {
165 hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, 171 hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv,
@@ -174,9 +180,8 @@ static void ccid3_hc_tx_update_x(struct sock *sk)
174static void ccid3_hc_tx_no_feedback_timer(unsigned long data) 180static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
175{ 181{
176 struct sock *sk = (struct sock *)data; 182 struct sock *sk = (struct sock *)data;
177 struct dccp_sock *dp = dccp_sk(sk);
178 unsigned long next_tmout = 0; 183 unsigned long next_tmout = 0;
179 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 184 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
180 185
181 bh_lock_sock(sk); 186 bh_lock_sock(sk);
182 if (sock_owned_by_user(sk)) { 187 if (sock_owned_by_user(sk)) {
@@ -274,20 +279,20 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
274 struct sk_buff *skb, int len) 279 struct sk_buff *skb, int len)
275{ 280{
276 struct dccp_sock *dp = dccp_sk(sk); 281 struct dccp_sock *dp = dccp_sk(sk);
277 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 282 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
278 struct dccp_tx_hist_entry *new_packet; 283 struct dccp_tx_hist_entry *new_packet;
279 struct timeval now; 284 struct timeval now;
280 long delay; 285 long delay;
281 int rc = -ENOTCONN; 286 int rc = -ENOTCONN;
282 287
283 /* Check if pure ACK or Terminating*/ 288 BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM);
284 289
290 /* Check if pure ACK or Terminating*/
285 /* 291 /*
286 * XXX: We only call this function for DATA and DATAACK, on, these 292 * XXX: We only call this function for DATA and DATAACK, on, these
287 * packets can have zero length, but why the comment about "pure ACK"? 293 * packets can have zero length, but why the comment about "pure ACK"?
288 */ 294 */
289 if (hctx == NULL || len == 0 || 295 if (unlikely(len == 0))
290 hctx->ccid3hctx_state == TFRC_SSTATE_TERM)
291 goto out; 296 goto out;
292 297
293 /* See if last packet allocated was not sent */ 298 /* See if last packet allocated was not sent */
@@ -297,23 +302,20 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
297 SLAB_ATOMIC); 302 SLAB_ATOMIC);
298 303
299 rc = -ENOBUFS; 304 rc = -ENOBUFS;
300 if (new_packet == NULL) { 305 if (unlikely(new_packet == NULL)) {
301 ccid3_pr_debug("%s, sk=%p, not enough mem to add " 306 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, not enough "
302 "to history, send refused\n", 307 "mem to add to history, send refused\n",
303 dccp_role(sk), sk); 308 __FUNCTION__, dccp_role(sk), sk);
304 goto out; 309 goto out;
305 } 310 }
306 311
307 dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); 312 dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet);
308 } 313 }
309 314
310 do_gettimeofday(&now); 315 dccp_timestamp(sk, &now);
311 316
312 switch (hctx->ccid3hctx_state) { 317 switch (hctx->ccid3hctx_state) {
313 case TFRC_SSTATE_NO_SENT: 318 case TFRC_SSTATE_NO_SENT:
314 ccid3_pr_debug("%s, sk=%p, first packet(%llu)\n",
315 dccp_role(sk), sk, dp->dccps_gss);
316
317 hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer; 319 hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer;
318 hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk; 320 hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk;
319 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, 321 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
@@ -321,7 +323,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
321 hctx->ccid3hctx_last_win_count = 0; 323 hctx->ccid3hctx_last_win_count = 0;
322 hctx->ccid3hctx_t_last_win_count = now; 324 hctx->ccid3hctx_t_last_win_count = now;
323 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); 325 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);
324 hctx->ccid3hctx_t_ipi = TFRC_INITIAL_TIMEOUT; 326 hctx->ccid3hctx_t_ipi = TFRC_INITIAL_IPI;
325 327
326 /* Set nominal send time for initial packet */ 328 /* Set nominal send time for initial packet */
327 hctx->ccid3hctx_t_nom = now; 329 hctx->ccid3hctx_t_nom = now;
@@ -334,7 +336,6 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
334 case TFRC_SSTATE_FBACK: 336 case TFRC_SSTATE_FBACK:
335 delay = (timeval_delta(&now, &hctx->ccid3hctx_t_nom) - 337 delay = (timeval_delta(&now, &hctx->ccid3hctx_t_nom) -
336 hctx->ccid3hctx_delta); 338 hctx->ccid3hctx_delta);
337 ccid3_pr_debug("send_packet delay=%ld\n", delay);
338 delay /= -1000; 339 delay /= -1000;
339 /* divide by -1000 is to convert to ms and get sign right */ 340 /* divide by -1000 is to convert to ms and get sign right */
340 rc = delay > 0 ? delay : 0; 341 rc = delay > 0 ? delay : 0;
@@ -348,29 +349,25 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
348 } 349 }
349 350
350 /* Can we send? if so add options and add to packet history */ 351 /* Can we send? if so add options and add to packet history */
351 if (rc == 0) 352 if (rc == 0) {
353 dp->dccps_hc_tx_insert_options = 1;
352 new_packet->dccphtx_ccval = 354 new_packet->dccphtx_ccval =
353 DCCP_SKB_CB(skb)->dccpd_ccval = 355 DCCP_SKB_CB(skb)->dccpd_ccval =
354 hctx->ccid3hctx_last_win_count; 356 hctx->ccid3hctx_last_win_count;
357 }
355out: 358out:
356 return rc; 359 return rc;
357} 360}
358 361
359static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) 362static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len)
360{ 363{
361 struct dccp_sock *dp = dccp_sk(sk); 364 const struct dccp_sock *dp = dccp_sk(sk);
362 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 365 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
363 struct timeval now; 366 struct timeval now;
364 367
365 BUG_ON(hctx == NULL); 368 BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM);
366
367 if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) {
368 ccid3_pr_debug("%s, sk=%p, while state is TFRC_SSTATE_TERM!\n",
369 dccp_role(sk), sk);
370 return;
371 }
372 369
373 do_gettimeofday(&now); 370 dccp_timestamp(sk, &now);
374 371
375 /* check if we have sent a data packet */ 372 /* check if we have sent a data packet */
376 if (len > 0) { 373 if (len > 0) {
@@ -378,14 +375,14 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len)
378 struct dccp_tx_hist_entry *packet; 375 struct dccp_tx_hist_entry *packet;
379 376
380 packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); 377 packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);
381 if (packet == NULL) { 378 if (unlikely(packet == NULL)) {
382 printk(KERN_CRIT "%s: packet doesn't exists in " 379 LIMIT_NETDEBUG(KERN_WARNING "%s: packet doesn't "
383 "history!\n", __FUNCTION__); 380 "exists in history!\n", __FUNCTION__);
384 return; 381 return;
385 } 382 }
386 if (packet->dccphtx_sent) { 383 if (unlikely(packet->dccphtx_sent)) {
387 printk(KERN_CRIT "%s: no unsent packet in history!\n", 384 LIMIT_NETDEBUG(KERN_WARNING "%s: no unsent packet in "
388 __FUNCTION__); 385 "history!\n", __FUNCTION__);
389 return; 386 return;
390 } 387 }
391 packet->dccphtx_tstamp = now; 388 packet->dccphtx_tstamp = now;
@@ -445,24 +442,18 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len)
445 442
446static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) 443static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
447{ 444{
448 struct dccp_sock *dp = dccp_sk(sk); 445 const struct dccp_sock *dp = dccp_sk(sk);
449 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 446 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
450 struct ccid3_options_received *opt_recv; 447 struct ccid3_options_received *opt_recv;
451 struct dccp_tx_hist_entry *packet; 448 struct dccp_tx_hist_entry *packet;
449 struct timeval now;
452 unsigned long next_tmout; 450 unsigned long next_tmout;
453 u32 t_elapsed; 451 u32 t_elapsed;
454 u32 pinv; 452 u32 pinv;
455 u32 x_recv; 453 u32 x_recv;
456 u32 r_sample; 454 u32 r_sample;
457 455
458 if (hctx == NULL) 456 BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM);
459 return;
460
461 if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) {
462 ccid3_pr_debug("%s, sk=%p, received a packet when "
463 "terminating!\n", dccp_role(sk), sk);
464 return;
465 }
466 457
467 /* we are only interested in ACKs */ 458 /* we are only interested in ACKs */
468 if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK || 459 if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK ||
@@ -471,7 +462,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
471 462
472 opt_recv = &hctx->ccid3hctx_options_received; 463 opt_recv = &hctx->ccid3hctx_options_received;
473 464
474 t_elapsed = dp->dccps_options_received.dccpor_elapsed_time; 465 t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10;
475 x_recv = opt_recv->ccid3or_receive_rate; 466 x_recv = opt_recv->ccid3or_receive_rate;
476 pinv = opt_recv->ccid3or_loss_event_rate; 467 pinv = opt_recv->ccid3or_loss_event_rate;
477 468
@@ -486,19 +477,24 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
486 /* get t_recvdata from history */ 477 /* get t_recvdata from history */
487 packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist, 478 packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist,
488 DCCP_SKB_CB(skb)->dccpd_ack_seq); 479 DCCP_SKB_CB(skb)->dccpd_ack_seq);
489 if (packet == NULL) { 480 if (unlikely(packet == NULL)) {
490 ccid3_pr_debug("%s, sk=%p, seqno %llu(%s) does't " 481 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, seqno "
491 "exist in history!\n", 482 "%llu(%s) does't exist in history!\n",
492 dccp_role(sk), sk, 483 __FUNCTION__, dccp_role(sk), sk,
493 DCCP_SKB_CB(skb)->dccpd_ack_seq, 484 (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq,
494 dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); 485 dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type));
495 return; 486 return;
496 } 487 }
497 488
498 /* Update RTT */ 489 /* Update RTT */
499 r_sample = timeval_now_delta(&packet->dccphtx_tstamp); 490 dccp_timestamp(sk, &now);
500 /* FIXME: */ 491 r_sample = timeval_delta(&now, &packet->dccphtx_tstamp);
501 // r_sample -= usecs_to_jiffies(t_elapsed * 10); 492 if (unlikely(r_sample <= t_elapsed))
493 LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, "
494 "t_elapsed=%uus\n",
495 __FUNCTION__, r_sample, t_elapsed);
496 else
497 r_sample -= t_elapsed;
502 498
503 /* Update RTT estimate by 499 /* Update RTT estimate by
504 * If (No feedback recv) 500 * If (No feedback recv)
@@ -591,11 +587,11 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
591 587
592static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb) 588static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb)
593{ 589{
594 const struct dccp_sock *dp = dccp_sk(sk); 590 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
595 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 591
592 BUG_ON(hctx == NULL);
596 593
597 if (hctx == NULL || !(sk->sk_state == DCCP_OPEN || 594 if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN))
598 sk->sk_state == DCCP_PARTOPEN))
599 return; 595 return;
600 596
601 DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count; 597 DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count;
@@ -606,12 +602,11 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
606 unsigned char *value) 602 unsigned char *value)
607{ 603{
608 int rc = 0; 604 int rc = 0;
609 struct dccp_sock *dp = dccp_sk(sk); 605 const struct dccp_sock *dp = dccp_sk(sk);
610 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 606 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
611 struct ccid3_options_received *opt_recv; 607 struct ccid3_options_received *opt_recv;
612 608
613 if (hctx == NULL) 609 BUG_ON(hctx == NULL);
614 return 0;
615 610
616 opt_recv = &hctx->ccid3hctx_options_received; 611 opt_recv = &hctx->ccid3hctx_options_received;
617 612
@@ -625,10 +620,10 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
625 620
626 switch (option) { 621 switch (option) {
627 case TFRC_OPT_LOSS_EVENT_RATE: 622 case TFRC_OPT_LOSS_EVENT_RATE:
628 if (len != 4) { 623 if (unlikely(len != 4)) {
629 ccid3_pr_debug("%s, sk=%p, invalid len for " 624 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid "
630 "TFRC_OPT_LOSS_EVENT_RATE\n", 625 "len for TFRC_OPT_LOSS_EVENT_RATE\n",
631 dccp_role(sk), sk); 626 __FUNCTION__, dccp_role(sk), sk);
632 rc = -EINVAL; 627 rc = -EINVAL;
633 } else { 628 } else {
634 opt_recv->ccid3or_loss_event_rate = ntohl(*(u32 *)value); 629 opt_recv->ccid3or_loss_event_rate = ntohl(*(u32 *)value);
@@ -646,10 +641,10 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
646 opt_recv->ccid3or_loss_intervals_len); 641 opt_recv->ccid3or_loss_intervals_len);
647 break; 642 break;
648 case TFRC_OPT_RECEIVE_RATE: 643 case TFRC_OPT_RECEIVE_RATE:
649 if (len != 4) { 644 if (unlikely(len != 4)) {
650 ccid3_pr_debug("%s, sk=%p, invalid len for " 645 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid "
651 "TFRC_OPT_RECEIVE_RATE\n", 646 "len for TFRC_OPT_RECEIVE_RATE\n",
652 dccp_role(sk), sk); 647 __FUNCTION__, dccp_role(sk), sk);
653 rc = -EINVAL; 648 rc = -EINVAL;
654 } else { 649 } else {
655 opt_recv->ccid3or_receive_rate = ntohl(*(u32 *)value); 650 opt_recv->ccid3or_receive_rate = ntohl(*(u32 *)value);
@@ -668,13 +663,11 @@ static int ccid3_hc_tx_init(struct sock *sk)
668 struct dccp_sock *dp = dccp_sk(sk); 663 struct dccp_sock *dp = dccp_sk(sk);
669 struct ccid3_hc_tx_sock *hctx; 664 struct ccid3_hc_tx_sock *hctx;
670 665
671 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); 666 dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), gfp_any());
672 667 if (dp->dccps_hc_tx_ccid_private == NULL)
673 hctx = dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx),
674 gfp_any());
675 if (hctx == NULL)
676 return -ENOMEM; 668 return -ENOMEM;
677 669
670 hctx = ccid3_hc_tx_sk(sk);
678 memset(hctx, 0, sizeof(*hctx)); 671 memset(hctx, 0, sizeof(*hctx));
679 672
680 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && 673 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE &&
@@ -696,9 +689,8 @@ static int ccid3_hc_tx_init(struct sock *sk)
696static void ccid3_hc_tx_exit(struct sock *sk) 689static void ccid3_hc_tx_exit(struct sock *sk)
697{ 690{
698 struct dccp_sock *dp = dccp_sk(sk); 691 struct dccp_sock *dp = dccp_sk(sk);
699 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 692 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
700 693
701 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
702 BUG_ON(hctx == NULL); 694 BUG_ON(hctx == NULL);
703 695
704 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM); 696 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM);
@@ -738,8 +730,7 @@ static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state)
738static inline void ccid3_hc_rx_set_state(struct sock *sk, 730static inline void ccid3_hc_rx_set_state(struct sock *sk,
739 enum ccid3_hc_rx_states state) 731 enum ccid3_hc_rx_states state)
740{ 732{
741 struct dccp_sock *dp = dccp_sk(sk); 733 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
742 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
743 enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; 734 enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state;
744 735
745 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", 736 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
@@ -751,14 +742,14 @@ static inline void ccid3_hc_rx_set_state(struct sock *sk,
751 742
752static void ccid3_hc_rx_send_feedback(struct sock *sk) 743static void ccid3_hc_rx_send_feedback(struct sock *sk)
753{ 744{
745 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
754 struct dccp_sock *dp = dccp_sk(sk); 746 struct dccp_sock *dp = dccp_sk(sk);
755 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
756 struct dccp_rx_hist_entry *packet; 747 struct dccp_rx_hist_entry *packet;
757 struct timeval now; 748 struct timeval now;
758 749
759 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); 750 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
760 751
761 do_gettimeofday(&now); 752 dccp_timestamp(sk, &now);
762 753
763 switch (hcrx->ccid3hcrx_state) { 754 switch (hcrx->ccid3hcrx_state) {
764 case TFRC_RSTATE_NO_DATA: 755 case TFRC_RSTATE_NO_DATA:
@@ -767,11 +758,8 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)
767 case TFRC_RSTATE_DATA: { 758 case TFRC_RSTATE_DATA: {
768 const u32 delta = timeval_delta(&now, 759 const u32 delta = timeval_delta(&now,
769 &hcrx->ccid3hcrx_tstamp_last_feedback); 760 &hcrx->ccid3hcrx_tstamp_last_feedback);
770 761 hcrx->ccid3hcrx_x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv,
771 hcrx->ccid3hcrx_x_recv = (hcrx->ccid3hcrx_bytes_recv * 762 delta);
772 USEC_PER_SEC);
773 if (likely(delta > 1))
774 hcrx->ccid3hcrx_x_recv /= delta;
775 } 763 }
776 break; 764 break;
777 default: 765 default:
@@ -782,10 +770,10 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)
782 } 770 }
783 771
784 packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist); 772 packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist);
785 if (packet == NULL) { 773 if (unlikely(packet == NULL)) {
786 printk(KERN_CRIT "%s: %s, sk=%p, no data packet in history!\n", 774 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, no data packet "
787 __FUNCTION__, dccp_role(sk), sk); 775 "in history!\n",
788 dump_stack(); 776 __FUNCTION__, dccp_role(sk), sk);
789 return; 777 return;
790 } 778 }
791 779
@@ -801,17 +789,18 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)
801 hcrx->ccid3hcrx_pinv = ~0; 789 hcrx->ccid3hcrx_pinv = ~0;
802 else 790 else
803 hcrx->ccid3hcrx_pinv = 1000000 / hcrx->ccid3hcrx_p; 791 hcrx->ccid3hcrx_pinv = 1000000 / hcrx->ccid3hcrx_p;
792 dp->dccps_hc_rx_insert_options = 1;
804 dccp_send_ack(sk); 793 dccp_send_ack(sk);
805} 794}
806 795
807static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) 796static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
808{ 797{
809 const struct dccp_sock *dp = dccp_sk(sk); 798 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
810 u32 x_recv, pinv; 799 u32 x_recv, pinv;
811 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
812 800
813 if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN || 801 BUG_ON(hcrx == NULL);
814 sk->sk_state == DCCP_PARTOPEN)) 802
803 if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN))
815 return; 804 return;
816 805
817 DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter; 806 DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter;
@@ -837,8 +826,7 @@ static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
837 826
838static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) 827static u32 ccid3_hc_rx_calc_first_li(struct sock *sk)
839{ 828{
840 struct dccp_sock *dp = dccp_sk(sk); 829 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
841 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
842 struct dccp_rx_hist_entry *entry, *next, *tail = NULL; 830 struct dccp_rx_hist_entry *entry, *next, *tail = NULL;
843 u32 rtt, delta, x_recv, fval, p, tmp2; 831 u32 rtt, delta, x_recv, fval, p, tmp2;
844 struct timeval tstamp = { 0, }; 832 struct timeval tstamp = { 0, };
@@ -869,17 +857,17 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk)
869 } 857 }
870 } 858 }
871 859
872 if (step == 0) { 860 if (unlikely(step == 0)) {
873 printk(KERN_CRIT "%s: %s, sk=%p, packet history contains no " 861 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, packet history "
874 "data packets!\n", 862 "contains no data packets!\n",
875 __FUNCTION__, dccp_role(sk), sk); 863 __FUNCTION__, dccp_role(sk), sk);
876 return ~0; 864 return ~0;
877 } 865 }
878 866
879 if (interval == 0) { 867 if (unlikely(interval == 0)) {
880 ccid3_pr_debug("%s, sk=%p, Could not find a win_count " 868 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Could not find a "
881 "interval > 0. Defaulting to 1\n", 869 "win_count interval > 0. Defaulting to 1\n",
882 dccp_role(sk), sk); 870 __FUNCTION__, dccp_role(sk), sk);
883 interval = 1; 871 interval = 1;
884 } 872 }
885found: 873found:
@@ -889,10 +877,9 @@ found:
889 if (rtt == 0) 877 if (rtt == 0)
890 rtt = 1; 878 rtt = 1;
891 879
892 delta = timeval_now_delta(&hcrx->ccid3hcrx_tstamp_last_feedback); 880 dccp_timestamp(sk, &tstamp);
893 x_recv = hcrx->ccid3hcrx_bytes_recv * USEC_PER_SEC; 881 delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback);
894 if (likely(delta > 1)) 882 x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, delta);
895 x_recv /= delta;
896 883
897 tmp1 = (u64)x_recv * (u64)rtt; 884 tmp1 = (u64)x_recv * (u64)rtt;
898 do_div(tmp1,10000000); 885 do_div(tmp1,10000000);
@@ -911,8 +898,7 @@ found:
911 898
912static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) 899static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss)
913{ 900{
914 struct dccp_sock *dp = dccp_sk(sk); 901 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
915 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
916 902
917 if (seq_loss != DCCP_MAX_SEQNO + 1 && 903 if (seq_loss != DCCP_MAX_SEQNO + 1 &&
918 list_empty(&hcrx->ccid3hcrx_li_hist)) { 904 list_empty(&hcrx->ccid3hcrx_li_hist)) {
@@ -924,14 +910,14 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss)
924 if (li_tail == NULL) 910 if (li_tail == NULL)
925 return; 911 return;
926 li_tail->dccplih_interval = ccid3_hc_rx_calc_first_li(sk); 912 li_tail->dccplih_interval = ccid3_hc_rx_calc_first_li(sk);
927 } 913 } else
928 /* FIXME: find end of interval */ 914 LIMIT_NETDEBUG(KERN_WARNING "%s: FIXME: find end of "
915 "interval\n", __FUNCTION__);
929} 916}
930 917
931static void ccid3_hc_rx_detect_loss(struct sock *sk) 918static void ccid3_hc_rx_detect_loss(struct sock *sk)
932{ 919{
933 struct dccp_sock *dp = dccp_sk(sk); 920 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
934 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
935 u8 win_loss; 921 u8 win_loss;
936 const u64 seq_loss = dccp_rx_hist_detect_loss(&hcrx->ccid3hcrx_hist, 922 const u64 seq_loss = dccp_rx_hist_detect_loss(&hcrx->ccid3hcrx_hist,
937 &hcrx->ccid3hcrx_li_hist, 923 &hcrx->ccid3hcrx_li_hist,
@@ -942,22 +928,19 @@ static void ccid3_hc_rx_detect_loss(struct sock *sk)
942 928
943static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) 929static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
944{ 930{
945 struct dccp_sock *dp = dccp_sk(sk); 931 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
946 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
947 const struct dccp_options_received *opt_recv; 932 const struct dccp_options_received *opt_recv;
948 struct dccp_rx_hist_entry *packet; 933 struct dccp_rx_hist_entry *packet;
949 struct timeval now; 934 struct timeval now;
950 u8 win_count; 935 u8 win_count;
951 u32 p_prev; 936 u32 p_prev, r_sample, t_elapsed;
952 int ins; 937 int ins;
953 938
954 if (hcrx == NULL) 939 BUG_ON(hcrx == NULL ||
955 return; 940 !(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA ||
956
957 BUG_ON(!(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA ||
958 hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA)); 941 hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA));
959 942
960 opt_recv = &dp->dccps_options_received; 943 opt_recv = &dccp_sk(sk)->dccps_options_received;
961 944
962 switch (DCCP_SKB_CB(skb)->dccpd_type) { 945 switch (DCCP_SKB_CB(skb)->dccpd_type) {
963 case DCCP_PKT_ACK: 946 case DCCP_PKT_ACK:
@@ -967,10 +950,24 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
967 if (opt_recv->dccpor_timestamp_echo == 0) 950 if (opt_recv->dccpor_timestamp_echo == 0)
968 break; 951 break;
969 p_prev = hcrx->ccid3hcrx_rtt; 952 p_prev = hcrx->ccid3hcrx_rtt;
970 do_gettimeofday(&now); 953 dccp_timestamp(sk, &now);
971 hcrx->ccid3hcrx_rtt = timeval_usecs(&now) - 954 timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10);
972 (opt_recv->dccpor_timestamp_echo - 955 r_sample = timeval_usecs(&now);
973 opt_recv->dccpor_elapsed_time) * 10; 956 t_elapsed = opt_recv->dccpor_elapsed_time * 10;
957
958 if (unlikely(r_sample <= t_elapsed))
959 LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, "
960 "t_elapsed=%uus\n",
961 __FUNCTION__, r_sample, t_elapsed);
962 else
963 r_sample -= t_elapsed;
964
965 if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA)
966 hcrx->ccid3hcrx_rtt = r_sample;
967 else
968 hcrx->ccid3hcrx_rtt = (hcrx->ccid3hcrx_rtt * 9) / 10 +
969 r_sample / 10;
970
974 if (p_prev != hcrx->ccid3hcrx_rtt) 971 if (p_prev != hcrx->ccid3hcrx_rtt)
975 ccid3_pr_debug("%s, New RTT=%luus, elapsed time=%u\n", 972 ccid3_pr_debug("%s, New RTT=%luus, elapsed time=%u\n",
976 dccp_role(sk), hcrx->ccid3hcrx_rtt, 973 dccp_role(sk), hcrx->ccid3hcrx_rtt,
@@ -978,19 +975,16 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
978 break; 975 break;
979 case DCCP_PKT_DATA: 976 case DCCP_PKT_DATA:
980 break; 977 break;
981 default: 978 default: /* We're not interested in other packet types, move along */
982 ccid3_pr_debug("%s, sk=%p, not DATA/DATAACK/ACK packet(%s)\n",
983 dccp_role(sk), sk,
984 dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type));
985 return; 979 return;
986 } 980 }
987 981
988 packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, 982 packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp,
989 skb, SLAB_ATOMIC); 983 skb, SLAB_ATOMIC);
990 if (packet == NULL) { 984 if (unlikely(packet == NULL)) {
991 ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet " 985 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Not enough mem to "
992 "to history (consider it lost)!", 986 "add rx packet to history, consider it lost!\n",
993 dccp_role(sk), sk); 987 __FUNCTION__, dccp_role(sk), sk);
994 return; 988 return;
995 } 989 }
996 990
@@ -1017,7 +1011,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1017 if (ins != 0) 1011 if (ins != 0)
1018 break; 1012 break;
1019 1013
1020 do_gettimeofday(&now); 1014 dccp_timestamp(sk, &now);
1021 if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= 1015 if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >=
1022 hcrx->ccid3hcrx_rtt) { 1016 hcrx->ccid3hcrx_rtt) {
1023 hcrx->ccid3hcrx_tstamp_last_ack = now; 1017 hcrx->ccid3hcrx_tstamp_last_ack = now;
@@ -1056,11 +1050,11 @@ static int ccid3_hc_rx_init(struct sock *sk)
1056 1050
1057 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); 1051 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
1058 1052
1059 hcrx = dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), 1053 dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), gfp_any());
1060 gfp_any()); 1054 if (dp->dccps_hc_rx_ccid_private == NULL)
1061 if (hcrx == NULL)
1062 return -ENOMEM; 1055 return -ENOMEM;
1063 1056
1057 hcrx = ccid3_hc_rx_sk(sk);
1064 memset(hcrx, 0, sizeof(*hcrx)); 1058 memset(hcrx, 0, sizeof(*hcrx));
1065 1059
1066 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && 1060 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE &&
@@ -1072,23 +1066,18 @@ static int ccid3_hc_rx_init(struct sock *sk)
1072 hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; 1066 hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA;
1073 INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); 1067 INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist);
1074 INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); 1068 INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist);
1075 /* 1069 dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack);
1076 * XXX this seems to be paranoid, need to think more about this, for 1070 hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack;
1077 * now start with something different than zero. -acme 1071 hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */
1078 */
1079 hcrx->ccid3hcrx_rtt = USEC_PER_SEC / 5;
1080 return 0; 1072 return 0;
1081} 1073}
1082 1074
1083static void ccid3_hc_rx_exit(struct sock *sk) 1075static void ccid3_hc_rx_exit(struct sock *sk)
1084{ 1076{
1077 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
1085 struct dccp_sock *dp = dccp_sk(sk); 1078 struct dccp_sock *dp = dccp_sk(sk);
1086 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
1087 1079
1088 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); 1080 BUG_ON(hcrx == NULL);
1089
1090 if (hcrx == NULL)
1091 return;
1092 1081
1093 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM); 1082 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM);
1094 1083
@@ -1104,11 +1093,9 @@ static void ccid3_hc_rx_exit(struct sock *sk)
1104 1093
1105static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) 1094static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
1106{ 1095{
1107 const struct dccp_sock *dp = dccp_sk(sk); 1096 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
1108 const struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
1109 1097
1110 if (hcrx == NULL) 1098 BUG_ON(hcrx == NULL);
1111 return;
1112 1099
1113 info->tcpi_ca_state = hcrx->ccid3hcrx_state; 1100 info->tcpi_ca_state = hcrx->ccid3hcrx_state;
1114 info->tcpi_options |= TCPI_OPT_TIMESTAMPS; 1101 info->tcpi_options |= TCPI_OPT_TIMESTAMPS;
@@ -1117,11 +1104,9 @@ static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
1117 1104
1118static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) 1105static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info)
1119{ 1106{
1120 const struct dccp_sock *dp = dccp_sk(sk); 1107 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
1121 const struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private;
1122 1108
1123 if (hctx == NULL) 1109 BUG_ON(hctx == NULL);
1124 return;
1125 1110
1126 info->tcpi_rto = hctx->ccid3hctx_t_rto; 1111 info->tcpi_rto = hctx->ccid3hctx_t_rto;
1127 info->tcpi_rtt = hctx->ccid3hctx_rtt; 1112 info->tcpi_rtt = hctx->ccid3hctx_rtt;
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index ee8cbace6630..eb248778eea3 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -48,6 +48,8 @@
48/* Two seconds as per CCID3 spec */ 48/* Two seconds as per CCID3 spec */
49#define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC) 49#define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC)
50 50
51#define TFRC_INITIAL_IPI (USEC_PER_SEC / 4)
52
51/* In usecs - half the scheduling granularity as per RFC3448 4.6 */ 53/* In usecs - half the scheduling granularity as per RFC3448 4.6 */
52#define TFRC_OPSYS_HALF_TIME_GRAN (USEC_PER_SEC / (2 * HZ)) 54#define TFRC_OPSYS_HALF_TIME_GRAN (USEC_PER_SEC / (2 * HZ))
53 55
@@ -115,7 +117,7 @@ struct ccid3_hc_rx_sock {
115 u64 ccid3hcrx_seqno_last_counter:48, 117 u64 ccid3hcrx_seqno_last_counter:48,
116 ccid3hcrx_state:8, 118 ccid3hcrx_state:8,
117 ccid3hcrx_last_counter:4; 119 ccid3hcrx_last_counter:4;
118 unsigned long ccid3hcrx_rtt; 120 u32 ccid3hcrx_rtt;
119 u32 ccid3hcrx_p; 121 u32 ccid3hcrx_p;
120 u32 ccid3hcrx_bytes_recv; 122 u32 ccid3hcrx_bytes_recv;
121 struct timeval ccid3hcrx_tstamp_last_feedback; 123 struct timeval ccid3hcrx_tstamp_last_feedback;
@@ -128,10 +130,14 @@ struct ccid3_hc_rx_sock {
128 u32 ccid3hcrx_x_recv; 130 u32 ccid3hcrx_x_recv;
129}; 131};
130 132
131#define ccid3_hc_tx_field(s,field) (s->dccps_hc_tx_ccid_private == NULL ? 0 : \ 133static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)
132 ((struct ccid3_hc_tx_sock *)s->dccps_hc_tx_ccid_private)->ccid3hctx_##field) 134{
135 return dccp_sk(sk)->dccps_hc_tx_ccid_private;
136}
133 137
134#define ccid3_hc_rx_field(s,field) (s->dccps_hc_rx_ccid_private == NULL ? 0 : \ 138static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk)
135 ((struct ccid3_hc_rx_sock *)s->dccps_hc_rx_ccid_private)->ccid3hcrx_##field) 139{
140 return dccp_sk(sk)->dccps_hc_rx_ccid_private;
141}
136 142
137#endif /* _DCCP_CCID3_H_ */ 143#endif /* _DCCP_CCID3_H_ */
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h
index fb90a91aa93d..b375ebdb7dcf 100644
--- a/net/dccp/ccids/lib/packet_history.h
+++ b/net/dccp/ccids/lib/packet_history.h
@@ -134,6 +134,7 @@ static inline struct dccp_tx_hist_entry *
134 134
135static inline struct dccp_rx_hist_entry * 135static inline struct dccp_rx_hist_entry *
136 dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, 136 dccp_rx_hist_entry_new(struct dccp_rx_hist *hist,
137 const struct sock *sk,
137 const u32 ndp, 138 const u32 ndp,
138 const struct sk_buff *skb, 139 const struct sk_buff *skb,
139 const unsigned int __nocast prio) 140 const unsigned int __nocast prio)
@@ -148,7 +149,7 @@ static inline struct dccp_rx_hist_entry *
148 entry->dccphrx_ccval = dh->dccph_ccval; 149 entry->dccphrx_ccval = dh->dccph_ccval;
149 entry->dccphrx_type = dh->dccph_type; 150 entry->dccphrx_type = dh->dccph_type;
150 entry->dccphrx_ndp = ndp; 151 entry->dccphrx_ndp = ndp;
151 do_gettimeofday(&(entry->dccphrx_tstamp)); 152 dccp_timestamp(sk, &entry->dccphrx_tstamp);
152 } 153 }
153 154
154 return entry; 155 return entry;
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 33456c0d5937..95c4630b3b18 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -426,10 +426,13 @@ extern struct dccp_ackpkts *
426 dccp_ackpkts_alloc(unsigned int len, 426 dccp_ackpkts_alloc(unsigned int len,
427 const unsigned int __nocast priority); 427 const unsigned int __nocast priority);
428extern void dccp_ackpkts_free(struct dccp_ackpkts *ap); 428extern void dccp_ackpkts_free(struct dccp_ackpkts *ap);
429extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state); 429extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk,
430 u64 ackno, u8 state);
430extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, 431extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap,
431 struct sock *sk, u64 ackno); 432 struct sock *sk, u64 ackno);
432 433
434extern void dccp_timestamp(const struct sock *sk, struct timeval *tv);
435
433static inline suseconds_t timeval_usecs(const struct timeval *tv) 436static inline suseconds_t timeval_usecs(const struct timeval *tv)
434{ 437{
435 return tv->tv_sec * USEC_PER_SEC + tv->tv_usec; 438 return tv->tv_sec * USEC_PER_SEC + tv->tv_usec;
@@ -468,17 +471,6 @@ static inline void timeval_sub_usecs(struct timeval *tv,
468 } 471 }
469} 472}
470 473
471/*
472 * Returns the difference in usecs between timeval
473 * passed in and current time
474 */
475static inline suseconds_t timeval_now_delta(const struct timeval *tv)
476{
477 struct timeval now;
478 do_gettimeofday(&now);
479 return timeval_delta(&now, tv);
480}
481
482#ifdef CONFIG_IP_DCCP_DEBUG 474#ifdef CONFIG_IP_DCCP_DEBUG
483extern void dccp_ackvector_print(const u64 ackno, 475extern void dccp_ackvector_print(const u64 ackno,
484 const unsigned char *vector, int len); 476 const unsigned char *vector, int len);
diff --git a/net/dccp/input.c b/net/dccp/input.c
index ef29cef1dafe..c60bc3433f5e 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -170,7 +170,7 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
170 if (dp->dccps_options.dccpo_send_ack_vector) { 170 if (dp->dccps_options.dccpo_send_ack_vector) {
171 struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; 171 struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
172 172
173 if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, 173 if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk,
174 DCCP_SKB_CB(skb)->dccpd_seq, 174 DCCP_SKB_CB(skb)->dccpd_seq,
175 DCCP_ACKPKTS_STATE_RECEIVED)) { 175 DCCP_ACKPKTS_STATE_RECEIVED)) {
176 LIMIT_NETDEBUG(KERN_WARNING "DCCP: acknowledgeable " 176 LIMIT_NETDEBUG(KERN_WARNING "DCCP: acknowledgeable "
@@ -498,7 +498,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
498 * DCCP_ACKPKTS_STATE_ECN_MARKED 498 * DCCP_ACKPKTS_STATE_ECN_MARKED
499 */ 499 */
500 if (dp->dccps_options.dccpo_send_ack_vector) { 500 if (dp->dccps_options.dccpo_send_ack_vector) {
501 if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, 501 if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk,
502 DCCP_SKB_CB(skb)->dccpd_seq, 502 DCCP_SKB_CB(skb)->dccpd_seq,
503 DCCP_ACKPKTS_STATE_RECEIVED)) 503 DCCP_ACKPKTS_STATE_RECEIVED))
504 goto discard; 504 goto discard;
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 3fc75dbee4b8..2afaa464e7f0 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -641,16 +641,12 @@ int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code)
641 641
642 skb = dccp_make_reset(sk, sk->sk_dst_cache, code); 642 skb = dccp_make_reset(sk, sk->sk_dst_cache, code);
643 if (skb != NULL) { 643 if (skb != NULL) {
644 const struct dccp_sock *dp = dccp_sk(sk);
645 const struct inet_sock *inet = inet_sk(sk); 644 const struct inet_sock *inet = inet_sk(sk);
646 645
647 err = ip_build_and_send_pkt(skb, sk, 646 err = ip_build_and_send_pkt(skb, sk,
648 inet->saddr, inet->daddr, NULL); 647 inet->saddr, inet->daddr, NULL);
649 if (err == NET_XMIT_CN) 648 if (err == NET_XMIT_CN)
650 err = 0; 649 err = 0;
651
652 ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk);
653 ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk);
654 } 650 }
655 651
656 return err; 652 return err;
@@ -1243,6 +1239,7 @@ static int dccp_v4_init_sock(struct sock *sk)
1243 static int dccp_ctl_socket_init = 1; 1239 static int dccp_ctl_socket_init = 1;
1244 1240
1245 dccp_options_init(&dp->dccps_options); 1241 dccp_options_init(&dp->dccps_options);
1242 do_gettimeofday(&dp->dccps_epoch);
1246 1243
1247 if (dp->dccps_options.dccpo_send_ack_vector) { 1244 if (dp->dccps_options.dccpo_send_ack_vector) {
1248 dp->dccps_hc_rx_ackpkts = 1245 dp->dccps_hc_rx_ackpkts =
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index ce5dff4ac22e..18461bc04cbe 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -96,6 +96,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
96 newdp->dccps_hc_rx_ackpkts = NULL; 96 newdp->dccps_hc_rx_ackpkts = NULL;
97 newdp->dccps_role = DCCP_ROLE_SERVER; 97 newdp->dccps_role = DCCP_ROLE_SERVER;
98 newicsk->icsk_rto = DCCP_TIMEOUT_INIT; 98 newicsk->icsk_rto = DCCP_TIMEOUT_INIT;
99 do_gettimeofday(&newdp->dccps_epoch);
99 100
100 if (newdp->dccps_options.dccpo_send_ack_vector) { 101 if (newdp->dccps_options.dccpo_send_ack_vector) {
101 newdp->dccps_hc_rx_ackpkts = 102 newdp->dccps_hc_rx_ackpkts =
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 382c5894acb2..d4c4242d8dd7 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -72,6 +72,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
72 struct dccp_options_received *opt_recv = &dp->dccps_options_received; 72 struct dccp_options_received *opt_recv = &dp->dccps_options_received;
73 unsigned char opt, len; 73 unsigned char opt, len;
74 unsigned char *value; 74 unsigned char *value;
75 u32 elapsed_time;
75 76
76 memset(opt_recv, 0, sizeof(*opt_recv)); 77 memset(opt_recv, 0, sizeof(*opt_recv));
77 78
@@ -139,7 +140,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
139 opt_recv->dccpor_timestamp = ntohl(*(u32 *)value); 140 opt_recv->dccpor_timestamp = ntohl(*(u32 *)value);
140 141
141 dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; 142 dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp;
142 do_gettimeofday(&dp->dccps_timestamp_time); 143 dccp_timestamp(sk, &dp->dccps_timestamp_time);
143 144
144 dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n", 145 dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n",
145 debug_prefix, opt_recv->dccpor_timestamp, 146 debug_prefix, opt_recv->dccpor_timestamp,
@@ -159,18 +160,18 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
159 (unsigned long long) 160 (unsigned long long)
160 DCCP_SKB_CB(skb)->dccpd_ack_seq); 161 DCCP_SKB_CB(skb)->dccpd_ack_seq);
161 162
162 if (len > 4) {
163 if (len == 6)
164 opt_recv->dccpor_elapsed_time =
165 ntohs(*(u16 *)(value + 4));
166 else
167 opt_recv->dccpor_elapsed_time =
168 ntohl(*(u32 *)(value + 4));
169 163
170 dccp_pr_debug("%sTIMESTAMP_ECHO ELAPSED_TIME=%d\n", 164 if (len == 4)
171 debug_prefix, 165 break;
172 opt_recv->dccpor_elapsed_time); 166
173 } 167 if (len == 6)
168 elapsed_time = ntohs(*(u16 *)(value + 4));
169 else
170 elapsed_time = ntohl(*(u32 *)(value + 4));
171
172 /* Give precedence to the biggest ELAPSED_TIME */
173 if (elapsed_time > opt_recv->dccpor_elapsed_time)
174 opt_recv->dccpor_elapsed_time = elapsed_time;
174 break; 175 break;
175 case DCCPO_ELAPSED_TIME: 176 case DCCPO_ELAPSED_TIME:
176 if (len != 2 && len != 4) 177 if (len != 2 && len != 4)
@@ -180,14 +181,15 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
180 continue; 181 continue;
181 182
182 if (len == 2) 183 if (len == 2)
183 opt_recv->dccpor_elapsed_time = 184 elapsed_time = ntohs(*(u16 *)value);
184 ntohs(*(u16 *)value);
185 else 185 else
186 opt_recv->dccpor_elapsed_time = 186 elapsed_time = ntohl(*(u32 *)value);
187 ntohl(*(u32 *)value); 187
188 if (elapsed_time > opt_recv->dccpor_elapsed_time)
189 opt_recv->dccpor_elapsed_time = elapsed_time;
188 190
189 dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix, 191 dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix,
190 opt_recv->dccpor_elapsed_time); 192 elapsed_time);
191 break; 193 break;
192 /* 194 /*
193 * From draft-ietf-dccp-spec-11.txt: 195 * From draft-ietf-dccp-spec-11.txt:
@@ -359,9 +361,13 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
359#endif 361#endif
360 struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; 362 struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
361 int len = ap->dccpap_buf_vector_len + 2; 363 int len = ap->dccpap_buf_vector_len + 2;
362 const u32 elapsed_time = timeval_now_delta(&ap->dccpap_time) / 10; 364 struct timeval now;
365 u32 elapsed_time;
363 unsigned char *to, *from; 366 unsigned char *to, *from;
364 367
368 dccp_timestamp(sk, &now);
369 elapsed_time = timeval_delta(&now, &ap->dccpap_time) / 10;
370
365 if (elapsed_time != 0) 371 if (elapsed_time != 0)
366 dccp_insert_option_elapsed_time(sk, skb, elapsed_time); 372 dccp_insert_option_elapsed_time(sk, skb, elapsed_time);
367 373
@@ -426,13 +432,29 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
426 (unsigned long long) ap->dccpap_ack_ackno); 432 (unsigned long long) ap->dccpap_ack_ackno);
427} 433}
428 434
435void dccp_timestamp(const struct sock *sk, struct timeval *tv)
436{
437 const struct dccp_sock *dp = dccp_sk(sk);
438
439 do_gettimeofday(tv);
440 tv->tv_sec -= dp->dccps_epoch.tv_sec;
441 tv->tv_usec -= dp->dccps_epoch.tv_usec;
442
443 while (tv->tv_usec < 0) {
444 tv->tv_sec--;
445 tv->tv_usec += USEC_PER_SEC;
446 }
447}
448
449EXPORT_SYMBOL_GPL(dccp_timestamp);
450
429void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) 451void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb)
430{ 452{
431 struct timeval tv; 453 struct timeval tv;
432 u32 now; 454 u32 now;
433 455
434 do_gettimeofday(&tv); 456 dccp_timestamp(sk, &tv);
435 now = (tv.tv_sec * USEC_PER_SEC + tv.tv_usec) / 10; 457 now = timeval_usecs(&tv) / 10;
436 /* yes this will overflow but that is the point as we want a 458 /* yes this will overflow but that is the point as we want a
437 * 10 usec 32 bit timer which mean it wraps every 11.9 hours */ 459 * 10 usec 32 bit timer which mean it wraps every 11.9 hours */
438 460
@@ -450,13 +472,17 @@ static void dccp_insert_option_timestamp_echo(struct sock *sk,
450 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? 472 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
451 "CLIENT TX opt: " : "server TX opt: "; 473 "CLIENT TX opt: " : "server TX opt: ";
452#endif 474#endif
475 struct timeval now;
453 u32 tstamp_echo; 476 u32 tstamp_echo;
454 const u32 elapsed_time = 477 u32 elapsed_time;
455 timeval_now_delta(&dp->dccps_timestamp_time) / 10; 478 int len, elapsed_time_len;
456 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
457 const int len = 6 + elapsed_time_len;
458 unsigned char *to; 479 unsigned char *to;
459 480
481 dccp_timestamp(sk, &now);
482 elapsed_time = timeval_delta(&now, &dp->dccps_timestamp_time) / 10;
483 elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
484 len = 6 + elapsed_time_len;
485
460 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { 486 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
461 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert " 487 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
462 "timestamp echo!\n"); 488 "timestamp echo!\n");
@@ -505,13 +531,18 @@ void dccp_insert_options(struct sock *sk, struct sk_buff *skb)
505 (dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno != 531 (dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno !=
506 DCCP_MAX_SEQNO + 1)) 532 DCCP_MAX_SEQNO + 1))
507 dccp_insert_option_ack_vector(sk, skb); 533 dccp_insert_option_ack_vector(sk, skb);
508
509 if (dp->dccps_timestamp_echo != 0) 534 if (dp->dccps_timestamp_echo != 0)
510 dccp_insert_option_timestamp_echo(sk, skb); 535 dccp_insert_option_timestamp_echo(sk, skb);
511 } 536 }
512 537
513 ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb); 538 if (dp->dccps_hc_rx_insert_options) {
514 ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb); 539 ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb);
540 dp->dccps_hc_rx_insert_options = 0;
541 }
542 if (dp->dccps_hc_tx_insert_options) {
543 ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb);
544 dp->dccps_hc_tx_insert_options = 0;
545 }
515 546
516 /* XXX: insert other options when appropriate */ 547 /* XXX: insert other options when appropriate */
517 548
@@ -616,7 +647,8 @@ static inline int dccp_ackpkts_set_buf_head_state(struct dccp_ackpkts *ap,
616/* 647/*
617 * Implements the draft-ietf-dccp-spec-11.txt Appendix A 648 * Implements the draft-ietf-dccp-spec-11.txt Appendix A
618 */ 649 */
619int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) 650int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk,
651 u64 ackno, u8 state)
620{ 652{
621 /* 653 /*
622 * Check at the right places if the buffer is full, if it is, tell the 654 * Check at the right places if the buffer is full, if it is, tell the
@@ -697,7 +729,7 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
697 } 729 }
698 730
699 ap->dccpap_buf_ackno = ackno; 731 ap->dccpap_buf_ackno = ackno;
700 do_gettimeofday(&ap->dccpap_time); 732 dccp_timestamp(sk, &ap->dccpap_time);
701out: 733out:
702 dccp_pr_debug(""); 734 dccp_pr_debug("");
703 dccp_ackpkts_print(ap); 735 dccp_ackpkts_print(ap);
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 28de157a4326..ea6d0e91e511 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -522,7 +522,4 @@ void dccp_send_close(struct sock *sk, const int active)
522 dccp_transmit_skb(sk, skb_clone(skb, prio)); 522 dccp_transmit_skb(sk, skb_clone(skb, prio));
523 } else 523 } else
524 dccp_transmit_skb(sk, skb); 524 dccp_transmit_skb(sk, skb);
525
526 ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk);
527 ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk);
528} 525}
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 2c915f305be3..3407f190afe8 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -117,8 +117,7 @@ static struct dn_rt_hash_bucket *dn_rt_hash_table;
117static unsigned dn_rt_hash_mask; 117static unsigned dn_rt_hash_mask;
118 118
119static struct timer_list dn_route_timer; 119static struct timer_list dn_route_timer;
120static struct timer_list dn_rt_flush_timer = 120static DEFINE_TIMER(dn_rt_flush_timer, dn_run_flush, 0, 0);
121 TIMER_INITIALIZER(dn_run_flush, 0, 0);
122int decnet_dst_gc_interval = 2; 121int decnet_dst_gc_interval = 2;
123 122
124static struct dst_ops dn_dst_ops = { 123static struct dst_ops dn_dst_ops = {
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index bf147f8db399..a9d84f93442c 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1248,11 +1248,6 @@ module_init(inet_init);
1248/* ------------------------------------------------------------------------ */ 1248/* ------------------------------------------------------------------------ */
1249 1249
1250#ifdef CONFIG_PROC_FS 1250#ifdef CONFIG_PROC_FS
1251#ifdef CONFIG_IP_FIB_TRIE
1252extern int fib_stat_proc_init(void);
1253extern void fib_stat_proc_exit(void);
1254#endif
1255
1256static int __init ipv4_proc_init(void) 1251static int __init ipv4_proc_init(void)
1257{ 1252{
1258 int rc = 0; 1253 int rc = 0;
@@ -1265,19 +1260,11 @@ static int __init ipv4_proc_init(void)
1265 goto out_udp; 1260 goto out_udp;
1266 if (fib_proc_init()) 1261 if (fib_proc_init())
1267 goto out_fib; 1262 goto out_fib;
1268#ifdef CONFIG_IP_FIB_TRIE
1269 if (fib_stat_proc_init())
1270 goto out_fib_stat;
1271#endif
1272 if (ip_misc_proc_init()) 1263 if (ip_misc_proc_init())
1273 goto out_misc; 1264 goto out_misc;
1274out: 1265out:
1275 return rc; 1266 return rc;
1276out_misc: 1267out_misc:
1277#ifdef CONFIG_IP_FIB_TRIE
1278 fib_stat_proc_exit();
1279out_fib_stat:
1280#endif
1281 fib_proc_exit(); 1268 fib_proc_exit();
1282out_fib: 1269out_fib:
1283 udp4_proc_exit(); 1270 udp4_proc_exit();
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index b2dea4e5da77..1b63b4824164 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -43,7 +43,7 @@
43 * 2 of the License, or (at your option) any later version. 43 * 2 of the License, or (at your option) any later version.
44 */ 44 */
45 45
46#define VERSION "0.402" 46#define VERSION "0.403"
47 47
48#include <linux/config.h> 48#include <linux/config.h>
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
@@ -164,7 +164,6 @@ static struct node *resize(struct trie *t, struct tnode *tn);
164static struct tnode *inflate(struct trie *t, struct tnode *tn); 164static struct tnode *inflate(struct trie *t, struct tnode *tn);
165static struct tnode *halve(struct trie *t, struct tnode *tn); 165static struct tnode *halve(struct trie *t, struct tnode *tn);
166static void tnode_free(struct tnode *tn); 166static void tnode_free(struct tnode *tn);
167static void trie_dump_seq(struct seq_file *seq, struct trie *t);
168 167
169static kmem_cache_t *fn_alias_kmem __read_mostly; 168static kmem_cache_t *fn_alias_kmem __read_mostly;
170static struct trie *trie_local = NULL, *trie_main = NULL; 169static struct trie *trie_local = NULL, *trie_main = NULL;
@@ -1971,558 +1970,525 @@ struct fib_table * __init fib_hash_init(int id)
1971 return tb; 1970 return tb;
1972} 1971}
1973 1972
1974/* Trie dump functions */ 1973#ifdef CONFIG_PROC_FS
1974/* Depth first Trie walk iterator */
1975struct fib_trie_iter {
1976 struct tnode *tnode;
1977 struct trie *trie;
1978 unsigned index;
1979 unsigned depth;
1980};
1975 1981
1976static void putspace_seq(struct seq_file *seq, int n) 1982static struct node *fib_trie_get_next(struct fib_trie_iter *iter)
1977{ 1983{
1978 while (n--) 1984 struct tnode *tn = iter->tnode;
1979 seq_printf(seq, " "); 1985 unsigned cindex = iter->index;
1980} 1986 struct tnode *p;
1981 1987
1982static void printbin_seq(struct seq_file *seq, unsigned int v, int bits) 1988 pr_debug("get_next iter={node=%p index=%d depth=%d}\n",
1983{ 1989 iter->tnode, iter->index, iter->depth);
1984 while (bits--) 1990rescan:
1985 seq_printf(seq, "%s", (v & (1<<bits))?"1":"0"); 1991 while (cindex < (1<<tn->bits)) {
1986} 1992 struct node *n = tnode_get_child(tn, cindex);
1987 1993
1988static void printnode_seq(struct seq_file *seq, int indent, struct node *n, 1994 if (n) {
1989 int pend, int cindex, int bits) 1995 if (IS_LEAF(n)) {
1990{ 1996 iter->tnode = tn;
1991 putspace_seq(seq, indent); 1997 iter->index = cindex + 1;
1992 if (IS_LEAF(n)) 1998 } else {
1993 seq_printf(seq, "|"); 1999 /* push down one level */
1994 else 2000 iter->tnode = (struct tnode *) n;
1995 seq_printf(seq, "+"); 2001 iter->index = 0;
1996 if (bits) { 2002 ++iter->depth;
1997 seq_printf(seq, "%d/", cindex); 2003 }
1998 printbin_seq(seq, cindex, bits); 2004 return n;
1999 seq_printf(seq, ": "); 2005 }
2000 } else
2001 seq_printf(seq, "<root>: ");
2002 seq_printf(seq, "%s:%p ", IS_LEAF(n)?"Leaf":"Internal node", n);
2003 2006
2004 if (IS_LEAF(n)) { 2007 ++cindex;
2005 struct leaf *l = (struct leaf *)n; 2008 }
2006 struct fib_alias *fa;
2007 int i;
2008 2009
2009 seq_printf(seq, "key=%d.%d.%d.%d\n", 2010 /* Current node exhausted, pop back up */
2010 n->key >> 24, (n->key >> 16) % 256, (n->key >> 8) % 256, n->key % 256); 2011 p = NODE_PARENT(tn);
2011 2012 if (p) {
2012 for (i = 32; i >= 0; i--) 2013 cindex = tkey_extract_bits(tn->key, p->pos, p->bits)+1;
2013 if (find_leaf_info(&l->list, i)) { 2014 tn = p;
2014 struct list_head *fa_head = get_fa_head(l, i); 2015 --iter->depth;
2015 2016 goto rescan;
2016 if (!fa_head)
2017 continue;
2018
2019 if (list_empty(fa_head))
2020 continue;
2021
2022 putspace_seq(seq, indent+2);
2023 seq_printf(seq, "{/%d...dumping}\n", i);
2024
2025 list_for_each_entry_rcu(fa, fa_head, fa_list) {
2026 putspace_seq(seq, indent+2);
2027 if (fa->fa_info == NULL) {
2028 seq_printf(seq, "Error fa_info=NULL\n");
2029 continue;
2030 }
2031 if (fa->fa_info->fib_nh == NULL) {
2032 seq_printf(seq, "Error _fib_nh=NULL\n");
2033 continue;
2034 }
2035
2036 seq_printf(seq, "{type=%d scope=%d TOS=%d}\n",
2037 fa->fa_type,
2038 fa->fa_scope,
2039 fa->fa_tos);
2040 }
2041 }
2042 } else {
2043 struct tnode *tn = (struct tnode *)n;
2044 int plen = ((struct tnode *)n)->pos;
2045 t_key prf = MASK_PFX(n->key, plen);
2046
2047 seq_printf(seq, "key=%d.%d.%d.%d/%d\n",
2048 prf >> 24, (prf >> 16) % 256, (prf >> 8) % 256, prf % 256, plen);
2049
2050 putspace_seq(seq, indent); seq_printf(seq, "| ");
2051 seq_printf(seq, "{key prefix=%08x/", tn->key & TKEY_GET_MASK(0, tn->pos));
2052 printbin_seq(seq, tkey_extract_bits(tn->key, 0, tn->pos), tn->pos);
2053 seq_printf(seq, "}\n");
2054 putspace_seq(seq, indent); seq_printf(seq, "| ");
2055 seq_printf(seq, "{pos=%d", tn->pos);
2056 seq_printf(seq, " (skip=%d bits)", tn->pos - pend);
2057 seq_printf(seq, " bits=%d (%u children)}\n", tn->bits, (1 << tn->bits));
2058 putspace_seq(seq, indent); seq_printf(seq, "| ");
2059 seq_printf(seq, "{empty=%d full=%d}\n", tn->empty_children, tn->full_children);
2060 } 2017 }
2018
2019 /* got root? */
2020 return NULL;
2061} 2021}
2062 2022
2063static void trie_dump_seq(struct seq_file *seq, struct trie *t) 2023static struct node *fib_trie_get_first(struct fib_trie_iter *iter,
2024 struct trie *t)
2064{ 2025{
2065 struct node *n; 2026 struct node *n = rcu_dereference(t->trie);
2066 int cindex = 0;
2067 int indent = 1;
2068 int pend = 0;
2069 int depth = 0;
2070 struct tnode *tn;
2071
2072 rcu_read_lock();
2073 n = rcu_dereference(t->trie);
2074 seq_printf(seq, "------ trie_dump of t=%p ------\n", t);
2075 2027
2076 if (!n) { 2028 if (n && IS_TNODE(n)) {
2077 seq_printf(seq, "------ trie is empty\n"); 2029 iter->tnode = (struct tnode *) n;
2078 2030 iter->trie = t;
2079 rcu_read_unlock(); 2031 iter->index = 0;
2080 return; 2032 iter->depth = 0;
2033 return n;
2081 } 2034 }
2035 return NULL;
2036}
2082 2037
2083 printnode_seq(seq, indent, n, pend, cindex, 0); 2038static void trie_collect_stats(struct trie *t, struct trie_stat *s)
2084 2039{
2085 if (!IS_TNODE(n)) { 2040 struct node *n;
2086 rcu_read_unlock(); 2041 struct fib_trie_iter iter;
2087 return;
2088 }
2089
2090 tn = (struct tnode *)n;
2091 pend = tn->pos+tn->bits;
2092 putspace_seq(seq, indent); seq_printf(seq, "\\--\n");
2093 indent += 3;
2094 depth++;
2095
2096 while (tn && cindex < (1 << tn->bits)) {
2097 struct node *child = rcu_dereference(tn->child[cindex]);
2098 if (!child)
2099 cindex++;
2100 else {
2101 /* Got a child */
2102 printnode_seq(seq, indent, child, pend,
2103 cindex, tn->bits);
2104
2105 if (IS_LEAF(child))
2106 cindex++;
2107
2108 else {
2109 /*
2110 * New tnode. Decend one level
2111 */
2112
2113 depth++;
2114 n = child;
2115 tn = (struct tnode *)n;
2116 pend = tn->pos+tn->bits;
2117 putspace_seq(seq, indent);
2118 seq_printf(seq, "\\--\n");
2119 indent += 3;
2120 cindex = 0;
2121 }
2122 }
2123
2124 /*
2125 * Test if we are done
2126 */
2127
2128 while (cindex >= (1 << tn->bits)) {
2129 /*
2130 * Move upwards and test for root
2131 * pop off all traversed nodes
2132 */
2133 2042
2134 if (NODE_PARENT(tn) == NULL) { 2043 memset(s, 0, sizeof(*s));
2135 tn = NULL;
2136 break;
2137 }
2138 2044
2139 cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); 2045 rcu_read_lock();
2140 cindex++; 2046 for (n = fib_trie_get_first(&iter, t); n;
2141 tn = NODE_PARENT(tn); 2047 n = fib_trie_get_next(&iter)) {
2142 pend = tn->pos + tn->bits; 2048 if (IS_LEAF(n)) {
2143 indent -= 3; 2049 s->leaves++;
2144 depth--; 2050 s->totdepth += iter.depth;
2051 if (iter.depth > s->maxdepth)
2052 s->maxdepth = iter.depth;
2053 } else {
2054 const struct tnode *tn = (const struct tnode *) n;
2055 int i;
2056
2057 s->tnodes++;
2058 s->nodesizes[tn->bits]++;
2059 for (i = 0; i < (1<<tn->bits); i++)
2060 if (!tn->child[i])
2061 s->nullpointers++;
2145 } 2062 }
2146 } 2063 }
2147 rcu_read_unlock(); 2064 rcu_read_unlock();
2148} 2065}
2149 2066
2150static struct trie_stat *trie_stat_new(void) 2067/*
2068 * This outputs /proc/net/fib_triestats
2069 */
2070static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat)
2151{ 2071{
2152 struct trie_stat *s; 2072 unsigned i, max, pointers, bytes, avdepth;
2153 int i;
2154 2073
2155 s = kmalloc(sizeof(struct trie_stat), GFP_KERNEL); 2074 if (stat->leaves)
2156 if (!s) 2075 avdepth = stat->totdepth*100 / stat->leaves;
2157 return NULL; 2076 else
2077 avdepth = 0;
2158 2078
2159 s->totdepth = 0; 2079 seq_printf(seq, "\tAver depth: %d.%02d\n", avdepth / 100, avdepth % 100 );
2160 s->maxdepth = 0; 2080 seq_printf(seq, "\tMax depth: %u\n", stat->maxdepth);
2161 s->tnodes = 0;
2162 s->leaves = 0;
2163 s->nullpointers = 0;
2164 2081
2165 for (i = 0; i < MAX_CHILDS; i++) 2082 seq_printf(seq, "\tLeaves: %u\n", stat->leaves);
2166 s->nodesizes[i] = 0;
2167 2083
2168 return s; 2084 bytes = sizeof(struct leaf) * stat->leaves;
2169} 2085 seq_printf(seq, "\tInternal nodes: %d\n\t", stat->tnodes);
2086 bytes += sizeof(struct tnode) * stat->tnodes;
2170 2087
2171static struct trie_stat *trie_collect_stats(struct trie *t) 2088 max = MAX_CHILDS-1;
2172{ 2089 while (max >= 0 && stat->nodesizes[max] == 0)
2173 struct node *n; 2090 max--;
2174 struct trie_stat *s = trie_stat_new();
2175 int cindex = 0;
2176 int pend = 0;
2177 int depth = 0;
2178 2091
2179 if (!s) 2092 pointers = 0;
2180 return NULL; 2093 for (i = 1; i <= max; i++)
2094 if (stat->nodesizes[i] != 0) {
2095 seq_printf(seq, " %d: %d", i, stat->nodesizes[i]);
2096 pointers += (1<<i) * stat->nodesizes[i];
2097 }
2098 seq_putc(seq, '\n');
2099 seq_printf(seq, "\tPointers: %d\n", pointers);
2181 2100
2182 rcu_read_lock(); 2101 bytes += sizeof(struct node *) * pointers;
2183 n = rcu_dereference(t->trie); 2102 seq_printf(seq, "Null ptrs: %d\n", stat->nullpointers);
2103 seq_printf(seq, "Total size: %d kB\n", (bytes + 1023) / 1024);
2184 2104
2185 if (!n) 2105#ifdef CONFIG_IP_FIB_TRIE_STATS
2186 return s; 2106 seq_printf(seq, "Counters:\n---------\n");
2107 seq_printf(seq,"gets = %d\n", t->stats.gets);
2108 seq_printf(seq,"backtracks = %d\n", t->stats.backtrack);
2109 seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed);
2110 seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss);
2111 seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit);
2112 seq_printf(seq,"skipped node resize = %d\n", t->stats.resize_node_skipped);
2113#ifdef CLEAR_STATS
2114 memset(&(t->stats), 0, sizeof(t->stats));
2115#endif
2116#endif /* CONFIG_IP_FIB_TRIE_STATS */
2117}
2187 2118
2188 if (IS_TNODE(n)) { 2119static int fib_triestat_seq_show(struct seq_file *seq, void *v)
2189 struct tnode *tn = (struct tnode *)n; 2120{
2190 pend = tn->pos+tn->bits; 2121 struct trie_stat *stat;
2191 s->nodesizes[tn->bits]++;
2192 depth++;
2193
2194 while (tn && cindex < (1 << tn->bits)) {
2195 struct node *ch = rcu_dereference(tn->child[cindex]);
2196 if (ch) {
2197
2198 /* Got a child */
2199
2200 if (IS_LEAF(tn->child[cindex])) {
2201 cindex++;
2202
2203 /* stats */
2204 if (depth > s->maxdepth)
2205 s->maxdepth = depth;
2206 s->totdepth += depth;
2207 s->leaves++;
2208 } else {
2209 /*
2210 * New tnode. Decend one level
2211 */
2212
2213 s->tnodes++;
2214 s->nodesizes[tn->bits]++;
2215 depth++;
2216
2217 n = ch;
2218 tn = (struct tnode *)n;
2219 pend = tn->pos+tn->bits;
2220
2221 cindex = 0;
2222 }
2223 } else {
2224 cindex++;
2225 s->nullpointers++;
2226 }
2227 2122
2228 /* 2123 stat = kmalloc(sizeof(*stat), GFP_KERNEL);
2229 * Test if we are done 2124 if (!stat)
2230 */ 2125 return -ENOMEM;
2231 2126
2232 while (cindex >= (1 << tn->bits)) { 2127 seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n",
2233 /* 2128 sizeof(struct leaf), sizeof(struct tnode));
2234 * Move upwards and test for root
2235 * pop off all traversed nodes
2236 */
2237 2129
2238 if (NODE_PARENT(tn) == NULL) { 2130 if (trie_local) {
2239 tn = NULL; 2131 seq_printf(seq, "Local:\n");
2240 n = NULL; 2132 trie_collect_stats(trie_local, stat);
2241 break; 2133 trie_show_stats(seq, stat);
2242 } 2134 }
2243 2135
2244 cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); 2136 if (trie_main) {
2245 tn = NODE_PARENT(tn); 2137 seq_printf(seq, "Main:\n");
2246 cindex++; 2138 trie_collect_stats(trie_main, stat);
2247 n = (struct node *)tn; 2139 trie_show_stats(seq, stat);
2248 pend = tn->pos+tn->bits;
2249 depth--;
2250 }
2251 }
2252 } 2140 }
2141 kfree(stat);
2253 2142
2254 rcu_read_unlock(); 2143 return 0;
2255 return s;
2256} 2144}
2257 2145
2258#ifdef CONFIG_PROC_FS 2146static int fib_triestat_seq_open(struct inode *inode, struct file *file)
2259
2260static struct fib_alias *fib_triestat_get_first(struct seq_file *seq)
2261{ 2147{
2262 return NULL; 2148 return single_open(file, fib_triestat_seq_show, NULL);
2263} 2149}
2264 2150
2265static struct fib_alias *fib_triestat_get_next(struct seq_file *seq) 2151static struct file_operations fib_triestat_fops = {
2152 .owner = THIS_MODULE,
2153 .open = fib_triestat_seq_open,
2154 .read = seq_read,
2155 .llseek = seq_lseek,
2156 .release = single_release,
2157};
2158
2159static struct node *fib_trie_get_idx(struct fib_trie_iter *iter,
2160 loff_t pos)
2266{ 2161{
2162 loff_t idx = 0;
2163 struct node *n;
2164
2165 for (n = fib_trie_get_first(iter, trie_local);
2166 n; ++idx, n = fib_trie_get_next(iter)) {
2167 if (pos == idx)
2168 return n;
2169 }
2170
2171 for (n = fib_trie_get_first(iter, trie_main);
2172 n; ++idx, n = fib_trie_get_next(iter)) {
2173 if (pos == idx)
2174 return n;
2175 }
2267 return NULL; 2176 return NULL;
2268} 2177}
2269 2178
2270static void *fib_triestat_seq_start(struct seq_file *seq, loff_t *pos) 2179static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos)
2271{ 2180{
2272 if (!ip_fib_main_table) 2181 rcu_read_lock();
2273 return NULL; 2182 if (*pos == 0)
2274
2275 if (*pos)
2276 return fib_triestat_get_next(seq);
2277 else
2278 return SEQ_START_TOKEN; 2183 return SEQ_START_TOKEN;
2184 return fib_trie_get_idx(seq->private, *pos - 1);
2279} 2185}
2280 2186
2281static void *fib_triestat_seq_next(struct seq_file *seq, void *v, loff_t *pos) 2187static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2282{ 2188{
2189 struct fib_trie_iter *iter = seq->private;
2190 void *l = v;
2191
2283 ++*pos; 2192 ++*pos;
2284 if (v == SEQ_START_TOKEN) 2193 if (v == SEQ_START_TOKEN)
2285 return fib_triestat_get_first(seq); 2194 return fib_trie_get_idx(iter, 0);
2286 else
2287 return fib_triestat_get_next(seq);
2288}
2289 2195
2290static void fib_triestat_seq_stop(struct seq_file *seq, void *v) 2196 v = fib_trie_get_next(iter);
2291{ 2197 BUG_ON(v == l);
2198 if (v)
2199 return v;
2292 2200
2293} 2201 /* continue scan in next trie */
2202 if (iter->trie == trie_local)
2203 return fib_trie_get_first(iter, trie_main);
2294 2204
2295/* 2205 return NULL;
2296 * This outputs /proc/net/fib_triestats 2206}
2297 *
2298 * It always works in backward compatibility mode.
2299 * The format of the file is not supposed to be changed.
2300 */
2301 2207
2302static void collect_and_show(struct trie *t, struct seq_file *seq) 2208static void fib_trie_seq_stop(struct seq_file *seq, void *v)
2303{ 2209{
2304 int bytes = 0; /* How many bytes are used, a ref is 4 bytes */ 2210 rcu_read_unlock();
2305 int i, max, pointers; 2211}
2306 struct trie_stat *stat;
2307 int avdepth;
2308
2309 stat = trie_collect_stats(t);
2310
2311 bytes = 0;
2312 seq_printf(seq, "trie=%p\n", t);
2313
2314 if (stat) {
2315 if (stat->leaves)
2316 avdepth = stat->totdepth*100 / stat->leaves;
2317 else
2318 avdepth = 0;
2319 seq_printf(seq, "Aver depth: %d.%02d\n", avdepth / 100, avdepth % 100);
2320 seq_printf(seq, "Max depth: %4d\n", stat->maxdepth);
2321 2212
2322 seq_printf(seq, "Leaves: %d\n", stat->leaves); 2213static void seq_indent(struct seq_file *seq, int n)
2323 bytes += sizeof(struct leaf) * stat->leaves; 2214{
2324 seq_printf(seq, "Internal nodes: %d\n", stat->tnodes); 2215 while (n-- > 0) seq_puts(seq, " ");
2325 bytes += sizeof(struct tnode) * stat->tnodes; 2216}
2326 2217
2327 max = MAX_CHILDS-1; 2218static inline const char *rtn_scope(enum rt_scope_t s)
2219{
2220 static char buf[32];
2328 2221
2329 while (max >= 0 && stat->nodesizes[max] == 0) 2222 switch(s) {
2330 max--; 2223 case RT_SCOPE_UNIVERSE: return "universe";
2331 pointers = 0; 2224 case RT_SCOPE_SITE: return "site";
2225 case RT_SCOPE_LINK: return "link";
2226 case RT_SCOPE_HOST: return "host";
2227 case RT_SCOPE_NOWHERE: return "nowhere";
2228 default:
2229 snprintf(buf, sizeof(buf), "scope=%d", s);
2230 return buf;
2231 }
2232}
2332 2233
2333 for (i = 1; i <= max; i++) 2234static const char *rtn_type_names[__RTN_MAX] = {
2334 if (stat->nodesizes[i] != 0) { 2235 [RTN_UNSPEC] = "UNSPEC",
2335 seq_printf(seq, " %d: %d", i, stat->nodesizes[i]); 2236 [RTN_UNICAST] = "UNICAST",
2336 pointers += (1<<i) * stat->nodesizes[i]; 2237 [RTN_LOCAL] = "LOCAL",
2337 } 2238 [RTN_BROADCAST] = "BROADCAST",
2338 seq_printf(seq, "\n"); 2239 [RTN_ANYCAST] = "ANYCAST",
2339 seq_printf(seq, "Pointers: %d\n", pointers); 2240 [RTN_MULTICAST] = "MULTICAST",
2340 bytes += sizeof(struct node *) * pointers; 2241 [RTN_BLACKHOLE] = "BLACKHOLE",
2341 seq_printf(seq, "Null ptrs: %d\n", stat->nullpointers); 2242 [RTN_UNREACHABLE] = "UNREACHABLE",
2342 seq_printf(seq, "Total size: %d kB\n", bytes / 1024); 2243 [RTN_PROHIBIT] = "PROHIBIT",
2244 [RTN_THROW] = "THROW",
2245 [RTN_NAT] = "NAT",
2246 [RTN_XRESOLVE] = "XRESOLVE",
2247};
2343 2248
2344 kfree(stat); 2249static inline const char *rtn_type(unsigned t)
2345 } 2250{
2251 static char buf[32];
2346 2252
2347#ifdef CONFIG_IP_FIB_TRIE_STATS 2253 if (t < __RTN_MAX && rtn_type_names[t])
2348 seq_printf(seq, "Counters:\n---------\n"); 2254 return rtn_type_names[t];
2349 seq_printf(seq,"gets = %d\n", t->stats.gets); 2255 snprintf(buf, sizeof(buf), "type %d", t);
2350 seq_printf(seq,"backtracks = %d\n", t->stats.backtrack); 2256 return buf;
2351 seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed);
2352 seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss);
2353 seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit);
2354 seq_printf(seq,"skipped node resize = %d\n", t->stats.resize_node_skipped);
2355#ifdef CLEAR_STATS
2356 memset(&(t->stats), 0, sizeof(t->stats));
2357#endif
2358#endif /* CONFIG_IP_FIB_TRIE_STATS */
2359} 2257}
2360 2258
2361static int fib_triestat_seq_show(struct seq_file *seq, void *v) 2259/* Pretty print the trie */
2260static int fib_trie_seq_show(struct seq_file *seq, void *v)
2362{ 2261{
2363 char bf[128]; 2262 const struct fib_trie_iter *iter = seq->private;
2263 struct node *n = v;
2364 2264
2365 if (v == SEQ_START_TOKEN) { 2265 if (v == SEQ_START_TOKEN)
2366 seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", 2266 return 0;
2367 sizeof(struct leaf), sizeof(struct tnode));
2368 if (trie_local)
2369 collect_and_show(trie_local, seq);
2370 2267
2371 if (trie_main) 2268 if (IS_TNODE(n)) {
2372 collect_and_show(trie_main, seq); 2269 struct tnode *tn = (struct tnode *) n;
2373 } else { 2270 t_key prf = ntohl(MASK_PFX(tn->key, tn->pos));
2374 snprintf(bf, sizeof(bf), "*\t%08X\t%08X", 200, 400);
2375 2271
2376 seq_printf(seq, "%-127s\n", bf); 2272 if (!NODE_PARENT(n)) {
2273 if (iter->trie == trie_local)
2274 seq_puts(seq, "<local>:\n");
2275 else
2276 seq_puts(seq, "<main>:\n");
2277 } else {
2278 seq_indent(seq, iter->depth-1);
2279 seq_printf(seq, " +-- %d.%d.%d.%d/%d\n",
2280 NIPQUAD(prf), tn->pos);
2281 }
2282 } else {
2283 struct leaf *l = (struct leaf *) n;
2284 int i;
2285 u32 val = ntohl(l->key);
2286
2287 seq_indent(seq, iter->depth);
2288 seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val));
2289 for (i = 32; i >= 0; i--) {
2290 struct leaf_info *li = find_leaf_info(&l->list, i);
2291 if (li) {
2292 struct fib_alias *fa;
2293 list_for_each_entry_rcu(fa, &li->falh, fa_list) {
2294 seq_indent(seq, iter->depth+1);
2295 seq_printf(seq, " /%d %s %s", i,
2296 rtn_scope(fa->fa_scope),
2297 rtn_type(fa->fa_type));
2298 if (fa->fa_tos)
2299 seq_printf(seq, "tos =%d\n",
2300 fa->fa_tos);
2301 seq_putc(seq, '\n');
2302 }
2303 }
2304 }
2377 } 2305 }
2306
2378 return 0; 2307 return 0;
2379} 2308}
2380 2309
2381static struct seq_operations fib_triestat_seq_ops = { 2310static struct seq_operations fib_trie_seq_ops = {
2382 .start = fib_triestat_seq_start, 2311 .start = fib_trie_seq_start,
2383 .next = fib_triestat_seq_next, 2312 .next = fib_trie_seq_next,
2384 .stop = fib_triestat_seq_stop, 2313 .stop = fib_trie_seq_stop,
2385 .show = fib_triestat_seq_show, 2314 .show = fib_trie_seq_show,
2386}; 2315};
2387 2316
2388static int fib_triestat_seq_open(struct inode *inode, struct file *file) 2317static int fib_trie_seq_open(struct inode *inode, struct file *file)
2389{ 2318{
2390 struct seq_file *seq; 2319 struct seq_file *seq;
2391 int rc = -ENOMEM; 2320 int rc = -ENOMEM;
2321 struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL);
2392 2322
2393 rc = seq_open(file, &fib_triestat_seq_ops); 2323 if (!s)
2324 goto out;
2325
2326 rc = seq_open(file, &fib_trie_seq_ops);
2394 if (rc) 2327 if (rc)
2395 goto out_kfree; 2328 goto out_kfree;
2396 2329
2397 seq = file->private_data; 2330 seq = file->private_data;
2331 seq->private = s;
2332 memset(s, 0, sizeof(*s));
2398out: 2333out:
2399 return rc; 2334 return rc;
2400out_kfree: 2335out_kfree:
2336 kfree(s);
2401 goto out; 2337 goto out;
2402} 2338}
2403 2339
2404static struct file_operations fib_triestat_seq_fops = { 2340static struct file_operations fib_trie_fops = {
2405 .owner = THIS_MODULE, 2341 .owner = THIS_MODULE,
2406 .open = fib_triestat_seq_open, 2342 .open = fib_trie_seq_open,
2407 .read = seq_read, 2343 .read = seq_read,
2408 .llseek = seq_lseek, 2344 .llseek = seq_lseek,
2409 .release = seq_release_private, 2345 .release = seq_release_private,
2410}; 2346};
2411 2347
2412int __init fib_stat_proc_init(void) 2348static unsigned fib_flag_trans(int type, u32 mask, const struct fib_info *fi)
2413{
2414 if (!proc_net_fops_create("fib_triestat", S_IRUGO, &fib_triestat_seq_fops))
2415 return -ENOMEM;
2416 return 0;
2417}
2418
2419void __init fib_stat_proc_exit(void)
2420{ 2349{
2421 proc_net_remove("fib_triestat"); 2350 static unsigned type2flags[RTN_MAX + 1] = {
2422} 2351 [7] = RTF_REJECT, [8] = RTF_REJECT,
2352 };
2353 unsigned flags = type2flags[type];
2423 2354
2424static struct fib_alias *fib_trie_get_first(struct seq_file *seq) 2355 if (fi && fi->fib_nh->nh_gw)
2425{ 2356 flags |= RTF_GATEWAY;
2426 return NULL; 2357 if (mask == 0xFFFFFFFF)
2358 flags |= RTF_HOST;
2359 flags |= RTF_UP;
2360 return flags;
2427} 2361}
2428 2362
2429static struct fib_alias *fib_trie_get_next(struct seq_file *seq) 2363/*
2364 * This outputs /proc/net/route.
2365 * The format of the file is not supposed to be changed
2366 * and needs to be same as fib_hash output to avoid breaking
2367 * legacy utilities
2368 */
2369static int fib_route_seq_show(struct seq_file *seq, void *v)
2430{ 2370{
2431 return NULL; 2371 struct leaf *l = v;
2432} 2372 int i;
2373 char bf[128];
2433 2374
2434static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) 2375 if (v == SEQ_START_TOKEN) {
2435{ 2376 seq_printf(seq, "%-127s\n", "Iface\tDestination\tGateway "
2436 if (!ip_fib_main_table) 2377 "\tFlags\tRefCnt\tUse\tMetric\tMask\t\tMTU"
2437 return NULL; 2378 "\tWindow\tIRTT");
2379 return 0;
2380 }
2438 2381
2439 if (*pos) 2382 if (IS_TNODE(l))
2440 return fib_trie_get_next(seq); 2383 return 0;
2441 else
2442 return SEQ_START_TOKEN;
2443}
2444 2384
2445static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) 2385 for (i=32; i>=0; i--) {
2446{ 2386 struct leaf_info *li = find_leaf_info(&l->list, i);
2447 ++*pos; 2387 struct fib_alias *fa;
2448 if (v == SEQ_START_TOKEN) 2388 u32 mask, prefix;
2449 return fib_trie_get_first(seq);
2450 else
2451 return fib_trie_get_next(seq);
2452 2389
2453} 2390 if (!li)
2391 continue;
2454 2392
2455static void fib_trie_seq_stop(struct seq_file *seq, void *v) 2393 mask = inet_make_mask(li->plen);
2456{ 2394 prefix = htonl(l->key);
2457}
2458 2395
2459/* 2396 list_for_each_entry_rcu(fa, &li->falh, fa_list) {
2460 * This outputs /proc/net/fib_trie. 2397 const struct fib_info *fi = rcu_dereference(fa->fa_info);
2461 * 2398 unsigned flags = fib_flag_trans(fa->fa_type, mask, fi);
2462 * It always works in backward compatibility mode.
2463 * The format of the file is not supposed to be changed.
2464 */
2465 2399
2466static int fib_trie_seq_show(struct seq_file *seq, void *v) 2400 if (fa->fa_type == RTN_BROADCAST
2467{ 2401 || fa->fa_type == RTN_MULTICAST)
2468 char bf[128]; 2402 continue;
2469 2403
2470 if (v == SEQ_START_TOKEN) { 2404 if (fi)
2471 if (trie_local) 2405 snprintf(bf, sizeof(bf),
2472 trie_dump_seq(seq, trie_local); 2406 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
2407 fi->fib_dev ? fi->fib_dev->name : "*",
2408 prefix,
2409 fi->fib_nh->nh_gw, flags, 0, 0,
2410 fi->fib_priority,
2411 mask,
2412 (fi->fib_advmss ? fi->fib_advmss + 40 : 0),
2413 fi->fib_window,
2414 fi->fib_rtt >> 3);
2415 else
2416 snprintf(bf, sizeof(bf),
2417 "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
2418 prefix, 0, flags, 0, 0, 0,
2419 mask, 0, 0, 0);
2473 2420
2474 if (trie_main) 2421 seq_printf(seq, "%-127s\n", bf);
2475 trie_dump_seq(seq, trie_main); 2422 }
2476 } else {
2477 snprintf(bf, sizeof(bf),
2478 "*\t%08X\t%08X", 200, 400);
2479 seq_printf(seq, "%-127s\n", bf);
2480 } 2423 }
2481 2424
2482 return 0; 2425 return 0;
2483} 2426}
2484 2427
2485static struct seq_operations fib_trie_seq_ops = { 2428static struct seq_operations fib_route_seq_ops = {
2486 .start = fib_trie_seq_start, 2429 .start = fib_trie_seq_start,
2487 .next = fib_trie_seq_next, 2430 .next = fib_trie_seq_next,
2488 .stop = fib_trie_seq_stop, 2431 .stop = fib_trie_seq_stop,
2489 .show = fib_trie_seq_show, 2432 .show = fib_route_seq_show,
2490}; 2433};
2491 2434
2492static int fib_trie_seq_open(struct inode *inode, struct file *file) 2435static int fib_route_seq_open(struct inode *inode, struct file *file)
2493{ 2436{
2494 struct seq_file *seq; 2437 struct seq_file *seq;
2495 int rc = -ENOMEM; 2438 int rc = -ENOMEM;
2439 struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL);
2496 2440
2497 rc = seq_open(file, &fib_trie_seq_ops); 2441 if (!s)
2442 goto out;
2443
2444 rc = seq_open(file, &fib_route_seq_ops);
2498 if (rc) 2445 if (rc)
2499 goto out_kfree; 2446 goto out_kfree;
2500 2447
2501 seq = file->private_data; 2448 seq = file->private_data;
2449 seq->private = s;
2450 memset(s, 0, sizeof(*s));
2502out: 2451out:
2503 return rc; 2452 return rc;
2504out_kfree: 2453out_kfree:
2454 kfree(s);
2505 goto out; 2455 goto out;
2506} 2456}
2507 2457
2508static struct file_operations fib_trie_seq_fops = { 2458static struct file_operations fib_route_fops = {
2509 .owner = THIS_MODULE, 2459 .owner = THIS_MODULE,
2510 .open = fib_trie_seq_open, 2460 .open = fib_route_seq_open,
2511 .read = seq_read, 2461 .read = seq_read,
2512 .llseek = seq_lseek, 2462 .llseek = seq_lseek,
2513 .release= seq_release_private, 2463 .release = seq_release_private,
2514}; 2464};
2515 2465
2516int __init fib_proc_init(void) 2466int __init fib_proc_init(void)
2517{ 2467{
2518 if (!proc_net_fops_create("fib_trie", S_IRUGO, &fib_trie_seq_fops)) 2468 if (!proc_net_fops_create("fib_trie", S_IRUGO, &fib_trie_fops))
2519 return -ENOMEM; 2469 goto out1;
2470
2471 if (!proc_net_fops_create("fib_triestat", S_IRUGO, &fib_triestat_fops))
2472 goto out2;
2473
2474 if (!proc_net_fops_create("route", S_IRUGO, &fib_route_fops))
2475 goto out3;
2476
2520 return 0; 2477 return 0;
2478
2479out3:
2480 proc_net_remove("fib_triestat");
2481out2:
2482 proc_net_remove("fib_trie");
2483out1:
2484 return -ENOMEM;
2521} 2485}
2522 2486
2523void __init fib_proc_exit(void) 2487void __init fib_proc_exit(void)
2524{ 2488{
2525 proc_net_remove("fib_trie"); 2489 proc_net_remove("fib_trie");
2490 proc_net_remove("fib_triestat");
2491 proc_net_remove("route");
2526} 2492}
2527 2493
2528#endif /* CONFIG_PROC_FS */ 2494#endif /* CONFIG_PROC_FS */
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index f84ba9c96551..2fc3fd38924f 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -100,8 +100,7 @@ DEFINE_SPINLOCK(inet_peer_unused_lock);
100#define PEER_MAX_CLEANUP_WORK 30 100#define PEER_MAX_CLEANUP_WORK 30
101 101
102static void peer_check_expire(unsigned long dummy); 102static void peer_check_expire(unsigned long dummy);
103static struct timer_list peer_periodic_timer = 103static DEFINE_TIMER(peer_periodic_timer, peer_check_expire, 0, 0);
104 TIMER_INITIALIZER(peer_check_expire, 0, 0);
105 104
106/* Exported for sysctl_net_ipv4. */ 105/* Exported for sysctl_net_ipv4. */
107int inet_peer_gc_mintime = 10 * HZ, 106int inet_peer_gc_mintime = 10 * HZ,
diff --git a/net/ipv4/netfilter/ipt_owner.c b/net/ipv4/netfilter/ipt_owner.c
index c1889f88262b..0cee2862ed85 100644
--- a/net/ipv4/netfilter/ipt_owner.c
+++ b/net/ipv4/netfilter/ipt_owner.c
@@ -11,6 +11,7 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/skbuff.h> 12#include <linux/skbuff.h>
13#include <linux/file.h> 13#include <linux/file.h>
14#include <linux/rcupdate.h>
14#include <net/sock.h> 15#include <net/sock.h>
15 16
16#include <linux/netfilter_ipv4/ipt_owner.h> 17#include <linux/netfilter_ipv4/ipt_owner.h>
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 15e1134da1b2..c10e4435e3b1 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -485,11 +485,6 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
485 TCP_SKB_CB(buff)->when = TCP_SKB_CB(skb)->when; 485 TCP_SKB_CB(buff)->when = TCP_SKB_CB(skb)->when;
486 buff->tstamp = skb->tstamp; 486 buff->tstamp = skb->tstamp;
487 487
488 if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) {
489 tp->lost_out -= tcp_skb_pcount(skb);
490 tp->left_out -= tcp_skb_pcount(skb);
491 }
492
493 old_factor = tcp_skb_pcount(skb); 488 old_factor = tcp_skb_pcount(skb);
494 489
495 /* Fix up tso_factor for both original and new SKB. */ 490 /* Fix up tso_factor for both original and new SKB. */
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 6d6fb74f3b52..2fea3f4402a0 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -123,8 +123,7 @@ DEFINE_RWLOCK(addrconf_lock);
123 123
124static void addrconf_verify(unsigned long); 124static void addrconf_verify(unsigned long);
125 125
126static struct timer_list addr_chk_timer = 126static DEFINE_TIMER(addr_chk_timer, addrconf_verify, 0, 0);
127 TIMER_INITIALIZER(addrconf_verify, 0, 0);
128static DEFINE_SPINLOCK(addrconf_verify_lock); 127static DEFINE_SPINLOCK(addrconf_verify_lock);
129 128
130static void addrconf_join_anycast(struct inet6_ifaddr *ifp); 129static void addrconf_join_anycast(struct inet6_ifaddr *ifp);
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 47122728212a..922549581abc 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -406,8 +406,7 @@ ipv6_invert_rthdr(struct sock *sk, struct ipv6_rt_hdr *hdr)
406 406
407 memcpy(opt->srcrt, hdr, sizeof(*hdr)); 407 memcpy(opt->srcrt, hdr, sizeof(*hdr));
408 irthdr = (struct rt0_hdr*)opt->srcrt; 408 irthdr = (struct rt0_hdr*)opt->srcrt;
409 /* Obsolete field, MBZ, when originated by us */ 409 irthdr->reserved = 0;
410 irthdr->bitmap = 0;
411 opt->srcrt->segments_left = n; 410 opt->srcrt->segments_left = n;
412 for (i=0; i<n; i++) 411 for (i=0; i<n; i++)
413 memcpy(irthdr->addr+i, rthdr->addr+(n-1-i), 16); 412 memcpy(irthdr->addr+i, rthdr->addr+(n-1-i), 16);
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 16af874c9e8f..4fcc5a7acf6e 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -92,7 +92,7 @@ static struct fib6_node * fib6_repair_tree(struct fib6_node *fn);
92 92
93static __u32 rt_sernum; 93static __u32 rt_sernum;
94 94
95static struct timer_list ip6_fib_timer = TIMER_INITIALIZER(fib6_run_gc, 0, 0); 95static DEFINE_TIMER(ip6_fib_timer, fib6_run_gc, 0, 0);
96 96
97struct fib6_walker_t fib6_walker_list = { 97struct fib6_walker_t fib6_walker_list = {
98 .prev = &fib6_walker_list, 98 .prev = &fib6_walker_list,
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index a7db762de14a..f841bde30c18 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -50,7 +50,7 @@ static atomic_t fl_size = ATOMIC_INIT(0);
50static struct ip6_flowlabel *fl_ht[FL_HASH_MASK+1]; 50static struct ip6_flowlabel *fl_ht[FL_HASH_MASK+1];
51 51
52static void ip6_fl_gc(unsigned long dummy); 52static void ip6_fl_gc(unsigned long dummy);
53static struct timer_list ip6_fl_gc_timer = TIMER_INITIALIZER(ip6_fl_gc, 0, 0); 53static DEFINE_TIMER(ip6_fl_gc_timer, ip6_fl_gc, 0, 0);
54 54
55/* FL hash table lock: it protects only of GC */ 55/* FL hash table lock: it protects only of GC */
56 56
diff --git a/net/ipv6/netfilter/ip6t_owner.c b/net/ipv6/netfilter/ip6t_owner.c
index 9b91decbfddb..4de4cdad4b7d 100644
--- a/net/ipv6/netfilter/ip6t_owner.c
+++ b/net/ipv6/netfilter/ip6t_owner.c
@@ -11,6 +11,7 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/skbuff.h> 12#include <linux/skbuff.h>
13#include <linux/file.h> 13#include <linux/file.h>
14#include <linux/rcupdate.h>
14#include <net/sock.h> 15#include <net/sock.h>
15 16
16#include <linux/netfilter_ipv6/ip6t_owner.h> 17#include <linux/netfilter_ipv6/ip6t_owner.h>
diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c
index a9526b773d28..2bb670037df3 100644
--- a/net/ipv6/netfilter/ip6t_rt.c
+++ b/net/ipv6/netfilter/ip6t_rt.c
@@ -161,8 +161,8 @@ match(const struct sk_buff *skb,
161 ((rtinfo->hdrlen == hdrlen) ^ 161 ((rtinfo->hdrlen == hdrlen) ^
162 !!(rtinfo->invflags & IP6T_RT_INV_LEN)))); 162 !!(rtinfo->invflags & IP6T_RT_INV_LEN))));
163 DEBUGP("res %02X %02X %02X ", 163 DEBUGP("res %02X %02X %02X ",
164 (rtinfo->flags & IP6T_RT_RES), ((struct rt0_hdr *)rh)->bitmap, 164 (rtinfo->flags & IP6T_RT_RES), ((struct rt0_hdr *)rh)->reserved,
165 !((rtinfo->flags & IP6T_RT_RES) && (((struct rt0_hdr *)rh)->bitmap))); 165 !((rtinfo->flags & IP6T_RT_RES) && (((struct rt0_hdr *)rh)->reserved)));
166 166
167 ret = (rh != NULL) 167 ret = (rh != NULL)
168 && 168 &&
@@ -179,12 +179,12 @@ match(const struct sk_buff *skb,
179 !!(rtinfo->invflags & IP6T_RT_INV_TYP))); 179 !!(rtinfo->invflags & IP6T_RT_INV_TYP)));
180 180
181 if (ret && (rtinfo->flags & IP6T_RT_RES)) { 181 if (ret && (rtinfo->flags & IP6T_RT_RES)) {
182 u_int32_t *bp, _bitmap; 182 u_int32_t *rp, _reserved;
183 bp = skb_header_pointer(skb, 183 rp = skb_header_pointer(skb,
184 ptr + offsetof(struct rt0_hdr, bitmap), 184 ptr + offsetof(struct rt0_hdr, reserved),
185 sizeof(_bitmap), &_bitmap); 185 sizeof(_reserved), &_reserved);
186 186
187 ret = (*bp == 0); 187 ret = (*rp == 0);
188 } 188 }
189 189
190 DEBUGP("#%d ",rtinfo->addrnr); 190 DEBUGP("#%d ",rtinfo->addrnr);
diff --git a/net/netrom/nr_loopback.c b/net/netrom/nr_loopback.c
index 165b2abce110..e856ae1b360a 100644
--- a/net/netrom/nr_loopback.c
+++ b/net/netrom/nr_loopback.c
@@ -17,7 +17,7 @@
17static void nr_loopback_timer(unsigned long); 17static void nr_loopback_timer(unsigned long);
18 18
19static struct sk_buff_head loopback_queue; 19static struct sk_buff_head loopback_queue;
20static struct timer_list loopback_timer = TIMER_INITIALIZER(nr_loopback_timer, 0, 0); 20static DEFINE_TIMER(loopback_timer, nr_loopback_timer, 0, 0);
21 21
22void __init nr_loopback_init(void) 22void __init nr_loopback_init(void)
23{ 23{
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 737681cb9a92..31570b9a6e9a 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1194,7 +1194,7 @@ EXPORT_SYMBOL(psched_time_base);
1194 * with 32-bit get_cycles(). Safe up to 4GHz CPU. 1194 * with 32-bit get_cycles(). Safe up to 4GHz CPU.
1195 */ 1195 */
1196static void psched_tick(unsigned long); 1196static void psched_tick(unsigned long);
1197static struct timer_list psched_timer = TIMER_INITIALIZER(psched_tick, 0, 0); 1197static DEFINE_TIMER(psched_timer, psched_tick, 0, 0);
1198 1198
1199static void psched_tick(unsigned long dummy) 1199static void psched_tick(unsigned long dummy)
1200{ 1200{