aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-atapi.c177
-rw-r--r--drivers/ide/ide-floppy.c128
-rw-r--r--drivers/ide/ide-tape.c132
-rw-r--r--drivers/scsi/ide-scsi.c115
-rw-r--r--include/linux/ide.h6
5 files changed, 195 insertions, 363 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 932a83abaf06..2802031de670 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -5,6 +5,183 @@
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/delay.h> 6#include <linux/delay.h>
7#include <linux/ide.h> 7#include <linux/ide.h>
8#include <scsi/scsi.h>
9
10#ifdef DEBUG
11#define debug_log(fmt, args...) \
12 printk(KERN_INFO "ide: " fmt, ## args)
13#else
14#define debug_log(fmt, args...) do {} while (0)
15#endif
16
17/* TODO: unify the code thus making some arguments go away */
18ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
19 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
20 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
21 void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *),
22 void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int))
23{
24 ide_hwif_t *hwif = drive->hwif;
25 xfer_func_t *xferfunc;
26 unsigned int temp;
27 u16 bcount;
28 u8 stat, ireason, scsi = drive->scsi;
29
30 debug_log("Enter %s - interrupt handler\n", __func__);
31
32 if (pc->flags & PC_FLAG_TIMEDOUT) {
33 pc->callback(drive);
34 return ide_stopped;
35 }
36
37 /* Clear the interrupt */
38 stat = ide_read_status(drive);
39
40 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
41 if (hwif->dma_ops->dma_end(drive) ||
42 (drive->media == ide_tape && !scsi && (stat & ERR_STAT))) {
43 if (drive->media == ide_floppy && !scsi)
44 printk(KERN_ERR "%s: DMA %s error\n",
45 drive->name, rq_data_dir(pc->rq)
46 ? "write" : "read");
47 pc->flags |= PC_FLAG_DMA_ERROR;
48 } else {
49 pc->xferred = pc->req_xfer;
50 if (update_buffers)
51 update_buffers(drive, pc);
52 }
53 debug_log("%s: DMA finished\n", drive->name);
54 }
55
56 /* No more interrupts */
57 if ((stat & DRQ_STAT) == 0) {
58 debug_log("Packet command completed, %d bytes transferred\n",
59 pc->xferred);
60
61 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
62
63 local_irq_enable_in_hardirq();
64
65 if (drive->media == ide_tape && !scsi &&
66 (stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE)
67 stat &= ~ERR_STAT;
68 if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
69 /* Error detected */
70 debug_log("%s: I/O error\n", drive->name);
71
72 if (drive->media != ide_tape || scsi) {
73 pc->rq->errors++;
74 if (scsi)
75 goto cmd_finished;
76 }
77
78 if (pc->c[0] == REQUEST_SENSE) {
79 printk(KERN_ERR "%s: I/O error in request sense"
80 " command\n", drive->name);
81 return ide_do_reset(drive);
82 }
83
84 debug_log("[cmd %x]: check condition\n", pc->c[0]);
85
86 /* Retry operation */
87 retry_pc(drive);
88 /* queued, but not started */
89 return ide_stopped;
90 }
91cmd_finished:
92 pc->error = 0;
93 if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) &&
94 (stat & SEEK_STAT) == 0) {
95 dsc_handle(drive);
96 return ide_stopped;
97 }
98 /* Command finished - Call the callback function */
99 pc->callback(drive);
100 return ide_stopped;
101 }
102
103 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
104 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
105 printk(KERN_ERR "%s: The device wants to issue more interrupts "
106 "in DMA mode\n", drive->name);
107 ide_dma_off(drive);
108 return ide_do_reset(drive);
109 }
110 /* Get the number of bytes to transfer on this interrupt. */
111 bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
112 hwif->INB(hwif->io_ports.lbam_addr);
113
114 ireason = hwif->INB(hwif->io_ports.nsect_addr);
115
116 if (ireason & CD) {
117 printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
118 return ide_do_reset(drive);
119 }
120 if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
121 /* Hopefully, we will never get here */
122 printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
123 "to %s!\n", drive->name,
124 (ireason & IO) ? "Write" : "Read",
125 (ireason & IO) ? "Read" : "Write");
126 return ide_do_reset(drive);
127 }
128 if (!(pc->flags & PC_FLAG_WRITING)) {
129 /* Reading - Check that we have enough space */
130 temp = pc->xferred + bcount;
131 if (temp > pc->req_xfer) {
132 if (temp > pc->buf_size) {
133 printk(KERN_ERR "%s: The device wants to send "
134 "us more data than expected - "
135 "discarding data\n",
136 drive->name);
137 if (scsi)
138 temp = pc->buf_size - pc->xferred;
139 else
140 temp = 0;
141 if (temp) {
142 if (pc->sg)
143 io_buffers(drive, pc, temp, 0);
144 else
145 hwif->input_data(drive, NULL,
146 pc->cur_pos, temp);
147 printk(KERN_ERR "%s: transferred %d of "
148 "%d bytes\n",
149 drive->name,
150 temp, bcount);
151 }
152 pc->xferred += temp;
153 pc->cur_pos += temp;
154 ide_pad_transfer(drive, 0, bcount - temp);
155 ide_set_handler(drive, handler, timeout,
156 expiry);
157 return ide_started;
158 }
159 debug_log("The device wants to send us more data than "
160 "expected - allowing transfer\n");
161 }
162 xferfunc = hwif->input_data;
163 } else
164 xferfunc = hwif->output_data;
165
166 if ((drive->media == ide_floppy && !scsi && !pc->buf) ||
167 (drive->media == ide_tape && !scsi && pc->bh) ||
168 (scsi && pc->sg))
169 io_buffers(drive, pc, bcount, !!(pc->flags & PC_FLAG_WRITING));
170 else
171 xferfunc(drive, NULL, pc->cur_pos, bcount);
172
173 /* Update the current position */
174 pc->xferred += bcount;
175 pc->cur_pos += bcount;
176
177 debug_log("[cmd %x] transferred %d bytes on that intr.\n",
178 pc->c[0], bcount);
179
180 /* And set the interrupt handler again */
181 ide_set_handler(drive, handler, timeout, expiry);
182 return ide_started;
183}
184EXPORT_SYMBOL_GPL(ide_pc_intr);
8 185
9static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) 186static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
10{ 187{
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 70aef97fb8bc..0f3602a5efb0 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -388,132 +388,10 @@ static void idefloppy_retry_pc(ide_drive_t *drive)
388static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) 388static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
389{ 389{
390 idefloppy_floppy_t *floppy = drive->driver_data; 390 idefloppy_floppy_t *floppy = drive->driver_data;
391 ide_hwif_t *hwif = drive->hwif;
392 struct ide_atapi_pc *pc = floppy->pc;
393 struct request *rq = pc->rq;
394 xfer_func_t *xferfunc;
395 unsigned int temp;
396 int dma_error = 0;
397 u16 bcount;
398 u8 stat, ireason;
399
400 debug_log("Enter %s - interrupt handler\n", __func__);
401
402 /* Clear the interrupt */
403 stat = ide_read_status(drive);
404
405 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
406 dma_error = hwif->dma_ops->dma_end(drive);
407 if (dma_error) {
408 printk(KERN_ERR "%s: DMA %s error\n", drive->name,
409 rq_data_dir(rq) ? "write" : "read");
410 pc->flags |= PC_FLAG_DMA_ERROR;
411 } else {
412 pc->xferred = pc->req_xfer;
413 idefloppy_update_buffers(drive, pc);
414 }
415 debug_log("%s: DMA finished\n", drive->name);
416 }
417
418 /* No more interrupts */
419 if ((stat & DRQ_STAT) == 0) {
420 debug_log("Packet command completed, %d bytes transferred\n",
421 pc->xferred);
422 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
423
424 local_irq_enable_in_hardirq();
425
426 if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
427 /* Error detected */
428 debug_log("%s: I/O error\n", drive->name);
429 rq->errors++;
430 if (pc->c[0] == GPCMD_REQUEST_SENSE) {
431 printk(KERN_ERR "%s: I/O error in request sense"
432 " command\n", drive->name);
433 return ide_do_reset(drive);
434 }
435
436 debug_log("[cmd %x]: check condition\n", pc->c[0]);
437
438 /* Retry operation */
439 idefloppy_retry_pc(drive);
440 /* queued, but not started */
441 return ide_stopped;
442 }
443 pc->error = 0;
444 /* Command finished - Call the callback function */
445 pc->callback(drive);
446 return ide_stopped;
447 }
448
449 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
450 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
451 printk(KERN_ERR "%s: The device wants to issue more interrupts "
452 "in DMA mode\n", drive->name);
453 ide_dma_off(drive);
454 return ide_do_reset(drive);
455 }
456
457 /* Get the number of bytes to transfer */
458 bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
459 hwif->INB(hwif->io_ports.lbam_addr);
460 /* on this interrupt */
461 ireason = hwif->INB(hwif->io_ports.nsect_addr);
462
463 if (ireason & CD) {
464 printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
465 return ide_do_reset(drive);
466 }
467 if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
468 /* Hopefully, we will never get here */
469 printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
470 "to %s!\n", drive->name,
471 (ireason & IO) ? "Write" : "Read",
472 (ireason & IO) ? "Read" : "Write");
473 return ide_do_reset(drive);
474 }
475 if (!(pc->flags & PC_FLAG_WRITING)) {
476 /* Reading - Check that we have enough space */
477 temp = pc->xferred + bcount;
478 if (temp > pc->req_xfer) {
479 if (temp > pc->buf_size) {
480 printk(KERN_ERR "%s: The device wants to send "
481 "us more data than expected - "
482 "discarding data\n",
483 drive->name);
484 ide_pad_transfer(drive, 0, bcount);
485
486 ide_set_handler(drive,
487 &idefloppy_pc_intr,
488 IDEFLOPPY_WAIT_CMD,
489 NULL);
490 return ide_started;
491 }
492 debug_log("The device wants to send us more data than "
493 "expected - allowing transfer\n");
494 }
495 }
496 if (pc->flags & PC_FLAG_WRITING)
497 xferfunc = hwif->output_data;
498 else
499 xferfunc = hwif->input_data;
500
501 if (pc->buf)
502 xferfunc(drive, NULL, pc->cur_pos, bcount);
503 else
504 ide_floppy_io_buffers(drive, pc, bcount,
505 !!(pc->flags & PC_FLAG_WRITING));
506
507 /* Update the current position */
508 pc->xferred += bcount;
509 pc->cur_pos += bcount;
510
511 debug_log("[cmd %x] transferred %d bytes on that intr.\n",
512 pc->c[0], bcount);
513 391
514 /* And set the interrupt handler again */ 392 return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr,
515 ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); 393 IDEFLOPPY_WAIT_CMD, NULL, idefloppy_update_buffers,
516 return ide_started; 394 idefloppy_retry_pc, NULL, ide_floppy_io_buffers);
517} 395}
518 396
519/* 397/*
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 10f2d3336286..0afa109ec99a 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -56,8 +56,6 @@ enum {
56 DBG_PROCS = (1 << 3), 56 DBG_PROCS = (1 << 3),
57 /* buffer alloc info (pc_stack & rq_stack) */ 57 /* buffer alloc info (pc_stack & rq_stack) */
58 DBG_PCRQ_STACK = (1 << 4), 58 DBG_PCRQ_STACK = (1 << 4),
59 /* IRQ handler (always log debug info if debugging is on) */
60 DBG_PC_INTR = (1 << 5),
61}; 59};
62 60
63/* define to see debug info */ 61/* define to see debug info */
@@ -66,7 +64,7 @@ enum {
66#if IDETAPE_DEBUG_LOG 64#if IDETAPE_DEBUG_LOG
67#define debug_log(lvl, fmt, args...) \ 65#define debug_log(lvl, fmt, args...) \
68{ \ 66{ \
69 if ((lvl & DBG_PC_INTR) || (tape->debug_mask & lvl)) \ 67 if (tape->debug_mask & lvl) \
70 printk(KERN_INFO "ide-tape: " fmt, ## args); \ 68 printk(KERN_INFO "ide-tape: " fmt, ## args); \
71} 69}
72#else 70#else
@@ -441,7 +439,7 @@ static void idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
441 } 439 }
442} 440}
443 441
444static void idetape_update_buffers(struct ide_atapi_pc *pc) 442static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc)
445{ 443{
446 struct idetape_bh *bh = pc->bh; 444 struct idetape_bh *bh = pc->bh;
447 int count; 445 int count;
@@ -526,7 +524,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
526 pc->xferred = pc->req_xfer - 524 pc->xferred = pc->req_xfer -
527 tape->blk_size * 525 tape->blk_size *
528 get_unaligned_be32(&sense[3]); 526 get_unaligned_be32(&sense[3]);
529 idetape_update_buffers(pc); 527 idetape_update_buffers(drive, pc);
530 } 528 }
531 529
532 /* 530 /*
@@ -800,129 +798,11 @@ static void ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
800 */ 798 */
801static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) 799static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
802{ 800{
803 ide_hwif_t *hwif = drive->hwif;
804 idetape_tape_t *tape = drive->driver_data; 801 idetape_tape_t *tape = drive->driver_data;
805 struct ide_atapi_pc *pc = tape->pc;
806 xfer_func_t *xferfunc;
807 unsigned int temp;
808 u16 bcount;
809 u8 stat, ireason;
810
811 debug_log(DBG_PC_INTR, "Enter %s - interrupt handler\n", __func__);
812
813 /* Clear the interrupt */
814 stat = ide_read_status(drive);
815
816 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
817 if (hwif->dma_ops->dma_end(drive) || (stat & ERR_STAT)) {
818 pc->flags |= PC_FLAG_DMA_ERROR;
819 } else {
820 pc->xferred = pc->req_xfer;
821 idetape_update_buffers(pc);
822 }
823 debug_log(DBG_PC_INTR, "%s: DMA finished\n", drive->name);
824 }
825
826 /* No more interrupts */
827 if ((stat & DRQ_STAT) == 0) {
828 debug_log(DBG_PC_INTR, "Packet command completed, %d bytes"
829 " transferred\n", pc->xferred);
830
831 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
832 local_irq_enable_in_hardirq();
833
834 if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE)
835 stat &= ~ERR_STAT;
836 if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
837 /* Error detected */
838 debug_log(DBG_PC_INTR, "%s: I/O error\n", drive->name);
839
840 if (pc->c[0] == REQUEST_SENSE) {
841 printk(KERN_ERR "%s: I/O error in request sense"
842 " command\n", drive->name);
843 return ide_do_reset(drive);
844 }
845 debug_log(DBG_PC_INTR, "[cmd %x]: check condition\n",
846 pc->c[0]);
847
848 /* Retry operation */
849 idetape_retry_pc(drive);
850 return ide_stopped;
851 }
852 pc->error = 0;
853 if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) &&
854 (stat & SEEK_STAT) == 0) {
855 ide_tape_handle_dsc(drive);
856 return ide_stopped;
857 }
858 /* Command finished - Call the callback function */
859 pc->callback(drive);
860 return ide_stopped;
861 }
862
863 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
864 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
865 printk(KERN_ERR "%s: The device wants to issue more interrupts "
866 "in DMA mode\n", drive->name);
867 ide_dma_off(drive);
868 return ide_do_reset(drive);
869 }
870 /* Get the number of bytes to transfer on this interrupt. */
871 bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
872 hwif->INB(hwif->io_ports.lbam_addr);
873
874 ireason = hwif->INB(hwif->io_ports.nsect_addr);
875
876 if (ireason & CD) {
877 printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
878 return ide_do_reset(drive);
879 }
880 if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
881 /* Hopefully, we will never get here */
882 printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
883 "to %s!\n", drive->name,
884 (ireason & IO) ? "Write" : "Read",
885 (ireason & IO) ? "Read" : "Write");
886 return ide_do_reset(drive);
887 }
888 if (!(pc->flags & PC_FLAG_WRITING)) {
889 /* Reading - Check that we have enough space */
890 temp = pc->xferred + bcount;
891 if (temp > pc->req_xfer) {
892 if (temp > pc->buf_size) {
893 printk(KERN_ERR "%s: The device wants to send "
894 "us more data than expected - "
895 "discarding data\n",
896 drive->name);
897 ide_pad_transfer(drive, 0, bcount);
898 ide_set_handler(drive, &idetape_pc_intr,
899 IDETAPE_WAIT_CMD, NULL);
900 return ide_started;
901 }
902 debug_log(DBG_PC_INTR, "The device wants to send us more "
903 "data than expected - allowing transfer\n");
904 }
905 xferfunc = hwif->input_data;
906 } else {
907 xferfunc = hwif->output_data;
908 }
909
910 if (pc->bh)
911 ide_tape_io_buffers(drive, pc, bcount,
912 !!(pc->flags & PC_FLAG_WRITING));
913 else
914 xferfunc(drive, NULL, pc->cur_pos, bcount);
915
916 /* Update the current position */
917 pc->xferred += bcount;
918 pc->cur_pos += bcount;
919
920 debug_log(DBG_PC_INTR, "[cmd %x] transferred %d bytes on that intr.\n",
921 pc->c[0], bcount);
922 802
923 /* And set the interrupt handler again */ 803 return ide_pc_intr(drive, tape->pc, idetape_pc_intr, IDETAPE_WAIT_CMD,
924 ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); 804 NULL, idetape_update_buffers, idetape_retry_pc,
925 return ide_started; 805 ide_tape_handle_dsc, ide_tape_io_buffers);
926} 806}
927 807
928/* 808/*
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index ada733ca6725..683bce375c74 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -356,120 +356,11 @@ static int idescsi_expiry(ide_drive_t *drive)
356static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) 356static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
357{ 357{
358 idescsi_scsi_t *scsi = drive_to_idescsi(drive); 358 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
359 ide_hwif_t *hwif = drive->hwif;
360 struct ide_atapi_pc *pc = scsi->pc; 359 struct ide_atapi_pc *pc = scsi->pc;
361 struct request *rq = pc->rq;
362 xfer_func_t *xferfunc;
363 unsigned int temp;
364 u16 bcount;
365 u8 stat, ireason;
366
367 debug_log("Enter %s - interrupt handler\n", __func__);
368
369 if (pc->flags & PC_FLAG_TIMEDOUT) {
370 pc->callback(drive);
371 return ide_stopped;
372 }
373
374 /* Clear the interrupt */
375 stat = ide_read_status(drive);
376
377 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
378 if (hwif->dma_ops->dma_end(drive))
379 pc->flags |= PC_FLAG_DMA_ERROR;
380 else
381 pc->xferred = pc->req_xfer;
382 debug_log("%s: DMA finished\n", drive->name);
383 }
384
385 if ((stat & DRQ_STAT) == 0) {
386 /* No more interrupts */
387 debug_log("Packet command completed, %d bytes transferred\n",
388 pc->xferred);
389 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
390 local_irq_enable_in_hardirq();
391 if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
392 /* Error detected */
393 debug_log("%s: I/O error\n", drive->name);
394
395 rq->errors++;
396 }
397 pc->callback(drive);
398 return ide_stopped;
399 }
400 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
401 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
402 printk(KERN_ERR "%s: The device wants to issue more interrupts "
403 "in DMA mode\n", drive->name);
404 ide_dma_off(drive);
405 return ide_do_reset(drive);
406 }
407 bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
408 hwif->INB(hwif->io_ports.lbam_addr);
409 ireason = hwif->INB(hwif->io_ports.nsect_addr);
410
411 if (ireason & CD) {
412 printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
413 return ide_do_reset (drive);
414 }
415 if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
416 /* Hopefully, we will never get here */
417 printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
418 "to %s!\n", drive->name,
419 (ireason & IO) ? "Write" : "Read",
420 (ireason & IO) ? "Read" : "Write");
421 return ide_do_reset(drive);
422 }
423 if (!(pc->flags & PC_FLAG_WRITING)) {
424 temp = pc->xferred + bcount;
425 if (temp > pc->req_xfer) {
426 if (temp > pc->buf_size) {
427 printk(KERN_ERR "%s: The device wants to send "
428 "us more data than expected - "
429 "discarding data\n",
430 drive->name);
431 temp = pc->buf_size - pc->xferred;
432 if (temp) {
433 if (pc->sg)
434 ide_scsi_io_buffers(drive, pc,
435 temp, 0);
436 else
437 hwif->input_data(drive, NULL,
438 pc->cur_pos, temp);
439 printk(KERN_ERR "%s: transferred %d of "
440 "%d bytes\n",
441 drive->name,
442 temp, bcount);
443 }
444 pc->xferred += temp;
445 pc->cur_pos += temp;
446 ide_pad_transfer(drive, 0, bcount - temp);
447 ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
448 return ide_started;
449 }
450 debug_log("The device wants to send us more data than "
451 "expected - allowing transfer\n");
452 }
453 xferfunc = hwif->input_data;
454 } else
455 xferfunc = hwif->output_data;
456
457 if (pc->sg)
458 ide_scsi_io_buffers(drive, pc, bcount,
459 !!(pc->flags & PC_FLAG_WRITING));
460 else
461 xferfunc(drive, NULL, pc->cur_pos, bcount);
462
463 /* Update the current position */
464 pc->xferred += bcount;
465 pc->cur_pos += bcount;
466
467 debug_log("[cmd %x] transferred %d bytes on that intr.\n",
468 pc->c[0], bcount);
469 360
470 /* And set the interrupt handler again */ 361 return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc),
471 ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry); 362 idescsi_expiry, NULL, NULL, NULL,
472 return ide_started; 363 ide_scsi_io_buffers);
473} 364}
474 365
475static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) 366static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
diff --git a/include/linux/ide.h b/include/linux/ide.h
index fee07a7edb19..ac4eeb2932ef 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -968,6 +968,12 @@ extern int drive_is_ready(ide_drive_t *);
968 968
969void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); 969void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8);
970 970
971ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
972 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
973 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
974 void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *),
975 void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int,
976 int));
971ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, 977ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *,
972 ide_handler_t *, unsigned int, ide_expiry_t *); 978 ide_handler_t *, unsigned int, ide_expiry_t *);
973ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *, 979ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *,
4-16 18:20:36 -0400 committer Linus Torvalds <torvalds@ppc970.osdl.org> 2005-04-16 18:20:36 -0400 Linux-2.6.12-rc2' href='/cgit/cgit.cgi/litmus-rt-ext-res.git/commit/net/ipv6/addrconf.c?id=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2'>1da177e4c3f4
3de232554a91

