diff options
author | Arnd Bergmann <arnd@arndb.de> | 2011-01-25 15:49:56 -0500 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2011-03-05 04:55:58 -0500 |
commit | b0d0d915d1d1a0fe486849f3e41333c66df620c4 (patch) | |
tree | f9fef7b282b0ad9260b87c8ab2b12baa7b5deaff /net | |
parent | 60d9f461a20ba59219fdcdc30cbf8e3a4ad3f625 (diff) |
ipx: remove the BKL
This replaces all instances of lock_kernel in the
IPX code with lock_sock. As far as I can tell, this
is safe to do, because there is no global state
that needs to be locked in IPX, and the code does
not recursively take the lock or sleep indefinitely
while holding it.
Compile-tested only.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: netdev@vger.kernel.org
Diffstat (limited to 'net')
-rw-r--r-- | net/ipx/Kconfig | 1 | ||||
-rw-r--r-- | net/ipx/af_ipx.c | 52 |
2 files changed, 20 insertions, 33 deletions
diff --git a/net/ipx/Kconfig b/net/ipx/Kconfig index 02549cb2c328..e9ad0062fbb6 100644 --- a/net/ipx/Kconfig +++ b/net/ipx/Kconfig | |||
@@ -3,7 +3,6 @@ | |||
3 | # | 3 | # |
4 | config IPX | 4 | config IPX |
5 | tristate "The IPX protocol" | 5 | tristate "The IPX protocol" |
6 | depends on BKL # should be fixable | ||
7 | select LLC | 6 | select LLC |
8 | ---help--- | 7 | ---help--- |
9 | This is support for the Novell networking protocol, IPX, commonly | 8 | This is support for the Novell networking protocol, IPX, commonly |
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index da3d21c41d90..2731b51923d1 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <linux/uio.h> | 42 | #include <linux/uio.h> |
43 | #include <linux/slab.h> | 43 | #include <linux/slab.h> |
44 | #include <linux/skbuff.h> | 44 | #include <linux/skbuff.h> |
45 | #include <linux/smp_lock.h> | ||
46 | #include <linux/socket.h> | 45 | #include <linux/socket.h> |
47 | #include <linux/sockios.h> | 46 | #include <linux/sockios.h> |
48 | #include <linux/string.h> | 47 | #include <linux/string.h> |
@@ -1299,7 +1298,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname, | |||
1299 | int opt; | 1298 | int opt; |
1300 | int rc = -EINVAL; | 1299 | int rc = -EINVAL; |
1301 | 1300 | ||
1302 | lock_kernel(); | 1301 | lock_sock(sk); |
1303 | if (optlen != sizeof(int)) | 1302 | if (optlen != sizeof(int)) |
1304 | goto out; | 1303 | goto out; |
1305 | 1304 | ||
@@ -1314,7 +1313,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname, | |||
1314 | ipx_sk(sk)->type = opt; | 1313 | ipx_sk(sk)->type = opt; |
1315 | rc = 0; | 1314 | rc = 0; |
1316 | out: | 1315 | out: |
1317 | unlock_kernel(); | 1316 | release_sock(sk); |
1318 | return rc; | 1317 | return rc; |
1319 | } | 1318 | } |
1320 | 1319 | ||
@@ -1326,7 +1325,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname, | |||
1326 | int len; | 1325 | int len; |
1327 | int rc = -ENOPROTOOPT; | 1326 | int rc = -ENOPROTOOPT; |
1328 | 1327 | ||
1329 | lock_kernel(); | 1328 | lock_sock(sk); |
1330 | if (!(level == SOL_IPX && optname == IPX_TYPE)) | 1329 | if (!(level == SOL_IPX && optname == IPX_TYPE)) |
1331 | goto out; | 1330 | goto out; |
1332 | 1331 | ||
@@ -1347,7 +1346,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname, | |||
1347 | 1346 | ||
1348 | rc = 0; | 1347 | rc = 0; |
1349 | out: | 1348 | out: |
1350 | unlock_kernel(); | 1349 | release_sock(sk); |
1351 | return rc; | 1350 | return rc; |
1352 | } | 1351 | } |
1353 | 1352 | ||
@@ -1396,7 +1395,7 @@ static int ipx_release(struct socket *sock) | |||
1396 | if (!sk) | 1395 | if (!sk) |
1397 | goto out; | 1396 | goto out; |
1398 | 1397 | ||
1399 | lock_kernel(); | 1398 | lock_sock(sk); |
1400 | if (!sock_flag(sk, SOCK_DEAD)) | 1399 | if (!sock_flag(sk, SOCK_DEAD)) |
1401 | sk->sk_state_change(sk); | 1400 | sk->sk_state_change(sk); |
1402 | 1401 | ||
@@ -1404,7 +1403,7 @@ static int ipx_release(struct socket *sock) | |||
1404 | sock->sk = NULL; | 1403 | sock->sk = NULL; |
1405 | sk_refcnt_debug_release(sk); | 1404 | sk_refcnt_debug_release(sk); |
1406 | ipx_destroy_socket(sk); | 1405 | ipx_destroy_socket(sk); |
1407 | unlock_kernel(); | 1406 | release_sock(sk); |
1408 | out: | 1407 | out: |
1409 | return 0; | 1408 | return 0; |
1410 | } | 1409 | } |
@@ -1530,11 +1529,12 @@ out: | |||
1530 | 1529 | ||
1531 | static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | 1530 | static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
1532 | { | 1531 | { |
1532 | struct sock *sk = sock->sk; | ||
1533 | int rc; | 1533 | int rc; |
1534 | 1534 | ||
1535 | lock_kernel(); | 1535 | lock_sock(sk); |
1536 | rc = __ipx_bind(sock, uaddr, addr_len); | 1536 | rc = __ipx_bind(sock, uaddr, addr_len); |
1537 | unlock_kernel(); | 1537 | release_sock(sk); |
1538 | 1538 | ||
1539 | return rc; | 1539 | return rc; |
1540 | } | 1540 | } |
@@ -1551,7 +1551,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr, | |||
1551 | sk->sk_state = TCP_CLOSE; | 1551 | sk->sk_state = TCP_CLOSE; |
1552 | sock->state = SS_UNCONNECTED; | 1552 | sock->state = SS_UNCONNECTED; |
1553 | 1553 | ||
1554 | lock_kernel(); | 1554 | lock_sock(sk); |
1555 | if (addr_len != sizeof(*addr)) | 1555 | if (addr_len != sizeof(*addr)) |
1556 | goto out; | 1556 | goto out; |
1557 | addr = (struct sockaddr_ipx *)uaddr; | 1557 | addr = (struct sockaddr_ipx *)uaddr; |
@@ -1598,7 +1598,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr, | |||
1598 | ipxrtr_put(rt); | 1598 | ipxrtr_put(rt); |
1599 | rc = 0; | 1599 | rc = 0; |
1600 | out: | 1600 | out: |
1601 | unlock_kernel(); | 1601 | release_sock(sk); |
1602 | return rc; | 1602 | return rc; |
1603 | } | 1603 | } |
1604 | 1604 | ||
@@ -1614,7 +1614,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr, | |||
1614 | 1614 | ||
1615 | *uaddr_len = sizeof(struct sockaddr_ipx); | 1615 | *uaddr_len = sizeof(struct sockaddr_ipx); |
1616 | 1616 | ||
1617 | lock_kernel(); | 1617 | lock_sock(sk); |
1618 | if (peer) { | 1618 | if (peer) { |
1619 | rc = -ENOTCONN; | 1619 | rc = -ENOTCONN; |
1620 | if (sk->sk_state != TCP_ESTABLISHED) | 1620 | if (sk->sk_state != TCP_ESTABLISHED) |
@@ -1649,19 +1649,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr, | |||
1649 | 1649 | ||
1650 | rc = 0; | 1650 | rc = 0; |
1651 | out: | 1651 | out: |
1652 | unlock_kernel(); | 1652 | release_sock(sk); |
1653 | return rc; | ||
1654 | } | ||
1655 | |||
1656 | static unsigned int ipx_datagram_poll(struct file *file, struct socket *sock, | ||
1657 | poll_table *wait) | ||
1658 | { | ||
1659 | int rc; | ||
1660 | |||
1661 | lock_kernel(); | ||
1662 | rc = datagram_poll(file, sock, wait); | ||
1663 | unlock_kernel(); | ||
1664 | |||
1665 | return rc; | 1653 | return rc; |
1666 | } | 1654 | } |
1667 | 1655 | ||
@@ -1736,7 +1724,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1736 | int rc = -EINVAL; | 1724 | int rc = -EINVAL; |
1737 | int flags = msg->msg_flags; | 1725 | int flags = msg->msg_flags; |
1738 | 1726 | ||
1739 | lock_kernel(); | 1727 | lock_sock(sk); |
1740 | /* Socket gets bound below anyway */ | 1728 | /* Socket gets bound below anyway */ |
1741 | /* if (sk->sk_zapped) | 1729 | /* if (sk->sk_zapped) |
1742 | return -EIO; */ /* Socket not bound */ | 1730 | return -EIO; */ /* Socket not bound */ |
@@ -1788,7 +1776,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1788 | if (rc >= 0) | 1776 | if (rc >= 0) |
1789 | rc = len; | 1777 | rc = len; |
1790 | out: | 1778 | out: |
1791 | unlock_kernel(); | 1779 | release_sock(sk); |
1792 | return rc; | 1780 | return rc; |
1793 | } | 1781 | } |
1794 | 1782 | ||
@@ -1803,7 +1791,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1803 | struct sk_buff *skb; | 1791 | struct sk_buff *skb; |
1804 | int copied, rc; | 1792 | int copied, rc; |
1805 | 1793 | ||
1806 | lock_kernel(); | 1794 | lock_sock(sk); |
1807 | /* put the autobinding in */ | 1795 | /* put the autobinding in */ |
1808 | if (!ipxs->port) { | 1796 | if (!ipxs->port) { |
1809 | struct sockaddr_ipx uaddr; | 1797 | struct sockaddr_ipx uaddr; |
@@ -1862,7 +1850,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1862 | out_free: | 1850 | out_free: |
1863 | skb_free_datagram(sk, skb); | 1851 | skb_free_datagram(sk, skb); |
1864 | out: | 1852 | out: |
1865 | unlock_kernel(); | 1853 | release_sock(sk); |
1866 | return rc; | 1854 | return rc; |
1867 | } | 1855 | } |
1868 | 1856 | ||
@@ -1874,7 +1862,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1874 | struct sock *sk = sock->sk; | 1862 | struct sock *sk = sock->sk; |
1875 | void __user *argp = (void __user *)arg; | 1863 | void __user *argp = (void __user *)arg; |
1876 | 1864 | ||
1877 | lock_kernel(); | 1865 | lock_sock(sk); |
1878 | switch (cmd) { | 1866 | switch (cmd) { |
1879 | case TIOCOUTQ: | 1867 | case TIOCOUTQ: |
1880 | amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk); | 1868 | amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk); |
@@ -1937,7 +1925,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1937 | rc = -ENOIOCTLCMD; | 1925 | rc = -ENOIOCTLCMD; |
1938 | break; | 1926 | break; |
1939 | } | 1927 | } |
1940 | unlock_kernel(); | 1928 | release_sock(sk); |
1941 | 1929 | ||
1942 | return rc; | 1930 | return rc; |
1943 | } | 1931 | } |
@@ -1984,7 +1972,7 @@ static const struct proto_ops ipx_dgram_ops = { | |||
1984 | .socketpair = sock_no_socketpair, | 1972 | .socketpair = sock_no_socketpair, |
1985 | .accept = sock_no_accept, | 1973 | .accept = sock_no_accept, |
1986 | .getname = ipx_getname, | 1974 | .getname = ipx_getname, |
1987 | .poll = ipx_datagram_poll, | 1975 | .poll = datagram_poll, |
1988 | .ioctl = ipx_ioctl, | 1976 | .ioctl = ipx_ioctl, |
1989 | #ifdef CONFIG_COMPAT | 1977 | #ifdef CONFIG_COMPAT |
1990 | .compat_ioctl = ipx_compat_ioctl, | 1978 | .compat_ioctl = ipx_compat_ioctl, |