diff options
author | Frank Blaschka <frank.blaschka@de.ibm.com> | 2011-02-02 01:04:32 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-02-02 18:00:00 -0500 |
commit | 9853b97bccbd2b08ce5fef497f21fa7395f68823 (patch) | |
tree | fa2e110362da71d5599c8f24bd393a593f542f49 /drivers/s390/net | |
parent | 221c17fe87033aa154df68679b437c83d835c284 (diff) |
qeth: add more strict MTU checking
HiperSockets and OSA hardware report a maximum MTU size. Add checking
to reject larger MTUs than allowed by hardware.
Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/s390/net')
-rw-r--r-- | drivers/s390/net/qeth_core_main.c | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 29f848bfc12f..ddeef41049ae 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
@@ -1832,33 +1832,6 @@ static inline int qeth_get_initial_mtu_for_card(struct qeth_card *card) | |||
1832 | } | 1832 | } |
1833 | } | 1833 | } |
1834 | 1834 | ||
1835 | static inline int qeth_get_max_mtu_for_card(int cardtype) | ||
1836 | { | ||
1837 | switch (cardtype) { | ||
1838 | |||
1839 | case QETH_CARD_TYPE_UNKNOWN: | ||
1840 | case QETH_CARD_TYPE_OSD: | ||
1841 | case QETH_CARD_TYPE_OSN: | ||
1842 | case QETH_CARD_TYPE_OSM: | ||
1843 | case QETH_CARD_TYPE_OSX: | ||
1844 | return 61440; | ||
1845 | case QETH_CARD_TYPE_IQD: | ||
1846 | return 57344; | ||
1847 | default: | ||
1848 | return 1500; | ||
1849 | } | ||
1850 | } | ||
1851 | |||
1852 | static inline int qeth_get_mtu_out_of_mpc(int cardtype) | ||
1853 | { | ||
1854 | switch (cardtype) { | ||
1855 | case QETH_CARD_TYPE_IQD: | ||
1856 | return 1; | ||
1857 | default: | ||
1858 | return 0; | ||
1859 | } | ||
1860 | } | ||
1861 | |||
1862 | static inline int qeth_get_mtu_outof_framesize(int framesize) | 1835 | static inline int qeth_get_mtu_outof_framesize(int framesize) |
1863 | { | 1836 | { |
1864 | switch (framesize) { | 1837 | switch (framesize) { |
@@ -1881,10 +1854,9 @@ static inline int qeth_mtu_is_valid(struct qeth_card *card, int mtu) | |||
1881 | case QETH_CARD_TYPE_OSD: | 1854 | case QETH_CARD_TYPE_OSD: |
1882 | case QETH_CARD_TYPE_OSM: | 1855 | case QETH_CARD_TYPE_OSM: |
1883 | case QETH_CARD_TYPE_OSX: | 1856 | case QETH_CARD_TYPE_OSX: |
1884 | return ((mtu >= 576) && (mtu <= 61440)); | ||
1885 | case QETH_CARD_TYPE_IQD: | 1857 | case QETH_CARD_TYPE_IQD: |
1886 | return ((mtu >= 576) && | 1858 | return ((mtu >= 576) && |
1887 | (mtu <= card->info.max_mtu + 4096 - 32)); | 1859 | (mtu <= card->info.max_mtu)); |
1888 | case QETH_CARD_TYPE_OSN: | 1860 | case QETH_CARD_TYPE_OSN: |
1889 | case QETH_CARD_TYPE_UNKNOWN: | 1861 | case QETH_CARD_TYPE_UNKNOWN: |
1890 | default: | 1862 | default: |
@@ -1907,7 +1879,7 @@ static int qeth_ulp_enable_cb(struct qeth_card *card, struct qeth_reply *reply, | |||
1907 | memcpy(&card->token.ulp_filter_r, | 1879 | memcpy(&card->token.ulp_filter_r, |
1908 | QETH_ULP_ENABLE_RESP_FILTER_TOKEN(iob->data), | 1880 | QETH_ULP_ENABLE_RESP_FILTER_TOKEN(iob->data), |
1909 | QETH_MPC_TOKEN_LENGTH); | 1881 | QETH_MPC_TOKEN_LENGTH); |
1910 | if (qeth_get_mtu_out_of_mpc(card->info.type)) { | 1882 | if (card->info.type == QETH_CARD_TYPE_IQD) { |
1911 | memcpy(&framesize, QETH_ULP_ENABLE_RESP_MAX_MTU(iob->data), 2); | 1883 | memcpy(&framesize, QETH_ULP_ENABLE_RESP_MAX_MTU(iob->data), 2); |
1912 | mtu = qeth_get_mtu_outof_framesize(framesize); | 1884 | mtu = qeth_get_mtu_outof_framesize(framesize); |
1913 | if (!mtu) { | 1885 | if (!mtu) { |
@@ -1920,7 +1892,8 @@ static int qeth_ulp_enable_cb(struct qeth_card *card, struct qeth_reply *reply, | |||
1920 | card->qdio.in_buf_size = mtu + 2 * PAGE_SIZE; | 1892 | card->qdio.in_buf_size = mtu + 2 * PAGE_SIZE; |
1921 | } else { | 1893 | } else { |
1922 | card->info.initial_mtu = qeth_get_initial_mtu_for_card(card); | 1894 | card->info.initial_mtu = qeth_get_initial_mtu_for_card(card); |
1923 | card->info.max_mtu = qeth_get_max_mtu_for_card(card->info.type); | 1895 | card->info.max_mtu = *(__u16 *)QETH_ULP_ENABLE_RESP_MAX_MTU( |
1896 | iob->data); | ||
1924 | card->qdio.in_buf_size = QETH_IN_BUF_SIZE_DEFAULT; | 1897 | card->qdio.in_buf_size = QETH_IN_BUF_SIZE_DEFAULT; |
1925 | } | 1898 | } |
1926 | 1899 | ||