a9b05723ffa2






































db9c7c3943f2
a9b05723ffa2























7cbca67c0732
a9b05723ffa2
7cbca67c0732

a9b05723ffa2
7cbca67c0732
a9b05723ffa2







3de232554a91

a9b05723ffa2

a9b05723ffa2
7cbca67c0732
a9b05723ffa2
25985edcedea
a9b05723ffa2
7cbca67c0732



a9b05723ffa2
7cbca67c0732
a9b05723ffa2








91b4b04ff85d



a9b05723ffa2











b3f644fc8232
9acd9f3ae92d
7cbca67c0732
1da177e4c3f4
a9b05723ffa2

a9b05723ffa2
072047e4de38
a9b05723ffa2
1da177e4c3f4
a9b05723ffa2



3de232554a91
7cbca67c0732
a9b05723ffa2


1da177e4c3f4
8814c4b53381
1da177e4c3f4
c6d14c84566d
072047e4de38
072047e4de38
a9b05723ffa2
072047e4de38










a9b05723ffa2


072047e4de38
1da177e4c3f4
1da177e4c3f4
072047e4de38



502a2ffd7376
a9b05723ffa2
072047e4de38
a9b05723ffa2
6b3ae80a63e4


95c385b4d5a7
6b3ae80a63e4
072047e4de38



a9b05723ffa2

6b3ae80a63e4
a9b05723ffa2




072047e4de38
3b6d821c4f06
072047e4de38




a9b05723ffa2





3de232554a91

a9b05723ffa2















a9b05723ffa2




a0bffffc148c
a9b05723ffa2




1da177e4c3f4
072047e4de38
1da177e4c3f4
a9b05723ffa2
072047e4de38
1da177e4c3f4
8814c4b53381
1da177e4c3f4
a9b05723ffa2
072047e4de38
1ab1457c42bc
4e3fd7a06dc2
a9b05723ffa2
072047e4de38
1da177e4c3f4
5e5f3f0f8013
1da177e4c3f4
8965779d2c0e
479840ffdbe4
b7b1bfce0bb6



602582ca7a15


b7b1bfce0bb6









95c385b4d5a7
479840ffdbe4
1da177e4c3f4



8814c4b53381
e21e8467d318

1da177e4c3f4
b7b1bfce0bb6
1da177e4c3f4

8814c4b53381
1da177e4c3f4








502a2ffd7376
1da177e4c3f4




b71d1d426d26
2a7851bffb00
1da177e4c3f4
eedf042a63ff
ddbe50320385
1da177e4c3f4
5c578aedcb21
b67bfe0d42ca
878628fbf258
bfeade087005
1da177e4c3f4
eedf042a63ff




1da177e4c3f4

5c578aedcb21
eedf042a63ff

1da177e4c3f4
7159039a128f

3e81c6da39a2

1da177e4c3f4
ddbe50320385
c2e21293c054
1da177e4c3f4
b67bfe0d42ca
878628fbf258
06bfe655e7db
1da177e4c3f4

3e81c6da39a2
1da177e4c3f4

3e81c6da39a2
1da177e4c3f4

7df37ff33dc1


























b71d1d426d26
52eeeb8481d7









502a2ffd7376
52eeeb8481d7









52eeeb8481d7

9acd9f3ae92d
1cab3da6be6c
1da177e4c3f4
b79d1d54cf06
ddbe50320385
1da177e4c3f4
5c578aedcb21
b67bfe0d42ca
878628fbf258
1cab3da6be6c
1da177e4c3f4


b79d1d54cf06
1da177e4c3f4




5c578aedcb21
1da177e4c3f4
b79d1d54cf06
1da177e4c3f4

1da177e4c3f4

cc411d0bae9c
1da177e4c3f4
1da177e4c3f4

b7b1bfce0bb6
1da177e4c3f4
cc411d0bae9c

1da177e4c3f4
e2577a065832

1da177e4c3f4
1da177e4c3f4












1da177e4c3f4



f2344a131bcc













3c21edbd1137

1b34be74cbf1
9bdd8d40c8c5
853dc2e03ddd

f2344a131bcc
853dc2e03ddd
f2344a131bcc
e87cc4728f0e

9bdd8d40c8c5
1b34be74cbf1









9bdd8d40c8c5
f32138319ca6
9bdd8d40c8c5
1b34be74cbf1


cc411d0bae9c
3c21edbd1137
1da177e4c3f4


b71d1d426d26
1da177e4c3f4









b71d1d426d26
1da177e4c3f4









20380731bc28
1da177e4c3f4

88ad31491e21
2bda8a0c8af5
1da177e4c3f4





20380731bc28
1da177e4c3f4

88ad31491e21
32019e651c6f
1da177e4c3f4





073a8e0e154c






























06a4c1c55dbe




5e98a36ed4bf
06a4c1c55dbe


cb6bf35502d5













073a8e0e154c





8e5e8f30d0de
073a8e0e154c











c61393ea8357
dfd982baff01
9af28511be10

dfd982baff01











dfd982baff01







aee80b54b235




e837735ec406









1da177e4c3f4




073a8e0e154c
1da177e4c3f4
073a8e0e154c
1da177e4c3f4
073a8e0e154c
c7dc89c0ac8e
dfd982baff01
aee80b54b235

e74bccb8a598
06a4c1c55dbe

cb6bf35502d5

e837735ec406

1da177e4c3f4









602582ca7a15


1da177e4c3f4









1da177e4c3f4
eb7e0575966f
1da177e4c3f4
1da177e4c3f4
955189efb447
1da177e4c3f4
1da177e4c3f4






c7dc89c0ac8e
1da177e4c3f4



1ab1457c42bc
1da177e4c3f4








1da177e4c3f4






8814c4b53381
1da177e4c3f4




eb7e0575966f
1ab1457c42bc
1da177e4c3f4
1ab1457c42bc
1f9248e5606a

784e2710ce35
1da177e4c3f4
f32138319ca6

1da177e4c3f4







8814c4b53381
1da177e4c3f4


eb7e0575966f
8e5e8f30d0de
1da177e4c3f4
eb7e0575966f
1da177e4c3f4
1da177e4c3f4






e431b8c004af
1da177e4c3f4
86872cb57925






c346dca10840
f410a1fba7af
86872cb57925
1da177e4c3f4
4e3fd7a06dc2
1da177e4c3f4




07a936260a94
86872cb57925

0be669bb3769
1da177e4c3f4
86872cb57925
1da177e4c3f4

14ef37b6d00e













5744dd9b71c6
14ef37b6d00e



d191854282fd
14ef37b6d00e


85da53bf1c33
14ef37b6d00e




5744dd9b71c6
14ef37b6d00e



1da177e4c3f4



86872cb57925





c346dca10840
86872cb57925




1da177e4c3f4

1da177e4c3f4





e21e8467d318

64e724f62ab7



1da177e4c3f4

4af04aba93f4

1da177e4c3f4
1da177e4c3f4


53bd67491537


































































e6bff995f8fe
1da177e4c3f4




1da177e4c3f4
56d417b12e57
1da177e4c3f4

1ab1457c42bc
1da177e4c3f4
ba3542e15cf8
1da177e4c3f4

1ab1457c42bc
1da177e4c3f4












e87cc4728f0e
1da177e4c3f4





e87cc4728f0e

1da177e4c3f4








4bed72e4f550



6f704992d365




4bed72e4f550



3dd4bc68fac5
4bed72e4f550

1da177e4c3f4
14ef37b6d00e




1da177e4c3f4
14ef37b6d00e
6f704992d365



4bed72e4f550
6f704992d365
1716a96101c4
6f704992d365
1716a96101c4
1da177e4c3f4

6f704992d365
4bed72e4f550

6f704992d365



1da177e4c3f4
6f704992d365
1da177e4c3f4
94e187c01512
1da177e4c3f4




8e5e8f30d0de
1da177e4c3f4

617fe29d45bd
1da177e4c3f4


f53adae4eae5





617fe29d45bd
f53adae4eae5

1da177e4c3f4




e87cc4728f0e

1da177e4c3f4




53b7997fd5c6
1da177e4c3f4


95c385b4d5a7



e6bff995f8fe
95c385b4d5a7

1da177e4c3f4





3f8f52982ad0

95c385b4d5a7
8a226b2cfa77

1da177e4c3f4
3f0d2ba0bd7d
1da177e4c3f4



53bd67491537
8a226b2cfa77

1da177e4c3f4
617fe29d45bd
cf22f9a2b83e
1da177e4c3f4


479840ffdbe4
1da177e4c3f4
1da177e4c3f4








8a226b2cfa77
c9d55d5bff05














1da177e4c3f4














53bd67491537

5d9efa7ee99e
1da177e4c3f4












af2849377e7b
1da177e4c3f4










af2849377e7b
1da177e4c3f4




07a936260a94
1da177e4c3f4
5bc3eb7e2f00
1da177e4c3f4
1da177e4c3f4












d20b3109e9d1
1da177e4c3f4
5bc3eb7e2f00







1da177e4c3f4


af2849377e7b

1da177e4c3f4



0be669bb3769
1da177e4c3f4








479840ffdbe4

caeaba79009c
479840ffdbe4

1da177e4c3f4




6f704992d365

4bed72e4f550
1da177e4c3f4

1ab1457c42bc
24ef0da7b864


0778769d392b



53bd67491537


af2849377e7b

1da177e4c3f4
1ab1457c42bc
64e724f62ab7


1da177e4c3f4


4bed72e4f550



6f704992d365
4bed72e4f550



6f704992d365
0778769d392b
4bed72e4f550





0778769d392b
8a226b2cfa77

0778769d392b
1da177e4c3f4
761aac737eb1




95c385b4d5a7




cf22f9a2b83e
53bd67491537


1da177e4c3f4
0778769d392b
1da177e4c3f4





b71d1d426d26
24ef0da7b864
1da177e4c3f4



1ab1457c42bc
24ef0da7b864


af2849377e7b

1da177e4c3f4

7eaa48a45ca7
1da177e4c3f4


502a2ffd7376
1da177e4c3f4



1ab1457c42bc
1da177e4c3f4
1da177e4c3f4







af2849377e7b
1da177e4c3f4


1ab1457c42bc
af31f412c7c7
1da177e4c3f4
1ab1457c42bc
1da177e4c3f4



caeaba79009c
af2849377e7b

1da177e4c3f4



af2849377e7b
1da177e4c3f4


1ab1457c42bc
af31f412c7c7
1da177e4c3f4





af2849377e7b

1da177e4c3f4



b5f348e5a41b




8a226b2cfa77
07edd741c838

b5f348e5a41b








07a936260a94
1da177e4c3f4

1da177e4c3f4

c346dca10840
929c9cf31056
f0e2acfa3092
1da177e4c3f4








929c9cf31056
1da177e4c3f4

929c9cf31056
f0e2acfa3092
1da177e4c3f4


929c9cf31056
f0e2acfa3092
1da177e4c3f4


6fda73500581
8e5e8f30d0de
1da177e4c3f4
8e5e8f30d0de
1da177e4c3f4



1da177e4c3f4









1da177e4c3f4
b5f348e5a41b
f0e2acfa3092

1da177e4c3f4

1ab1457c42bc
1da177e4c3f4
0be669bb3769
1da177e4c3f4



25fb6ca4ed9c


1da177e4c3f4




7eaa48a45ca7
91df42bedccb
1da177e4c3f4


b5f348e5a41b
25fb6ca4ed9c















33d99113b110











a881ae1f625c
57ec0afe2938
25fb6ca4ed9c

534c877928a1

25fb6ca4ed9c
534c877928a1
25fb6ca4ed9c


1da177e4c3f4

b71d1d426d26
1da177e4c3f4
8e5e8f30d0de
95c385b4d5a7



702beb87d6b4
95c385b4d5a7

1da177e4c3f4
95c385b4d5a7
07edd741c838

1da177e4c3f4
46d480468fd9
cf22f9a2b83e
1da177e4c3f4






8e5e8f30d0de
1da177e4c3f4


74235a25c673

74235a25c673
06a4c1c55dbe
cb6bf35502d5
e837735ec406
e74bccb8a598

74235a25c673



1da177e4c3f4
64e724f62ab7
1da177e4c3f4








07a936260a94
1da177e4c3f4





1ab1457c42bc


1da177e4c3f4


7eaa48a45ca7
91df42bedccb
1da177e4c3f4


c7dc89c0ac8e



c7dc89c0ac8e




1da177e4c3f4

62b54dd91567
1da177e4c3f4
1da177e4c3f4
0be669bb3769
1da177e4c3f4
07a936260a94
aee80b54b235




aee80b54b235

7eaa48a45ca7
91df42bedccb
aee80b54b235



aee80b54b235

08b44656c08c

aee80b54b235


1da177e4c3f4




95c385b4d5a7
1da177e4c3f4





1ab1457c42bc
351638e7deee
1da177e4c3f4
351638e7deee
748e2d9396a1
c5e33bddd3c7
b217d616a15f
1da177e4c3f4
e21e8467d318
45ba9dd2007d
74235a25c673
45ba9dd2007d

b217d616a15f
45ba9dd2007d

bcdd553fd303
1da177e4c3f4
3c21edbd1137
c2edacf80e15


3c21edbd1137
f24e3d658cf3
3c21edbd1137
f32138319ca6
3c21edbd1137


990810493532
d31c7b8fa303


e3ec6cfc260e
990810493532
e3ec6cfc260e

3c21edbd1137
f24e3d658cf3
3c21edbd1137




bcdd553fd303
3c21edbd1137

3c21edbd1137


f32138319ca6

3c21edbd1137
c5e33bddd3c7
3c21edbd1137

e21e8467d318
07a936260a94
1da177e4c3f4


0be669bb3769
07a936260a94
aee80b54b235



1da177e4c3f4






3ff50b7997fe
bcdd553fd303
1da177e4c3f4
c5e33bddd3c7


bcdd553fd303



1da177e4c3f4
bcdd553fd303

1da177e4c3f4




bcdd553fd303



1da177e4c3f4

bcdd553fd303
1da177e4c3f4



d31c7b8fa303
1da177e4c3f4




d31c7b8fa303





bcdd553fd303
db9c7c3943f2
bcdd553fd303

1da177e4c3f4







