From 1fd2a25b77bb6755d38aca50b826ff8dca81d762 Mon Sep 17 00:00:00 2001 From: Paul Moore Date: Fri, 15 Dec 2006 16:49:27 -0500 Subject: NetLabel: perform input validation earlier on CIPSOv4 DOI add ops There are a couple of cases where the user input for a CIPSOv4 DOI add operation was not being done soon enough; the result was unexpected behavior which was resulting in oops/panics/lockups on some platforms. This patch moves the existing input validation code earlier in the code path to protect against bogus user input. Signed-off-by: Paul Moore Signed-off-by: James Morris --- net/netlabel/netlabel_cipso_v4.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c index 743b05734a4..1fbc906a973 100644 --- a/net/netlabel/netlabel_cipso_v4.c +++ b/net/netlabel/netlabel_cipso_v4.c @@ -185,20 +185,31 @@ static int netlbl_cipsov4_add_std(struct genl_info *info) ret_val = netlbl_cipsov4_add_common(info, doi_def); if (ret_val != 0) goto add_std_failure; + ret_val = -EINVAL; nla_for_each_nested(nla_a, info->attrs[NLBL_CIPSOV4_A_MLSLVLLST], nla_a_rem) if (nla_a->nla_type == NLBL_CIPSOV4_A_MLSLVL) { + if (nla_validate_nested(nla_a, + NLBL_CIPSOV4_A_MAX, + netlbl_cipsov4_genl_policy) != 0) + goto add_std_failure; nla_for_each_nested(nla_b, nla_a, nla_b_rem) switch (nla_b->nla_type) { case NLBL_CIPSOV4_A_MLSLVLLOC: + if (nla_get_u32(nla_b) > + CIPSO_V4_MAX_LOC_LVLS) + goto add_std_failure; if (nla_get_u32(nla_b) >= doi_def->map.std->lvl.local_size) doi_def->map.std->lvl.local_size = nla_get_u32(nla_b) + 1; break; case NLBL_CIPSOV4_A_MLSLVLREM: + if (nla_get_u32(nla_b) > + CIPSO_V4_MAX_REM_LVLS) + goto add_std_failure; if (nla_get_u32(nla_b) >= doi_def->map.std->lvl.cipso_size) doi_def->map.std->lvl.cipso_size = @@ -206,9 +217,6 @@ static int netlbl_cipsov4_add_std(struct genl_info *info) break; } } - if (doi_def->map.std->lvl.local_size > CIPSO_V4_MAX_LOC_LVLS || - doi_def->map.std->lvl.cipso_size > CIPSO_V4_MAX_REM_LVLS) - goto add_std_failure; doi_def->map.std->lvl.local = kcalloc(doi_def->map.std->lvl.local_size, sizeof(u32), GFP_KERNEL); @@ -230,11 +238,6 @@ static int netlbl_cipsov4_add_std(struct genl_info *info) struct nlattr *lvl_loc; struct nlattr *lvl_rem; - if (nla_validate_nested(nla_a, - NLBL_CIPSOV4_A_MAX, - netlbl_cipsov4_genl_policy) != 0) - goto add_std_failure; - lvl_loc = nla_find_nested(nla_a, NLBL_CIPSOV4_A_MLSLVLLOC); lvl_rem = nla_find_nested(nla_a, @@ -264,12 +267,18 @@ static int netlbl_cipsov4_add_std(struct genl_info *info) nla_for_each_nested(nla_b, nla_a, nla_b_rem) switch (nla_b->nla_type) { case NLBL_CIPSOV4_A_MLSCATLOC: + if (nla_get_u32(nla_b) > + CIPSO_V4_MAX_LOC_CATS) + goto add_std_failure; if (nla_get_u32(nla_b) >= doi_def->map.std->cat.local_size) doi_def->map.std->cat.local_size = nla_get_u32(nla_b) + 1; break; case NLBL_CIPSOV4_A_MLSCATREM: + if (nla_get_u32(nla_b) > + CIPSO_V4_MAX_REM_CATS) + goto add_std_failure; if (nla_get_u32(nla_b) >= doi_def->map.std->cat.cipso_size) doi_def->map.std->cat.cipso_size = @@ -277,9 +286,6 @@ static int netlbl_cipsov4_add_std(struct genl_info *info) break; } } - if (doi_def->map.std->cat.local_size > CIPSO_V4_MAX_LOC_CATS || - doi_def->map.std->cat.cipso_size > CIPSO_V4_MAX_REM_CATS) - goto add_std_failure; doi_def->map.std->cat.local = kcalloc( doi_def->map.std->cat.local_size, sizeof(u32), -- cgit v1.2.3 From caff5b6a6bfd0c55b359b2b4acd8c14f828b689e Mon Sep 17 00:00:00 2001 From: Paul Moore Date: Fri, 15 Dec 2006 16:49:28 -0500 Subject: NetLabel: correctly fill in unused CIPSOv4 level and category mappings Back when the original NetLabel patches were being changed to use Netlink attributes correctly some code was accidentially dropped which set all of the undefined CIPSOv4 level and category mappings to a sentinel value. The result is the mappings data in the kernel contains bogus mappings which always map to zero. This patch restores the old/correct behavior by initializing the mapping data to the correct sentinel value. Signed-off-by: Paul Moore Signed-off-by: James Morris --- net/netlabel/netlabel_cipso_v4.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c index 1fbc906a973..4afc75f9e37 100644 --- a/net/netlabel/netlabel_cipso_v4.c +++ b/net/netlabel/netlabel_cipso_v4.c @@ -162,6 +162,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info) struct nlattr *nla_b; int nla_a_rem; int nla_b_rem; + u32 iter; if (!info->attrs[NLBL_CIPSOV4_A_TAGLST] || !info->attrs[NLBL_CIPSOV4_A_MLSLVLLST]) @@ -231,6 +232,10 @@ static int netlbl_cipsov4_add_std(struct genl_info *info) ret_val = -ENOMEM; goto add_std_failure; } + for (iter = 0; iter < doi_def->map.std->lvl.local_size; iter++) + doi_def->map.std->lvl.local[iter] = CIPSO_V4_INV_LVL; + for (iter = 0; iter < doi_def->map.std->lvl.cipso_size; iter++) + doi_def->map.std->lvl.cipso[iter] = CIPSO_V4_INV_LVL; nla_for_each_nested(nla_a, info->attrs[NLBL_CIPSOV4_A_MLSLVLLST], nla_a_rem) @@ -302,6 +307,10 @@ static int netlbl_cipsov4_add_std(struct genl_info *info) ret_val = -ENOMEM; goto add_std_failure; } + for (iter = 0; iter < doi_def->map.std->cat.local_size; iter++) + doi_def->map.std->cat.local[iter] = CIPSO_V4_INV_CAT; + for (iter = 0; iter < doi_def->map.std->cat.cipso_size; iter++) + doi_def->map.std->cat.cipso[iter] = CIPSO_V4_INV_CAT; nla_for_each_nested(nla_a, info->attrs[NLBL_CIPSOV4_A_MLSCATLST], nla_a_rem) -- cgit v1.2.3 From 52a91071306c3b129efa6ea2bfe16244b8619cd9 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 19 Dec 2006 19:35:05 -0800 Subject: [ATM]: Remove dead ATM_TNETA1570 option. This patch removes the unconverted ATM_TNETA1570 option that also lacks any code in the kernel. Signed-off-by: Adrian Bunk Signed-off-by: David S. Miller --- drivers/atm/Kconfig | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/atm/Kconfig b/drivers/atm/Kconfig index 2ddd76fdbc4..33687454eb3 100644 --- a/drivers/atm/Kconfig +++ b/drivers/atm/Kconfig @@ -167,10 +167,6 @@ config ATM_ZATM_DEBUG Note that extended debugging may create certain race conditions itself. Enable this ONLY if you suspect problems with the driver. -# bool 'Rolfs TI TNETA1570' CONFIG_ATM_TNETA1570 y -# if [ "$CONFIG_ATM_TNETA1570" = "y" ]; then -# bool ' Enable extended debugging' CONFIG_ATM_TNETA1570_DEBUG n -# fi config ATM_NICSTAR tristate "IDT 77201 (NICStAR) (ForeRunnerLE)" depends on PCI && ATM && !64BIT -- cgit v1.2.3 From 1f8a5fb80e63aab63de81169ab749d73e7509e3f Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 19 Dec 2006 19:36:32 -0800 Subject: [ATM] drivers/atm/fore200e.c: Cleanups. This patch contains the following transformations from custom functions to standard kernel version: - fore200e_kmalloc() -> kzalloc() - fore200e_kfree() -> kfree() - fore200e_swap() -> cpu_to_be32() Signed-off-by: Adrian Bunk Signed-off-by: David S. Miller --- drivers/atm/fore200e.c | 166 ++++++++++++++++++++----------------------------- 1 file changed, 68 insertions(+), 98 deletions(-) diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index 3a7b21ff30a..4aeb3d062ff 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c @@ -172,25 +172,6 @@ fore200e_irq_itoa(int irq) } -static void* -fore200e_kmalloc(int size, gfp_t flags) -{ - void *chunk = kzalloc(size, flags); - - if (!chunk) - printk(FORE200E "kmalloc() failed, requested size = %d, flags = 0x%x\n", size, flags); - - return chunk; -} - - -static void -fore200e_kfree(void* chunk) -{ - kfree(chunk); -} - - /* allocate and align a chunk of memory intended to hold the data behing exchanged between the driver and the adapter (using streaming DVMA) */ @@ -206,7 +187,7 @@ fore200e_chunk_alloc(struct fore200e* fore200e, struct chunk* chunk, int size, i chunk->align_size = size; chunk->direction = direction; - chunk->alloc_addr = fore200e_kmalloc(chunk->alloc_size, GFP_KERNEL | GFP_DMA); + chunk->alloc_addr = kzalloc(chunk->alloc_size, GFP_KERNEL | GFP_DMA); if (chunk->alloc_addr == NULL) return -ENOMEM; @@ -228,7 +209,7 @@ fore200e_chunk_free(struct fore200e* fore200e, struct chunk* chunk) { fore200e->bus->dma_unmap(fore200e, chunk->dma_addr, chunk->dma_size, chunk->direction); - fore200e_kfree(chunk->alloc_addr); + kfree(chunk->alloc_addr); } @@ -882,7 +863,7 @@ fore200e_sba_detect(const struct fore200e_bus* bus, int index) return NULL; } - fore200e = fore200e_kmalloc(sizeof(struct fore200e), GFP_KERNEL); + fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL); if (fore200e == NULL) return NULL; @@ -1505,7 +1486,7 @@ fore200e_open(struct atm_vcc *vcc) spin_unlock_irqrestore(&fore200e->q_lock, flags); - fore200e_vcc = fore200e_kmalloc(sizeof(struct fore200e_vcc), GFP_ATOMIC); + fore200e_vcc = kzalloc(sizeof(struct fore200e_vcc), GFP_ATOMIC); if (fore200e_vcc == NULL) { vc_map->vcc = NULL; return -ENOMEM; @@ -1526,7 +1507,7 @@ fore200e_open(struct atm_vcc *vcc) if (fore200e->available_cell_rate < vcc->qos.txtp.max_pcr) { up(&fore200e->rate_sf); - fore200e_kfree(fore200e_vcc); + kfree(fore200e_vcc); vc_map->vcc = NULL; return -EAGAIN; } @@ -1554,7 +1535,7 @@ fore200e_open(struct atm_vcc *vcc) fore200e->available_cell_rate += vcc->qos.txtp.max_pcr; - fore200e_kfree(fore200e_vcc); + kfree(fore200e_vcc); return -EINVAL; } @@ -1630,7 +1611,7 @@ fore200e_close(struct atm_vcc* vcc) clear_bit(ATM_VF_PARTIAL,&vcc->flags); ASSERT(fore200e_vcc); - fore200e_kfree(fore200e_vcc); + kfree(fore200e_vcc); } @@ -1831,7 +1812,7 @@ fore200e_getstats(struct fore200e* fore200e) u32 stats_dma_addr; if (fore200e->stats == NULL) { - fore200e->stats = fore200e_kmalloc(sizeof(struct stats), GFP_KERNEL | GFP_DMA); + fore200e->stats = kzalloc(sizeof(struct stats), GFP_KERNEL | GFP_DMA); if (fore200e->stats == NULL) return -ENOMEM; } @@ -2002,17 +1983,6 @@ fore200e_setloop(struct fore200e* fore200e, int loop_mode) } -static inline unsigned int -fore200e_swap(unsigned int in) -{ -#if defined(__LITTLE_ENDIAN) - return swab32(in); -#else - return in; -#endif -} - - static int fore200e_fetch_stats(struct fore200e* fore200e, struct sonet_stats __user *arg) { @@ -2021,19 +1991,19 @@ fore200e_fetch_stats(struct fore200e* fore200e, struct sonet_stats __user *arg) if (fore200e_getstats(fore200e) < 0) return -EIO; - tmp.section_bip = fore200e_swap(fore200e->stats->oc3.section_bip8_errors); - tmp.line_bip = fore200e_swap(fore200e->stats->oc3.line_bip24_errors); - tmp.path_bip = fore200e_swap(fore200e->stats->oc3.path_bip8_errors); - tmp.line_febe = fore200e_swap(fore200e->stats->oc3.line_febe_errors); - tmp.path_febe = fore200e_swap(fore200e->stats->oc3.path_febe_errors); - tmp.corr_hcs = fore200e_swap(fore200e->stats->oc3.corr_hcs_errors); - tmp.uncorr_hcs = fore200e_swap(fore200e->stats->oc3.ucorr_hcs_errors); - tmp.tx_cells = fore200e_swap(fore200e->stats->aal0.cells_transmitted) + - fore200e_swap(fore200e->stats->aal34.cells_transmitted) + - fore200e_swap(fore200e->stats->aal5.cells_transmitted); - tmp.rx_cells = fore200e_swap(fore200e->stats->aal0.cells_received) + - fore200e_swap(fore200e->stats->aal34.cells_received) + - fore200e_swap(fore200e->stats->aal5.cells_received); + tmp.section_bip = cpu_to_be32(fore200e->stats->oc3.section_bip8_errors); + tmp.line_bip = cpu_to_be32(fore200e->stats->oc3.line_bip24_errors); + tmp.path_bip = cpu_to_be32(fore200e->stats->oc3.path_bip8_errors); + tmp.line_febe = cpu_to_be32(fore200e->stats->oc3.line_febe_errors); + tmp.path_febe = cpu_to_be32(fore200e->stats->oc3.path_febe_errors); + tmp.corr_hcs = cpu_to_be32(fore200e->stats->oc3.corr_hcs_errors); + tmp.uncorr_hcs = cpu_to_be32(fore200e->stats->oc3.ucorr_hcs_errors); + tmp.tx_cells = cpu_to_be32(fore200e->stats->aal0.cells_transmitted) + + cpu_to_be32(fore200e->stats->aal34.cells_transmitted) + + cpu_to_be32(fore200e->stats->aal5.cells_transmitted); + tmp.rx_cells = cpu_to_be32(fore200e->stats->aal0.cells_received) + + cpu_to_be32(fore200e->stats->aal34.cells_received) + + cpu_to_be32(fore200e->stats->aal5.cells_received); if (arg) return copy_to_user(arg, &tmp, sizeof(struct sonet_stats)) ? -EFAULT : 0; @@ -2146,7 +2116,7 @@ fore200e_irq_request(struct fore200e* fore200e) static int __devinit fore200e_get_esi(struct fore200e* fore200e) { - struct prom_data* prom = fore200e_kmalloc(sizeof(struct prom_data), GFP_KERNEL | GFP_DMA); + struct prom_data* prom = kzalloc(sizeof(struct prom_data), GFP_KERNEL | GFP_DMA); int ok, i; if (!prom) @@ -2154,7 +2124,7 @@ fore200e_get_esi(struct fore200e* fore200e) ok = fore200e->bus->prom_read(fore200e, prom); if (ok < 0) { - fore200e_kfree(prom); + kfree(prom); return -EBUSY; } @@ -2169,7 +2139,7 @@ fore200e_get_esi(struct fore200e* fore200e) fore200e->esi[ i ] = fore200e->atm_dev->esi[ i ] = prom->mac_addr[ i + 2 ]; } - fore200e_kfree(prom); + kfree(prom); return 0; } @@ -2194,7 +2164,7 @@ fore200e_alloc_rx_buf(struct fore200e* fore200e) DPRINTK(2, "rx buffers %d / %d are being allocated\n", scheme, magn); /* allocate the array of receive buffers */ - buffer = bsq->buffer = fore200e_kmalloc(nbr * sizeof(struct buffer), GFP_KERNEL); + buffer = bsq->buffer = kzalloc(nbr * sizeof(struct buffer), GFP_KERNEL); if (buffer == NULL) return -ENOMEM; @@ -2217,7 +2187,7 @@ fore200e_alloc_rx_buf(struct fore200e* fore200e) while (i > 0) fore200e_chunk_free(fore200e, &buffer[ --i ].data); - fore200e_kfree(buffer); + kfree(buffer); return -ENOMEM; } @@ -2736,7 +2706,7 @@ fore200e_pca_detect(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent goto out; } - fore200e = fore200e_kmalloc(sizeof(struct fore200e), GFP_KERNEL); + fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL); if (fore200e == NULL) { err = -ENOMEM; goto out_disable; @@ -2999,8 +2969,8 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page) " 4b5b:\n" " crc_header_errors:\t\t%10u\n" " framing_errors:\t\t%10u\n", - fore200e_swap(fore200e->stats->phy.crc_header_errors), - fore200e_swap(fore200e->stats->phy.framing_errors)); + cpu_to_be32(fore200e->stats->phy.crc_header_errors), + cpu_to_be32(fore200e->stats->phy.framing_errors)); if (!left--) return sprintf(page, "\n" @@ -3012,13 +2982,13 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page) " path_febe_errors:\t\t%10u\n" " corr_hcs_errors:\t\t%10u\n" " ucorr_hcs_errors:\t\t%10u\n", - fore200e_swap(fore200e->stats->oc3.section_bip8_errors), - fore200e_swap(fore200e->stats->oc3.path_bip8_errors), - fore200e_swap(fore200e->stats->oc3.line_bip24_errors), - fore200e_swap(fore200e->stats->oc3.line_febe_errors), - fore200e_swap(fore200e->stats->oc3.path_febe_errors), - fore200e_swap(fore200e->stats->oc3.corr_hcs_errors), - fore200e_swap(fore200e->stats->oc3.ucorr_hcs_errors)); + cpu_to_be32(fore200e->stats->oc3.section_bip8_errors), + cpu_to_be32(fore200e->stats->oc3.path_bip8_errors), + cpu_to_be32(fore200e->stats->oc3.line_bip24_errors), + cpu_to_be32(fore200e->stats->oc3.line_febe_errors), + cpu_to_be32(fore200e->stats->oc3.path_febe_errors), + cpu_to_be32(fore200e->stats->oc3.corr_hcs_errors), + cpu_to_be32(fore200e->stats->oc3.ucorr_hcs_errors)); if (!left--) return sprintf(page,"\n" @@ -3029,12 +2999,12 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page) " vpi no conn:\t\t%10u\n" " vci out of range:\t\t%10u\n" " vci no conn:\t\t%10u\n", - fore200e_swap(fore200e->stats->atm.cells_transmitted), - fore200e_swap(fore200e->stats->atm.cells_received), - fore200e_swap(fore200e->stats->atm.vpi_bad_range), - fore200e_swap(fore200e->stats->atm.vpi_no_conn), - fore200e_swap(fore200e->stats->atm.vci_bad_range), - fore200e_swap(fore200e->stats->atm.vci_no_conn)); + cpu_to_be32(fore200e->stats->atm.cells_transmitted), + cpu_to_be32(fore200e->stats->atm.cells_received), + cpu_to_be32(fore200e->stats->atm.vpi_bad_range), + cpu_to_be32(fore200e->stats->atm.vpi_no_conn), + cpu_to_be32(fore200e->stats->atm.vci_bad_range), + cpu_to_be32(fore200e->stats->atm.vci_no_conn)); if (!left--) return sprintf(page,"\n" @@ -3042,9 +3012,9 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page) " TX:\t\t\t%10u\n" " RX:\t\t\t%10u\n" " dropped:\t\t\t%10u\n", - fore200e_swap(fore200e->stats->aal0.cells_transmitted), - fore200e_swap(fore200e->stats->aal0.cells_received), - fore200e_swap(fore200e->stats->aal0.cells_dropped)); + cpu_to_be32(fore200e->stats->aal0.cells_transmitted), + cpu_to_be32(fore200e->stats->aal0.cells_received), + cpu_to_be32(fore200e->stats->aal0.cells_dropped)); if (!left--) return sprintf(page,"\n" @@ -3060,15 +3030,15 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page) " RX:\t\t\t%10u\n" " dropped:\t\t\t%10u\n" " protocol errors:\t\t%10u\n", - fore200e_swap(fore200e->stats->aal34.cells_transmitted), - fore200e_swap(fore200e->stats->aal34.cells_received), - fore200e_swap(fore200e->stats->aal34.cells_dropped), - fore200e_swap(fore200e->stats->aal34.cells_crc_errors), - fore200e_swap(fore200e->stats->aal34.cells_protocol_errors), - fore200e_swap(fore200e->stats->aal34.cspdus_transmitted), - fore200e_swap(fore200e->stats->aal34.cspdus_received), - fore200e_swap(fore200e->stats->aal34.cspdus_dropped), - fore200e_swap(fore200e->stats->aal34.cspdus_protocol_errors)); + cpu_to_be32(fore200e->stats->aal34.cells_transmitted), + cpu_to_be32(fore200e->stats->aal34.cells_received), + cpu_to_be32(fore200e->stats->aal34.cells_dropped), + cpu_to_be32(fore200e->stats->aal34.cells_crc_errors), + cpu_to_be32(fore200e->stats->aal34.cells_protocol_errors), + cpu_to_be32(fore200e->stats->aal34.cspdus_transmitted), + cpu_to_be32(fore200e->stats->aal34.cspdus_received), + cpu_to_be32(fore200e->stats->aal34.cspdus_dropped), + cpu_to_be32(fore200e->stats->aal34.cspdus_protocol_errors)); if (!left--) return sprintf(page,"\n" @@ -3084,15 +3054,15 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page) " dropped:\t\t\t%10u\n" " CRC errors:\t\t%10u\n" " protocol errors:\t\t%10u\n", - fore200e_swap(fore200e->stats->aal5.cells_transmitted), - fore200e_swap(fore200e->stats->aal5.cells_received), - fore200e_swap(fore200e->stats->aal5.cells_dropped), - fore200e_swap(fore200e->stats->aal5.congestion_experienced), - fore200e_swap(fore200e->stats->aal5.cspdus_transmitted), - fore200e_swap(fore200e->stats->aal5.cspdus_received), - fore200e_swap(fore200e->stats->aal5.cspdus_dropped), - fore200e_swap(fore200e->stats->aal5.cspdus_crc_errors), - fore200e_swap(fore200e->stats->aal5.cspdus_protocol_errors)); + cpu_to_be32(fore200e->stats->aal5.cells_transmitted), + cpu_to_be32(fore200e->stats->aal5.cells_received), + cpu_to_be32(fore200e->stats->aal5.cells_dropped), + cpu_to_be32(fore200e->stats->aal5.congestion_experienced), + cpu_to_be32(fore200e->stats->aal5.cspdus_transmitted), + cpu_to_be32(fore200e->stats->aal5.cspdus_received), + cpu_to_be32(fore200e->stats->aal5.cspdus_dropped), + cpu_to_be32(fore200e->stats->aal5.cspdus_crc_errors), + cpu_to_be32(fore200e->stats->aal5.cspdus_protocol_errors)); if (!left--) return sprintf(page,"\n" @@ -3103,11 +3073,11 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page) " large b2:\t\t\t%10u\n" " RX PDUs:\t\t\t%10u\n" " TX PDUs:\t\t\t%10lu\n", - fore200e_swap(fore200e->stats->aux.small_b1_failed), - fore200e_swap(fore200e->stats->aux.large_b1_failed), - fore200e_swap(fore200e->stats->aux.small_b2_failed), - fore200e_swap(fore200e->stats->aux.large_b2_failed), - fore200e_swap(fore200e->stats->aux.rpd_alloc_failed), + cpu_to_be32(fore200e->stats->aux.small_b1_failed), + cpu_to_be32(fore200e->stats->aux.large_b1_failed), + cpu_to_be32(fore200e->stats->aux.small_b2_failed), + cpu_to_be32(fore200e->stats->aux.large_b2_failed), + cpu_to_be32(fore200e->stats->aux.rpd_alloc_failed), fore200e->tx_sat); if (!left--) -- cgit v1.2.3 From 9a036b9c33f74c989c4c8ac0abe05e0ed88f1f25 Mon Sep 17 00:00:00 2001 From: Gerrit Renker Date: Wed, 20 Dec 2006 10:25:55 -0800 Subject: [TCP]: Fix ambiguity in the `before' relation. While looking at DCCP sequence numbers, I stumbled over a problem with the following definition of before in tcp.h: static inline int before(__u32 seq1, __u32 seq2) { return (__s32)(seq1-seq2) < 0; } Problem: This definition suffers from an an ambiguity, i.e. always before(a, (a + 2^31) % 2^32)) = 1 before((a + 2^31) % 2^32), a) = 1 In text: when the difference between a and b amounts to 2^31, a is always considered `before' b, the function can not decide. The reason is that implicitly 0 is `before' 1 ... 2^31-1 ... 2^31 Solution: There is a simple fix, by defining before in such a way that 0 is no longer `before' 2^31, i.e. 0 `before' 1 ... 2^31-1 By not using the middle between 0 and 2^32, before can be made unambiguous. This is achieved by testing whether seq2-seq1 > 0 (using signed 32-bit arithmetic). I attach a patch to codify this. Also the `after' relation is basically a redefinition of `before', it is now defined as a macro after before. Signed-off-by: Gerrit Renker Signed-off-by: David S. Miller --- include/net/tcp.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index c99774f15eb..b7d8317f22a 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -242,14 +242,9 @@ extern int tcp_memory_pressure; static inline int before(__u32 seq1, __u32 seq2) { - return (__s32)(seq1-seq2) < 0; + return (__s32)(seq2-seq1) > 0; } - -static inline int after(__u32 seq1, __u32 seq2) -{ - return (__s32)(seq2-seq1) < 0; -} - +#define after(seq2, seq1) before(seq1, seq2) /* is s2<=s1<=s3 ? */ static inline int between(__u32 seq1, __u32 seq2, __u32 seq3) -- cgit v1.2.3 From a3f7f142f73ed4cb23826bee84afc31d10377e39 Mon Sep 17 00:00:00 2001 From: Sridhar Samudrala Date: Wed, 20 Dec 2006 16:06:09 -0800 Subject: [SCTP]: Don't export include/linux/sctp.h to userspace. This file contains protocol definitions and there are no SCTP apps that use this file. Signed-off-by: Sridhar Samudrala Signed-off-by: David S. Miller --- include/linux/Kbuild | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/Kbuild b/include/linux/Kbuild index 68dd42b9bac..862e483cce8 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild @@ -137,7 +137,6 @@ header-y += radeonfb.h header-y += raw.h header-y += resource.h header-y += rose.h -header-y += sctp.h header-y += smbno.h header-y += snmp.h header-y += sockios.h -- cgit v1.2.3 From 0f3fffd8ab1db7658c97c167e8ab001cc814e1f4 Mon Sep 17 00:00:00 2001 From: Ivan Skytte Jorgensen Date: Wed, 20 Dec 2006 16:07:04 -0800 Subject: [SCTP]: Fix typo adaption -> adaptation as per the latest API draft. Signed-off-by: Ivan Skytte Jorgensen Signed-off-by: Sridhar Samudrala Signed-off-by: David S. Miller --- include/linux/sctp.h | 10 +++++----- include/net/sctp/structs.h | 8 ++++---- include/net/sctp/ulpevent.h | 2 +- include/net/sctp/user.h | 28 ++++++++++++++-------------- net/sctp/sm_make_chunk.c | 24 ++++++++++++------------ net/sctp/sm_statefuns.c | 32 ++++++++++++++++---------------- net/sctp/socket.c | 34 +++++++++++++++++----------------- net/sctp/ulpevent.c | 20 ++++++++++---------- 8 files changed, 79 insertions(+), 79 deletions(-) diff --git a/include/linux/sctp.h b/include/linux/sctp.h index 35108fe7a68..d4f86560bff 100644 --- a/include/linux/sctp.h +++ b/include/linux/sctp.h @@ -180,7 +180,7 @@ typedef enum { SCTP_PARAM_ERR_CAUSE = __constant_htons(0xc003), SCTP_PARAM_SET_PRIMARY = __constant_htons(0xc004), SCTP_PARAM_SUCCESS_REPORT = __constant_htons(0xc005), - SCTP_PARAM_ADAPTION_LAYER_IND = __constant_htons(0xc006), + SCTP_PARAM_ADAPTATION_LAYER_IND = __constant_htons(0xc006), } sctp_param_t; /* enum */ @@ -281,11 +281,11 @@ typedef struct sctp_ecn_capable_param { sctp_paramhdr_t param_hdr; } __attribute__((packed)) sctp_ecn_capable_param_t; -/* ADDIP Section 3.2.6 Adaption Layer Indication */ -typedef struct sctp_adaption_ind_param { +/* ADDIP Section 3.2.6 Adaptation Layer Indication */ +typedef struct sctp_adaptation_ind_param { struct sctp_paramhdr param_hdr; - __be32 adaption_ind; -} __attribute__((packed)) sctp_adaption_ind_param_t; + __be32 adaptation_ind; +} __attribute__((packed)) sctp_adaptation_ind_param_t; /* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2): * The INIT ACK chunk is used to acknowledge the initiation of an SCTP diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 8d7f26d684e..31a8e88f1a7 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -306,7 +306,7 @@ struct sctp_sock { __u8 disable_fragments; __u8 pd_mode; __u8 v4mapped; - __u32 adaption_ind; + __u32 adaptation_ind; /* Receive to here while partial delivery is in effect. */ struct sk_buff_head pd_lobby; @@ -388,7 +388,7 @@ struct sctp_cookie { /* Padding for future use */ __u8 padding; - __u32 adaption_ind; + __u32 adaptation_ind; /* This is a shim for my peer's INIT packet, followed by @@ -431,7 +431,7 @@ union sctp_params { struct sctp_ipv4addr_param *v4; struct sctp_ipv6addr_param *v6; union sctp_addr_param *addr; - struct sctp_adaption_ind_param *aind; + struct sctp_adaptation_ind_param *aind; }; /* RFC 2960. Section 3.3.5 Heartbeat. @@ -1483,7 +1483,7 @@ struct sctp_association { __u8 asconf_capable; /* Does peer support ADDIP? */ __u8 prsctp_capable; /* Can peer do PR-SCTP? */ - __u32 adaption_ind; /* Adaption Code point. */ + __u32 adaptation_ind; /* Adaptation Code point. */ /* This mask is used to disable sending the ASCONF chunk * with specified parameter to peer. diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h index 1a4ddc1ec7d..2923e3d31a0 100644 --- a/include/net/sctp/ulpevent.h +++ b/include/net/sctp/ulpevent.h @@ -120,7 +120,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_pdapi( const struct sctp_association *asoc, __u32 indication, gfp_t gfp); -struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication( +struct sctp_ulpevent *sctp_ulpevent_make_adaptation_indication( const struct sctp_association *asoc, gfp_t gfp); struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc, diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h index 9e4a39fd129..67a30eb2b3a 100644 --- a/include/net/sctp/user.h +++ b/include/net/sctp/user.h @@ -75,8 +75,8 @@ enum sctp_optname { #define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR SCTP_PRIMARY_ADDR, #define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR - SCTP_ADAPTION_LAYER, -#define SCTP_ADAPTION_LAYER SCTP_ADAPTION_LAYER + SCTP_ADAPTATION_LAYER, +#define SCTP_ADAPTATION_LAYER SCTP_ADAPTATION_LAYER SCTP_DISABLE_FRAGMENTS, #define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS SCTP_PEER_ADDR_PARAMS, @@ -331,17 +331,17 @@ struct sctp_shutdown_event { }; /* - * 5.3.1.6 SCTP_ADAPTION_INDICATION + * 5.3.1.6 SCTP_ADAPTATION_INDICATION * - * When a peer sends a Adaption Layer Indication parameter , SCTP + * When a peer sends a Adaptation Layer Indication parameter , SCTP * delivers this notification to inform the application - * that of the peers requested adaption layer. + * that of the peers requested adaptation layer. */ -struct sctp_adaption_event { +struct sctp_adaptation_event { __u16 sai_type; __u16 sai_flags; __u32 sai_length; - __u32 sai_adaption_ind; + __u32 sai_adaptation_ind; sctp_assoc_t sai_assoc_id; }; @@ -374,7 +374,7 @@ struct sctp_event_subscribe { __u8 sctp_peer_error_event; __u8 sctp_shutdown_event; __u8 sctp_partial_delivery_event; - __u8 sctp_adaption_layer_event; + __u8 sctp_adaptation_layer_event; }; /* @@ -395,7 +395,7 @@ union sctp_notification { struct sctp_remote_error sn_remote_error; struct sctp_send_failed sn_send_failed; struct sctp_shutdown_event sn_shutdown_event; - struct sctp_adaption_event sn_adaption_event; + struct sctp_adaptation_event sn_adaptation_event; struct sctp_pdapi_event sn_pdapi_event; }; @@ -412,7 +412,7 @@ enum sctp_sn_type { SCTP_REMOTE_ERROR, SCTP_SHUTDOWN_EVENT, SCTP_PARTIAL_DELIVERY_EVENT, - SCTP_ADAPTION_INDICATION, + SCTP_ADAPTATION_INDICATION, }; /* Notification error codes used to fill up the error fields in some @@ -488,13 +488,13 @@ struct sctp_prim { } __attribute__((packed, aligned(4))); /* - * 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER) + * 7.1.11 Set Adaptation Layer Indicator (SCTP_ADAPTATION_LAYER) * - * Requests that the local endpoint set the specified Adaption Layer + * Requests that the local endpoint set the specified Adaptation Layer * Indication parameter for all future INIT and INIT-ACK exchanges. */ -struct sctp_setadaption { - __u32 ssb_adaption_ind; +struct sctp_setadaptation { + __u32 ssb_adaptation_ind; }; /* diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 30927d3a597..f0bbe36799c 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -184,7 +184,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, struct sctp_sock *sp; sctp_supported_addrs_param_t sat; __be16 types[2]; - sctp_adaption_ind_param_t aiparam; + sctp_adaptation_ind_param_t aiparam; /* RFC 2960 3.3.2 Initiation (INIT) (1) * @@ -249,9 +249,9 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, sctp_addto_chunk(retval, sizeof(ecap_param), &ecap_param); if (sctp_prsctp_enable) sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); - aiparam.param_hdr.type = SCTP_PARAM_ADAPTION_LAYER_IND; + aiparam.param_hdr.type = SCTP_PARAM_ADAPTATION_LAYER_IND; aiparam.param_hdr.length = htons(sizeof(aiparam)); - aiparam.adaption_ind = htonl(sp->adaption_ind); + aiparam.adaptation_ind = htonl(sp->adaptation_ind); sctp_addto_chunk(retval, sizeof(aiparam), &aiparam); nodata: kfree(addrs.v); @@ -269,7 +269,7 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, sctp_cookie_param_t *cookie; int cookie_len; size_t chunksize; - sctp_adaption_ind_param_t aiparam; + sctp_adaptation_ind_param_t aiparam; retval = NULL; @@ -323,9 +323,9 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, if (asoc->peer.prsctp_capable) sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); - aiparam.param_hdr.type = SCTP_PARAM_ADAPTION_LAYER_IND; + aiparam.param_hdr.type = SCTP_PARAM_ADAPTATION_LAYER_IND; aiparam.param_hdr.length = htons(sizeof(aiparam)); - aiparam.adaption_ind = htonl(sctp_sk(asoc->base.sk)->adaption_ind); + aiparam.adaptation_ind = htonl(sctp_sk(asoc->base.sk)->adaptation_ind); sctp_addto_chunk(retval, sizeof(aiparam), &aiparam); /* We need to remove the const qualifier at this point. */ @@ -1300,8 +1300,8 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep, /* Remember PR-SCTP capability. */ cookie->c.prsctp_capable = asoc->peer.prsctp_capable; - /* Save adaption indication in the cookie. */ - cookie->c.adaption_ind = asoc->peer.adaption_ind; + /* Save adaptation indication in the cookie. */ + cookie->c.adaptation_ind = asoc->peer.adaptation_ind; /* Set an expiration time for the cookie. */ do_gettimeofday(&cookie->c.expiration); @@ -1512,7 +1512,7 @@ no_hmac: retval->addip_serial = retval->c.initial_tsn; retval->adv_peer_ack_point = retval->ctsn_ack_point; retval->peer.prsctp_capable = retval->c.prsctp_capable; - retval->peer.adaption_ind = retval->c.adaption_ind; + retval->peer.adaptation_ind = retval->c.adaptation_ind; /* The INIT stuff will be done by the side effects. */ return retval; @@ -1743,7 +1743,7 @@ static int sctp_verify_param(const struct sctp_association *asoc, case SCTP_PARAM_HEARTBEAT_INFO: case SCTP_PARAM_UNRECOGNIZED_PARAMETERS: case SCTP_PARAM_ECN_CAPABLE: - case SCTP_PARAM_ADAPTION_LAYER_IND: + case SCTP_PARAM_ADAPTATION_LAYER_IND: break; case SCTP_PARAM_HOST_NAME_ADDRESS: @@ -2098,8 +2098,8 @@ static int sctp_process_param(struct sctp_association *asoc, asoc->peer.ecn_capable = 1; break; - case SCTP_PARAM_ADAPTION_LAYER_IND: - asoc->peer.adaption_ind = param.aind->adaption_ind; + case SCTP_PARAM_ADAPTATION_LAYER_IND: + asoc->peer.adaptation_ind = param.aind->adaptation_ind; break; case SCTP_PARAM_FWD_TSN_SUPPORT: diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 27cc444aaf1..aa51d190bfb 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -688,12 +688,12 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, goto nomem_ev; /* Sockets API Draft Section 5.3.1.6 - * When a peer sends a Adaption Layer Indication parameter , SCTP + * When a peer sends a Adaptation Layer Indication parameter , SCTP * delivers this notification to inform the application that of the - * peers requested adaption layer. + * peers requested adaptation layer. */ - if (new_asoc->peer.adaption_ind) { - ai_ev = sctp_ulpevent_make_adaption_indication(new_asoc, + if (new_asoc->peer.adaptation_ind) { + ai_ev = sctp_ulpevent_make_adaptation_indication(new_asoc, GFP_ATOMIC); if (!ai_ev) goto nomem_aiev; @@ -820,12 +820,12 @@ sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep, sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); /* Sockets API Draft Section 5.3.1.6 - * When a peer sends a Adaption Layer Indication parameter , SCTP + * When a peer sends a Adaptation Layer Indication parameter , SCTP * delivers this notification to inform the application that of the - * peers requested adaption layer. + * peers requested adaptation layer. */ - if (asoc->peer.adaption_ind) { - ev = sctp_ulpevent_make_adaption_indication(asoc, GFP_ATOMIC); + if (asoc->peer.adaptation_ind) { + ev = sctp_ulpevent_make_adaptation_indication(asoc, GFP_ATOMIC); if (!ev) goto nomem; @@ -1698,12 +1698,12 @@ static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep, sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); /* Sockets API Draft Section 5.3.1.6 - * When a peer sends a Adaption Layer Indication parameter , SCTP + * When a peer sends a Adaptation Layer Indication parameter , SCTP * delivers this notification to inform the application that of the - * peers requested adaption layer. + * peers requested adaptation layer. */ - if (asoc->peer.adaption_ind) { - ev = sctp_ulpevent_make_adaption_indication(asoc, GFP_ATOMIC); + if (asoc->peer.adaptation_ind) { + ev = sctp_ulpevent_make_adaptation_indication(asoc, GFP_ATOMIC); if (!ev) goto nomem_ev; @@ -1791,12 +1791,12 @@ static sctp_disposition_t sctp_sf_do_dupcook_d(const struct sctp_endpoint *ep, goto nomem; /* Sockets API Draft Section 5.3.1.6 - * When a peer sends a Adaption Layer Indication parameter, + * When a peer sends a Adaptation Layer Indication parameter, * SCTP delivers this notification to inform the application - * that of the peers requested adaption layer. + * that of the peers requested adaptation layer. */ - if (asoc->peer.adaption_ind) { - ai_ev = sctp_ulpevent_make_adaption_indication(asoc, + if (asoc->peer.adaptation_ind) { + ai_ev = sctp_ulpevent_make_adaptation_indication(asoc, GFP_ATOMIC); if (!ai_ev) goto nomem; diff --git a/net/sctp/socket.c b/net/sctp/socket.c index bdd8bd428b6..388d0fb1a37 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -2731,17 +2731,17 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva return err; } -static int sctp_setsockopt_adaption_layer(struct sock *sk, char __user *optval, +static int sctp_setsockopt_adaptation_layer(struct sock *sk, char __user *optval, int optlen) { - struct sctp_setadaption adaption; + struct sctp_setadaptation adaptation; - if (optlen != sizeof(struct sctp_setadaption)) + if (optlen != sizeof(struct sctp_setadaptation)) return -EINVAL; - if (copy_from_user(&adaption, optval, optlen)) + if (copy_from_user(&adaptation, optval, optlen)) return -EFAULT; - sctp_sk(sk)->adaption_ind = adaption.ssb_adaption_ind; + sctp_sk(sk)->adaptation_ind = adaptation.ssb_adaptation_ind; return 0; } @@ -2894,8 +2894,8 @@ SCTP_STATIC int sctp_setsockopt(struct sock *sk, int level, int optname, case SCTP_MAXSEG: retval = sctp_setsockopt_maxseg(sk, optval, optlen); break; - case SCTP_ADAPTION_LAYER: - retval = sctp_setsockopt_adaption_layer(sk, optval, optlen); + case SCTP_ADAPTATION_LAYER: + retval = sctp_setsockopt_adaptation_layer(sk, optval, optlen); break; case SCTP_CONTEXT: retval = sctp_setsockopt_context(sk, optval, optlen); @@ -3123,7 +3123,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) /* User specified fragmentation limit. */ sp->user_frag = 0; - sp->adaption_ind = 0; + sp->adaptation_ind = 0; sp->pf = sctp_get_pf_specific(sk->sk_family); @@ -4210,21 +4210,21 @@ static int sctp_getsockopt_primary_addr(struct sock *sk, int len, } /* - * 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER) + * 7.1.11 Set Adaptation Layer Indicator (SCTP_ADAPTATION_LAYER) * - * Requests that the local endpoint set the specified Adaption Layer + * Requests that the local endpoint set the specified Adaptation Layer * Indication parameter for all future INIT and INIT-ACK exchanges. */ -static int sctp_getsockopt_adaption_layer(struct sock *sk, int len, +static int sctp_getsockopt_adaptation_layer(struct sock *sk, int len, char __user *optval, int __user *optlen) { - struct sctp_setadaption adaption; + struct sctp_setadaptation adaptation; - if (len != sizeof(struct sctp_setadaption)) + if (len != sizeof(struct sctp_setadaptation)) return -EINVAL; - adaption.ssb_adaption_ind = sctp_sk(sk)->adaption_ind; - if (copy_to_user(optval, &adaption, len)) + adaptation.ssb_adaptation_ind = sctp_sk(sk)->adaptation_ind; + if (copy_to_user(optval, &adaptation, len)) return -EFAULT; return 0; @@ -4635,8 +4635,8 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, retval = sctp_getsockopt_peer_addr_info(sk, len, optval, optlen); break; - case SCTP_ADAPTION_LAYER: - retval = sctp_getsockopt_adaption_layer(sk, len, optval, + case SCTP_ADAPTATION_LAYER: + retval = sctp_getsockopt_adaptation_layer(sk, len, optval, optlen); break; case SCTP_CONTEXT: diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c index 93ac63b055b..445e07a7ac4 100644 --- a/net/sctp/ulpevent.c +++ b/net/sctp/ulpevent.c @@ -609,31 +609,31 @@ fail: return NULL; } -/* Create and initialize a SCTP_ADAPTION_INDICATION notification. +/* Create and initialize a SCTP_ADAPTATION_INDICATION notification. * * Socket Extensions for SCTP - * 5.3.1.6 SCTP_ADAPTION_INDICATION + * 5.3.1.6 SCTP_ADAPTATION_INDICATION */ -struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication( +struct sctp_ulpevent *sctp_ulpevent_make_adaptation_indication( const struct sctp_association *asoc, gfp_t gfp) { struct sctp_ulpevent *event; - struct sctp_adaption_event *sai; + struct sctp_adaptation_event *sai; struct sk_buff *skb; - event = sctp_ulpevent_new(sizeof(struct sctp_adaption_event), + event = sctp_ulpevent_new(sizeof(struct sctp_adaptation_event), MSG_NOTIFICATION, gfp); if (!event) goto fail; skb = sctp_event2skb(event); - sai = (struct sctp_adaption_event *) - skb_put(skb, sizeof(struct sctp_adaption_event)); + sai = (struct sctp_adaptation_event *) + skb_put(skb, sizeof(struct sctp_adaptation_event)); - sai->sai_type = SCTP_ADAPTION_INDICATION; + sai->sai_type = SCTP_ADAPTATION_INDICATION; sai->sai_flags = 0; - sai->sai_length = sizeof(struct sctp_adaption_event); - sai->sai_adaption_ind = asoc->peer.adaption_ind; + sai->sai_length = sizeof(struct sctp_adaptation_event); + sai->sai_adaptation_ind = asoc->peer.adaptation_ind; sctp_ulpevent_set_owner(event, asoc); sai->sai_assoc_id = sctp_assoc2id(asoc); -- cgit v1.2.3 From 24123186fa271e7ad34a40f815782e6205f34ff7 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 20 Dec 2006 16:08:22 -0800 Subject: [SCTP]: make 2 functions static This patch makes the following needlessly global functions static: - ipv6.c: sctp_inet6addr_event() - protocol.c: sctp_inetaddr_event() Signed-off-by: Adrian Bunk Signed-off-by: Sridhar Samudrala Signed-off-by: David S. Miller --- include/net/sctp/sctp.h | 2 -- net/sctp/ipv6.c | 4 ++-- net/sctp/protocol.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index c818f87122a..28af6805952 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h @@ -128,8 +128,6 @@ extern int sctp_copy_local_addr_list(struct sctp_bind_addr *, int flags); extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family); extern int sctp_register_pf(struct sctp_pf *, sa_family_t); -int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev, - void *ptr); /* * sctp/socket.c diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index d8d36dee5ab..ef36be073a1 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -79,8 +79,8 @@ #include /* Event handler for inet6 address addition/deletion events. */ -int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev, - void *ptr) +static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev, + void *ptr) { struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr; struct sctp_sockaddr_entry *addr; diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 3a3db56729c..225f39b5d59 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -601,8 +601,8 @@ static void sctp_v4_seq_dump_addr(struct seq_file *seq, union sctp_addr *addr) } /* Event handler for inet address addition/deletion events. */ -int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev, - void *ptr) +static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev, + void *ptr) { struct in_ifaddr *ifa = (struct in_ifaddr *)ptr; struct sctp_sockaddr_entry *addr; -- cgit v1.2.3 From b23e3536667373e44f52a907f63cb55f75969490 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 21 Dec 2006 13:15:18 -0800 Subject: [IPV6]: Dumb typo in generic csum_ipv6_magic() ... duh Signed-off-by: Al Viro Signed-off-by: David S. Miller --- include/net/ip6_checksum.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/ip6_checksum.h b/include/net/ip6_checksum.h index 68e2b32cf1d..bc1b0fda2b0 100644 --- a/include/net/ip6_checksum.h +++ b/include/net/ip6_checksum.h @@ -87,7 +87,7 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, carry = (sum < uproto); sum += carry; - return csum_fold((__force __wsum)csum); + return csum_fold((__force __wsum)sum); } #endif -- cgit v1.2.3 From 5c668704b7fa5a4ebf21a490ddfbd6dc2e01fc97 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 22 Dec 2006 11:42:26 -0800 Subject: [UDP]: Fix reversed logic in udp_get_port(). When this code was converted to use sk_for_each() the logic for the "best hash chain length" code was reversed, breaking everything. The original code was of the form: size = 0; do { if (++size >= best_size_so_far) goto next; } while ((sk = sk->next) != NULL); best_size_so_far = size; best = result; next:; and this got converted into: sk_for_each(sk2, node, head) if (++size < best_size_so_far) { best_size_so_far = size; best = result; } Which does something very very different from the original. Signed-off-by: David S. Miller --- net/ipv4/udp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 035915fc9ed..cfff930f2ba 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -165,11 +165,14 @@ int __udp_lib_get_port(struct sock *sk, unsigned short snum, goto gotit; } size = 0; - sk_for_each(sk2, node, head) - if (++size < best_size_so_far) { - best_size_so_far = size; - best = result; - } + sk_for_each(sk2, node, head) { + if (++size >= best_size_so_far) + goto next; + } + best_size_so_far = size; + best = result; + next: + ; } result = best; for(i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) { -- cgit v1.2.3