3c21edbd1137
1da177e4c3f4
1da177e4c3f4
5632c5152aa6
408c4768cd08
f52295a9c55c
b217d616a15f


5632c5152aa6
1da177e4c3f4
bcdd553fd303
93d9b7d7a85c


75c78500ddad
3ff50b7997fe
1da177e4c3f4








1da177e4c3f4

93d9b7d7a85c
75c78500ddad





93d9b7d7a85c
75c78500ddad
93d9b7d7a85c
75c78500ddad


1da177e4c3f4

c346dca10840
502a2ffd7376

73a8bd74e261
1da177e4c3f4


73a8bd74e261

1da177e4c3f4




bcdd553fd303


1da177e4c3f4
439e23857a21
1da177e4c3f4
8814c4b53381

a9b3cd7f323b
1da177e4c3f4





73a8bd74e261


73a8bd74e261


b67bfe0d42ca
73a8bd74e261

b7b1bfce0bb6
73a8bd74e261





1da177e4c3f4

b7b1bfce0bb6

bcdd553fd303
439e23857a21
3c21edbd1137
1da177e4c3f4
439e23857a21
1da177e4c3f4

bcdd553fd303
372e6c8f1f7b



1da177e4c3f4










8f37ada5b5f6
502a2ffd7376


b7b1bfce0bb6
84e8b803f1e1
73a8bd74e261
84e8b803f1e1
73a8bd74e261
84e8b803f1e1
73a8bd74e261



9d82ca98f71f
73a8bd74e261

f88c91ddba95
27bdb2abcc5e
73a8bd74e261
8f37ada5b5f6
73a8bd74e261

8f37ada5b5f6
1da177e4c3f4


439e23857a21
1da177e4c3f4



1da177e4c3f4
1ab1457c42bc
bcdd553fd303
439e23857a21
408c4768cd08
1da177e4c3f4








b7b1bfce0bb6
caf92bc40070
b7b1bfce0bb6
1da177e4c3f4
b7b1bfce0bb6
5b2a19539c5f
1da177e4c3f4

9ba2add3cf5c
5b2a19539c5f



1da177e4c3f4
1da177e4c3f4
b7b1bfce0bb6
caf92bc40070


b7b1bfce0bb6

caf92bc40070
1da177e4c3f4
caf92bc40070
b7b1bfce0bb6




1da177e4c3f4
1da177e4c3f4



91df42bedccb
1da177e4c3f4


b7b1bfce0bb6
caf92bc40070
b7b1bfce0bb6
1da177e4c3f4




3c21edbd1137




95c385b4d5a7


63862b5bef73
95c385b4d5a7
b7b1bfce0bb6

3c21edbd1137

cf22f9a2b83e
1da177e4c3f4


1da177e4c3f4


63862b5bef73
1da177e4c3f4

622ccdf107bc
e9d3e0849758
1da177e4c3f4
1da177e4c3f4

1b34be74cbf1
55ebaef1d5db

cc411d0bae9c
21809fafa042
1da177e4c3f4





6732badee0da
21809fafa042
6732badee0da
3c21edbd1137
590a9887a23b
3c21edbd1137



cc411d0bae9c
6732badee0da
3c21edbd1137
95c385b4d5a7




e21e8467d318
95c385b4d5a7

6732badee0da
1da177e4c3f4
622ccdf107bc
1da177e4c3f4






1da177e4c3f4

b7b1bfce0bb6
f2344a131bcc

b7b1bfce0bb6
122e4519cd5c
b7b1bfce0bb6
1da177e4c3f4

21809fafa042

622ccdf107bc

b7b1bfce0bb6
622ccdf107bc


b7b1bfce0bb6
1da177e4c3f4



cc411d0bae9c
21809fafa042
b7b1bfce0bb6
1da177e4c3f4





b7b1bfce0bb6
1f9248e5606a

21809fafa042
b7b1bfce0bb6
1da177e4c3f4

1da177e4c3f4
d7aabf22efb5
1da177e4c3f4



11ffff752c6a





602582ca7a15


11ffff752c6a








1da177e4c3f4

e21e8467d318
b7b1bfce0bb6
b173ee488dcc
b7b1bfce0bb6

1da177e4c3f4






026359bc6edd

1da177e4c3f4

1ec047eb4751
11ffff752c6a
b173ee488dcc

1ec047eb4751
b173ee488dcc
1ec047eb4751

b173ee488dcc





1ec047eb4751
1da177e4c3f4




1ec047eb4751
b7b1bfce0bb6
1ec047eb4751
1da177e4c3f4
b7b1bfce0bb6


1da177e4c3f4
b7b1bfce0bb6



1da177e4c3f4


e21e8467d318

c5e33bddd3c7


502a2ffd7376
21809fafa042
f2344a131bcc


21809fafa042
c5e33bddd3c7



1da177e4c3f4

3c40090a0f5b
1da177e4c3f4
1d5783030a14
1da177e4c3f4

1d5783030a14
1da177e4c3f4


1218854afa6f
1d5783030a14
1da177e4c3f4
1d5783030a14






b67bfe0d42ca
1d5783030a14
9f0d3c2781ba

1d5783030a14





9f0d3c2781ba
1d5783030a14




1da177e4c3f4
c2e21293c054
1da177e4c3f4

c2e21293c054

1da177e4c3f4

1218854afa6f
1da177e4c3f4
b67bfe0d42ca
9f0d3c2781ba

1d5783030a14
9f0d3c2781ba
1d5783030a14
3c40090a0f5b
c2e21293c054
1d5783030a14
b67bfe0d42ca
c2e21293c054
9f0d3c2781ba

1d5783030a14
9f0d3c2781ba
c2e21293c054
1da177e4c3f4
3c40090a0f5b
c2e21293c054
1da177e4c3f4

1da177e4c3f4
4f70ecca9c57
1da177e4c3f4
5c578aedcb21
1d5783030a14
1da177e4c3f4











4f70ecca9c57
1da177e4c3f4
5c578aedcb21
1da177e4c3f4




971a351ccbbd
b071195deba1
1da177e4c3f4


971a351ccbbd
1da177e4c3f4



56b3d975bbce
1da177e4c3f4







3c40090a0f5b

1da177e4c3f4

9a32144e9d7b
1da177e4c3f4



3c40090a0f5b
1da177e4c3f4

2c8c1e7297e1
1da177e4c3f4
d4beaa66add8
1da177e4c3f4



2c8c1e7297e1
3c40090a0f5b
ece31ffd539e
3c40090a0f5b











1da177e4c3f4

3c40090a0f5b
1da177e4c3f4


07a936260a94
3b9f9a1c3903
b71d1d426d26
3b9f9a1c3903

c2e21293c054
ddbe50320385
c2e21293c054
5c578aedcb21
b67bfe0d42ca
878628fbf258
389f661224cd
caad295fed8b
3b9f9a1c3903




5c578aedcb21
3b9f9a1c3903



1da177e4c3f4





b2db756449f6
1da177e4c3f4
1da177e4c3f4

5c578aedcb21

1da177e4c3f4
b2db756449f6
1da177e4c3f4


bcdd553fd303
1da177e4c3f4
b67bfe0d42ca
5c578aedcb21
1da177e4c3f4
1da177e4c3f4
fad8da3e085d





1da177e4c3f4


b2db756449f6

1da177e4c3f4
8f27ebb9823b

1da177e4c3f4

1da177e4c3f4

8f27ebb9823b


1da177e4c3f4
a1ed05263b74
1da177e4c3f4






fad8da3e085d

1da177e4c3f4





1da177e4c3f4




1da177e4c3f4

88949cf484bf

1f9248e5606a
88949cf484bf
1da177e4c3f4








5c578aedcb21
291d809ba5c8


1da177e4c3f4







1da177e4c3f4






1da177e4c3f4

b2db756449f6










ba3542e15cf8

b2db756449f6

1da177e4c3f4
5c578aedcb21

1da177e4c3f4

caeaba79009c

461d8837faac


caeaba79009c

461d8837faac




caeaba79009c

461d8837faac




ef7c79ed645f
461d8837faac


479840ffdbe4
461d8837faac

1da177e4c3f4
661d2967b3f1
1da177e4c3f4
3b1e0a655f8e
b933f7166ba3

caeaba79009c
b933f7166ba3
1da177e4c3f4
b933f7166ba3




caeaba79009c
1da177e4c3f4


af2849377e7b
1da177e4c3f4

479840ffdbe4
55ebaef1d5db
081bba5b3ace
6f704992d365

4bed72e4f550
53bd67491537
5b84efecb7d9
46d480468fd9
081bba5b3ace


53bd67491537



4bed72e4f550



6f704992d365
4bed72e4f550



6f704992d365
081bba5b3ace
4bed72e4f550





081bba5b3ace

53bd67491537
5b84efecb7d9

53bd67491537
761aac737eb1

53bd67491537
081bba5b3ace






081bba5b3ace
761aac737eb1


5b84efecb7d9











761aac737eb1
53bd67491537







081bba5b3ace





661d2967b3f1
1da177e4c3f4
3b1e0a655f8e
461d8837faac

caeaba79009c
7198f8cec12c

55ebaef1d5db
479840ffdbe4
461d8837faac
1da177e4c3f4
461d8837faac




caeaba79009c
1da177e4c3f4


461d8837faac
0778769d392b
461d8837faac

0778769d392b
461d8837faac



0778769d392b

af2849377e7b
7198f8cec12c


479840ffdbe4

55ebaef1d5db
761aac737eb1

55ebaef1d5db
1cab3da6be6c
7198f8cec12c


db9c7c3943f2
7198f8cec12c
caeaba79009c
af2849377e7b

081bba5b3ace

7198f8cec12c



55ebaef1d5db
7198f8cec12c



1da177e4c3f4

479840ffdbe4
101bb229691c











85486af00b62




18a31e1e282f

85486af00b62





101bb229691c











0ab6803bc90a

339bf98ffc6a
caeaba79009c
339bf98ffc6a
479840ffdbe4

0ab6803bc90a
c5396a31b209
1da177e4c3f4
15e473046cb6
1da177e4c3f4
1da177e4c3f4
85486af00b62
1da177e4c3f4
15e473046cb6
0ab6803bc90a
26932566a42d
0ab6803bc90a
101bb229691c


fad8da3e085d

85486af00b62


1da177e4c3f4
a1faa69810b2



f56619fc7240





1da177e4c3f4

85486af00b62



7996c799ae32
caeaba79009c








1da177e4c3f4
479840ffdbe4


0ab6803bc90a
caeaba79009c



1da177e4c3f4


15e473046cb6
1da177e4c3f4
1da177e4c3f4
101bb229691c




1da177e4c3f4
15e473046cb6
0ab6803bc90a
26932566a42d
85486af00b62
0ab6803bc90a


26932566a42d



85486af00b62
0ab6803bc90a
1da177e4c3f4


15e473046cb6
1da177e4c3f4
1da177e4c3f4
101bb229691c




1da177e4c3f4
15e473046cb6
0ab6803bc90a
26932566a42d
85486af00b62
0ab6803bc90a


26932566a42d



1da177e4c3f4
0ab6803bc90a
1da177e4c3f4

e21e8467d318
1da177e4c3f4




234b27c3fd58




234b27c3fd58






502a2ffd7376


234b27c3fd58
502a2ffd7376

234b27c3fd58

15e473046cb6
234b27c3fd58




63998ac24f83
234b27c3fd58

502a2ffd7376
234b27c3fd58






15e473046cb6
234b27c3fd58













15e473046cb6
234b27c3fd58














1da177e4c3f4


234b27c3fd58

1da177e4c3f4

1da177e4c3f4
234b27c3fd58

1ab1457c42bc
234b27c3fd58


5d5619b40c24
234b27c3fd58
63998ac24f83
234b27c3fd58


b67bfe0d42ca
234b27c3fd58

4b97efdf3925
234b27c3fd58

e21e8467d318

234b27c3fd58




7562f876cd93
234b27c3fd58

1da177e4c3f4
234b27c3fd58





1da177e4c3f4





b854272b3c73
1da177e4c3f4





b854272b3c73
1da177e4c3f4






b854272b3c73
1da177e4c3f4


661d2967b3f1
6c223828058b
3b1e0a655f8e
1b29fc2c8bf4

caeaba79009c
6c223828058b


6c223828058b

1b29fc2c8bf4



caeaba79009c
1b29fc2c8bf4


6c223828058b
6c223828058b
1b29fc2c8bf4
6c223828058b
6fda73500581
6c223828058b
e21e8467d318

1b29fc2c8bf4


6c223828058b
e21e8467d318

6c223828058b
1b29fc2c8bf4
6c223828058b

15e473046cb6
6c223828058b
26932566a42d





15e473046cb6
1b29fc2c8bf4
6c223828058b
1b29fc2c8bf4
6c223828058b
6c223828058b

1da177e4c3f4


c346dca10840
5d620266431c
1da177e4c3f4
0ab6803bc90a
5d620266431c



26932566a42d





1ce85fe40213

5d620266431c

6fda73500581
1da177e4c3f4

b6f99a211957
1da177e4c3f4

04561c1fe7b0

1da177e4c3f4








93908d192686



1da177e4c3f4
fc4eba58b4c1



1da177e4c3f4




1da177e4c3f4
65f5c7c1143f
c4fd30eb1866
930d6ff2e2a5

93908d192686

fa03ef38e151
09c884d4c3b4

930d6ff2e2a5
fbea49e1e240
0bcbc9262904
95c385b4d5a7


7bc570c8b4f7


778d80be5269
1b34be74cbf1
c3faca053d0a
5cb04436eef6
b800c3b966bc
1da177e4c3f4

b382b191ea9e





f53adae4eae5

b382b191ea9e

339bf98ffc6a






b382b191ea9e
339bf98ffc6a
c5396a31b209
be281e554e2a
7d720c3e4f0c
7f7d9a6b96c5







be281e554e2a
7f7d9a6b96c5



4ce3c183fcad














7f7d9a6b96c5


e21e8467d318
7f7d9a6b96c5
4ce3c183fcad

7f7d9a6b96c5

be281e554e2a
7f7d9a6b96c5



b382b191ea9e




c78679e8f31b

b382b191ea9e
24912420e923

1f9248e5606a
c78679e8f31b

b382b191ea9e
















f53adae4eae5






b382b191ea9e


























f53adae4eae5

f53adae4eae5

fc403832f7bd
dc8482926e2b
f53adae4eae5






f53adae4eae5











dc8482926e2b


fc403832f7bd






f53adae4eae5

fc403832f7bd
77ecaace6c54
fc403832f7bd
77ecaace6c54


f53adae4eae5



617fe29d45bd
f53adae4eae5






2b9651d72d3f
f53adae4eae5




















1ab1457c42bc
15e473046cb6
1da177e4c3f4
04561c1fe7b0
04561c1fe7b0


04561c1fe7b0
15e473046cb6
04561c1fe7b0
26932566a42d
04561c1fe7b0








c78679e8f31b






04561c1fe7b0


1da177e4c3f4
b382b191ea9e
bf99f1bde3b3
1da177e4c3f4
04561c1fe7b0

1da177e4c3f4
04561c1fe7b0
26932566a42d

1da177e4c3f4



3b1e0a655f8e
84d2697d9649
434a8a58d75f
1da177e4c3f4

84d2697d9649
1da177e4c3f4
84d2697d9649






b67bfe0d42ca
84d2697d9649





15e473046cb6
84d2697d9649


7562f876cd93
84d2697d9649

1da177e4c3f4
84d2697d9649



1da177e4c3f4






c346dca10840
8d7a76c9b178
1ab1457c42bc
339bf98ffc6a
8d7a76c9b178



26932566a42d





5f75a1042fec
1ce85fe40213
8d7a76c9b178

5f75a1042fec
1da177e4c3f4

339bf98ffc6a





c5396a31b209
1da177e4c3f4
15e473046cb6
6051e2f4fb68
1da177e4c3f4
6051e2f4fb68

1da177e4c3f4

15e473046cb6
6051e2f4fb68
26932566a42d
6051e2f4fb68

1da177e4c3f4
8a47077a0b5a

1da177e4c3f4


8a47077a0b5a
1da177e4c3f4





c78679e8f31b

1da177e4c3f4

c78679e8f31b

6051e2f4fb68
1da177e4c3f4
6051e2f4fb68
26932566a42d

1da177e4c3f4

1ab1457c42bc
1da177e4c3f4


c346dca10840
8c384bfa36b1
1da177e4c3f4
339bf98ffc6a
8c384bfa36b1



26932566a42d





1ce85fe40213

8c384bfa36b1

6fda73500581
1da177e4c3f4

1da177e4c3f4

63998ac24f83

1da177e4c3f4



95c385b4d5a7







1da177e4c3f4

7996c799ae32
caeaba79009c

1da177e4c3f4




7996c799ae32
caeaba79009c










d8d1f30b95a6
93fa159abe50
73a8bd74e261
d8d1f30b95a6
1da177e4c3f4

63998ac24f83
439677d766ba
1da177e4c3f4



8814c4b53381
1da177e4c3f4

8814c4b53381
1da177e4c3f4




fe2c6338fd2c
1da177e4c3f4



88af182e3890
fe2c6338fd2c
1da177e4c3f4

013d97e9da18







1da177e4c3f4
c8fecf2242a0
b325fddb7f86
88af182e3890

1ab1457c42bc
1da177e4c3f4

56d417b12e57

75538c2b85cf

56d417b12e57


75538c2b85cf
56d417b12e57
75538c2b85cf
56d417b12e57
75538c2b85cf
56d417b12e57






c6d14c84566d

56d417b12e57






56d417b12e57
c6d14c84566d
56d417b12e57

013d97e9da18
56d417b12e57

013d97e9da18



56d417b12e57

013d97e9da18

56d417b12e57
013d97e9da18

56d417b12e57
88af182e3890
56d417b12e57

56d417b12e57

013d97e9da18
56d417b12e57






fe2c6338fd2c
56d417b12e57



88af182e3890
fe2c6338fd2c
56d417b12e57

013d97e9da18







56d417b12e57


88af182e3890

56d417b12e57


c92d5491a6d9







































1da177e4c3f4


fe2c6338fd2c
ab32ea5d8a76
1da177e4c3f4

1ab1457c42bc
e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4
fc4eba58b4c1















1da177e4c3f4
e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4

e21e8467d318




1da177e4c3f4
1da177e4c3f4
e21e8467d318




1da177e4c3f4

e21e8467d318




65f5c7c1143f

e21e8467d318




c4fd30eb1866
930d6ff2e2a5

e21e8467d318




930d6ff2e2a5
52e1635631b3
e21e8467d318




52e1635631b3
fa03ef38e151
09c884d4c3b4
e21e8467d318




09c884d4c3b4

930d6ff2e2a5
c4fd30eb1866
e21e8467d318



c92d5491a6d9
fbea49e1e240

e21e8467d318




0bcbc9262904
95c385b4d5a7

e21e8467d318




95c385b4d5a7


7bc570c8b4f7

e21e8467d318




7bc570c8b4f7

0bcbc9262904
e21e8467d318




778d80be5269

e21e8467d318




1b34be74cbf1

f7734fdf61ec






5cb04436eef6






b800c3b966bc






f8572d8f2a2b
1da177e4c3f4

1da177e4c3f4

bff16c2f9913
f8572d8f2a2b
1da177e4c3f4

1da177e4c3f4
6105e29320f6
1dab62226dd9
af879cc70437
1da177e4c3f4
f68635e627f9

bcdd553fd303
e21e8467d318
1da177e4c3f4
bff16c2f9913
1da177e4c3f4
1da177e4c3f4
6105e29320f6
1da177e4c3f4
6105e29320f6
1da177e4c3f4
6105e29320f6
f68635e627f9

9589731220ed
1da177e4c3f4
f68635e627f9
1da177e4c3f4
f68635e627f9
9589731220ed
1da177e4c3f4

408c4768cd08








ff538818f4a8
408c4768cd08


f52295a9c55c

73af614aedd2
f8572d8f2a2b
c346dca10840
f8572d8f2a2b
f52295a9c55c

408c4768cd08
1da177e4c3f4
408c4768cd08

1da177e4c3f4




2c8c1e7297e1
e0da5a480caf
a79ca223e029
e0da5a480caf

a79ca223e029


e0da5a480caf
a79ca223e029


e0da5a480caf
a79ca223e029


e0da5a480caf




f8572d8f2a2b
e0da5a480caf


f8572d8f2a2b
e0da5a480caf
















2c8c1e7297e1
e0da5a480caf




09ad9bc75251
e0da5a480caf









b382b191ea9e



f53adae4eae5
b382b191ea9e

1da177e4c3f4





c2e21293c054
2a8cc6c89039
e21e8467d318

f32138319ca6

2cc6d2bf3d61
2a8cc6c89039
1da177e4c3f4
2cc6d2bf3d61


e0da5a480caf
1da177e4c3f4


















2774c7aba6c9
1da177e4c3f4


e0da5a480caf
1da177e4c3f4
c2e21293c054


1da177e4c3f4

1da177e4c3f4
c127ea2c45d1
3678a9d86324
b382b191ea9e
c7ac8679bec9

c127ea2c45d1



c7ac8679bec9







76f8f6cb76b1
7a6742003f3c
c127ea2c45d1
2a8cc6c89039

1da177e4c3f4
c127ea2c45d1
b382b191ea9e
c127ea2c45d1
e0da5a480caf

2cc6d2bf3d61


c127ea2c45d1
1da177e4c3f4

09f7709f4929
1da177e4c3f4
176c39af29bc
1da177e4c3f4


e0da5a480caf
2cc6d2bf3d61
1da177e4c3f4


b382b191ea9e

176c39af29bc







1da177e4c3f4
1da177e4c3f4

5c578aedcb21
c2e21293c054

5c578aedcb21
1da177e4c3f4

1da177e4c3f4
1da177e4c3f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343




                                        
                                                   

                                                      


























                                                                             


                                                                          

   

                                

                        
                         

                          


                            
                          





                                
                       


                         
                             

                           
                         
                       
 
                              


                     
                              
                         






                          
                        
                          

                            
                          
                         
                          
                          


                           
                         




                                
                                                 
     
                                                                          


                                          




                                                       

                    
                                                             








                                                                     

      

                                                                                     
                                                 
 
                                                                




                                                        
                                                        
                                           
 

                                           
                                                           




                                                             

                                                        

                                                            




                                                                               
                                                         

                                                             
                                                     



                                                                   
                                                                  
                                                           

                                                                            
 
                                                         






                                                        

                                                     



                                                             




                                                          
                                                     
                                    
                                    

                                    
                                          


                                        
      
                                    
                                                                              
                                    
                                    
                                    

  
                                                              





                                                        


                                                     



                                                             




                                                          
                                                     
                                    
                                    

                                    
                                          


                                        
      
                                    
                                                                              
                                    
                                    
                                    

  
                                         
                                                                  
 
                                      

 
                                                         
 






                                                            


                                   






                                                         
 

                                                            
 
                                            
                                  
                                                   

 

                                                  

              
                                                             

                                                               
                            











                                                                     


                                                                         
                              


                                                                               
                                 


                 
            
                                     
         
                                                          
       
                       

 
                                                             







                                    
                                                             
 

                            


                                 
                                         

                                                       
                                                                               






                                                         

                                     

                                    
 
                                        
                                 
                                                                               
                                             
                                                             

                             

                            
 
                                           
                                 
                                                                     
                                             









                                                             
 


                                                    
                               
                                                                        
                                                                  



                                           
                                             
                                                                               

                                         
                                          
                                      
                                       




                                                       
 
                                  
 
                                                         

                                           

                               
                                       
                                    
                                               
 


                                                               
                                           
                                                          
 
                                                                  
                                                                 

                                                                    


                    
                                                               




                               



                                         

                                    
 




                                 




                                                                      

                                                      
                                          
                         

                                                         
      

                                                       






















                                                                               

                                                          

                                                                           
                         



                                                             
      



                                                                           






                                   

                                                                         


















                                                                              
                                                        

 


                                                                      
                                                         


                                                            
                                                          


























































                                                                              
















                                                                  

                                                                  
















                                                                                  
                                                                     

































                                                                             




                                                      



                        

                                     
                                         
                                           
                                                                            


                                                                                 
                                                                            


                                                                                 
         

                                                             

                                               




                                                    

                                                                       


 
                                                                



                               
                                   

                                          

                                                                        


                                                         
         
 
 
                                                                               
 
                        



                                         

                                          

                  
 
                                                       



                                                                              

                              
         
 
                                                      

                                                          



                                                                              
                                    
                                                                      
                      
 
                 
                                            
                 
 

      
                                              

                                                       
                                                 
 
                       
                                   



                               
                                       
                                                                                
 
                                                    
                                                                 

                       
                            
 
                            

 


                                                                    
                            
                                                        




                                                                 


                                                                      
                                                                 


                              
                                        

 
                                                       
 
                                                                   

 


                                                              

                                                                  
                                                                    


                                        
                          
                    






                                                  
 
                           




                                                       
                                     



                              
                                       

                                                               
                                                                      
                                                          



                              
                                                               

                          
                                                       



                               
                                                   




                                  

                                                      
                          

                                            

                                   
                                         

                                                        
                                        


                                             

                                         
                                            
                               
 

                     





                                   
                                     
 
                                                                  
                                         


                                                 
                                      
 
                                         
                                                               

                                  
 


                                  
                             
 
                             
                                                              






                                   
                                         


                  

















































































                                                                                  



                                                                             
                  

                                                                
 

                                       
                                             



                                             
 

                                           
                                            
 
                                        
 
                                         



                                                
                 
                                   
         
 

                                                                                
 



                                          
 
                                    
 

                                          
                                                        
 


                                                         

         

                                      
    


                         



                                                                                   
                                                                       
                                    

                     
                       
                                    
 
                                   










                                                                   
                                             
                                                                    







                                                              
                                             

                                                                                                





                                                   
                                              
                                                 
                                       

                                             
                                                              

                                                   
                                                                    
                                                              
                                   


                                   
                                                   
                                                 
                                                                     
                                     
 



                                                                             

                                                                         
           

                                                                  





                                  




                                               



                                                               

                                  
                                                                                
                                
                                           




                                 
                          


                                   
                                




                          

  
                                                      
   









                                  
                                




                               
                         





                                                       

  
                       
                                    


                    
                           
  
 
                                                
 
                                                                            

                         

 

                                                              






































                                                                     
                                                                          























                                                                                 
             
                                                 

                                                                          
                      
             







                                                                       

                                                                          

                                                                                    
                                     
             
                                                
                                                                      
                   



                                                                                         
                      
             








                                                             



                                                                   











                                               
                                                                         
                                                                        
                                              
 

                                                                           
                                  
                               
                     
 



                                                     
                                                                       
                          


                            
 
                        
 
                                       
                                       
 
                                                       










                                                                   


                                                               
                                 
 
                                          



                                          
                                                                            
                              
 
                          


                                                                           
                                                                             
                                                                 



                                                                         

                                                                      
                                         




                                                                               
                                                         
                                                                                           




                                                                                   





                                                                           

                                                                                         















                                                                             




                                                                          
                                                             




                                                                  
                                 
                         
                 
            
                                            
         
                          
 
                          
                                      
 
                                    
                                  
                 
 
                                  
 
                                                                    
                                       



                                 


                                                                     









                                                   
                                                                  
                                     



                                 
                        

                                  
                                          
                                                                  

                                            
                          








                                                       
                                                           




                                    
                                                               
                                                           
 
                                 
                                                  
 
                           
                                                                        
                                                          
                                 
                                                        




                                                                    

                 
 

                             
 

                             

                                                                            
 
                                                  
                                 
 
                                                                    
                                                          
                                 

                                                                 
                                            

                 
                     

 


























                                                                              
                                                                        









                                          
                                                                     









                                                                    

                               
                                                                                  
                                                                        
 
                                                 
                                                  
 
                           
                                                                           
                                                          
                                 


                                                                          
                                             




                                                  
                             
 
                      

 

                                              
                                                                       
 

                                         
                                            
                                              

                                                      
                                           

                                                
                                 












                                                         



                                   













                                                        

                                                   
                                           
 

                                    
                       
         
 

                                                                            
 









                                                                            
 
                                                             
                                                      


                 
                                  
 


                                             
                                                                              









                                                
                                                                               









                                                      
                                                           

                             
                                                  
                       





                                                             
                                                            

                             
                                                  
                       





                                                             






























                                                                      




                                                               
                    


                 













                                                                  





                                                                  
                                      











                                                                    
                                                   
 

                          











                                                                            







                                                                         




                                                                 









                                                                




                                                               
                                                     
                           
                                                      
                               
                                                          
                        
                                                   

                                                   
                            

                                                     

                                                        

                                                      









                                                              


                                                                     









                                                                              
                                                                           
                                                      
 
      
                                                           
                                






                                                          
                                  



                                                               
                                     








                                                                                                                        






                                                           
                           




                                   
                                 
 
                           
                                                  

                                                                     
                                                 
                                            

                                                                                       







                                                    
                             


                          
                                                                                     
 
                                                                         
                                         
 






                                                                             
                                                       
 






                                                  
                                                 
                                             
          
 
                          




                                                           
                               

                                                                      
      
 
                            

 













                                                                               
                                       



                                                               
                                                         


                                                      
                                                    




                                   
                                         



                  



                                                       





                                                  
                                                 




                                                               

 





                                                                 

                                   



                                         

                                         

                                         
 


                    


































































                                                                                
                                                                              




                                  
                                  
                                       

                                           
 
                                               
                                                            

                       
 












                                                                  
                                                                                       





                                   

                                                                           








                                                            



                                         




                                                                   



                                                                                
 

                                                        
 




                                                                            
 
                         



                                                   
                                                                         
                                                  
                                                                          
                                
                                                      

                                       
                                            

                                                                  



                                                                         
                                                                                
                                                                   
                 
                               




                                                                 
                                         

                                               
                                       


                                                         





                                                                      
                                                 

                                                                                   




                                                     

                                                                                   




                                     
                                                          


                                                                       



                                                          
                                                                        

                                                              





                                                                                 

                                                                         
                                                                                   

                                                                          
 
                                                  



                                                     
                                                           

                                       
                                              
                                                   
                                                


                          
                                  
                                          








                                                                                       
                                                                   














                                                                                














                                                                 

                                                                               
 












                                                                       
                                                           










                                                                 
                                                         




                              
                               
                                      
                                                                   
                                 












                                                                            
                                                                   
 







                                                                          


                                       

                                                             



                                              
      








                                                       

                                                       
                                                          

                                                              




                                 

                        
                              

                      
 


                               



                                                   


                                                           

                                               
                               
 


                                     


                                     



                                                           
                                    



                                             
         
 





                                                           
 

                                                                        
 
                           




                                                                               




                                                                 
                                        


                                                                            
                                 
                                   





                            
                                                                                   
                                            



                                 
 


                               

                                               

                               
                                                


                                  
                                                             



                                                       
 
                                           







                                    
                                                          


                              
 
                                                     
                              
 



                                                                 
                                                                           

                                                                     



                      
                                                          


                              
 
                                                     





                                                                 

                                                                     



                      




                                                                         
                                                   

                                                                    








                                                  
                               

                                                    

                               
                                             
                        
                       








                                                           
                          

                                           
                          
                                        


                                
                                                   
                                                                         


                       
                                   
                                                                  
                                                      
                                              



                                                                                









                                                                             
 
                                                                  

                                                                                

                         
         
 
      



                                                 


                                    




                      
                                                   
                                                           


                       
                                                         















                                                                                











                                                                                
 
                                                                               

                                                       

                                                   
                                                  
                         


                                            

 
                                                                                       
 
                                 



                                         
                                                              

                                               
 
 

                                                                       
                           
                                                                                    
                                        






                                                       
                               


                      

                                          
                                           
                                               
                                               
                                             

                                            



                                                                       
                                     
                         








                                                            
                               





                                                       


                                                    


                                     
                                                   
                                                           


                       



                                                                  




                                                                

                               
                                       
                                         
 
      
 
                                




                                                       

                      
                                                   
                                                           



                                                          

                                                        

                                                            


      




                                                                           
                                                                   





                                                      
                                                                            
                                     
 
                                                                  
                                                    
                            
                
 
                        
                             
                                                        

                                                 
                                                                    

                      
 
                       
                           


                                           
                                         
                                                      
                                                              
                                                                                       


                                                   
 


                                                              
                                   
                                                           

                                                
                        
                                                      




                                                                
                                                              

                                                                           


                                                           

                                                                                    
 
                                        

                 
                                    
                               


                                                 
      
                                



                                                 






                                                 
                 
 
                           


                                                       



                                                                         
                           

                                                         




                                                               



                                                                       

                                                    
                                                        



                              
                                                       




                                                      





                                                        
                  
                                             

                                               







                                                                 
 
                               
                           
                                                   
                                                         
                                                       


                                                                
                 
                      
 


                                                 
                      
         








                                                               

  
                                                                             





                                  
                                             
                                    
                                                 


                                    

                                                           
                                       

                                 
                     


                      

                                   




                                  


                                                                      
           
                  
                               

                                            
                                                     





                                                  


                                                          


                                                  
                                                            

                                                                   
                                                            





                                                    

                                   

                                    
                                                        
                 
                                                                    
 
                                                 

                                  
                                         



                                                                      










                                                
 


                                                                     
                                            
 
                                        
 
                                             
 



                                                     
 

                                                            
                                                                        
                 
                                 
 

                                           
 


                                            
                



                                          
                               
 
                                                     
                  
                                                 








                                                             
                                                          
                                           
                               
 
                                
                                                       

                         
                                  



                                                               
                         
 
                                                         


                                                                    

                                                                     
                                 
 
                                        




                                                                      
                



                                                                   
                                                                           


         
                                  
    
                          




                                   




                                                       


                                          
                                                                               
 

                                                  

 
                                                        


                                           


                                              
                                                           

                                  
                              
                                                  
                         

                                                  
                                       

                                            
                                                                                  
                                        





                                            
                                           
                                        
                                            
                  
                                              



                                                                    
                                          
                       
         




                                               
                                          

                                    
                               
    
                                






                                                                

                               
                                                      

                         
                                
                                                         
                                          

                         

                              

                                                    
                                          


                         
                                   



                                     
                                                                                  
                                        
                                          





                                            
                          

                                                                             
                                
                                  

                                                        
                                                       
                                                                               



                         





                                                        


                                                                         








                                                                            

                                                            
                                                
                               
                               

                                    






                                                                     

                                                                       

           
                                       
                                                                     

                                              
                                                    
                                                 

                                         





                                                                               
                      




                                                                     
                                                                   
                               
                                                                           
 


                                                
                                                  



                                                                           


         

                                                    


                                  
                                                             
                                      


                                                         
                                        



                                    

                       
                                 
                   
                   

  
                                                                           


                                                    
                                            
                  
 






                                                                 
                                                                                
                                                    

                                                                  





                                                
                                   




                                             
         
                    

 

                                                                  

                                                    
                                            
 
                                                             

                                                          
                                
                           
         
 
                                                  
                                  
                                                
                                                                                

                                                                  
                                        
                                   
                 
         
 
                    

 
                                                             
                          
 
                           
                                        











                                                                     
                          
 
                             




                                                            
                                                         
                              


                                           
                                   



                                         
                                                  







                                                               

                                                           

 
                                                



                                       
                                          

  
                                                        
 
                                                                        



                               
                                                         
 
                                                     











                                                         

                        
                                                    


                            
                                
                                                                     
                                                                    

                    
                                        
                                                  
 
                           
                                                                           
                                                          
                                 
                                                        




                                                       
                             



                   





                                              
                                                      
                                 

              

                                         
                      
                                                            


                                   
                                              
        
                                                
                                                                        
                                          
 





                                                                            


                                              

                                                                                   
 

                                                                   

                                                        

                                                   


                                                                             
                                                              
                                                                                      






                                                                       

                                                                                           





                                                                                 




                                                                

                                                                   

                                                                                              
                                                                                          
 








                                                                                                    
 


                                                                          







                                                                                                                        






                                                                                            

         










                                                                       

                                                                                     

                                            
                                   

                                           

 

                                                                               


                                    

                         




                                                                

                                        




                   
                                                             


                                                                          
                                                         

  
          
                                                            
 
                                            

                                     
                                        
                
 




                                                                           
                                                                      


                               
                                                                            

 
                                                                     
                                                             
 

                        
                              
                                
                             
 


                                                     



                                                                    



                                                           
                                    



                                             
         
 





                                                           

                                 
                                                               

                                                              
                                                                          

                                                                  
                                






                                          
 


                                                                                  











                                                                      
         







                                                                               





                           
                                                            
 
                                            

                                     
                                        

                                 
                                                                               
                      
                
 




                                                                           
                                                                      


                               
                                
                                         

                                                 
                                          



                                                   

         
                                                       


                               

                                                                                
                                           

                                                                             
 
                                                


                                                                       
                                                                          
                   
                                                                         

                                                                    

         



                                                
                                                                                  



                         

 
                                                                        











                                                




                                                                        

                                         





                                                            











                                         

                                            
                                                    
                                                   
                                                     

                                                             
 
 
                                                                           
                                                                                
 
                              
                             
 
                                                                                  
                        
                                 
 


                                                                             

                                                           


                                                      
                                                               



                                                  





                                                          

                 



                                               
                                              








                                                                               
 


                                                        
                                   



                               


                                                                            
                                                                          
 
                              




                                                         
 
                                                                                  
                        
                                 
 


                                                                    



                                                                        
 
                                   


                                                                            
                                                                                   
 
                              




                                                         
 
                                                                                  
                        
                                 
 


                                                                    



                                                                        
 
                                   

 
                  




                       




                                                                             






                                  


                                         
                                                     

                                                                     

                                                         
                                                                           




                                                                   
                                                                     

                      
         






                                                             
                                                                             













                                                                     
                                                                             














                                                                     


                                                                            

                                            

                            
                               

                                
 


                                        
 
                        
                                                                             


                                                               
                                                                  

                                          
                                                   

                                             

                                                  




                                                                   
     

                              
         





                             





                                                                              
 





                                                                                
 






                                                                                
 


                                              
                                                                          
 
                                               

                                     
                                            


                                      

                



                                                                           
                                                                   


                              
         
 
                              
                           
                                                              
 

                                                 


                                     
 

                                                            
                               
                                

         
                                                                    
                                                                





                                                                     
                                                                
           
                         
       
                   

 


                                                                 
                                                  
                           
 
                                                            



                                                          





                                                                     

                                                                        

                    
                                                               

 
                                                               

                                                        

                                          








                                                                



                                                            
                                                                  



                                                                         




                                                                  
                                                          
                                                                
                                                              

                                                                    

                                                          
                             

                                                                                    
      
                                                  
                                                                      


                                                            


                                                          
                                                        
                                                    
                                                      
                                                        
                                                                      

 





                                                                         

                                                                              

 






                                                                
                                                                        
 
 
                                                                        
                                                           







                                                                           
                                                                    



                                      














                                                                              


                                                                              
                           
                              

                                                                                                  

                                   
                                                                                                



                      




                                                                              

                                                               
                                        

                                                                             
                                                                                    

                                                                
















                                                                                   






                                                                          


























                                                                                

                                                                            

                                           
                               
                                






                                                    











                                                               


                                                             






                                                                            

                                   
 
                        
                                             


                                                                            



                                                             
                                     






                                              
                           




















                                                                              
                                                                         
                                                                                
 
                                           


                              
 
                                                                      
                        
                                 








                                            






                                                                         


                                                       
 
                                                  
                                     
 

                                     
 
                

                               



                                                                              
                                            
                   
                           

                               
                                
 






                                                               
                                                                  





                                                        
                                                                         


                                                                             
     

                              
         



                          






                                                           
                                             
                           
 
                                                           



                                                           





                                                                    
                                                                        
               

                    
                                                               

 





                                                                 
 
                                                                         
                                                                            
                                                           
 

                               

                                   
                                                                       
                        
                                 

                               
                                       

                              


                                                  
                              





                                                         

                                                                                

                                                   

                                                            
                                   
 
                

                               

 
                                                                  


                                                   
                                             
                           
 
                                                               



                                                                  





                                                                        

                                                                        

                    
                                                               

 

                                                                  

                                                  



                                                     







                                                        

                                                   
                                                    

                                                                    




                                                             
                                                      










                                                                            
                                        
 
                                        
                                                

                      
                                              
                                



                                                                
                           

                                              
                             




                    
                                                             



                                                                           
                           
                              

                







                                                              
 
                  
                                                                

                            
                   

 

                                                      

                                         


                                
                                                    
                                   
                                                          
            
                                                        






                                                                

                                       






                                                                          
         
                          

 
                                                                           

                        



                                         

                                          

                  
 

                                                         
                         
         

                                                        

                                                            
                                    






                                                                      
                                                             



                                                                            
                           
                              

                







                                                                


                                                            

                            


                   







































                                                                               


                                               
                                                      
                                   

                              
                 




                                                                   

                  




                                                                  

                  




                                                             

                  




                                                                  

                  




                                                                         

                  




                                                                 

                  




                                                                      

                  




                                                                     

                  




                                                                             

                  




                                                                          

                  




                                                                          
                  















                                                                                
                 




                                                                     

                  




                                                                       

                  




                                                                          

                  




                                                                        

                  




                                                                          
                  
                 




                                                                      

                  




                                                                         

                  




                                                                        
                  

                              




                                                                           
                  
                 




                                                                           
                  
                             
                 




                                                                                   

                  
      
                 



                                                                  
                                                                    

                  




                                                                            
                  

                                 




                                                                       


                  

                         




                                                                      

                  
                 




                                                                     

                  




                                                                   

                  






                                                                    






                                                                     






                                                                            
                                      

                 

  
                                                                      
                                                               

              
                                        
                                                       
 
                                                              
                      

                         
                                                    
                                                                              
                                                                         
                                                 
         
 
                                                                   
 
                                                                            
                                     
                          

                      
                 
 
     
                 
    
                        

 








                                                                
                                                      


                 

                                                            
                                                        
                                                           
                                                                       
                                                          

 
                                                              
 

                                                 




      
                                                        
 
                          

                                        


                                                                       
 


                                                                                  
 


                                                        




                                      
                                                                


                                 
                                                                     
















                                          
                                                         




                                                             
                                      









                                                



                                                   
                                              

  





                              
                   
 

                                     

                                                                           
                         
         
 


                                                    
 


















                                                                          
                                                 


                              
                           
 


                                                    

                                                    
                           
 
                                     
 

                                                                             



                                                             







                                                                              
                                                                            
                                                          
 

                                        
                 
       
                                       
                                                      

                                                


                                  
                   

 
                           
 
                               


                                                      
                                                
                                  


                    

                                         







                                                  
          

                                 
                                          

                                                          
                                            

                                   
                      
 
/*
 *	IPv6 Address [auto]configuration
 *	Linux INET6 implementation
 *
 *	Authors:
 *	Pedro Roque		<roque@di.fc.ul.pt>
 *	Alexey Kuznetsov	<kuznet@ms2.inr.ac.ru>
 *
 *	This program is free software; you can redistribute it and/or
 *      modify it under the terms of the GNU General Public License
 *      as published by the Free Software Foundation; either version
 *      2 of the License, or (at your option) any later version.
 */

/*
 *	Changes:
 *
 *	Janos Farkas			:	delete timer on ifdown
 *	<chexum@bankinf.banki.hu>
 *	Andi Kleen			:	kill double kfree on module
 *						unload.
 *	Maciej W. Rozycki		:	FDDI support
 *	sekiya@USAGI			:	Don't send too many RS
 *						packets.
 *	yoshfuji@USAGI			:       Fixed interval between DAD
 *						packets.
 *	YOSHIFUJI Hideaki @USAGI	:	improved accuracy of
 *						address validation timer.
 *	YOSHIFUJI Hideaki @USAGI	:	Privacy Extensions (RFC3041)
 *						support.
 *	Yuji SEKIYA @USAGI		:	Don't assign a same IPv6
 *						address on a same interface.
 *	YOSHIFUJI Hideaki @USAGI	:	ARCnet support
 *	YOSHIFUJI Hideaki @USAGI	:	convert /proc/net/if_inet6 to
 *						seq_file.
 *	YOSHIFUJI Hideaki @USAGI	:	improved source address
 *						selection; consider scope,
 *						status etc.
 */

#define pr_fmt(fmt) "IPv6: " fmt

#include <linux/errno.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/net.h>
#include <linux/in6.h>
#include <linux/netdevice.h>
#include <linux/if_addr.h>
#include <linux/if_arp.h>
#include <linux/if_arcnet.h>
#include <linux/if_infiniband.h>
#include <linux/route.h>
#include <linux/inetdevice.h>
#include <linux/init.h>
#include <linux/slab.h>
#ifdef CONFIG_SYSCTL
#include <linux/sysctl.h>
#endif
#include <linux/capability.h>
#include <linux/delay.h>
#include <linux/notifier.h>
#include <linux/string.h>
#include <linux/hash.h>

#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/snmp.h>

#include <net/af_ieee802154.h>
#include <net/firewire.h>
#include <net/ipv6.h>
#include <net/protocol.h>
#include <net/ndisc.h>
#include <net/ip6_route.h>
#include <net/addrconf.h>
#include <net/tcp.h>
#include <net/ip.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>
#include <linux/if_tunnel.h>
#include <linux/rtnetlink.h>
#include <linux/netconf.h>
#include <linux/random.h>
#include <linux/uaccess.h>
#include <asm/unaligned.h>

#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/export.h>

/* Set to 3 to get tracing... */
#define ACONF_DEBUG 2

#if ACONF_DEBUG >= 3
#define ADBG(fmt, ...) printk(fmt, ##__VA_ARGS__)
#else
#define ADBG(fmt, ...) do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
#endif

#define	INFINITY_LIFE_TIME	0xFFFFFFFF

static inline u32 cstamp_delta(unsigned long cstamp)
{
	return (cstamp - INITIAL_JIFFIES) * 100UL / HZ;
}

#ifdef CONFIG_SYSCTL
static void addrconf_sysctl_register(struct inet6_dev *idev);
static void addrconf_sysctl_unregister(struct inet6_dev *idev);
#else
static inline void addrconf_sysctl_register(struct inet6_dev *idev)
{
}

static inline void addrconf_sysctl_unregister(struct inet6_dev *idev)
{
}
#endif

static void __ipv6_regen_rndid(struct inet6_dev *idev);
static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr);
static void ipv6_regen_rndid(unsigned long data);

static int ipv6_generate_eui64(u8 *eui, struct net_device *dev);
static int ipv6_count_addresses(struct inet6_dev *idev);

/*
 *	Configured unicast address hash table
 */
static struct hlist_head inet6_addr_lst[IN6_ADDR_HSIZE];
static DEFINE_SPINLOCK(addrconf_hash_lock);

static void addrconf_verify(unsigned long);

static DEFINE_TIMER(addr_chk_timer, addrconf_verify, 0, 0);
static DEFINE_SPINLOCK(addrconf_verify_lock);

static void addrconf_join_anycast(struct inet6_ifaddr *ifp);
static void addrconf_leave_anycast(struct inet6_ifaddr *ifp);

static void addrconf_type_change(struct net_device *dev,
				 unsigned long event);
static int addrconf_ifdown(struct net_device *dev, int how);

static struct rt6_info *addrconf_get_prefix_route(const struct in6_addr *pfx,
						  int plen,
						  const struct net_device *dev,
						  u32 flags, u32 noflags);

static void addrconf_dad_start(struct inet6_ifaddr *ifp);
static void addrconf_dad_timer(unsigned long data);
static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
static void addrconf_dad_run(struct inet6_dev *idev);
static void addrconf_rs_timer(unsigned long data);
static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);

static void inet6_prefix_notify(int event, struct inet6_dev *idev,
				struct prefix_info *pinfo);
static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
			       struct net_device *dev);

static struct ipv6_devconf ipv6_devconf __read_mostly = {
	.forwarding		= 0,
	.hop_limit		= IPV6_DEFAULT_HOPLIMIT,
	.mtu6			= IPV6_MIN_MTU,
	.accept_ra		= 1,
	.accept_redirects	= 1,
	.autoconf		= 1,
	.force_mld_version	= 0,
	.mldv1_unsolicited_report_interval = 10 * HZ,
	.mldv2_unsolicited_report_interval = HZ,
	.dad_transmits		= 1,
	.rtr_solicits		= MAX_RTR_SOLICITATIONS,
	.rtr_solicit_interval	= RTR_SOLICITATION_INTERVAL,
	.rtr_solicit_delay	= MAX_RTR_SOLICITATION_DELAY,
	.use_tempaddr 		= 0,
	.temp_valid_lft		= TEMP_VALID_LIFETIME,
	.temp_prefered_lft	= TEMP_PREFERRED_LIFETIME,
	.regen_max_retry	= REGEN_MAX_RETRY,
	.max_desync_factor	= MAX_DESYNC_FACTOR,
	.max_addresses		= IPV6_MAX_ADDRESSES,
	.accept_ra_defrtr	= 1,
	.accept_ra_pinfo	= 1,
#ifdef CONFIG_IPV6_ROUTER_PREF
	.accept_ra_rtr_pref	= 1,
	.rtr_probe_interval	= 60 * HZ,
#ifdef CONFIG_IPV6_ROUTE_INFO
	.accept_ra_rt_info_max_plen = 0,
#endif
#endif
	.proxy_ndp		= 0,
	.accept_source_route	= 0,	/* we do not accept RH0 by default. */
	.disable_ipv6		= 0,
	.accept_dad		= 1,
	.suppress_frag_ndisc	= 1,
};

static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
	.forwarding		= 0,
	.hop_limit		= IPV6_DEFAULT_HOPLIMIT,
	.mtu6			= IPV6_MIN_MTU,
	.accept_ra		= 1,
	.accept_redirects	= 1,
	.autoconf		= 1,
	.force_mld_version	= 0,
	.mldv1_unsolicited_report_interval = 10 * HZ,
	.mldv2_unsolicited_report_interval = HZ,
	.dad_transmits		= 1,
	.rtr_solicits		= MAX_RTR_SOLICITATIONS,
	.rtr_solicit_interval	= RTR_SOLICITATION_INTERVAL,
	.rtr_solicit_delay	= MAX_RTR_SOLICITATION_DELAY,
	.use_tempaddr		= 0,
	.temp_valid_lft		= TEMP_VALID_LIFETIME,
	.temp_prefered_lft	= TEMP_PREFERRED_LIFETIME,
	.regen_max_retry	= REGEN_MAX_RETRY,
	.max_desync_factor	= MAX_DESYNC_FACTOR,
	.max_addresses		= IPV6_MAX_ADDRESSES,
	.accept_ra_defrtr	= 1,
	.accept_ra_pinfo	= 1,
#ifdef CONFIG_IPV6_ROUTER_PREF
	.accept_ra_rtr_pref	= 1,
	.rtr_probe_interval	= 60 * HZ,
#ifdef CONFIG_IPV6_ROUTE_INFO
	.accept_ra_rt_info_max_plen = 0,
#endif
#endif
	.proxy_ndp		= 0,
	.accept_source_route	= 0,	/* we do not accept RH0 by default. */
	.disable_ipv6		= 0,
	.accept_dad		= 1,
	.suppress_frag_ndisc	= 1,
};

/* Check if a valid qdisc is available */
static inline bool addrconf_qdisc_ok(const struct net_device *dev)
{
	return !qdisc_tx_is_noop(dev);
}

static void addrconf_del_rs_timer(struct inet6_dev *idev)
{
	if (del_timer(&idev->rs_timer))
		__in6_dev_put(idev);
}

static void addrconf_del_dad_timer(struct inet6_ifaddr *ifp)
{
	if (del_timer(&ifp->dad_timer))
		__in6_ifa_put(ifp);
}

static void addrconf_mod_rs_timer(struct inet6_dev *idev,
				  unsigned long when)
{
	if (!timer_pending(&idev->rs_timer))
		in6_dev_hold(idev);
	mod_timer(&idev->rs_timer, jiffies + when);
}

static void addrconf_mod_dad_timer(struct inet6_ifaddr *ifp,
				   unsigned long when)
{
	if (!timer_pending(&ifp->dad_timer))
		in6_ifa_hold(ifp);
	mod_timer(&ifp->dad_timer, jiffies + when);
}

static int snmp6_alloc_dev(struct inet6_dev *idev)
{
	int i;

	if (snmp_mib_init((void __percpu **)idev->stats.ipv6,
			  sizeof(struct ipstats_mib),
			  __alignof__(struct ipstats_mib)) < 0)
		goto err_ip;

	for_each_possible_cpu(i) {
		struct ipstats_mib *addrconf_stats;
		addrconf_stats = per_cpu_ptr(idev->stats.ipv6[0], i);
		u64_stats_init(&addrconf_stats->syncp);
#if SNMP_ARRAY_SZ == 2
		addrconf_stats = per_cpu_ptr(idev->stats.ipv6[1], i);
		u64_stats_init(&addrconf_stats->syncp);
#endif
	}


	idev->stats.icmpv6dev = kzalloc(sizeof(struct icmpv6_mib_device),
					GFP_KERNEL);
	if (!idev->stats.icmpv6dev)
		goto err_icmp;
	idev->stats.icmpv6msgdev = kzalloc(sizeof(struct icmpv6msg_mib_device),
					   GFP_KERNEL);
	if (!idev->stats.icmpv6msgdev)
		goto err_icmpmsg;

	return 0;

err_icmpmsg:
	kfree(idev->stats.icmpv6dev);
err_icmp:
	snmp_mib_free((void __percpu **)idev->stats.ipv6);
err_ip:
	return -ENOMEM;
}

static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
{
	struct inet6_dev *ndev;

	ASSERT_RTNL();

	if (dev->mtu < IPV6_MIN_MTU)
		return NULL;

	ndev = kzalloc(sizeof(struct inet6_dev), GFP_KERNEL);

	if (ndev == NULL)
		return NULL;

	rwlock_init(&ndev->lock);
	ndev->dev = dev;
	INIT_LIST_HEAD(&ndev->addr_list);
	setup_timer(&ndev->rs_timer, addrconf_rs_timer,
		    (unsigned long)ndev);
	memcpy(&ndev->cnf, dev_net(dev)->ipv6.devconf_dflt, sizeof(ndev->cnf));
	ndev->cnf.mtu6 = dev->mtu;
	ndev->cnf.sysctl = NULL;
	ndev->nd_parms = neigh_parms_alloc(dev, &nd_tbl);
	if (ndev->nd_parms == NULL) {
		kfree(ndev);
		return NULL;
	}
	if (ndev->cnf.forwarding)
		dev_disable_lro(dev);
	/* We refer to the device */
	dev_hold(dev);

	if (snmp6_alloc_dev(ndev) < 0) {
		ADBG(KERN_WARNING
			"%s: cannot allocate memory for statistics; dev=%s.\n",
			__func__, dev->name);
		neigh_parms_release(&nd_tbl, ndev->nd_parms);
		dev_put(dev);
		kfree(ndev);
		return NULL;
	}

	if (snmp6_register_dev(ndev) < 0) {
		ADBG(KERN_WARNING
			"%s: cannot create /proc/net/dev_snmp6/%s\n",
			__func__, dev->name);
		neigh_parms_release(&nd_tbl, ndev->nd_parms);
		ndev->dead = 1;
		in6_dev_finish_destroy(ndev);
		return NULL;
	}

	/* One reference from device.  We must do this before
	 * we invoke __ipv6_regen_rndid().
	 */
	in6_dev_hold(ndev);

	if (dev->flags & (IFF_NOARP | IFF_LOOPBACK))
		ndev->cnf.accept_dad = -1;

#if IS_ENABLED(CONFIG_IPV6_SIT)
	if (dev->type == ARPHRD_SIT && (dev->priv_flags & IFF_ISATAP)) {
		pr_info("%s: Disabled Multicast RS\n", dev->name);
		ndev->cnf.rtr_solicits = 0;
	}
#endif

	INIT_LIST_HEAD(&ndev->tempaddr_list);
	setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev);
	if ((dev->flags&IFF_LOOPBACK) ||
	    dev->type == ARPHRD_TUNNEL ||
	    dev->type == ARPHRD_TUNNEL6 ||
	    dev->type == ARPHRD_SIT ||
	    dev->type == ARPHRD_NONE) {
		ndev->cnf.use_tempaddr = -1;
	} else {
		in6_dev_hold(ndev);
		ipv6_regen_rndid((unsigned long) ndev);
	}

	ndev->token = in6addr_any;

	if (netif_running(dev) && addrconf_qdisc_ok(dev))
		ndev->if_flags |= IF_READY;

	ipv6_mc_init_dev(ndev);
	ndev->tstamp = jiffies;
	addrconf_sysctl_register(ndev);
	/* protected by rtnl_lock */
	rcu_assign_pointer(dev->ip6_ptr, ndev);

	/* Join interface-local all-node multicast group */
	ipv6_dev_mc_inc(dev, &in6addr_interfacelocal_allnodes);

	/* Join all-node multicast group */
	ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes);

	/* Join all-router multicast group if forwarding is set */
	if (ndev->cnf.forwarding && (dev->flags & IFF_MULTICAST))
		ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters);

	return ndev;
}

static struct inet6_dev *ipv6_find_idev(struct net_device *dev)
{
	struct inet6_dev *idev;

	ASSERT_RTNL();

	idev = __in6_dev_get(dev);
	if (!idev) {
		idev = ipv6_add_dev(dev);
		if (!idev)
			return NULL;
	}

	if (dev->flags&IFF_UP)
		ipv6_mc_up(idev);
	return idev;
}

static int inet6_netconf_msgsize_devconf(int type)
{
	int size =  NLMSG_ALIGN(sizeof(struct netconfmsg))
		    + nla_total_size(4);	/* NETCONFA_IFINDEX */

	/* type -1 is used for ALL */
	if (type == -1 || type == NETCONFA_FORWARDING)
		size += nla_total_size(4);
#ifdef CONFIG_IPV6_MROUTE
	if (type == -1 || type == NETCONFA_MC_FORWARDING)
		size += nla_total_size(4);
#endif
	if (type == -1 || type == NETCONFA_PROXY_NEIGH)
		size += nla_total_size(4);

	return size;
}

static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
				      struct ipv6_devconf *devconf, u32 portid,
				      u32 seq, int event, unsigned int flags,
				      int type)
{
	struct nlmsghdr  *nlh;
	struct netconfmsg *ncm;

	nlh = nlmsg_put(skb, portid, seq, event, sizeof(struct netconfmsg),
			flags);
	if (nlh == NULL)
		return -EMSGSIZE;

	ncm = nlmsg_data(nlh);
	ncm->ncm_family = AF_INET6;

	if (nla_put_s32(skb, NETCONFA_IFINDEX, ifindex) < 0)
		goto nla_put_failure;

	/* type -1 is used for ALL */
	if ((type == -1 || type == NETCONFA_FORWARDING) &&
	    nla_put_s32(skb, NETCONFA_FORWARDING, devconf->forwarding) < 0)
		goto nla_put_failure;
#ifdef CONFIG_IPV6_MROUTE
	if ((type == -1 || type == NETCONFA_MC_FORWARDING) &&
	    nla_put_s32(skb, NETCONFA_MC_FORWARDING,
			devconf->mc_forwarding) < 0)
		goto nla_put_failure;
#endif
	if ((type == -1 || type == NETCONFA_PROXY_NEIGH) &&
	    nla_put_s32(skb, NETCONFA_PROXY_NEIGH, devconf->proxy_ndp) < 0)
		goto nla_put_failure;

	return nlmsg_end(skb, nlh);

nla_put_failure:
	nlmsg_cancel(skb, nlh);
	return -EMSGSIZE;
}

void inet6_netconf_notify_devconf(struct net *net, int type, int ifindex,
				  struct ipv6_devconf *devconf)
{
	struct sk_buff *skb;
	int err = -ENOBUFS;

	skb = nlmsg_new(inet6_netconf_msgsize_devconf(type), GFP_ATOMIC);
	if (skb == NULL)
		goto errout;

	err = inet6_netconf_fill_devconf(skb, ifindex, devconf, 0, 0,
					 RTM_NEWNETCONF, 0, type);
	if (err < 0) {
		/* -EMSGSIZE implies BUG in inet6_netconf_msgsize_devconf() */
		WARN_ON(err == -EMSGSIZE);
		kfree_skb(skb);
		goto errout;
	}
	rtnl_notify(skb, net, 0, RTNLGRP_IPV6_NETCONF, NULL, GFP_ATOMIC);
	return;
errout:
	rtnl_set_sk_err(net, RTNLGRP_IPV6_NETCONF, err);
}

static const struct nla_policy devconf_ipv6_policy[NETCONFA_MAX+1] = {
	[NETCONFA_IFINDEX]	= { .len = sizeof(int) },
	[NETCONFA_FORWARDING]	= { .len = sizeof(int) },
	[NETCONFA_PROXY_NEIGH]	= { .len = sizeof(int) },
};

static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
				     struct nlmsghdr *nlh)
{
	struct net *net = sock_net(in_skb->sk);
	struct nlattr *tb[NETCONFA_MAX+1];
	struct netconfmsg *ncm;
	struct sk_buff *skb;
	struct ipv6_devconf *devconf;
	struct inet6_dev *in6_dev;
	struct net_device *dev;
	int ifindex;
	int err;

	err = nlmsg_parse(nlh, sizeof(*ncm), tb, NETCONFA_MAX,
			  devconf_ipv6_policy);
	if (err < 0)
		goto errout;

	err = EINVAL;
	if (!tb[NETCONFA_IFINDEX])
		goto errout;

	ifindex = nla_get_s32(tb[NETCONFA_IFINDEX]);
	switch (ifindex) {
	case NETCONFA_IFINDEX_ALL:
		devconf = net->ipv6.devconf_all;
		break;
	case NETCONFA_IFINDEX_DEFAULT:
		devconf = net->ipv6.devconf_dflt;
		break;
	default:
		dev = __dev_get_by_index(net, ifindex);
		if (dev == NULL)
			goto errout;
		in6_dev = __in6_dev_get(dev);
		if (in6_dev == NULL)
			goto errout;
		devconf = &in6_dev->cnf;
		break;
	}

	err = -ENOBUFS;
	skb = nlmsg_new(inet6_netconf_msgsize_devconf(-1), GFP_ATOMIC);
	if (skb == NULL)
		goto errout;

	err = inet6_netconf_fill_devconf(skb, ifindex, devconf,
					 NETLINK_CB(in_skb).portid,
					 nlh->nlmsg_seq, RTM_NEWNETCONF, 0,
					 -1);
	if (err < 0) {
		/* -EMSGSIZE implies BUG in inet6_netconf_msgsize_devconf() */
		WARN_ON(err == -EMSGSIZE);
		kfree_skb(skb);
		goto errout;
	}
	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
errout:
	return err;
}

static int inet6_netconf_dump_devconf(struct sk_buff *skb,
				      struct netlink_callback *cb)
{
	struct net *net = sock_net(skb->sk);
	int h, s_h;
	int idx, s_idx;
	struct net_device *dev;
	struct inet6_dev *idev;
	struct hlist_head *head;

	s_h = cb->args[0];
	s_idx = idx = cb->args[1];

	for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
		idx = 0;
		head = &net->dev_index_head[h];
		rcu_read_lock();
		cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
			  net->dev_base_seq;
		hlist_for_each_entry_rcu(dev, head, index_hlist) {
			if (idx < s_idx)
				goto cont;
			idev = __in6_dev_get(dev);
			if (!idev)
				goto cont;

			if (inet6_netconf_fill_devconf(skb, dev->ifindex,
						       &idev->cnf,
						       NETLINK_CB(cb->skb).portid,
						       cb->nlh->nlmsg_seq,
						       RTM_NEWNETCONF,
						       NLM_F_MULTI,
						       -1) <= 0) {
				rcu_read_unlock();
				goto done;
			}
			nl_dump_check_consistent(cb, nlmsg_hdr(skb));
cont:
			idx++;
		}
		rcu_read_unlock();
	}
	if (h == NETDEV_HASHENTRIES) {
		if (inet6_netconf_fill_devconf(skb, NETCONFA_IFINDEX_ALL,
					       net->ipv6.devconf_all,
					       NETLINK_CB(cb->skb).portid,
					       cb->nlh->nlmsg_seq,
					       RTM_NEWNETCONF, NLM_F_MULTI,
					       -1) <= 0)
			goto done;
		else
			h++;
	}
	if (h == NETDEV_HASHENTRIES + 1) {
		if (inet6_netconf_fill_devconf(skb, NETCONFA_IFINDEX_DEFAULT,
					       net->ipv6.devconf_dflt,
					       NETLINK_CB(cb->skb).portid,
					       cb->nlh->nlmsg_seq,
					       RTM_NEWNETCONF, NLM_F_MULTI,
					       -1) <= 0)
			goto done;
		else
			h++;
	}
done:
	cb->args[0] = h;
	cb->args[1] = idx;

	return skb->len;
}

#ifdef CONFIG_SYSCTL
static void dev_forward_change(struct inet6_dev *idev)
{
	struct net_device *dev;
	struct inet6_ifaddr *ifa;

	if (!idev)
		return;
	dev = idev->dev;
	if (idev->cnf.forwarding)
		dev_disable_lro(dev);
	if (dev->flags & IFF_MULTICAST) {
		if (idev->cnf.forwarding) {
			ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters);
			ipv6_dev_mc_inc(dev, &in6addr_interfacelocal_allrouters);
			ipv6_dev_mc_inc(dev, &in6addr_sitelocal_allrouters);
		} else {
			ipv6_dev_mc_dec(dev, &in6addr_linklocal_allrouters);
			ipv6_dev_mc_dec(dev, &in6addr_interfacelocal_allrouters);
			ipv6_dev_mc_dec(dev, &in6addr_sitelocal_allrouters);
		}
	}

	list_for_each_entry(ifa, &idev->addr_list, if_list) {
		if (ifa->flags&IFA_F_TENTATIVE)
			continue;
		if (idev->cnf.forwarding)
			addrconf_join_anycast(ifa);
		else
			addrconf_leave_anycast(ifa);
	}
	inet6_netconf_notify_devconf(dev_net(dev), NETCONFA_FORWARDING,
				     dev->ifindex, &idev->cnf);
}


static void addrconf_forward_change(struct net *net, __s32 newf)
{
	struct net_device *dev;
	struct inet6_dev *idev;

	for_each_netdev(net, dev) {
		idev = __in6_dev_get(dev);
		if (idev) {
			int changed = (!idev->cnf.forwarding) ^ (!newf);
			idev->cnf.forwarding = newf;
			if (changed)
				dev_forward_change(idev);
		}
	}
}

static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int newf)
{
	struct net *net;
	int old;

	if (!rtnl_trylock())
		return restart_syscall();

	net = (struct net *)table->extra2;
	old = *p;
	*p = newf;

	if (p == &net->ipv6.devconf_dflt->forwarding) {
		if ((!newf) ^ (!old))
			inet6_netconf_notify_devconf(net, NETCONFA_FORWARDING,
						     NETCONFA_IFINDEX_DEFAULT,
						     net->ipv6.devconf_dflt);
		rtnl_unlock();
		return 0;
	}

	if (p == &net->ipv6.devconf_all->forwarding) {
		net->ipv6.devconf_dflt->forwarding = newf;
		addrconf_forward_change(net, newf);
		if ((!newf) ^ (!old))
			inet6_netconf_notify_devconf(net, NETCONFA_FORWARDING,
						     NETCONFA_IFINDEX_ALL,
						     net->ipv6.devconf_all);
	} else if ((!newf) ^ (!old))
		dev_forward_change((struct inet6_dev *)table->extra1);
	rtnl_unlock();

	if (newf)
		rt6_purge_dflt_routers(net);
	return 1;
}
#endif

/* Nobody refers to this ifaddr, destroy it */
void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp)
{
	WARN_ON(!hlist_unhashed(&ifp->addr_lst));

#ifdef NET_REFCNT_DEBUG
	pr_debug("%s\n", __func__);
#endif

	in6_dev_put(ifp->idev);

	if (del_timer(&ifp->dad_timer))
		pr_notice("Timer is still running, when freeing ifa=%p\n", ifp);

	if (ifp->state != INET6_IFADDR_STATE_DEAD) {
		pr_warn("Freeing alive inet6 address %p\n", ifp);
		return;
	}
	ip6_rt_put(ifp->rt);

	kfree_rcu(ifp, rcu);
}

static void
ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
{
	struct list_head *p;
	int ifp_scope = ipv6_addr_src_scope(&ifp->addr);

	/*
	 * Each device address list is sorted in order of scope -
	 * global before linklocal.
	 */
	list_for_each(p, &idev->addr_list) {
		struct inet6_ifaddr *ifa
			= list_entry(p, struct inet6_ifaddr, if_list);
		if (ifp_scope >= ipv6_addr_src_scope(&ifa->addr))
			break;
	}

	list_add_tail(&ifp->if_list, p);
}

static u32 inet6_addr_hash(const struct in6_addr *addr)
{
	return hash_32(ipv6_addr_hash(addr), IN6_ADDR_HSIZE_SHIFT);
}

/* On success it returns ifp with increased reference count */

static struct inet6_ifaddr *
ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
	      const struct in6_addr *peer_addr, int pfxlen,
	      int scope, u32 flags, u32 valid_lft, u32 prefered_lft)
{
	struct inet6_ifaddr *ifa = NULL;
	struct rt6_info *rt;
	unsigned int hash;
	int err = 0;
	int addr_type = ipv6_addr_type(addr);

	if (addr_type == IPV6_ADDR_ANY ||
	    addr_type & IPV6_ADDR_MULTICAST ||
	    (!(idev->dev->flags & IFF_LOOPBACK) &&
	     addr_type & IPV6_ADDR_LOOPBACK))
		return ERR_PTR(-EADDRNOTAVAIL);

	rcu_read_lock_bh();
	if (idev->dead) {
		err = -ENODEV;			/*XXX*/
		goto out2;
	}

	if (idev->cnf.disable_ipv6) {
		err = -EACCES;
		goto out2;
	}

	spin_lock(&addrconf_hash_lock);

	/* Ignore adding duplicate addresses on an interface */
	if (ipv6_chk_same_addr(dev_net(idev->dev), addr, idev->dev)) {
		ADBG("ipv6_add_addr: already assigned\n");
		err = -EEXIST;
		goto out;
	}

	ifa = kzalloc(sizeof(struct inet6_ifaddr), GFP_ATOMIC);

	if (ifa == NULL) {
		ADBG("ipv6_add_addr: malloc failed\n");
		err = -ENOBUFS;
		goto out;
	}

	rt = addrconf_dst_alloc(idev, addr, false);
	if (IS_ERR(rt)) {
		err = PTR_ERR(rt);
		goto out;
	}

	neigh_parms_data_state_setall(idev->nd_parms);

	ifa->addr = *addr;
	if (peer_addr)
		ifa->peer_addr = *peer_addr;

	spin_lock_init(&ifa->lock);
	spin_lock_init(&ifa->state_lock);
	setup_timer(&ifa->dad_timer, addrconf_dad_timer,
		    (unsigned long)ifa);
	INIT_HLIST_NODE(&ifa->addr_lst);
	ifa->scope = scope;
	ifa->prefix_len = pfxlen;
	ifa->flags = flags | IFA_F_TENTATIVE;
	ifa->valid_lft = valid_lft;
	ifa->prefered_lft = prefered_lft;
	ifa->cstamp = ifa->tstamp = jiffies;
	ifa->tokenized = false;

	ifa->rt = rt;

	ifa->idev = idev;
	in6_dev_hold(idev);
	/* For caller */
	in6_ifa_hold(ifa);

	/* Add to big hash table */
	hash = inet6_addr_hash(addr);

	hlist_add_head_rcu(&ifa->addr_lst, &inet6_addr_lst[hash]);
	spin_unlock(&addrconf_hash_lock);

	write_lock(&idev->lock);
	/* Add to inet6_dev unicast addr list. */
	ipv6_link_dev_addr(idev, ifa);

	if (ifa->flags&IFA_F_TEMPORARY) {
		list_add(&ifa->tmp_list, &idev->tempaddr_list);
		in6_ifa_hold(ifa);
	}

	in6_ifa_hold(ifa);
	write_unlock(&idev->lock);
out2:
	rcu_read_unlock_bh();

	if (likely(err == 0))
		inet6addr_notifier_call_chain(NETDEV_UP, ifa);
	else {
		kfree(ifa);
		ifa = ERR_PTR(err);
	}

	return ifa;
out:
	spin_unlock(&addrconf_hash_lock);
	goto out2;
}

enum cleanup_prefix_rt_t {
	CLEANUP_PREFIX_RT_NOP,    /* no cleanup action for prefix route */
	CLEANUP_PREFIX_RT_DEL,    /* delete the prefix route */
	CLEANUP_PREFIX_RT_EXPIRE, /* update the lifetime of the prefix route */
};

/*
 * Check, whether the prefix for ifp would still need a prefix route
 * after deleting ifp. The function returns one of the CLEANUP_PREFIX_RT_*
 * constants.
 *
 * 1) we don't purge prefix if address was not permanent.
 *    prefix is managed by its own lifetime.
 * 2) we also don't purge, if the address was IFA_F_NOPREFIXROUTE.
 * 3) if there are no addresses, delete prefix.
 * 4) if there are still other permanent address(es),
 *    corresponding prefix is still permanent.
 * 5) if there are still other addresses with IFA_F_NOPREFIXROUTE,
 *    don't purge the prefix, assume user space is managing it.
 * 6) otherwise, update prefix lifetime to the
 *    longest valid lifetime among the corresponding
 *    addresses on the device.
 *    Note: subsequent RA will update lifetime.
 **/
static enum cleanup_prefix_rt_t
check_cleanup_prefix_route(struct inet6_ifaddr *ifp, unsigned long *expires)
{
	struct inet6_ifaddr *ifa;
	struct inet6_dev *idev = ifp->idev;
	unsigned long lifetime;
	enum cleanup_prefix_rt_t action = CLEANUP_PREFIX_RT_DEL;

	*expires = jiffies;

	list_for_each_entry(ifa, &idev->addr_list, if_list) {
		if (ifa == ifp)
			continue;
		if (!ipv6_prefix_equal(&ifa->addr, &ifp->addr,
				       ifp->prefix_len))
			continue;
		if (ifa->flags & (IFA_F_PERMANENT | IFA_F_NOPREFIXROUTE))
			return CLEANUP_PREFIX_RT_NOP;

		action = CLEANUP_PREFIX_RT_EXPIRE;

		spin_lock(&ifa->lock);

		lifetime = addrconf_timeout_fixup(ifa->valid_lft, HZ);
		/*
		 * Note: Because this address is
		 * not permanent, lifetime <
		 * LONG_MAX / HZ here.
		 */
		if (time_before(*expires, ifa->tstamp + lifetime * HZ))
			*expires = ifa->tstamp + lifetime * HZ;
		spin_unlock(&ifa->lock);
	}

	return action;
}

static void
cleanup_prefix_route(struct inet6_ifaddr *ifp, unsigned long expires, bool del_rt)
{
	struct rt6_info *rt;

	rt = addrconf_get_prefix_route(&ifp->addr,
				       ifp->prefix_len,
				       ifp->idev->dev,
				       0, RTF_GATEWAY | RTF_DEFAULT);
	if (rt) {
		if (del_rt)
			ip6_del_rt(rt);
		else {
			if (!(rt->rt6i_flags & RTF_EXPIRES))
				rt6_set_expires(rt, expires);
			ip6_rt_put(rt);
		}
	}
}


/* This function wants to get referenced ifp and releases it before return */

static void ipv6_del_addr(struct inet6_ifaddr *ifp)
{
	int state;
	enum cleanup_prefix_rt_t action = CLEANUP_PREFIX_RT_NOP;
	unsigned long expires;

	spin_lock_bh(&ifp->state_lock);
	state = ifp->state;
	ifp->state = INET6_IFADDR_STATE_DEAD;
	spin_unlock_bh(&ifp->state_lock);

	if (state == INET6_IFADDR_STATE_DEAD)
		goto out;

	spin_lock_bh(&addrconf_hash_lock);
	hlist_del_init_rcu(&ifp->addr_lst);
	spin_unlock_bh(&addrconf_hash_lock);

	write_lock_bh(&ifp->idev->lock);

	if (ifp->flags&IFA_F_TEMPORARY) {
		list_del(&ifp->tmp_list);
		if (ifp->ifpub) {
			in6_ifa_put(ifp->ifpub);
			ifp->ifpub = NULL;
		}
		__in6_ifa_put(ifp);
	}

	if (ifp->flags & IFA_F_PERMANENT && !(ifp->flags & IFA_F_NOPREFIXROUTE))
		action = check_cleanup_prefix_route(ifp, &expires);

	list_del_init(&ifp->if_list);
	__in6_ifa_put(ifp);

	write_unlock_bh(&ifp->idev->lock);

	addrconf_del_dad_timer(ifp);

	ipv6_ifa_notify(RTM_DELADDR, ifp);

	inet6addr_notifier_call_chain(NETDEV_DOWN, ifp);

	if (action != CLEANUP_PREFIX_RT_NOP) {
		cleanup_prefix_route(ifp, expires,
			action == CLEANUP_PREFIX_RT_DEL);
	}

	/* clean up prefsrc entries */
	rt6_remove_prefsrc(ifp);
out:
	in6_ifa_put(ifp);
}

static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *ift)
{
	struct inet6_dev *idev = ifp->idev;
	struct in6_addr addr, *tmpaddr;
	unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_tstamp, age;
	unsigned long regen_advance;
	int tmp_plen;
	int ret = 0;
	u32 addr_flags;
	unsigned long now = jiffies;

	write_lock_bh(&idev->lock);
	if (ift) {
		spin_lock_bh(&ift->lock);
		memcpy(&addr.s6_addr[8], &ift->addr.s6_addr[8], 8);
		spin_unlock_bh(&ift->lock);
		tmpaddr = &addr;
	} else {
		tmpaddr = NULL;
	}
retry:
	in6_dev_hold(idev);
	if (idev->cnf.use_tempaddr <= 0) {
		write_unlock_bh(&idev->lock);
		pr_info("%s: use_tempaddr is disabled\n", __func__);
		in6_dev_put(idev);
		ret = -1;
		goto out;
	}
	spin_lock_bh(&ifp->lock);
	if (ifp->regen_count++ >= idev->cnf.regen_max_retry) {
		idev->cnf.use_tempaddr = -1;	/*XXX*/
		spin_unlock_bh(&ifp->lock);
		write_unlock_bh(&idev->lock);
		pr_warn("%s: regeneration time exceeded - disabled temporary address support\n",
			__func__);
		in6_dev_put(idev);
		ret = -1;
		goto out;
	}
	in6_ifa_hold(ifp);
	memcpy(addr.s6_addr, ifp->addr.s6_addr, 8);
	__ipv6_try_regen_rndid(idev, tmpaddr);
	memcpy(&addr.s6_addr[8], idev->rndid, 8);
	age = (now - ifp->tstamp) / HZ;
	tmp_valid_lft = min_t(__u32,
			      ifp->valid_lft,
			      idev->cnf.temp_valid_lft + age);
	tmp_prefered_lft = min_t(__u32,
				 ifp->prefered_lft,
				 idev->cnf.temp_prefered_lft + age -
				 idev->cnf.max_desync_factor);
	tmp_plen = ifp->prefix_len;
	tmp_tstamp = ifp->tstamp;
	spin_unlock_bh(&ifp->lock);

	regen_advance = idev->cnf.regen_max_retry *
	                idev->cnf.dad_transmits *
	                NEIGH_VAR(idev->nd_parms, RETRANS_TIME) / HZ;
	write_unlock_bh(&idev->lock);

	/* A temporary address is created only if this calculated Preferred
	 * Lifetime is greater than REGEN_ADVANCE time units.  In particular,
	 * an implementation must not create a temporary address with a zero
	 * Preferred Lifetime.
	 * Use age calculation as in addrconf_verify to avoid unnecessary
	 * temporary addresses being generated.
	 */
	age = (now - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
	if (tmp_prefered_lft <= regen_advance + age) {
		in6_ifa_put(ifp);
		in6_dev_put(idev);
		ret = -1;
		goto out;
	}

	addr_flags = IFA_F_TEMPORARY;
	/* set in addrconf_prefix_rcv() */
	if (ifp->flags & IFA_F_OPTIMISTIC)
		addr_flags |= IFA_F_OPTIMISTIC;

	ift = ipv6_add_addr(idev, &addr, NULL, tmp_plen,
			    ipv6_addr_scope(&addr), addr_flags,
			    tmp_valid_lft, tmp_prefered_lft);
	if (IS_ERR(ift)) {
		in6_ifa_put(ifp);
		in6_dev_put(idev);
		pr_info("%s: retry temporary address regeneration\n", __func__);
		tmpaddr = &addr;
		write_lock_bh(&idev->lock);
		goto retry;
	}

	spin_lock_bh(&ift->lock);
	ift->ifpub = ifp;
	ift->cstamp = now;
	ift->tstamp = tmp_tstamp;
	spin_unlock_bh(&ift->lock);

	addrconf_dad_start(ift);
	in6_ifa_put(ift);
	in6_dev_put(idev);
out:
	return ret;
}

/*
 *	Choose an appropriate source address (RFC3484)
 */
enum {
	IPV6_SADDR_RULE_INIT = 0,
	IPV6_SADDR_RULE_LOCAL,
	IPV6_SADDR_RULE_SCOPE,
	IPV6_SADDR_RULE_PREFERRED,
#ifdef CONFIG_IPV6_MIP6
	IPV6_SADDR_RULE_HOA,
#endif
	IPV6_SADDR_RULE_OIF,
	IPV6_SADDR_RULE_LABEL,
	IPV6_SADDR_RULE_PRIVACY,
	IPV6_SADDR_RULE_ORCHID,
	IPV6_SADDR_RULE_PREFIX,
	IPV6_SADDR_RULE_MAX
};

struct ipv6_saddr_score {
	int			rule;
	int			addr_type;
	struct inet6_ifaddr	*ifa;
	DECLARE_BITMAP(scorebits, IPV6_SADDR_RULE_MAX);
	int			scopedist;
	int			matchlen;
};

struct ipv6_saddr_dst {
	const struct in6_addr *addr;
	int ifindex;
	int scope;
	int label;
	unsigned int prefs;
};

static inline int ipv6_saddr_preferred(int type)
{
	if (type & (IPV6_ADDR_MAPPED|IPV6_ADDR_COMPATv4|IPV6_ADDR_LOOPBACK))
		return 1;
	return 0;
}

static int ipv6_get_saddr_eval(struct net *net,
			       struct ipv6_saddr_score *score,
			       struct ipv6_saddr_dst *dst,
			       int i)
{
	int ret;

	if (i <= score->rule) {
		switch (i) {
		case IPV6_SADDR_RULE_SCOPE:
			ret = score->scopedist;
			break;
		case IPV6_SADDR_RULE_PREFIX:
			ret = score->matchlen;
			break;
		default:
			ret = !!test_bit(i, score->scorebits);
		}
		goto out;
	}

	switch (i) {
	case IPV6_SADDR_RULE_INIT:
		/* Rule 0: remember if hiscore is not ready yet */
		ret = !!score->ifa;
		break;
	case IPV6_SADDR_RULE_LOCAL:
		/* Rule 1: Prefer same address */
		ret = ipv6_addr_equal(&score->ifa->addr, dst->addr);
		break;
	case IPV6_SADDR_RULE_SCOPE:
		/* Rule 2: Prefer appropriate scope
		 *
		 *      ret
		 *       ^
		 *    -1 |  d 15
		 *    ---+--+-+---> scope
		 *       |
		 *       |             d is scope of the destination.
		 *  B-d  |  \
		 *       |   \      <- smaller scope is better if
		 *  B-15 |    \        if scope is enough for destination.
		 *       |             ret = B - scope (-1 <= scope >= d <= 15).
		 * d-C-1 | /
		 *       |/         <- greater is better
		 *   -C  /             if scope is not enough for destination.
		 *      /|             ret = scope - C (-1 <= d < scope <= 15).
		 *
		 * d - C - 1 < B -15 (for all -1 <= d <= 15).
		 * C > d + 14 - B >= 15 + 14 - B = 29 - B.
		 * Assume B = 0 and we get C > 29.
		 */
		ret = __ipv6_addr_src_scope(score->addr_type);
		if (ret >= dst->scope)
			ret = -ret;
		else
			ret -= 128;	/* 30 is enough */
		score->scopedist = ret;
		break;
	case IPV6_SADDR_RULE_PREFERRED:
		/* Rule 3: Avoid deprecated and optimistic addresses */
		ret = ipv6_saddr_preferred(score->addr_type) ||
		      !(score->ifa->flags & (IFA_F_DEPRECATED|IFA_F_OPTIMISTIC));
		break;
#ifdef CONFIG_IPV6_MIP6
	case IPV6_SADDR_RULE_HOA:
	    {
		/* Rule 4: Prefer home address */
		int prefhome = !(dst->prefs & IPV6_PREFER_SRC_COA);
		ret = !(score->ifa->flags & IFA_F_HOMEADDRESS) ^ prefhome;
		break;
	    }
#endif
	case IPV6_SADDR_RULE_OIF:
		/* Rule 5: Prefer outgoing interface */
		ret = (!dst->ifindex ||
		       dst->ifindex == score->ifa->idev->dev->ifindex);
		break;
	case IPV6_SADDR_RULE_LABEL:
		/* Rule 6: Prefer matching label */
		ret = ipv6_addr_label(net,
				      &score->ifa->addr, score->addr_type,
				      score->ifa->idev->dev->ifindex) == dst->label;
		break;
	case IPV6_SADDR_RULE_PRIVACY:
	    {
		/* Rule 7: Prefer public address
		 * Note: prefer temporary address if use_tempaddr >= 2
		 */
		int preftmp = dst->prefs & (IPV6_PREFER_SRC_PUBLIC|IPV6_PREFER_SRC_TMP) ?
				!!(dst->prefs & IPV6_PREFER_SRC_TMP) :
				score->ifa->idev->cnf.use_tempaddr >= 2;
		ret = (!(score->ifa->flags & IFA_F_TEMPORARY)) ^ preftmp;
		break;
	    }
	case IPV6_SADDR_RULE_ORCHID:
		/* Rule 8-: Prefer ORCHID vs ORCHID or
		 *	    non-ORCHID vs non-ORCHID
		 */
		ret = !(ipv6_addr_orchid(&score->ifa->addr) ^
			ipv6_addr_orchid(dst->addr));
		break;
	case IPV6_SADDR_RULE_PREFIX:
		/* Rule 8: Use longest matching prefix */
		ret = ipv6_addr_diff(&score->ifa->addr, dst->addr);
		if (ret > score->ifa->prefix_len)
			ret = score->ifa->prefix_len;
		score->matchlen = ret;
		break;
	default:
		ret = 0;
	}

	if (ret)
		__set_bit(i, score->scorebits);
	score->rule = i;
out:
	return ret;
}

int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
		       const struct in6_addr *daddr, unsigned int prefs,
		       struct in6_addr *saddr)
{
	struct ipv6_saddr_score scores[2],
				*score = &scores[0], *hiscore = &scores[1];
	struct ipv6_saddr_dst dst;
	struct net_device *dev;
	int dst_type;

	dst_type = __ipv6_addr_type(daddr);
	dst.addr = daddr;
	dst.ifindex = dst_dev ? dst_dev->ifindex : 0;
	dst.scope = __ipv6_addr_src_scope(dst_type);
	dst.label = ipv6_addr_label(net, daddr, dst_type, dst.ifindex);
	dst.prefs = prefs;

	hiscore->rule = -1;
	hiscore->ifa = NULL;

	rcu_read_lock();

	for_each_netdev_rcu(net, dev) {
		struct inet6_dev *idev;

		/* Candidate Source Address (section 4)
		 *  - multicast and link-local destination address,
		 *    the set of candidate source address MUST only
		 *    include addresses assigned to interfaces
		 *    belonging to the same link as the outgoing
		 *    interface.
		 * (- For site-local destination addresses, the
		 *    set of candidate source addresses MUST only
		 *    include addresses assigned to interfaces
		 *    belonging to the same site as the outgoing
		 *    interface.)
		 */
		if (((dst_type & IPV6_ADDR_MULTICAST) ||
		     dst.scope <= IPV6_ADDR_SCOPE_LINKLOCAL) &&
		    dst.ifindex && dev->ifindex != dst.ifindex)
			continue;

		idev = __in6_dev_get(dev);
		if (!idev)
			continue;

		read_lock_bh(&idev->lock);
		list_for_each_entry(score->ifa, &idev->addr_list, if_list) {
			int i;

			/*
			 * - Tentative Address (RFC2462 section 5.4)
			 *  - A tentative address is not considered
			 *    "assigned to an interface" in the traditional
			 *    sense, unless it is also flagged as optimistic.
			 * - Candidate Source Address (section 4)
			 *  - In any case, anycast addresses, multicast
			 *    addresses, and the unspecified address MUST
			 *    NOT be included in a candidate set.
			 */
			if ((score->ifa->flags & IFA_F_TENTATIVE) &&
			    (!(score->ifa->flags & IFA_F_OPTIMISTIC)))
				continue;

			score->addr_type = __ipv6_addr_type(&score->ifa->addr);

			if (unlikely(score->addr_type == IPV6_ADDR_ANY ||
				     score->addr_type & IPV6_ADDR_MULTICAST)) {
				LIMIT_NETDEBUG(KERN_DEBUG
					       "ADDRCONF: unspecified / multicast address "
					       "assigned as unicast address on %s",
					       dev->name);
				continue;
			}

			score->rule = -1;
			bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);

			for (i = 0; i < IPV6_SADDR_RULE_MAX; i++) {
				int minihiscore, miniscore;

				minihiscore = ipv6_get_saddr_eval(net, hiscore, &dst, i);
				miniscore = ipv6_get_saddr_eval(net, score, &dst, i);

				if (minihiscore > miniscore) {
					if (i == IPV6_SADDR_RULE_SCOPE &&
					    score->scopedist > 0) {
						/*
						 * special case:
						 * each remaining entry
						 * has too small (not enough)
						 * scope, because ifa entries
						 * are sorted by their scope
						 * values.
						 */
						goto try_nextdev;
					}
					break;
				} else if (minihiscore < miniscore) {
					if (hiscore->ifa)
						in6_ifa_put(hiscore->ifa);

					in6_ifa_hold(score->ifa);

					swap(hiscore, score);

					/* restore our iterator */
					score->ifa = hiscore->ifa;

					break;
				}
			}
		}
try_nextdev:
		read_unlock_bh(&idev->lock);
	}
	rcu_read_unlock();

	if (!hiscore->ifa)
		return -EADDRNOTAVAIL;

	*saddr = hiscore->ifa->addr;
	in6_ifa_put(hiscore->ifa);
	return 0;
}
EXPORT_SYMBOL(ipv6_dev_get_saddr);

int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
		      u32 banned_flags)
{
	struct inet6_ifaddr *ifp;
	int err = -EADDRNOTAVAIL;

	list_for_each_entry_reverse(ifp, &idev->addr_list, if_list) {
		if (ifp->scope > IFA_LINK)
			break;
		if (ifp->scope == IFA_LINK &&
		    !(ifp->flags & banned_flags)) {
			*addr = ifp->addr;
			err = 0;
			break;
		}
	}
	return err;
}

int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *addr,
		    u32 banned_flags)
{
	struct inet6_dev *idev;
	int err = -EADDRNOTAVAIL;

	rcu_read_lock();
	idev = __in6_dev_get(dev);
	if (idev) {
		read_lock_bh(&idev->lock);
		err = __ipv6_get_lladdr(idev, addr, banned_flags);
		read_unlock_bh(&idev->lock);
	}
	rcu_read_unlock();
	return err;
}

static int ipv6_count_addresses(struct inet6_dev *idev)
{
	int cnt = 0;
	struct inet6_ifaddr *ifp;

	read_lock_bh(&idev->lock);
	list_for_each_entry(ifp, &idev->addr_list, if_list)
		cnt++;
	read_unlock_bh(&idev->lock);
	return cnt;
}

int ipv6_chk_addr(struct net *net, const struct in6_addr *addr,
		  const struct net_device *dev, int strict)
{
	struct inet6_ifaddr *ifp;
	unsigned int hash = inet6_addr_hash(addr);

	rcu_read_lock_bh();
	hlist_for_each_entry_rcu(ifp, &inet6_addr_lst[hash], addr_lst) {
		if (!net_eq(dev_net(ifp->idev->dev), net))
			continue;
		if (ipv6_addr_equal(&ifp->addr, addr) &&
		    !(ifp->flags&IFA_F_TENTATIVE) &&
		    (dev == NULL || ifp->idev->dev == dev ||
		     !(ifp->scope&(IFA_LINK|IFA_HOST) || strict))) {
			rcu_read_unlock_bh();
			return 1;
		}
	}

	rcu_read_unlock_bh();
	return 0;
}
EXPORT_SYMBOL(ipv6_chk_addr);

static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
			       struct net_device *dev)
{
	unsigned int hash = inet6_addr_hash(addr);
	struct inet6_ifaddr *ifp;

	hlist_for_each_entry(ifp, &inet6_addr_lst[hash], addr_lst) {
		if (!net_eq(dev_net(ifp->idev->dev), net))
			continue;
		if (ipv6_addr_equal(&ifp->addr, addr)) {
			if (dev == NULL || ifp->idev->dev == dev)
				return true;
		}
	}
	return false;
}

/* Compares an address/prefix_len with addresses on device @dev.
 * If one is found it returns true.
 */
bool ipv6_chk_custom_prefix(const struct in6_addr *addr,
	const unsigned int prefix_len, struct net_device *dev)
{
	struct inet6_dev *idev;
	struct inet6_ifaddr *ifa;
	bool ret = false;

	rcu_read_lock();
	idev = __in6_dev_get(dev);
	if (idev) {
		read_lock_bh(&idev->lock);
		list_for_each_entry(ifa, &idev->addr_list, if_list) {
			ret = ipv6_prefix_equal(addr, &ifa->addr, prefix_len);
			if (ret)
				break;
		}
		read_unlock_bh(&idev->lock);
	}
	rcu_read_unlock();

	return ret;
}
EXPORT_SYMBOL(ipv6_chk_custom_prefix);

int ipv6_chk_prefix(const struct in6_addr *addr, struct net_device *dev)
{
	struct inet6_dev *idev;
	struct inet6_ifaddr *ifa;
	int	onlink;

	onlink = 0;
	rcu_read_lock();
	idev = __in6_dev_get(dev);
	if (idev) {
		read_lock_bh(&idev->lock);
		list_for_each_entry(ifa, &idev->addr_list, if_list) {
			onlink = ipv6_prefix_equal(addr, &ifa->addr,
						   ifa->prefix_len);
			if (onlink)
				break;
		}
		read_unlock_bh(&idev->lock);
	}
	rcu_read_unlock();
	return onlink;
}
EXPORT_SYMBOL(ipv6_chk_prefix);

struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *addr,
				     struct net_device *dev, int strict)
{
	struct inet6_ifaddr *ifp, *result = NULL;
	unsigned int hash = inet6_addr_hash(addr);

	rcu_read_lock_bh();
	hlist_for_each_entry_rcu_bh(ifp, &inet6_addr_lst[hash], addr_lst) {
		if (!net_eq(dev_net(ifp->idev->dev), net))
			continue;
		if (ipv6_addr_equal(&ifp->addr, addr)) {
			if (dev == NULL || ifp->idev->dev == dev ||
			    !(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) {
				result = ifp;
				in6_ifa_hold(ifp);
				break;
			}
		}
	}
	rcu_read_unlock_bh();

	return result;
}

/* Gets referenced address, destroys ifaddr */

static void addrconf_dad_stop(struct inet6_ifaddr *ifp, int dad_failed)
{
	if (ifp->flags&IFA_F_PERMANENT) {
		spin_lock_bh(&ifp->lock);
		addrconf_del_dad_timer(ifp);
		ifp->flags |= IFA_F_TENTATIVE;
		if (dad_failed)
			ifp->flags |= IFA_F_DADFAILED;
		spin_unlock_bh(&ifp->lock);
		if (dad_failed)
			ipv6_ifa_notify(0, ifp);
		in6_ifa_put(ifp);
	} else if (ifp->flags&IFA_F_TEMPORARY) {
		struct inet6_ifaddr *ifpub;
		spin_lock_bh(&ifp->lock);
		ifpub = ifp->ifpub;
		if (ifpub) {
			in6_ifa_hold(ifpub);
			spin_unlock_bh(&ifp->lock);
			ipv6_create_tempaddr(ifpub, ifp);
			in6_ifa_put(ifpub);
		} else {
			spin_unlock_bh(&ifp->lock);
		}
		ipv6_del_addr(ifp);
	} else
		ipv6_del_addr(ifp);
}

static int addrconf_dad_end(struct inet6_ifaddr *ifp)
{
	int err = -ENOENT;

	spin_lock(&ifp->state_lock);
	if (ifp->state == INET6_IFADDR_STATE_DAD) {
		ifp->state = INET6_IFADDR_STATE_POSTDAD;
		err = 0;
	}
	spin_unlock(&ifp->state_lock);

	return err;
}

void addrconf_dad_failure(struct inet6_ifaddr *ifp)
{
	struct inet6_dev *idev = ifp->idev;

	if (addrconf_dad_end(ifp)) {
		in6_ifa_put(ifp);
		return;
	}

	net_info_ratelimited("%s: IPv6 duplicate address %pI6c detected!\n",
			     ifp->idev->dev->name, &ifp->addr);

	if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) {
		struct in6_addr addr;

		addr.s6_addr32[0] = htonl(0xfe800000);
		addr.s6_addr32[1] = 0;

		if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) &&
		    ipv6_addr_equal(&ifp->addr, &addr)) {
			/* DAD failed for link-local based on MAC address */
			idev->cnf.disable_ipv6 = 1;

			pr_info("%s: IPv6 being disabled!\n",
				ifp->idev->dev->name);
		}
	}

	addrconf_dad_stop(ifp, 1);
}

/* Join to solicited addr multicast group. */

void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr)
{
	struct in6_addr maddr;

	if (dev->flags&(IFF_LOOPBACK|IFF_NOARP))
		return;

	addrconf_addr_solict_mult(addr, &maddr);
	ipv6_dev_mc_inc(dev, &maddr);
}

void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr)
{
	struct in6_addr maddr;

	if (idev->dev->flags&(IFF_LOOPBACK|IFF_NOARP))
		return;

	addrconf_addr_solict_mult(addr, &maddr);
	__ipv6_dev_mc_dec(idev, &maddr);
}

static void addrconf_join_anycast(struct inet6_ifaddr *ifp)
{
	struct in6_addr addr;
	if (ifp->prefix_len >= 127) /* RFC 6164 */
		return;
	ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
	if (ipv6_addr_any(&addr))
		return;
	ipv6_dev_ac_inc(ifp->idev->dev, &addr);
}

static void addrconf_leave_anycast(struct inet6_ifaddr *ifp)
{
	struct in6_addr addr;
	if (ifp->prefix_len >= 127) /* RFC 6164 */
		return;
	ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
	if (ipv6_addr_any(&addr))
		return;
	__ipv6_dev_ac_dec(ifp->idev, &addr);
}

static int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
{
	if (dev->addr_len != ETH_ALEN)
		return -1;
	memcpy(eui, dev->dev_addr, 3);
	memcpy(eui + 5, dev->dev_addr + 3, 3);

	/*
	 * The zSeries OSA network cards can be shared among various
	 * OS instances, but the OSA cards have only one MAC address.
	 * This leads to duplicate address conflicts in conjunction
	 * with IPv6 if more than one instance uses the same card.
	 *
	 * The driver for these cards can deliver a unique 16-bit
	 * identifier for each instance sharing the same card.  It is
	 * placed instead of 0xFFFE in the interface identifier.  The
	 * "u" bit of the interface identifier is not inverted in this
	 * case.  Hence the resulting interface identifier has local
	 * scope according to RFC2373.
	 */
	if (dev->dev_id) {
		eui[3] = (dev->dev_id >> 8) & 0xFF;
		eui[4] = dev->dev_id & 0xFF;
	} else {
		eui[3] = 0xFF;
		eui[4] = 0xFE;
		eui[0] ^= 2;
	}
	return 0;
}

static int addrconf_ifid_eui64(u8 *eui, struct net_device *dev)
{
	if (dev->addr_len != IEEE802154_ADDR_LEN)
		return -1;
	memcpy(eui, dev->dev_addr, 8);
	eui[0] ^= 2;
	return 0;
}

static int addrconf_ifid_ieee1394(u8 *eui, struct net_device *dev)
{
	union fwnet_hwaddr *ha;

	if (dev->addr_len != FWNET_ALEN)
		return -1;

	ha = (union fwnet_hwaddr *)dev->dev_addr;

	memcpy(eui, &ha->uc.uniq_id, sizeof(ha->uc.uniq_id));
	eui[0] ^= 2;
	return 0;
}

static int addrconf_ifid_arcnet(u8 *eui, struct net_device *dev)
{
	/* XXX: inherit EUI-64 from other interface -- yoshfuji */
	if (dev->addr_len != ARCNET_ALEN)
		return -1;
	memset(eui, 0, 7);
	eui[7] = *(u8 *)dev->dev_addr;
	return 0;
}

static int addrconf_ifid_infiniband(u8 *eui, struct net_device *dev)
{
	if (dev->addr_len != INFINIBAND_ALEN)
		return -1;
	memcpy(eui, dev->dev_addr + 12, 8);
	eui[0] |= 2;
	return 0;
}

static int __ipv6_isatap_ifid(u8 *eui, __be32 addr)
{
	if (addr == 0)
		return -1;
	eui[0] = (ipv4_is_zeronet(addr) || ipv4_is_private_10(addr) ||
		  ipv4_is_loopback(addr) || ipv4_is_linklocal_169(addr) ||
		  ipv4_is_private_172(addr) || ipv4_is_test_192(addr) ||
		  ipv4_is_anycast_6to4(addr) || ipv4_is_private_192(addr) ||
		  ipv4_is_test_198(addr) || ipv4_is_multicast(addr) ||
		  ipv4_is_lbcast(addr)) ? 0x00 : 0x02;
	eui[1] = 0;
	eui[2] = 0x5E;
	eui[3] = 0xFE;
	memcpy(eui + 4, &addr, 4);
	return 0;
}

static int addrconf_ifid_sit(u8 *eui, struct net_device *dev)
{
	if (dev->priv_flags & IFF_ISATAP)
		return __ipv6_isatap_ifid(eui, *(__be32 *)dev->dev_addr);
	return -1;
}

static int addrconf_ifid_gre(u8 *eui, struct net_device *dev)
{
	return __ipv6_isatap_ifid(eui, *(__be32 *)dev->dev_addr);
}

static int addrconf_ifid_ip6tnl(u8 *eui, struct net_device *dev)
{
	memcpy(eui, dev->perm_addr, 3);
	memcpy(eui + 5, dev->perm_addr + 3, 3);
	eui[3] = 0xFF;
	eui[4] = 0xFE;
	eui[0] ^= 2;
	return 0;
}

static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
{
	switch (dev->type) {
	case ARPHRD_ETHER:
	case ARPHRD_FDDI:
		return addrconf_ifid_eui48(eui, dev);
	case ARPHRD_ARCNET:
		return addrconf_ifid_arcnet(eui, dev);
	case ARPHRD_INFINIBAND:
		return addrconf_ifid_infiniband(eui, dev);
	case ARPHRD_SIT:
		return addrconf_ifid_sit(eui, dev);
	case ARPHRD_IPGRE:
		return addrconf_ifid_gre(eui, dev);
	case ARPHRD_6LOWPAN:
	case ARPHRD_IEEE802154:
		return addrconf_ifid_eui64(eui, dev);
	case ARPHRD_IEEE1394:
		return addrconf_ifid_ieee1394(eui, dev);
	case ARPHRD_TUNNEL6:
		return addrconf_ifid_ip6tnl(eui, dev);
	}
	return -1;
}

static int ipv6_inherit_eui64(u8 *eui, struct inet6_dev *idev)
{
	int err = -1;
	struct inet6_ifaddr *ifp;

	read_lock_bh(&idev->lock);
	list_for_each_entry_reverse(ifp, &idev->addr_list, if_list) {
		if (ifp->scope > IFA_LINK)
			break;
		if (ifp->scope == IFA_LINK && !(ifp->flags&IFA_F_TENTATIVE)) {
			memcpy(eui, ifp->addr.s6_addr+8, 8);
			err = 0;
			break;
		}
	}
	read_unlock_bh(&idev->lock);
	return err;
}

/* (re)generation of randomized interface identifier (RFC 3041 3.2, 3.5) */
static void __ipv6_regen_rndid(struct inet6_dev *idev)
{
regen:
	get_random_bytes(idev->rndid, sizeof(idev->rndid));
	idev->rndid[0] &= ~0x02;

	/*
	 * <draft-ietf-ipngwg-temp-addresses-v2-00.txt>:
	 * check if generated address is not inappropriate
	 *
	 *  - Reserved subnet anycast (RFC 2526)
	 *	11111101 11....11 1xxxxxxx
	 *  - ISATAP (RFC4214) 6.1
	 *	00-00-5E-FE-xx-xx-xx-xx
	 *  - value 0
	 *  - XXX: already assigned to an address on the device
	 */
	if (idev->rndid[0] == 0xfd &&
	    (idev->rndid[1]&idev->rndid[2]&idev->rndid[3]&idev->rndid[4]&idev->rndid[5]&idev->rndid[6]) == 0xff &&
	    (idev->rndid[7]&0x80))
		goto regen;
	if ((idev->rndid[0]|idev->rndid[1]) == 0) {
		if (idev->rndid[2] == 0x5e && idev->rndid[3] == 0xfe)
			goto regen;
		if ((idev->rndid[2]|idev->rndid[3]|idev->rndid[4]|idev->rndid[5]|idev->rndid[6]|idev->rndid[7]) == 0x00)
			goto regen;
	}
}

static void ipv6_regen_rndid(unsigned long data)
{
	struct inet6_dev *idev = (struct inet6_dev *) data;
	unsigned long expires;

	rcu_read_lock_bh();
	write_lock_bh(&idev->lock);

	if (idev->dead)
		goto out;

	__ipv6_regen_rndid(idev);

	expires = jiffies +
		idev->cnf.temp_prefered_lft * HZ -
		idev->cnf.regen_max_retry * idev->cnf.dad_transmits *
		NEIGH_VAR(idev->nd_parms, RETRANS_TIME) -
		idev->cnf.max_desync_factor * HZ;
	if (time_before(expires, jiffies)) {
		pr_warn("%s: too short regeneration interval; timer disabled for %s\n",
			__func__, idev->dev->name);
		goto out;
	}

	if (!mod_timer(&idev->regen_timer, expires))
		in6_dev_hold(idev);

out:
	write_unlock_bh(&idev->lock);
	rcu_read_unlock_bh();
	in6_dev_put(idev);
}

static void  __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr)
{
	if (tmpaddr && memcmp(idev->rndid, &tmpaddr->s6_addr[8], 8) == 0)
		__ipv6_regen_rndid(idev);
}

/*
 *	Add prefix route.
 */

static void
addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev,
		      unsigned long expires, u32 flags)
{
	struct fib6_config cfg = {
		.fc_table = RT6_TABLE_PREFIX,
		.fc_metric = IP6_RT_PRIO_ADDRCONF,
		.fc_ifindex = dev->ifindex,
		.fc_expires = expires,
		.fc_dst_len = plen,
		.fc_flags = RTF_UP | flags,
		.fc_nlinfo.nl_net = dev_net(dev),
		.fc_protocol = RTPROT_KERNEL,
	};

	cfg.fc_dst = *pfx;

	/* Prevent useless cloning on PtP SIT.
	   This thing is done here expecting that the whole
	   class of non-broadcast devices need not cloning.
	 */
#if IS_ENABLED(CONFIG_IPV6_SIT)
	if (dev->type == ARPHRD_SIT && (dev->flags & IFF_POINTOPOINT))
		cfg.fc_flags |= RTF_NONEXTHOP;
#endif

	ip6_route_add(&cfg);
}


static struct rt6_info *addrconf_get_prefix_route(const struct in6_addr *pfx,
						  int plen,
						  const struct net_device *dev,
						  u32 flags, u32 noflags)
{
	struct fib6_node *fn;
	struct rt6_info *rt = NULL;
	struct fib6_table *table;

	table = fib6_get_table(dev_net(dev), RT6_TABLE_PREFIX);
	if (table == NULL)
		return NULL;

	read_lock_bh(&table->tb6_lock);
	fn = fib6_locate(&table->tb6_root, pfx, plen, NULL, 0);
	if (!fn)
		goto out;
	for (rt = fn->leaf; rt; rt = rt->dst.rt6_next) {