diff options
Diffstat (limited to 'net')
94 files changed, 2245 insertions, 1077 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index dd43a8289b0d..787ccddb85ea 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -117,9 +117,6 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | if (!clnt->trans_mod) | ||
121 | clnt->trans_mod = v9fs_get_default_trans(); | ||
122 | |||
123 | kfree(options); | 120 | kfree(options); |
124 | return ret; | 121 | return ret; |
125 | } | 122 | } |
@@ -689,6 +686,9 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
689 | if (err < 0) | 686 | if (err < 0) |
690 | goto error; | 687 | goto error; |
691 | 688 | ||
689 | if (!clnt->trans_mod) | ||
690 | clnt->trans_mod = v9fs_get_default_trans(); | ||
691 | |||
692 | if (clnt->trans_mod == NULL) { | 692 | if (clnt->trans_mod == NULL) { |
693 | err = -EPROTONOSUPPORT; | 693 | err = -EPROTONOSUPPORT; |
694 | P9_DPRINTK(P9_DEBUG_ERROR, | 694 | P9_DPRINTK(P9_DEBUG_ERROR, |
@@ -1098,7 +1098,6 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset, | |||
1098 | 1098 | ||
1099 | if (data) { | 1099 | if (data) { |
1100 | memmove(data, dataptr, count); | 1100 | memmove(data, dataptr, count); |
1101 | data += count; | ||
1102 | } | 1101 | } |
1103 | 1102 | ||
1104 | if (udata) { | 1103 | if (udata) { |
@@ -1192,9 +1191,9 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid) | |||
1192 | 1191 | ||
1193 | err = p9pdu_readf(req->rc, clnt->dotu, "wS", &ignored, ret); | 1192 | err = p9pdu_readf(req->rc, clnt->dotu, "wS", &ignored, ret); |
1194 | if (err) { | 1193 | if (err) { |
1195 | ret = ERR_PTR(err); | ||
1196 | p9pdu_dump(1, req->rc); | 1194 | p9pdu_dump(1, req->rc); |
1197 | goto free_and_error; | 1195 | p9_free_req(clnt, req); |
1196 | goto error; | ||
1198 | } | 1197 | } |
1199 | 1198 | ||
1200 | P9_DPRINTK(P9_DEBUG_9P, | 1199 | P9_DPRINTK(P9_DEBUG_9P, |
@@ -1211,8 +1210,6 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid) | |||
1211 | p9_free_req(clnt, req); | 1210 | p9_free_req(clnt, req); |
1212 | return ret; | 1211 | return ret; |
1213 | 1212 | ||
1214 | free_and_error: | ||
1215 | p9_free_req(clnt, req); | ||
1216 | error: | 1213 | error: |
1217 | kfree(ret); | 1214 | kfree(ret); |
1218 | return ERR_PTR(err); | 1215 | return ERR_PTR(err); |
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index a2a1814c7a8d..8c2588e4edc0 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -735,12 +735,14 @@ static int parse_opts(char *params, struct p9_fd_opts *opts) | |||
735 | if (!*p) | 735 | if (!*p) |
736 | continue; | 736 | continue; |
737 | token = match_token(p, tokens, args); | 737 | token = match_token(p, tokens, args); |
738 | r = match_int(&args[0], &option); | 738 | if (token != Opt_err) { |
739 | if (r < 0) { | 739 | r = match_int(&args[0], &option); |
740 | P9_DPRINTK(P9_DEBUG_ERROR, | 740 | if (r < 0) { |
741 | "integer field, but no integer?\n"); | 741 | P9_DPRINTK(P9_DEBUG_ERROR, |
742 | ret = r; | 742 | "integer field, but no integer?\n"); |
743 | continue; | 743 | ret = r; |
744 | continue; | ||
745 | } | ||
744 | } | 746 | } |
745 | switch (token) { | 747 | switch (token) { |
746 | case Opt_port: | 748 | case Opt_port: |
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 590b83963622..bfbe13786bb4 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/capability.h> | 54 | #include <linux/capability.h> |
55 | #include <linux/module.h> | 55 | #include <linux/module.h> |
56 | #include <linux/if_arp.h> | 56 | #include <linux/if_arp.h> |
57 | #include <linux/smp_lock.h> | ||
57 | #include <linux/termios.h> /* For TIOCOUTQ/INQ */ | 58 | #include <linux/termios.h> /* For TIOCOUTQ/INQ */ |
58 | #include <net/datalink.h> | 59 | #include <net/datalink.h> |
59 | #include <net/psnap.h> | 60 | #include <net/psnap.h> |
diff --git a/net/atm/common.c b/net/atm/common.c index c1c97936192c..8c4d843eb17f 100644 --- a/net/atm/common.c +++ b/net/atm/common.c | |||
@@ -92,7 +92,7 @@ static void vcc_sock_destruct(struct sock *sk) | |||
92 | static void vcc_def_wakeup(struct sock *sk) | 92 | static void vcc_def_wakeup(struct sock *sk) |
93 | { | 93 | { |
94 | read_lock(&sk->sk_callback_lock); | 94 | read_lock(&sk->sk_callback_lock); |
95 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 95 | if (sk_has_sleeper(sk)) |
96 | wake_up(sk->sk_sleep); | 96 | wake_up(sk->sk_sleep); |
97 | read_unlock(&sk->sk_callback_lock); | 97 | read_unlock(&sk->sk_callback_lock); |
98 | } | 98 | } |
@@ -110,7 +110,7 @@ static void vcc_write_space(struct sock *sk) | |||
110 | read_lock(&sk->sk_callback_lock); | 110 | read_lock(&sk->sk_callback_lock); |
111 | 111 | ||
112 | if (vcc_writable(sk)) { | 112 | if (vcc_writable(sk)) { |
113 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 113 | if (sk_has_sleeper(sk)) |
114 | wake_up_interruptible(sk->sk_sleep); | 114 | wake_up_interruptible(sk->sk_sleep); |
115 | 115 | ||
116 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); | 116 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); |
@@ -594,7 +594,7 @@ unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
594 | struct atm_vcc *vcc; | 594 | struct atm_vcc *vcc; |
595 | unsigned int mask; | 595 | unsigned int mask; |
596 | 596 | ||
597 | poll_wait(file, sk->sk_sleep, wait); | 597 | sock_poll_wait(file, sk->sk_sleep, wait); |
598 | mask = 0; | 598 | mask = 0; |
599 | 599 | ||
600 | vcc = ATM_SD(sock); | 600 | vcc = ATM_SD(sock); |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index e50566ebf9f9..94b3388c188b 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -2080,28 +2080,41 @@ static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL); | |||
2080 | /* ---- Initialization ---- */ | 2080 | /* ---- Initialization ---- */ |
2081 | static int __init rfcomm_init(void) | 2081 | static int __init rfcomm_init(void) |
2082 | { | 2082 | { |
2083 | int ret; | ||
2084 | |||
2083 | l2cap_load(); | 2085 | l2cap_load(); |
2084 | 2086 | ||
2085 | hci_register_cb(&rfcomm_cb); | 2087 | hci_register_cb(&rfcomm_cb); |
2086 | 2088 | ||
2087 | rfcomm_thread = kthread_run(rfcomm_run, NULL, "krfcommd"); | 2089 | rfcomm_thread = kthread_run(rfcomm_run, NULL, "krfcommd"); |
2088 | if (IS_ERR(rfcomm_thread)) { | 2090 | if (IS_ERR(rfcomm_thread)) { |
2089 | hci_unregister_cb(&rfcomm_cb); | 2091 | ret = PTR_ERR(rfcomm_thread); |
2090 | return PTR_ERR(rfcomm_thread); | 2092 | goto out_thread; |
2091 | } | 2093 | } |
2092 | 2094 | ||
2093 | if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0) | 2095 | if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0) |
2094 | BT_ERR("Failed to create RFCOMM info file"); | 2096 | BT_ERR("Failed to create RFCOMM info file"); |
2095 | 2097 | ||
2096 | rfcomm_init_sockets(); | 2098 | ret = rfcomm_init_ttys(); |
2099 | if (ret) | ||
2100 | goto out_tty; | ||
2097 | 2101 | ||
2098 | #ifdef CONFIG_BT_RFCOMM_TTY | 2102 | ret = rfcomm_init_sockets(); |
2099 | rfcomm_init_ttys(); | 2103 | if (ret) |
2100 | #endif | 2104 | goto out_sock; |
2101 | 2105 | ||
2102 | BT_INFO("RFCOMM ver %s", VERSION); | 2106 | BT_INFO("RFCOMM ver %s", VERSION); |
2103 | 2107 | ||
2104 | return 0; | 2108 | return 0; |
2109 | |||
2110 | out_sock: | ||
2111 | rfcomm_cleanup_ttys(); | ||
2112 | out_tty: | ||
2113 | kthread_stop(rfcomm_thread); | ||
2114 | out_thread: | ||
2115 | hci_unregister_cb(&rfcomm_cb); | ||
2116 | |||
2117 | return ret; | ||
2105 | } | 2118 | } |
2106 | 2119 | ||
2107 | static void __exit rfcomm_exit(void) | 2120 | static void __exit rfcomm_exit(void) |
@@ -2112,9 +2125,7 @@ static void __exit rfcomm_exit(void) | |||
2112 | 2125 | ||
2113 | kthread_stop(rfcomm_thread); | 2126 | kthread_stop(rfcomm_thread); |
2114 | 2127 | ||
2115 | #ifdef CONFIG_BT_RFCOMM_TTY | ||
2116 | rfcomm_cleanup_ttys(); | 2128 | rfcomm_cleanup_ttys(); |
2117 | #endif | ||
2118 | 2129 | ||
2119 | rfcomm_cleanup_sockets(); | 2130 | rfcomm_cleanup_sockets(); |
2120 | } | 2131 | } |
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 7f482784e9f7..0b85e8116859 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -1132,7 +1132,7 @@ error: | |||
1132 | return err; | 1132 | return err; |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | void __exit rfcomm_cleanup_sockets(void) | 1135 | void rfcomm_cleanup_sockets(void) |
1136 | { | 1136 | { |
1137 | class_remove_file(bt_class, &class_attr_rfcomm); | 1137 | class_remove_file(bt_class, &class_attr_rfcomm); |
1138 | 1138 | ||
diff --git a/net/bridge/br.c b/net/bridge/br.c index 9aac5213105a..e1241c76239a 100644 --- a/net/bridge/br.c +++ b/net/bridge/br.c | |||
@@ -93,7 +93,7 @@ static void __exit br_deinit(void) | |||
93 | 93 | ||
94 | unregister_pernet_subsys(&br_net_ops); | 94 | unregister_pernet_subsys(&br_net_ops); |
95 | 95 | ||
96 | synchronize_net(); | 96 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ |
97 | 97 | ||
98 | br_netfilter_fini(); | 98 | br_netfilter_fini(); |
99 | #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE) | 99 | #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE) |
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 8a96672e2c5c..eb404dc3ed6e 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c | |||
@@ -424,7 +424,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) | |||
424 | err2: | 424 | err2: |
425 | br_fdb_delete_by_port(br, p, 1); | 425 | br_fdb_delete_by_port(br, p, 1); |
426 | err1: | 426 | err1: |
427 | kobject_del(&p->kobj); | 427 | kobject_put(&p->kobj); |
428 | err0: | 428 | err0: |
429 | dev_set_promiscuity(dev, -1); | 429 | dev_set_promiscuity(dev, -1); |
430 | put_back: | 430 | put_back: |
diff --git a/net/can/bcm.c b/net/can/bcm.c index 95d7f32643ae..72720c710351 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c | |||
@@ -75,6 +75,7 @@ static __initdata const char banner[] = KERN_INFO | |||
75 | MODULE_DESCRIPTION("PF_CAN broadcast manager protocol"); | 75 | MODULE_DESCRIPTION("PF_CAN broadcast manager protocol"); |
76 | MODULE_LICENSE("Dual BSD/GPL"); | 76 | MODULE_LICENSE("Dual BSD/GPL"); |
77 | MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>"); | 77 | MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>"); |
78 | MODULE_ALIAS("can-proto-2"); | ||
78 | 79 | ||
79 | /* easy access to can_frame payload */ | 80 | /* easy access to can_frame payload */ |
80 | static inline u64 GET_U64(const struct can_frame *cp) | 81 | static inline u64 GET_U64(const struct can_frame *cp) |
@@ -1469,6 +1470,9 @@ static int bcm_release(struct socket *sock) | |||
1469 | bo->ifindex = 0; | 1470 | bo->ifindex = 0; |
1470 | } | 1471 | } |
1471 | 1472 | ||
1473 | sock_orphan(sk); | ||
1474 | sock->sk = NULL; | ||
1475 | |||
1472 | release_sock(sk); | 1476 | release_sock(sk); |
1473 | sock_put(sk); | 1477 | sock_put(sk); |
1474 | 1478 | ||
diff --git a/net/can/raw.c b/net/can/raw.c index 6aa154e806ae..f4cc44548bda 100644 --- a/net/can/raw.c +++ b/net/can/raw.c | |||
@@ -62,6 +62,7 @@ static __initdata const char banner[] = | |||
62 | MODULE_DESCRIPTION("PF_CAN raw protocol"); | 62 | MODULE_DESCRIPTION("PF_CAN raw protocol"); |
63 | MODULE_LICENSE("Dual BSD/GPL"); | 63 | MODULE_LICENSE("Dual BSD/GPL"); |
64 | MODULE_AUTHOR("Urs Thuermann <urs.thuermann@volkswagen.de>"); | 64 | MODULE_AUTHOR("Urs Thuermann <urs.thuermann@volkswagen.de>"); |
65 | MODULE_ALIAS("can-proto-1"); | ||
65 | 66 | ||
66 | #define MASK_ALL 0 | 67 | #define MASK_ALL 0 |
67 | 68 | ||
@@ -306,6 +307,9 @@ static int raw_release(struct socket *sock) | |||
306 | ro->bound = 0; | 307 | ro->bound = 0; |
307 | ro->count = 0; | 308 | ro->count = 0; |
308 | 309 | ||
310 | sock_orphan(sk); | ||
311 | sock->sk = NULL; | ||
312 | |||
309 | release_sock(sk); | 313 | release_sock(sk); |
310 | sock_put(sk); | 314 | sock_put(sk); |
311 | 315 | ||
diff --git a/net/core/datagram.c b/net/core/datagram.c index 58abee1f1df1..b0fe69211eef 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
@@ -712,7 +712,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock, | |||
712 | struct sock *sk = sock->sk; | 712 | struct sock *sk = sock->sk; |
713 | unsigned int mask; | 713 | unsigned int mask; |
714 | 714 | ||
715 | poll_wait(file, sk->sk_sleep, wait); | 715 | sock_poll_wait(file, sk->sk_sleep, wait); |
716 | mask = 0; | 716 | mask = 0; |
717 | 717 | ||
718 | /* exceptional events? */ | 718 | /* exceptional events? */ |
diff --git a/net/core/dev.c b/net/core/dev.c index 60b572812278..6a94475aee85 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -2823,9 +2823,11 @@ static void net_rx_action(struct softirq_action *h) | |||
2823 | * move the instance around on the list at-will. | 2823 | * move the instance around on the list at-will. |
2824 | */ | 2824 | */ |
2825 | if (unlikely(work == weight)) { | 2825 | if (unlikely(work == weight)) { |
2826 | if (unlikely(napi_disable_pending(n))) | 2826 | if (unlikely(napi_disable_pending(n))) { |
2827 | __napi_complete(n); | 2827 | local_irq_enable(); |
2828 | else | 2828 | napi_complete(n); |
2829 | local_irq_disable(); | ||
2830 | } else | ||
2829 | list_move_tail(&n->poll_list, list); | 2831 | list_move_tail(&n->poll_list, list); |
2830 | } | 2832 | } |
2831 | 2833 | ||
@@ -3863,10 +3865,12 @@ int dev_unicast_delete(struct net_device *dev, void *addr) | |||
3863 | 3865 | ||
3864 | ASSERT_RTNL(); | 3866 | ASSERT_RTNL(); |
3865 | 3867 | ||
3868 | netif_addr_lock_bh(dev); | ||
3866 | err = __hw_addr_del(&dev->uc, addr, dev->addr_len, | 3869 | err = __hw_addr_del(&dev->uc, addr, dev->addr_len, |
3867 | NETDEV_HW_ADDR_T_UNICAST); | 3870 | NETDEV_HW_ADDR_T_UNICAST); |
3868 | if (!err) | 3871 | if (!err) |
3869 | __dev_set_rx_mode(dev); | 3872 | __dev_set_rx_mode(dev); |
3873 | netif_addr_unlock_bh(dev); | ||
3870 | return err; | 3874 | return err; |
3871 | } | 3875 | } |
3872 | EXPORT_SYMBOL(dev_unicast_delete); | 3876 | EXPORT_SYMBOL(dev_unicast_delete); |
@@ -3887,10 +3891,12 @@ int dev_unicast_add(struct net_device *dev, void *addr) | |||
3887 | 3891 | ||
3888 | ASSERT_RTNL(); | 3892 | ASSERT_RTNL(); |
3889 | 3893 | ||
3894 | netif_addr_lock_bh(dev); | ||
3890 | err = __hw_addr_add(&dev->uc, addr, dev->addr_len, | 3895 | err = __hw_addr_add(&dev->uc, addr, dev->addr_len, |
3891 | NETDEV_HW_ADDR_T_UNICAST); | 3896 | NETDEV_HW_ADDR_T_UNICAST); |
3892 | if (!err) | 3897 | if (!err) |
3893 | __dev_set_rx_mode(dev); | 3898 | __dev_set_rx_mode(dev); |
3899 | netif_addr_unlock_bh(dev); | ||
3894 | return err; | 3900 | return err; |
3895 | } | 3901 | } |
3896 | EXPORT_SYMBOL(dev_unicast_add); | 3902 | EXPORT_SYMBOL(dev_unicast_add); |
@@ -3947,7 +3953,8 @@ void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, | |||
3947 | * @from: source device | 3953 | * @from: source device |
3948 | * | 3954 | * |
3949 | * Add newly added addresses to the destination device and release | 3955 | * Add newly added addresses to the destination device and release |
3950 | * addresses that have no users left. | 3956 | * addresses that have no users left. The source device must be |
3957 | * locked by netif_tx_lock_bh. | ||
3951 | * | 3958 | * |
3952 | * This function is intended to be called from the dev->set_rx_mode | 3959 | * This function is intended to be called from the dev->set_rx_mode |
3953 | * function of layered software devices. | 3960 | * function of layered software devices. |
@@ -3956,14 +3963,14 @@ int dev_unicast_sync(struct net_device *to, struct net_device *from) | |||
3956 | { | 3963 | { |
3957 | int err = 0; | 3964 | int err = 0; |
3958 | 3965 | ||
3959 | ASSERT_RTNL(); | ||
3960 | |||
3961 | if (to->addr_len != from->addr_len) | 3966 | if (to->addr_len != from->addr_len) |
3962 | return -EINVAL; | 3967 | return -EINVAL; |
3963 | 3968 | ||
3969 | netif_addr_lock_bh(to); | ||
3964 | err = __hw_addr_sync(&to->uc, &from->uc, to->addr_len); | 3970 | err = __hw_addr_sync(&to->uc, &from->uc, to->addr_len); |
3965 | if (!err) | 3971 | if (!err) |
3966 | __dev_set_rx_mode(to); | 3972 | __dev_set_rx_mode(to); |
3973 | netif_addr_unlock_bh(to); | ||
3967 | return err; | 3974 | return err; |
3968 | } | 3975 | } |
3969 | EXPORT_SYMBOL(dev_unicast_sync); | 3976 | EXPORT_SYMBOL(dev_unicast_sync); |
@@ -3979,27 +3986,27 @@ EXPORT_SYMBOL(dev_unicast_sync); | |||
3979 | */ | 3986 | */ |
3980 | void dev_unicast_unsync(struct net_device *to, struct net_device *from) | 3987 | void dev_unicast_unsync(struct net_device *to, struct net_device *from) |
3981 | { | 3988 | { |
3982 | ASSERT_RTNL(); | ||
3983 | |||
3984 | if (to->addr_len != from->addr_len) | 3989 | if (to->addr_len != from->addr_len) |
3985 | return; | 3990 | return; |
3986 | 3991 | ||
3992 | netif_addr_lock_bh(from); | ||
3993 | netif_addr_lock(to); | ||
3987 | __hw_addr_unsync(&to->uc, &from->uc, to->addr_len); | 3994 | __hw_addr_unsync(&to->uc, &from->uc, to->addr_len); |
3988 | __dev_set_rx_mode(to); | 3995 | __dev_set_rx_mode(to); |
3996 | netif_addr_unlock(to); | ||
3997 | netif_addr_unlock_bh(from); | ||
3989 | } | 3998 | } |
3990 | EXPORT_SYMBOL(dev_unicast_unsync); | 3999 | EXPORT_SYMBOL(dev_unicast_unsync); |
3991 | 4000 | ||
3992 | static void dev_unicast_flush(struct net_device *dev) | 4001 | static void dev_unicast_flush(struct net_device *dev) |
3993 | { | 4002 | { |
3994 | /* rtnl_mutex must be held here */ | 4003 | netif_addr_lock_bh(dev); |
3995 | |||
3996 | __hw_addr_flush(&dev->uc); | 4004 | __hw_addr_flush(&dev->uc); |
4005 | netif_addr_unlock_bh(dev); | ||
3997 | } | 4006 | } |
3998 | 4007 | ||
3999 | static void dev_unicast_init(struct net_device *dev) | 4008 | static void dev_unicast_init(struct net_device *dev) |
4000 | { | 4009 | { |
4001 | /* rtnl_mutex must be held here */ | ||
4002 | |||
4003 | __hw_addr_init(&dev->uc); | 4010 | __hw_addr_init(&dev->uc); |
4004 | } | 4011 | } |
4005 | 4012 | ||
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index b7292a2719dc..197283072cc8 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c | |||
@@ -488,7 +488,7 @@ int net_assign_generic(struct net *net, int id, void *data) | |||
488 | */ | 488 | */ |
489 | 489 | ||
490 | ng->len = id; | 490 | ng->len = id; |
491 | memcpy(&ng->ptr, &old_ng->ptr, old_ng->len); | 491 | memcpy(&ng->ptr, &old_ng->ptr, old_ng->len * sizeof(void*)); |
492 | 492 | ||
493 | rcu_assign_pointer(net->gen, ng); | 493 | rcu_assign_pointer(net->gen, ng); |
494 | call_rcu(&old_ng->rcu, net_generic_release); | 494 | call_rcu(&old_ng->rcu, net_generic_release); |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 9675f312830d..df30feb2fc72 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -740,7 +740,7 @@ int netpoll_setup(struct netpoll *np) | |||
740 | np->name); | 740 | np->name); |
741 | break; | 741 | break; |
742 | } | 742 | } |
743 | cond_resched(); | 743 | msleep(1); |
744 | } | 744 | } |
745 | 745 | ||
746 | /* If carrier appears to come up instantly, we don't | 746 | /* If carrier appears to come up instantly, we don't |
diff --git a/net/core/sock.c b/net/core/sock.c index b0ba569bc973..bbb25be7ddfe 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -631,7 +631,7 @@ set_rcvbuf: | |||
631 | 631 | ||
632 | case SO_TIMESTAMPING: | 632 | case SO_TIMESTAMPING: |
633 | if (val & ~SOF_TIMESTAMPING_MASK) { | 633 | if (val & ~SOF_TIMESTAMPING_MASK) { |
634 | ret = EINVAL; | 634 | ret = -EINVAL; |
635 | break; | 635 | break; |
636 | } | 636 | } |
637 | sock_valbool_flag(sk, SOCK_TIMESTAMPING_TX_HARDWARE, | 637 | sock_valbool_flag(sk, SOCK_TIMESTAMPING_TX_HARDWARE, |
@@ -919,13 +919,19 @@ static inline void sock_lock_init(struct sock *sk) | |||
919 | af_family_keys + sk->sk_family); | 919 | af_family_keys + sk->sk_family); |
920 | } | 920 | } |
921 | 921 | ||
922 | /* | ||
923 | * Copy all fields from osk to nsk but nsk->sk_refcnt must not change yet, | ||
924 | * even temporarly, because of RCU lookups. sk_node should also be left as is. | ||
925 | */ | ||
922 | static void sock_copy(struct sock *nsk, const struct sock *osk) | 926 | static void sock_copy(struct sock *nsk, const struct sock *osk) |
923 | { | 927 | { |
924 | #ifdef CONFIG_SECURITY_NETWORK | 928 | #ifdef CONFIG_SECURITY_NETWORK |
925 | void *sptr = nsk->sk_security; | 929 | void *sptr = nsk->sk_security; |
926 | #endif | 930 | #endif |
927 | 931 | BUILD_BUG_ON(offsetof(struct sock, sk_copy_start) != | |
928 | memcpy(nsk, osk, osk->sk_prot->obj_size); | 932 | sizeof(osk->sk_node) + sizeof(osk->sk_refcnt)); |
933 | memcpy(&nsk->sk_copy_start, &osk->sk_copy_start, | ||
934 | osk->sk_prot->obj_size - offsetof(struct sock, sk_copy_start)); | ||
929 | #ifdef CONFIG_SECURITY_NETWORK | 935 | #ifdef CONFIG_SECURITY_NETWORK |
930 | nsk->sk_security = sptr; | 936 | nsk->sk_security = sptr; |
931 | security_sk_clone(osk, nsk); | 937 | security_sk_clone(osk, nsk); |
@@ -939,8 +945,23 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority, | |||
939 | struct kmem_cache *slab; | 945 | struct kmem_cache *slab; |
940 | 946 | ||
941 | slab = prot->slab; | 947 | slab = prot->slab; |
942 | if (slab != NULL) | 948 | if (slab != NULL) { |
943 | sk = kmem_cache_alloc(slab, priority); | 949 | sk = kmem_cache_alloc(slab, priority & ~__GFP_ZERO); |
950 | if (!sk) | ||
951 | return sk; | ||
952 | if (priority & __GFP_ZERO) { | ||
953 | /* | ||
954 | * caches using SLAB_DESTROY_BY_RCU should let | ||
955 | * sk_node.next un-modified. Special care is taken | ||
956 | * when initializing object to zero. | ||
957 | */ | ||
958 | if (offsetof(struct sock, sk_node.next) != 0) | ||
959 | memset(sk, 0, offsetof(struct sock, sk_node.next)); | ||
960 | memset(&sk->sk_node.pprev, 0, | ||
961 | prot->obj_size - offsetof(struct sock, | ||
962 | sk_node.pprev)); | ||
963 | } | ||
964 | } | ||
944 | else | 965 | else |
945 | sk = kmalloc(prot->obj_size, priority); | 966 | sk = kmalloc(prot->obj_size, priority); |
946 | 967 | ||
@@ -1125,6 +1146,11 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority) | |||
1125 | 1146 | ||
1126 | newsk->sk_err = 0; | 1147 | newsk->sk_err = 0; |
1127 | newsk->sk_priority = 0; | 1148 | newsk->sk_priority = 0; |
1149 | /* | ||
1150 | * Before updating sk_refcnt, we must commit prior changes to memory | ||
1151 | * (Documentation/RCU/rculist_nulls.txt for details) | ||
1152 | */ | ||
1153 | smp_wmb(); | ||
1128 | atomic_set(&newsk->sk_refcnt, 2); | 1154 | atomic_set(&newsk->sk_refcnt, 2); |
1129 | 1155 | ||
1130 | /* | 1156 | /* |
@@ -1715,7 +1741,7 @@ EXPORT_SYMBOL(sock_no_sendpage); | |||
1715 | static void sock_def_wakeup(struct sock *sk) | 1741 | static void sock_def_wakeup(struct sock *sk) |
1716 | { | 1742 | { |
1717 | read_lock(&sk->sk_callback_lock); | 1743 | read_lock(&sk->sk_callback_lock); |
1718 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 1744 | if (sk_has_sleeper(sk)) |
1719 | wake_up_interruptible_all(sk->sk_sleep); | 1745 | wake_up_interruptible_all(sk->sk_sleep); |
1720 | read_unlock(&sk->sk_callback_lock); | 1746 | read_unlock(&sk->sk_callback_lock); |
1721 | } | 1747 | } |
@@ -1723,7 +1749,7 @@ static void sock_def_wakeup(struct sock *sk) | |||
1723 | static void sock_def_error_report(struct sock *sk) | 1749 | static void sock_def_error_report(struct sock *sk) |
1724 | { | 1750 | { |
1725 | read_lock(&sk->sk_callback_lock); | 1751 | read_lock(&sk->sk_callback_lock); |
1726 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 1752 | if (sk_has_sleeper(sk)) |
1727 | wake_up_interruptible_poll(sk->sk_sleep, POLLERR); | 1753 | wake_up_interruptible_poll(sk->sk_sleep, POLLERR); |
1728 | sk_wake_async(sk, SOCK_WAKE_IO, POLL_ERR); | 1754 | sk_wake_async(sk, SOCK_WAKE_IO, POLL_ERR); |
1729 | read_unlock(&sk->sk_callback_lock); | 1755 | read_unlock(&sk->sk_callback_lock); |
@@ -1732,7 +1758,7 @@ static void sock_def_error_report(struct sock *sk) | |||
1732 | static void sock_def_readable(struct sock *sk, int len) | 1758 | static void sock_def_readable(struct sock *sk, int len) |
1733 | { | 1759 | { |
1734 | read_lock(&sk->sk_callback_lock); | 1760 | read_lock(&sk->sk_callback_lock); |
1735 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 1761 | if (sk_has_sleeper(sk)) |
1736 | wake_up_interruptible_sync_poll(sk->sk_sleep, POLLIN | | 1762 | wake_up_interruptible_sync_poll(sk->sk_sleep, POLLIN | |
1737 | POLLRDNORM | POLLRDBAND); | 1763 | POLLRDNORM | POLLRDBAND); |
1738 | sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); | 1764 | sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); |
@@ -1747,7 +1773,7 @@ static void sock_def_write_space(struct sock *sk) | |||
1747 | * progress. --DaveM | 1773 | * progress. --DaveM |
1748 | */ | 1774 | */ |
1749 | if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) { | 1775 | if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) { |
1750 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 1776 | if (sk_has_sleeper(sk)) |
1751 | wake_up_interruptible_sync_poll(sk->sk_sleep, POLLOUT | | 1777 | wake_up_interruptible_sync_poll(sk->sk_sleep, POLLOUT | |
1752 | POLLWRNORM | POLLWRBAND); | 1778 | POLLWRNORM | POLLWRBAND); |
1753 | 1779 | ||
@@ -1840,6 +1866,11 @@ void sock_init_data(struct socket *sock, struct sock *sk) | |||
1840 | 1866 | ||
1841 | sk->sk_stamp = ktime_set(-1L, 0); | 1867 | sk->sk_stamp = ktime_set(-1L, 0); |
1842 | 1868 | ||
1869 | /* | ||
1870 | * Before updating sk_refcnt, we must commit prior changes to memory | ||
1871 | * (Documentation/RCU/rculist_nulls.txt for details) | ||
1872 | */ | ||
1873 | smp_wmb(); | ||
1843 | atomic_set(&sk->sk_refcnt, 1); | 1874 | atomic_set(&sk->sk_refcnt, 1); |
1844 | atomic_set(&sk->sk_wmem_alloc, 1); | 1875 | atomic_set(&sk->sk_wmem_alloc, 1); |
1845 | atomic_set(&sk->sk_drops, 0); | 1876 | atomic_set(&sk->sk_drops, 0); |
diff --git a/net/dccp/output.c b/net/dccp/output.c index c0e88c16d088..c96119fda688 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c | |||
@@ -196,7 +196,7 @@ void dccp_write_space(struct sock *sk) | |||
196 | { | 196 | { |
197 | read_lock(&sk->sk_callback_lock); | 197 | read_lock(&sk->sk_callback_lock); |
198 | 198 | ||
199 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 199 | if (sk_has_sleeper(sk)) |
200 | wake_up_interruptible(sk->sk_sleep); | 200 | wake_up_interruptible(sk->sk_sleep); |
201 | /* Should agree with poll, otherwise some programs break */ | 201 | /* Should agree with poll, otherwise some programs break */ |
202 | if (sock_writeable(sk)) | 202 | if (sock_writeable(sk)) |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 314a1b5c033c..3281013ce038 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -311,7 +311,7 @@ unsigned int dccp_poll(struct file *file, struct socket *sock, | |||
311 | unsigned int mask; | 311 | unsigned int mask; |
312 | struct sock *sk = sock->sk; | 312 | struct sock *sk = sock->sk; |
313 | 313 | ||
314 | poll_wait(file, sk->sk_sleep, wait); | 314 | sock_poll_wait(file, sk->sk_sleep, wait); |
315 | if (sk->sk_state == DCCP_LISTEN) | 315 | if (sk->sk_state == DCCP_LISTEN) |
316 | return inet_csk_listen_poll(sk); | 316 | return inet_csk_listen_poll(sk); |
317 | 317 | ||
@@ -1066,7 +1066,7 @@ static int __init dccp_init(void) | |||
1066 | (dccp_hashinfo.ehash_size - 1)) | 1066 | (dccp_hashinfo.ehash_size - 1)) |
1067 | dccp_hashinfo.ehash_size--; | 1067 | dccp_hashinfo.ehash_size--; |
1068 | dccp_hashinfo.ehash = (struct inet_ehash_bucket *) | 1068 | dccp_hashinfo.ehash = (struct inet_ehash_bucket *) |
1069 | __get_free_pages(GFP_ATOMIC, ehash_order); | 1069 | __get_free_pages(GFP_ATOMIC|__GFP_NOWARN, ehash_order); |
1070 | } while (!dccp_hashinfo.ehash && --ehash_order > 0); | 1070 | } while (!dccp_hashinfo.ehash && --ehash_order > 0); |
1071 | 1071 | ||
1072 | if (!dccp_hashinfo.ehash) { | 1072 | if (!dccp_hashinfo.ehash) { |
@@ -1091,7 +1091,7 @@ static int __init dccp_init(void) | |||
1091 | bhash_order > 0) | 1091 | bhash_order > 0) |
1092 | continue; | 1092 | continue; |
1093 | dccp_hashinfo.bhash = (struct inet_bind_hashbucket *) | 1093 | dccp_hashinfo.bhash = (struct inet_bind_hashbucket *) |
1094 | __get_free_pages(GFP_ATOMIC, bhash_order); | 1094 | __get_free_pages(GFP_ATOMIC|__GFP_NOWARN, bhash_order); |
1095 | } while (!dccp_hashinfo.bhash && --bhash_order >= 0); | 1095 | } while (!dccp_hashinfo.bhash && --bhash_order >= 0); |
1096 | 1096 | ||
1097 | if (!dccp_hashinfo.bhash) { | 1097 | if (!dccp_hashinfo.bhash) { |
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index d351b8db0df5..77d40289653c 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c | |||
@@ -2413,6 +2413,8 @@ static void __exit decnet_exit(void) | |||
2413 | proc_net_remove(&init_net, "decnet"); | 2413 | proc_net_remove(&init_net, "decnet"); |
2414 | 2414 | ||
2415 | proto_unregister(&dn_proto); | 2415 | proto_unregister(&dn_proto); |
2416 | |||
2417 | rcu_barrier_bh(); /* Wait for completion of call_rcu_bh()'s */ | ||
2416 | } | 2418 | } |
2417 | module_exit(decnet_exit); | 2419 | module_exit(decnet_exit); |
2418 | #endif | 2420 | #endif |
diff --git a/net/dsa/mv88e6xxx.c b/net/dsa/mv88e6xxx.c index 4e4d8b5ad03d..efe661a9def4 100644 --- a/net/dsa/mv88e6xxx.c +++ b/net/dsa/mv88e6xxx.c | |||
@@ -418,7 +418,7 @@ static int mv88e6xxx_stats_wait(struct dsa_switch *ds) | |||
418 | int i; | 418 | int i; |
419 | 419 | ||
420 | for (i = 0; i < 10; i++) { | 420 | for (i = 0; i < 10; i++) { |
421 | ret = REG_READ(REG_GLOBAL2, 0x1d); | 421 | ret = REG_READ(REG_GLOBAL, 0x1d); |
422 | if ((ret & 0x8000) == 0) | 422 | if ((ret & 0x8000) == 0) |
423 | return 0; | 423 | return 0; |
424 | } | 424 | } |
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c index 105ad10876af..27eda9fdf3c2 100644 --- a/net/ieee802154/netlink.c +++ b/net/ieee802154/netlink.c | |||
@@ -276,6 +276,9 @@ static struct net_device *ieee802154_nl_get_dev(struct genl_info *info) | |||
276 | else | 276 | else |
277 | return NULL; | 277 | return NULL; |
278 | 278 | ||
279 | if (!dev) | ||
280 | return NULL; | ||
281 | |||
279 | if (dev->type != ARPHRD_IEEE802154) { | 282 | if (dev->type != ARPHRD_IEEE802154) { |
280 | dev_put(dev); | 283 | dev_put(dev); |
281 | return NULL; | 284 | return NULL; |
@@ -521,3 +524,6 @@ static void __exit ieee802154_nl_exit(void) | |||
521 | } | 524 | } |
522 | module_exit(ieee802154_nl_exit); | 525 | module_exit(ieee802154_nl_exit); |
523 | 526 | ||
527 | MODULE_LICENSE("GPL v2"); | ||
528 | MODULE_DESCRIPTION("ieee 802.15.4 configuration interface"); | ||
529 | |||
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 8a3881e28aca..090e9991ac2a 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -801,11 +801,8 @@ static int arp_process(struct sk_buff *skb) | |||
801 | * cache. | 801 | * cache. |
802 | */ | 802 | */ |
803 | 803 | ||
804 | /* | 804 | /* Special case: IPv4 duplicate address detection packet (RFC2131) */ |
805 | * Special case: IPv4 duplicate address detection packet (RFC2131) | 805 | if (sip == 0) { |
806 | * and Gratuitous ARP/ARP Announce. (RFC3927, Section 2.4) | ||
807 | */ | ||
808 | if (sip == 0 || tip == sip) { | ||
809 | if (arp->ar_op == htons(ARPOP_REQUEST) && | 806 | if (arp->ar_op == htons(ARPOP_REQUEST) && |
810 | inet_addr_type(net, tip) == RTN_LOCAL && | 807 | inet_addr_type(net, tip) == RTN_LOCAL && |
811 | !arp_ignore(in_dev, sip, tip)) | 808 | !arp_ignore(in_dev, sip, tip)) |
@@ -1307,7 +1304,9 @@ static void arp_format_neigh_entry(struct seq_file *seq, | |||
1307 | hbuffer[k++] = hex_asc_lo(n->ha[j]); | 1304 | hbuffer[k++] = hex_asc_lo(n->ha[j]); |
1308 | hbuffer[k++] = ':'; | 1305 | hbuffer[k++] = ':'; |
1309 | } | 1306 | } |
1310 | hbuffer[--k] = 0; | 1307 | if (k != 0) |
1308 | --k; | ||
1309 | hbuffer[k] = 0; | ||
1311 | #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) | 1310 | #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) |
1312 | } | 1311 | } |
1313 | #endif | 1312 | #endif |
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 012cf5a68581..63c2fa7b68c4 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -316,8 +316,8 @@ static inline void check_tnode(const struct tnode *tn) | |||
316 | 316 | ||
317 | static const int halve_threshold = 25; | 317 | static const int halve_threshold = 25; |
318 | static const int inflate_threshold = 50; | 318 | static const int inflate_threshold = 50; |
319 | static const int halve_threshold_root = 8; | 319 | static const int halve_threshold_root = 15; |
320 | static const int inflate_threshold_root = 15; | 320 | static const int inflate_threshold_root = 25; |
321 | 321 | ||
322 | 322 | ||
323 | static void __alias_free_mem(struct rcu_head *head) | 323 | static void __alias_free_mem(struct rcu_head *head) |
@@ -1021,6 +1021,9 @@ static void trie_rebalance(struct trie *t, struct tnode *tn) | |||
1021 | (struct node *)tn, wasfull); | 1021 | (struct node *)tn, wasfull); |
1022 | 1022 | ||
1023 | tp = node_parent((struct node *) tn); | 1023 | tp = node_parent((struct node *) tn); |
1024 | if (!tp) | ||
1025 | rcu_assign_pointer(t->trie, (struct node *)tn); | ||
1026 | |||
1024 | tnode_free_flush(); | 1027 | tnode_free_flush(); |
1025 | if (!tp) | 1028 | if (!tp) |
1026 | break; | 1029 | break; |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 44e2a3d2359a..cb4a0f4bd5e5 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -735,10 +735,10 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
735 | } | 735 | } |
736 | 736 | ||
737 | tos = tiph->tos; | 737 | tos = tiph->tos; |
738 | if (tos&1) { | 738 | if (tos == 1) { |
739 | tos = 0; | ||
739 | if (skb->protocol == htons(ETH_P_IP)) | 740 | if (skb->protocol == htons(ETH_P_IP)) |
740 | tos = old_iph->tos; | 741 | tos = old_iph->tos; |
741 | tos &= ~1; | ||
742 | } | 742 | } |
743 | 743 | ||
744 | { | 744 | { |
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index 490ce20faf38..db46b4b5b2b9 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c | |||
@@ -440,6 +440,9 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, | |||
440 | /* Remove any debris in the socket control block */ | 440 | /* Remove any debris in the socket control block */ |
441 | memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); | 441 | memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); |
442 | 442 | ||
443 | /* Must drop socket now because of tproxy. */ | ||
444 | skb_orphan(skb); | ||
445 | |||
443 | return NF_HOOK(PF_INET, NF_INET_PRE_ROUTING, skb, dev, NULL, | 446 | return NF_HOOK(PF_INET, NF_INET_PRE_ROUTING, skb, dev, NULL, |
444 | ip_rcv_finish); | 447 | ip_rcv_finish); |
445 | 448 | ||
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 247026282669..7d0821054729 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -1243,7 +1243,6 @@ int ip_push_pending_frames(struct sock *sk) | |||
1243 | skb->len += tmp_skb->len; | 1243 | skb->len += tmp_skb->len; |
1244 | skb->data_len += tmp_skb->len; | 1244 | skb->data_len += tmp_skb->len; |
1245 | skb->truesize += tmp_skb->truesize; | 1245 | skb->truesize += tmp_skb->truesize; |
1246 | __sock_put(tmp_skb->sk); | ||
1247 | tmp_skb->destructor = NULL; | 1246 | tmp_skb->destructor = NULL; |
1248 | tmp_skb->sk = NULL; | 1247 | tmp_skb->sk = NULL; |
1249 | } | 1248 | } |
diff --git a/net/ipv4/netfilter/nf_nat_helper.c b/net/ipv4/netfilter/nf_nat_helper.c index 155c008626c8..09172a65d9b6 100644 --- a/net/ipv4/netfilter/nf_nat_helper.c +++ b/net/ipv4/netfilter/nf_nat_helper.c | |||
@@ -191,7 +191,8 @@ nf_nat_mangle_tcp_packet(struct sk_buff *skb, | |||
191 | ct, ctinfo); | 191 | ct, ctinfo); |
192 | /* Tell TCP window tracking about seq change */ | 192 | /* Tell TCP window tracking about seq change */ |
193 | nf_conntrack_tcp_update(skb, ip_hdrlen(skb), | 193 | nf_conntrack_tcp_update(skb, ip_hdrlen(skb), |
194 | ct, CTINFO2DIR(ctinfo)); | 194 | ct, CTINFO2DIR(ctinfo), |
195 | (int)rep_len - (int)match_len); | ||
195 | 196 | ||
196 | nf_conntrack_event_cache(IPCT_NATSEQADJ, ct); | 197 | nf_conntrack_event_cache(IPCT_NATSEQADJ, ct); |
197 | } | 198 | } |
@@ -377,6 +378,7 @@ nf_nat_seq_adjust(struct sk_buff *skb, | |||
377 | struct tcphdr *tcph; | 378 | struct tcphdr *tcph; |
378 | int dir; | 379 | int dir; |
379 | __be32 newseq, newack; | 380 | __be32 newseq, newack; |
381 | s16 seqoff, ackoff; | ||
380 | struct nf_conn_nat *nat = nfct_nat(ct); | 382 | struct nf_conn_nat *nat = nfct_nat(ct); |
381 | struct nf_nat_seq *this_way, *other_way; | 383 | struct nf_nat_seq *this_way, *other_way; |
382 | 384 | ||
@@ -390,15 +392,18 @@ nf_nat_seq_adjust(struct sk_buff *skb, | |||
390 | 392 | ||
391 | tcph = (void *)skb->data + ip_hdrlen(skb); | 393 | tcph = (void *)skb->data + ip_hdrlen(skb); |
392 | if (after(ntohl(tcph->seq), this_way->correction_pos)) | 394 | if (after(ntohl(tcph->seq), this_way->correction_pos)) |
393 | newseq = htonl(ntohl(tcph->seq) + this_way->offset_after); | 395 | seqoff = this_way->offset_after; |
394 | else | 396 | else |
395 | newseq = htonl(ntohl(tcph->seq) + this_way->offset_before); | 397 | seqoff = this_way->offset_before; |
396 | 398 | ||
397 | if (after(ntohl(tcph->ack_seq) - other_way->offset_before, | 399 | if (after(ntohl(tcph->ack_seq) - other_way->offset_before, |
398 | other_way->correction_pos)) | 400 | other_way->correction_pos)) |
399 | newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_after); | 401 | ackoff = other_way->offset_after; |
400 | else | 402 | else |
401 | newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_before); | 403 | ackoff = other_way->offset_before; |
404 | |||
405 | newseq = htonl(ntohl(tcph->seq) + seqoff); | ||
406 | newack = htonl(ntohl(tcph->ack_seq) - ackoff); | ||
402 | 407 | ||
403 | inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, 0); | 408 | inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, 0); |
404 | inet_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack, 0); | 409 | inet_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack, 0); |
@@ -413,7 +418,7 @@ nf_nat_seq_adjust(struct sk_buff *skb, | |||
413 | if (!nf_nat_sack_adjust(skb, tcph, ct, ctinfo)) | 418 | if (!nf_nat_sack_adjust(skb, tcph, ct, ctinfo)) |
414 | return 0; | 419 | return 0; |
415 | 420 | ||
416 | nf_conntrack_tcp_update(skb, ip_hdrlen(skb), ct, dir); | 421 | nf_conntrack_tcp_update(skb, ip_hdrlen(skb), ct, dir, seqoff); |
417 | 422 | ||
418 | return 1; | 423 | return 1; |
419 | } | 424 | } |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 17b89c523f9d..91145244ea63 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -339,7 +339,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
339 | struct sock *sk = sock->sk; | 339 | struct sock *sk = sock->sk; |
340 | struct tcp_sock *tp = tcp_sk(sk); | 340 | struct tcp_sock *tp = tcp_sk(sk); |
341 | 341 | ||
342 | poll_wait(file, sk->sk_sleep, wait); | 342 | sock_poll_wait(file, sk->sk_sleep, wait); |
343 | if (sk->sk_state == TCP_LISTEN) | 343 | if (sk->sk_state == TCP_LISTEN) |
344 | return inet_csk_listen_poll(sk); | 344 | return inet_csk_listen_poll(sk); |
345 | 345 | ||
@@ -903,13 +903,17 @@ int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
903 | iov++; | 903 | iov++; |
904 | 904 | ||
905 | while (seglen > 0) { | 905 | while (seglen > 0) { |
906 | int copy; | 906 | int copy = 0; |
907 | int max = size_goal; | ||
907 | 908 | ||
908 | skb = tcp_write_queue_tail(sk); | 909 | skb = tcp_write_queue_tail(sk); |
910 | if (tcp_send_head(sk)) { | ||
911 | if (skb->ip_summed == CHECKSUM_NONE) | ||
912 | max = mss_now; | ||
913 | copy = max - skb->len; | ||
914 | } | ||
909 | 915 | ||
910 | if (!tcp_send_head(sk) || | 916 | if (copy <= 0) { |
911 | (copy = size_goal - skb->len) <= 0) { | ||
912 | |||
913 | new_segment: | 917 | new_segment: |
914 | /* Allocate new segment. If the interface is SG, | 918 | /* Allocate new segment. If the interface is SG, |
915 | * allocate skb fitting to single page. | 919 | * allocate skb fitting to single page. |
@@ -930,6 +934,7 @@ new_segment: | |||
930 | 934 | ||
931 | skb_entail(sk, skb); | 935 | skb_entail(sk, skb); |
932 | copy = size_goal; | 936 | copy = size_goal; |
937 | max = size_goal; | ||
933 | } | 938 | } |
934 | 939 | ||
935 | /* Try to append data to the end of skb. */ | 940 | /* Try to append data to the end of skb. */ |
@@ -1028,7 +1033,7 @@ new_segment: | |||
1028 | if ((seglen -= copy) == 0 && iovlen == 0) | 1033 | if ((seglen -= copy) == 0 && iovlen == 0) |
1029 | goto out; | 1034 | goto out; |
1030 | 1035 | ||
1031 | if (skb->len < size_goal || (flags & MSG_OOB)) | 1036 | if (skb->len < max || (flags & MSG_OOB)) |
1032 | continue; | 1037 | continue; |
1033 | 1038 | ||
1034 | if (forced_push(tp)) { | 1039 | if (forced_push(tp)) { |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 5a1ca2698c88..6d88219c5e22 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -1160,6 +1160,7 @@ struct request_sock_ops tcp_request_sock_ops __read_mostly = { | |||
1160 | #ifdef CONFIG_TCP_MD5SIG | 1160 | #ifdef CONFIG_TCP_MD5SIG |
1161 | static struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = { | 1161 | static struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = { |
1162 | .md5_lookup = tcp_v4_reqsk_md5_lookup, | 1162 | .md5_lookup = tcp_v4_reqsk_md5_lookup, |
1163 | .calc_md5_hash = tcp_v4_md5_hash_skb, | ||
1163 | }; | 1164 | }; |
1164 | #endif | 1165 | #endif |
1165 | 1166 | ||
@@ -1373,7 +1374,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1373 | */ | 1374 | */ |
1374 | char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC); | 1375 | char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC); |
1375 | if (newkey != NULL) | 1376 | if (newkey != NULL) |
1376 | tcp_v4_md5_do_add(newsk, inet_sk(sk)->daddr, | 1377 | tcp_v4_md5_do_add(newsk, newinet->daddr, |
1377 | newkey, key->keylen); | 1378 | newkey, key->keylen); |
1378 | newsk->sk_route_caps &= ~NETIF_F_GSO_MASK; | 1379 | newsk->sk_route_caps &= ~NETIF_F_GSO_MASK; |
1379 | } | 1380 | } |
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 43bbba7926ee..f8d67ccc64f3 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -128,7 +128,8 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb, | |||
128 | goto kill_with_rst; | 128 | goto kill_with_rst; |
129 | 129 | ||
130 | /* Dup ACK? */ | 130 | /* Dup ACK? */ |
131 | if (!after(TCP_SKB_CB(skb)->end_seq, tcptw->tw_rcv_nxt) || | 131 | if (!th->ack || |
132 | !after(TCP_SKB_CB(skb)->end_seq, tcptw->tw_rcv_nxt) || | ||
132 | TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq) { | 133 | TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq) { |
133 | inet_twsk_put(tw); | 134 | inet_twsk_put(tw); |
134 | return TCP_TW_SUCCESS; | 135 | return TCP_TW_SUCCESS; |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 416fc4c2e7eb..bd62712848fa 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -725,7 +725,8 @@ static void tcp_queue_skb(struct sock *sk, struct sk_buff *skb) | |||
725 | static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, | 725 | static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, |
726 | unsigned int mss_now) | 726 | unsigned int mss_now) |
727 | { | 727 | { |
728 | if (skb->len <= mss_now || !sk_can_gso(sk)) { | 728 | if (skb->len <= mss_now || !sk_can_gso(sk) || |
729 | skb->ip_summed == CHECKSUM_NONE) { | ||
729 | /* Avoid the costly divide in the normal | 730 | /* Avoid the costly divide in the normal |
730 | * non-TSO case. | 731 | * non-TSO case. |
731 | */ | 732 | */ |
@@ -2260,7 +2261,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst, | |||
2260 | #ifdef CONFIG_TCP_MD5SIG | 2261 | #ifdef CONFIG_TCP_MD5SIG |
2261 | /* Okay, we have all we need - do the md5 hash if needed */ | 2262 | /* Okay, we have all we need - do the md5 hash if needed */ |
2262 | if (md5) { | 2263 | if (md5) { |
2263 | tp->af_specific->calc_md5_hash(md5_hash_location, | 2264 | tcp_rsk(req)->af_specific->calc_md5_hash(md5_hash_location, |
2264 | md5, NULL, req, skb); | 2265 | md5, NULL, req, skb); |
2265 | } | 2266 | } |
2266 | #endif | 2267 | #endif |
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 60d918c96a4f..0071ee6f441f 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
@@ -136,7 +136,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
136 | case IPPROTO_TCP: | 136 | case IPPROTO_TCP: |
137 | case IPPROTO_SCTP: | 137 | case IPPROTO_SCTP: |
138 | case IPPROTO_DCCP: | 138 | case IPPROTO_DCCP: |
139 | if (pskb_may_pull(skb, xprth + 4 - skb->data)) { | 139 | if (xprth + 4 < skb->data || |
140 | pskb_may_pull(skb, xprth + 4 - skb->data)) { | ||
140 | __be16 *ports = (__be16 *)xprth; | 141 | __be16 *ports = (__be16 *)xprth; |
141 | 142 | ||
142 | fl->fl_ip_sport = ports[!!reverse]; | 143 | fl->fl_ip_sport = ports[!!reverse]; |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 8c1e86afbbf5..43b3c9f89c12 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -1916,8 +1916,32 @@ ok: | |||
1916 | update_lft = 1; | 1916 | update_lft = 1; |
1917 | else if (stored_lft <= MIN_VALID_LIFETIME) { | 1917 | else if (stored_lft <= MIN_VALID_LIFETIME) { |
1918 | /* valid_lft <= stored_lft is always true */ | 1918 | /* valid_lft <= stored_lft is always true */ |
1919 | /* XXX: IPsec */ | 1919 | /* |
1920 | update_lft = 0; | 1920 | * RFC 4862 Section 5.5.3e: |
1921 | * "Note that the preferred lifetime of | ||
1922 | * the corresponding address is always | ||
1923 | * reset to the Preferred Lifetime in | ||
1924 | * the received Prefix Information | ||
1925 | * option, regardless of whether the | ||
1926 | * valid lifetime is also reset or | ||
1927 | * ignored." | ||
1928 | * | ||
1929 | * So if the preferred lifetime in | ||
1930 | * this advertisement is different | ||
1931 | * than what we have stored, but the | ||
1932 | * valid lifetime is invalid, just | ||
1933 | * reset prefered_lft. | ||
1934 | * | ||
1935 | * We must set the valid lifetime | ||
1936 | * to the stored lifetime since we'll | ||
1937 | * be updating the timestamp below, | ||
1938 | * else we'll set it back to the | ||
1939 | * minumum. | ||
1940 | */ | ||
1941 | if (prefered_lft != ifp->prefered_lft) { | ||
1942 | valid_lft = stored_lft; | ||
1943 | update_lft = 1; | ||
1944 | } | ||
1921 | } else { | 1945 | } else { |
1922 | valid_lft = MIN_VALID_LIFETIME; | 1946 | valid_lft = MIN_VALID_LIFETIME; |
1923 | if (valid_lft < prefered_lft) | 1947 | if (valid_lft < prefered_lft) |
@@ -3085,7 +3109,7 @@ restart: | |||
3085 | spin_unlock(&ifp->lock); | 3109 | spin_unlock(&ifp->lock); |
3086 | continue; | 3110 | continue; |
3087 | } else if (age >= ifp->prefered_lft) { | 3111 | } else if (age >= ifp->prefered_lft) { |
3088 | /* jiffies - ifp->tsamp > age >= ifp->prefered_lft */ | 3112 | /* jiffies - ifp->tstamp > age >= ifp->prefered_lft */ |
3089 | int deprecate = 0; | 3113 | int deprecate = 0; |
3090 | 3114 | ||
3091 | if (!(ifp->flags&IFA_F_DEPRECATED)) { | 3115 | if (!(ifp->flags&IFA_F_DEPRECATED)) { |
@@ -3362,7 +3386,10 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa, | |||
3362 | valid = ifa->valid_lft; | 3386 | valid = ifa->valid_lft; |
3363 | if (preferred != INFINITY_LIFE_TIME) { | 3387 | if (preferred != INFINITY_LIFE_TIME) { |
3364 | long tval = (jiffies - ifa->tstamp)/HZ; | 3388 | long tval = (jiffies - ifa->tstamp)/HZ; |
3365 | preferred -= tval; | 3389 | if (preferred > tval) |
3390 | preferred -= tval; | ||
3391 | else | ||
3392 | preferred = 0; | ||
3366 | if (valid != INFINITY_LIFE_TIME) | 3393 | if (valid != INFINITY_LIFE_TIME) |
3367 | valid -= tval; | 3394 | valid -= tval; |
3368 | } | 3395 | } |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 85b3d0036afd..caa0278d30a9 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -1284,6 +1284,8 @@ static void __exit inet6_exit(void) | |||
1284 | proto_unregister(&udplitev6_prot); | 1284 | proto_unregister(&udplitev6_prot); |
1285 | proto_unregister(&udpv6_prot); | 1285 | proto_unregister(&udpv6_prot); |
1286 | proto_unregister(&tcpv6_prot); | 1286 | proto_unregister(&tcpv6_prot); |
1287 | |||
1288 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ | ||
1287 | } | 1289 | } |
1288 | module_exit(inet6_exit); | 1290 | module_exit(inet6_exit); |
1289 | 1291 | ||
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index c3a07d75b5f5..6d6a4277c677 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c | |||
@@ -139,6 +139,9 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt | |||
139 | 139 | ||
140 | rcu_read_unlock(); | 140 | rcu_read_unlock(); |
141 | 141 | ||
142 | /* Must drop socket now because of tproxy. */ | ||
143 | skb_orphan(skb); | ||
144 | |||
142 | return NF_HOOK(PF_INET6, NF_INET_PRE_ROUTING, skb, dev, NULL, | 145 | return NF_HOOK(PF_INET6, NF_INET_PRE_ROUTING, skb, dev, NULL, |
143 | ip6_rcv_finish); | 146 | ip6_rcv_finish); |
144 | err: | 147 | err: |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 7c76e3d18215..87f8419a68fd 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -1484,7 +1484,6 @@ int ip6_push_pending_frames(struct sock *sk) | |||
1484 | skb->len += tmp_skb->len; | 1484 | skb->len += tmp_skb->len; |
1485 | skb->data_len += tmp_skb->len; | 1485 | skb->data_len += tmp_skb->len; |
1486 | skb->truesize += tmp_skb->truesize; | 1486 | skb->truesize += tmp_skb->truesize; |
1487 | __sock_put(tmp_skb->sk); | ||
1488 | tmp_skb->destructor = NULL; | 1487 | tmp_skb->destructor = NULL; |
1489 | tmp_skb->sk = NULL; | 1488 | tmp_skb->sk = NULL; |
1490 | } | 1489 | } |
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 68e52308e552..98b7327d0949 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -1018,6 +1018,7 @@ static void ipip6_tunnel_setup(struct net_device *dev) | |||
1018 | dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr); | 1018 | dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr); |
1019 | dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr); | 1019 | dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr); |
1020 | dev->flags = IFF_NOARP; | 1020 | dev->flags = IFF_NOARP; |
1021 | dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; | ||
1021 | dev->iflink = 0; | 1022 | dev->iflink = 0; |
1022 | dev->addr_len = 4; | 1023 | dev->addr_len = 4; |
1023 | dev->features |= NETIF_F_NETNS_LOCAL; | 1024 | dev->features |= NETIF_F_NETNS_LOCAL; |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 58810c65b635..d849dd53b788 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -896,6 +896,7 @@ struct request_sock_ops tcp6_request_sock_ops __read_mostly = { | |||
896 | #ifdef CONFIG_TCP_MD5SIG | 896 | #ifdef CONFIG_TCP_MD5SIG |
897 | static struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = { | 897 | static struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = { |
898 | .md5_lookup = tcp_v6_reqsk_md5_lookup, | 898 | .md5_lookup = tcp_v6_reqsk_md5_lookup, |
899 | .calc_md5_hash = tcp_v6_md5_hash_skb, | ||
899 | }; | 900 | }; |
900 | #endif | 901 | #endif |
901 | 902 | ||
@@ -1441,7 +1442,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1441 | */ | 1442 | */ |
1442 | char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC); | 1443 | char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC); |
1443 | if (newkey != NULL) | 1444 | if (newkey != NULL) |
1444 | tcp_v6_md5_do_add(newsk, &inet6_sk(sk)->daddr, | 1445 | tcp_v6_md5_do_add(newsk, &newnp->daddr, |
1445 | newkey, key->keylen); | 1446 | newkey, key->keylen); |
1446 | } | 1447 | } |
1447 | #endif | 1448 | #endif |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index b4b16a43f277..3a3c677bc0f2 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
@@ -157,7 +157,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
157 | ipv6_addr_copy(&fl->fl6_dst, reverse ? &hdr->saddr : &hdr->daddr); | 157 | ipv6_addr_copy(&fl->fl6_dst, reverse ? &hdr->saddr : &hdr->daddr); |
158 | ipv6_addr_copy(&fl->fl6_src, reverse ? &hdr->daddr : &hdr->saddr); | 158 | ipv6_addr_copy(&fl->fl6_src, reverse ? &hdr->daddr : &hdr->saddr); |
159 | 159 | ||
160 | while (pskb_may_pull(skb, nh + offset + 1 - skb->data)) { | 160 | while (nh + offset + 1 < skb->data || |
161 | pskb_may_pull(skb, nh + offset + 1 - skb->data)) { | ||
161 | nh = skb_network_header(skb); | 162 | nh = skb_network_header(skb); |
162 | exthdr = (struct ipv6_opt_hdr *)(nh + offset); | 163 | exthdr = (struct ipv6_opt_hdr *)(nh + offset); |
163 | 164 | ||
@@ -177,7 +178,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
177 | case IPPROTO_TCP: | 178 | case IPPROTO_TCP: |
178 | case IPPROTO_SCTP: | 179 | case IPPROTO_SCTP: |
179 | case IPPROTO_DCCP: | 180 | case IPPROTO_DCCP: |
180 | if (!onlyproto && pskb_may_pull(skb, nh + offset + 4 - skb->data)) { | 181 | if (!onlyproto && (nh + offset + 4 < skb->data || |
182 | pskb_may_pull(skb, nh + offset + 4 - skb->data))) { | ||
181 | __be16 *ports = (__be16 *)exthdr; | 183 | __be16 *ports = (__be16 *)exthdr; |
182 | 184 | ||
183 | fl->fl_ip_sport = ports[!!reverse]; | 185 | fl->fl_ip_sport = ports[!!reverse]; |
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index 417b0e309495..f1118d92a191 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/netdevice.h> | 41 | #include <linux/netdevice.h> |
42 | #include <linux/uio.h> | 42 | #include <linux/uio.h> |
43 | #include <linux/skbuff.h> | 43 | #include <linux/skbuff.h> |
44 | #include <linux/smp_lock.h> | ||
44 | #include <linux/socket.h> | 45 | #include <linux/socket.h> |
45 | #include <linux/sockios.h> | 46 | #include <linux/sockios.h> |
46 | #include <linux/string.h> | 47 | #include <linux/string.h> |
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index cb762c8723ea..80cf29aae096 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/capability.h> | 45 | #include <linux/capability.h> |
46 | #include <linux/module.h> | 46 | #include <linux/module.h> |
47 | #include <linux/types.h> | 47 | #include <linux/types.h> |
48 | #include <linux/smp_lock.h> | ||
48 | #include <linux/socket.h> | 49 | #include <linux/socket.h> |
49 | #include <linux/sockios.h> | 50 | #include <linux/sockios.h> |
50 | #include <linux/init.h> | 51 | #include <linux/init.h> |
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h index bccf4d0059f0..b001c361ad30 100644 --- a/net/irda/irnet/irnet.h +++ b/net/irda/irnet/irnet.h | |||
@@ -241,7 +241,6 @@ | |||
241 | #include <linux/module.h> | 241 | #include <linux/module.h> |
242 | 242 | ||
243 | #include <linux/kernel.h> | 243 | #include <linux/kernel.h> |
244 | #include <linux/smp_lock.h> | ||
245 | #include <linux/skbuff.h> | 244 | #include <linux/skbuff.h> |
246 | #include <linux/tty.h> | 245 | #include <linux/tty.h> |
247 | #include <linux/proc_fs.h> | 246 | #include <linux/proc_fs.h> |
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c index 6d8ae03c14f5..68cbcb19cbd8 100644 --- a/net/irda/irnet/irnet_ppp.c +++ b/net/irda/irnet/irnet_ppp.c | |||
@@ -13,6 +13,7 @@ | |||
13 | * 2) as a control channel (write commands, read events) | 13 | * 2) as a control channel (write commands, read events) |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/smp_lock.h> | ||
16 | #include "irnet_ppp.h" /* Private header */ | 17 | #include "irnet_ppp.h" /* Private header */ |
17 | /* Please put other headers in irnet.h - Thanks */ | 18 | /* Please put other headers in irnet.h - Thanks */ |
18 | 19 | ||
diff --git a/net/irda/irttp.c b/net/irda/irttp.c index ecf4eb2717cb..9cb79f95bf63 100644 --- a/net/irda/irttp.c +++ b/net/irda/irttp.c | |||
@@ -1453,6 +1453,7 @@ struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance) | |||
1453 | } | 1453 | } |
1454 | /* Dup */ | 1454 | /* Dup */ |
1455 | memcpy(new, orig, sizeof(struct tsap_cb)); | 1455 | memcpy(new, orig, sizeof(struct tsap_cb)); |
1456 | spin_lock_init(&new->lock); | ||
1456 | 1457 | ||
1457 | /* We don't need the old instance any more */ | 1458 | /* We don't need the old instance any more */ |
1458 | spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags); | 1459 | spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags); |
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 6be5f92d1094..49c15b48408e 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c | |||
@@ -306,7 +306,7 @@ static inline int iucv_below_msglim(struct sock *sk) | |||
306 | static void iucv_sock_wake_msglim(struct sock *sk) | 306 | static void iucv_sock_wake_msglim(struct sock *sk) |
307 | { | 307 | { |
308 | read_lock(&sk->sk_callback_lock); | 308 | read_lock(&sk->sk_callback_lock); |
309 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 309 | if (sk_has_sleeper(sk)) |
310 | wake_up_interruptible_all(sk->sk_sleep); | 310 | wake_up_interruptible_all(sk->sk_sleep); |
311 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); | 311 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); |
312 | read_unlock(&sk->sk_callback_lock); | 312 | read_unlock(&sk->sk_callback_lock); |
@@ -1256,7 +1256,7 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock, | |||
1256 | struct sock *sk = sock->sk; | 1256 | struct sock *sk = sock->sk; |
1257 | unsigned int mask = 0; | 1257 | unsigned int mask = 0; |
1258 | 1258 | ||
1259 | poll_wait(file, sk->sk_sleep, wait); | 1259 | sock_poll_wait(file, sk->sk_sleep, wait); |
1260 | 1260 | ||
1261 | if (sk->sk_state == IUCV_LISTEN) | 1261 | if (sk->sk_state == IUCV_LISTEN) |
1262 | return iucv_accept_poll(sk); | 1262 | return iucv_accept_poll(sk); |
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig index ba2643a43c73..7836ee928983 100644 --- a/net/mac80211/Kconfig +++ b/net/mac80211/Kconfig | |||
@@ -83,6 +83,7 @@ endmenu | |||
83 | config MAC80211_MESH | 83 | config MAC80211_MESH |
84 | bool "Enable mac80211 mesh networking (pre-802.11s) support" | 84 | bool "Enable mac80211 mesh networking (pre-802.11s) support" |
85 | depends on MAC80211 && EXPERIMENTAL | 85 | depends on MAC80211 && EXPERIMENTAL |
86 | depends on BROKEN | ||
86 | ---help--- | 87 | ---help--- |
87 | This options enables support of Draft 802.11s mesh networking. | 88 | This options enables support of Draft 802.11s mesh networking. |
88 | The implementation is based on Draft 1.08 of the Mesh Networking | 89 | The implementation is based on Draft 1.08 of the Mesh Networking |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index fc712e60705d..11cf45bce38a 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -494,7 +494,7 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata) | |||
494 | * should it be using the interface and enqueuing | 494 | * should it be using the interface and enqueuing |
495 | * frames at this very time on another CPU. | 495 | * frames at this very time on another CPU. |
496 | */ | 496 | */ |
497 | synchronize_rcu(); | 497 | rcu_barrier(); /* Wait for RX path and call_rcu()'s */ |
498 | skb_queue_purge(&sdata->u.mesh.skb_queue); | 498 | skb_queue_purge(&sdata->u.mesh.skb_queue); |
499 | } | 499 | } |
500 | 500 | ||
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 003cb470ac84..f49ef288e2e2 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -637,7 +637,7 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) | |||
637 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 637 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
638 | struct mesh_preq_queue *preq_node; | 638 | struct mesh_preq_queue *preq_node; |
639 | 639 | ||
640 | preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_KERNEL); | 640 | preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_ATOMIC); |
641 | if (!preq_node) { | 641 | if (!preq_node) { |
642 | printk(KERN_DEBUG "Mesh HWMP: could not allocate PREQ node\n"); | 642 | printk(KERN_DEBUG "Mesh HWMP: could not allocate PREQ node\n"); |
643 | return; | 643 | return; |
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 3c72557df45a..479597e88583 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
@@ -175,6 +175,8 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) | |||
175 | int err = 0; | 175 | int err = 0; |
176 | u32 hash_idx; | 176 | u32 hash_idx; |
177 | 177 | ||
178 | might_sleep(); | ||
179 | |||
178 | if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0) | 180 | if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0) |
179 | /* never add ourselves as neighbours */ | 181 | /* never add ourselves as neighbours */ |
180 | return -ENOTSUPP; | 182 | return -ENOTSUPP; |
@@ -265,6 +267,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) | |||
265 | int err = 0; | 267 | int err = 0; |
266 | u32 hash_idx; | 268 | u32 hash_idx; |
267 | 269 | ||
270 | might_sleep(); | ||
268 | 271 | ||
269 | if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0) | 272 | if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0) |
270 | /* never add ourselves as neighbours */ | 273 | /* never add ourselves as neighbours */ |
@@ -491,8 +494,10 @@ void mesh_path_tx_pending(struct mesh_path *mpath) | |||
491 | * @skb: frame to discard | 494 | * @skb: frame to discard |
492 | * @sdata: network subif the frame was to be sent through | 495 | * @sdata: network subif the frame was to be sent through |
493 | * | 496 | * |
494 | * If the frame was beign forwarded from another MP, a PERR frame will be sent | 497 | * If the frame was being forwarded from another MP, a PERR frame will be sent |
495 | * to the precursor. | 498 | * to the precursor. The precursor's address (i.e. the previous hop) was saved |
499 | * in addr1 of the frame-to-be-forwarded, and would only be overwritten once | ||
500 | * the destination is successfully resolved. | ||
496 | * | 501 | * |
497 | * Locking: the function must me called within a rcu_read_lock region | 502 | * Locking: the function must me called within a rcu_read_lock region |
498 | */ | 503 | */ |
@@ -507,7 +512,7 @@ void mesh_path_discard_frame(struct sk_buff *skb, | |||
507 | u8 *ra, *da; | 512 | u8 *ra, *da; |
508 | 513 | ||
509 | da = hdr->addr3; | 514 | da = hdr->addr3; |
510 | ra = hdr->addr2; | 515 | ra = hdr->addr1; |
511 | mpath = mesh_path_lookup(da, sdata); | 516 | mpath = mesh_path_lookup(da, sdata); |
512 | if (mpath) | 517 | if (mpath) |
513 | dsn = ++mpath->dsn; | 518 | dsn = ++mpath->dsn; |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index aca22b00b6a3..07e7e41816be 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -721,7 +721,7 @@ void ieee80211_dynamic_ps_timer(unsigned long data) | |||
721 | { | 721 | { |
722 | struct ieee80211_local *local = (void *) data; | 722 | struct ieee80211_local *local = (void *) data; |
723 | 723 | ||
724 | if (local->quiescing) | 724 | if (local->quiescing || local->suspended) |
725 | return; | 725 | return; |
726 | 726 | ||
727 | queue_work(local->hw.workqueue, &local->dynamic_ps_enable_work); | 727 | queue_work(local->hw.workqueue, &local->dynamic_ps_enable_work); |
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index 7a549f9deb96..5e3d476972f9 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c | |||
@@ -55,15 +55,6 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) | |||
55 | 55 | ||
56 | rcu_read_unlock(); | 56 | rcu_read_unlock(); |
57 | 57 | ||
58 | /* flush again, in case driver queued work */ | ||
59 | flush_workqueue(local->hw.workqueue); | ||
60 | |||
61 | /* stop hardware - this must stop RX */ | ||
62 | if (local->open_count) { | ||
63 | ieee80211_led_radio(local, false); | ||
64 | drv_stop(local); | ||
65 | } | ||
66 | |||
67 | /* remove STAs */ | 58 | /* remove STAs */ |
68 | spin_lock_irqsave(&local->sta_lock, flags); | 59 | spin_lock_irqsave(&local->sta_lock, flags); |
69 | list_for_each_entry(sta, &local->sta_list, list) { | 60 | list_for_each_entry(sta, &local->sta_list, list) { |
@@ -111,7 +102,22 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) | |||
111 | drv_remove_interface(local, &conf); | 102 | drv_remove_interface(local, &conf); |
112 | } | 103 | } |
113 | 104 | ||
105 | /* stop hardware - this must stop RX */ | ||
106 | if (local->open_count) { | ||
107 | ieee80211_led_radio(local, false); | ||
108 | drv_stop(local); | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | * flush again, in case driver queued work -- it | ||
113 | * shouldn't be doing (or cancel everything in the | ||
114 | * stop callback) that but better safe than sorry. | ||
115 | */ | ||
116 | flush_workqueue(local->hw.workqueue); | ||
117 | |||
114 | local->suspended = true; | 118 | local->suspended = true; |
119 | /* need suspended to be visible before quiescing is false */ | ||
120 | barrier(); | ||
115 | local->quiescing = false; | 121 | local->quiescing = false; |
116 | 122 | ||
117 | return 0; | 123 | return 0; |
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c index b218b98fba7f..37771abd8f5a 100644 --- a/net/mac80211/rc80211_minstrel.c +++ b/net/mac80211/rc80211_minstrel.c | |||
@@ -66,7 +66,7 @@ rix_to_ndx(struct minstrel_sta_info *mi, int rix) | |||
66 | for (i = rix; i >= 0; i--) | 66 | for (i = rix; i >= 0; i--) |
67 | if (mi->r[i].rix == rix) | 67 | if (mi->r[i].rix == rix) |
68 | break; | 68 | break; |
69 | WARN_ON(mi->r[i].rix != rix); | 69 | WARN_ON(i < 0); |
70 | return i; | 70 | return i; |
71 | } | 71 | } |
72 | 72 | ||
@@ -181,6 +181,9 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband, | |||
181 | break; | 181 | break; |
182 | 182 | ||
183 | ndx = rix_to_ndx(mi, ar[i].idx); | 183 | ndx = rix_to_ndx(mi, ar[i].idx); |
184 | if (ndx < 0) | ||
185 | continue; | ||
186 | |||
184 | mi->r[ndx].attempts += ar[i].count; | 187 | mi->r[ndx].attempts += ar[i].count; |
185 | 188 | ||
186 | if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0)) | 189 | if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0)) |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index de5bba7f910a..0936fc24942d 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -2453,6 +2453,18 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2453 | return; | 2453 | return; |
2454 | } | 2454 | } |
2455 | 2455 | ||
2456 | /* | ||
2457 | * If we're suspending, it is possible although not too likely | ||
2458 | * that we'd be receiving frames after having already partially | ||
2459 | * quiesced the stack. We can't process such frames then since | ||
2460 | * that might, for example, cause stations to be added or other | ||
2461 | * driver callbacks be invoked. | ||
2462 | */ | ||
2463 | if (unlikely(local->quiescing || local->suspended)) { | ||
2464 | kfree_skb(skb); | ||
2465 | return; | ||
2466 | } | ||
2467 | |||
2456 | if (status->flag & RX_FLAG_HT) { | 2468 | if (status->flag & RX_FLAG_HT) { |
2457 | /* rate_idx is MCS index */ | 2469 | /* rate_idx is MCS index */ |
2458 | if (WARN_ON(status->rate_idx < 0 || | 2470 | if (WARN_ON(status->rate_idx < 0 || |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index d238a8939a09..3a8922cd1038 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -1455,7 +1455,7 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1455 | monitor_iface = UNKNOWN_ADDRESS; | 1455 | monitor_iface = UNKNOWN_ADDRESS; |
1456 | 1456 | ||
1457 | len_rthdr = ieee80211_get_radiotap_len(skb->data); | 1457 | len_rthdr = ieee80211_get_radiotap_len(skb->data); |
1458 | hdr = (struct ieee80211_hdr *)skb->data + len_rthdr; | 1458 | hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); |
1459 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 1459 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
1460 | 1460 | ||
1461 | /* check the header is complete in the frame */ | 1461 | /* check the header is complete in the frame */ |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 7508f11c5b39..b5869b9574b0 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -561,23 +561,38 @@ struct nf_conn *nf_conntrack_alloc(struct net *net, | |||
561 | } | 561 | } |
562 | } | 562 | } |
563 | 563 | ||
564 | ct = kmem_cache_zalloc(nf_conntrack_cachep, gfp); | 564 | /* |
565 | * Do not use kmem_cache_zalloc(), as this cache uses | ||
566 | * SLAB_DESTROY_BY_RCU. | ||
567 | */ | ||
568 | ct = kmem_cache_alloc(nf_conntrack_cachep, gfp); | ||
565 | if (ct == NULL) { | 569 | if (ct == NULL) { |
566 | pr_debug("nf_conntrack_alloc: Can't alloc conntrack.\n"); | 570 | pr_debug("nf_conntrack_alloc: Can't alloc conntrack.\n"); |
567 | atomic_dec(&net->ct.count); | 571 | atomic_dec(&net->ct.count); |
568 | return ERR_PTR(-ENOMEM); | 572 | return ERR_PTR(-ENOMEM); |
569 | } | 573 | } |
570 | 574 | /* | |
575 | * Let ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode.next | ||
576 | * and ct->tuplehash[IP_CT_DIR_REPLY].hnnode.next unchanged. | ||
577 | */ | ||
578 | memset(&ct->tuplehash[IP_CT_DIR_MAX], 0, | ||
579 | sizeof(*ct) - offsetof(struct nf_conn, tuplehash[IP_CT_DIR_MAX])); | ||
571 | spin_lock_init(&ct->lock); | 580 | spin_lock_init(&ct->lock); |
572 | atomic_set(&ct->ct_general.use, 1); | ||
573 | ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *orig; | 581 | ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *orig; |
582 | ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode.pprev = NULL; | ||
574 | ct->tuplehash[IP_CT_DIR_REPLY].tuple = *repl; | 583 | ct->tuplehash[IP_CT_DIR_REPLY].tuple = *repl; |
584 | ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev = NULL; | ||
575 | /* Don't set timer yet: wait for confirmation */ | 585 | /* Don't set timer yet: wait for confirmation */ |
576 | setup_timer(&ct->timeout, death_by_timeout, (unsigned long)ct); | 586 | setup_timer(&ct->timeout, death_by_timeout, (unsigned long)ct); |
577 | #ifdef CONFIG_NET_NS | 587 | #ifdef CONFIG_NET_NS |
578 | ct->ct_net = net; | 588 | ct->ct_net = net; |
579 | #endif | 589 | #endif |
580 | 590 | ||
591 | /* | ||
592 | * changes to lookup keys must be done before setting refcnt to 1 | ||
593 | */ | ||
594 | smp_wmb(); | ||
595 | atomic_set(&ct->ct_general.use, 1); | ||
581 | return ct; | 596 | return ct; |
582 | } | 597 | } |
583 | EXPORT_SYMBOL_GPL(nf_conntrack_alloc); | 598 | EXPORT_SYMBOL_GPL(nf_conntrack_alloc); |
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c index afde8f991646..2032dfe25ca8 100644 --- a/net/netfilter/nf_conntrack_expect.c +++ b/net/netfilter/nf_conntrack_expect.c | |||
@@ -617,8 +617,10 @@ err1: | |||
617 | void nf_conntrack_expect_fini(struct net *net) | 617 | void nf_conntrack_expect_fini(struct net *net) |
618 | { | 618 | { |
619 | exp_proc_remove(net); | 619 | exp_proc_remove(net); |
620 | if (net_eq(net, &init_net)) | 620 | if (net_eq(net, &init_net)) { |
621 | rcu_barrier(); /* Wait for call_rcu() before destroy */ | ||
621 | kmem_cache_destroy(nf_ct_expect_cachep); | 622 | kmem_cache_destroy(nf_ct_expect_cachep); |
623 | } | ||
622 | nf_ct_free_hashtable(net->ct.expect_hash, net->ct.expect_vmalloc, | 624 | nf_ct_free_hashtable(net->ct.expect_hash, net->ct.expect_vmalloc, |
623 | nf_ct_expect_hsize); | 625 | nf_ct_expect_hsize); |
624 | } | 626 | } |
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c index 4b2c769d555f..fef95be334bd 100644 --- a/net/netfilter/nf_conntrack_extend.c +++ b/net/netfilter/nf_conntrack_extend.c | |||
@@ -186,6 +186,6 @@ void nf_ct_extend_unregister(struct nf_ct_ext_type *type) | |||
186 | rcu_assign_pointer(nf_ct_ext_types[type->id], NULL); | 186 | rcu_assign_pointer(nf_ct_ext_types[type->id], NULL); |
187 | update_alloc_size(type); | 187 | update_alloc_size(type); |
188 | mutex_unlock(&nf_ct_ext_type_mutex); | 188 | mutex_unlock(&nf_ct_ext_type_mutex); |
189 | synchronize_rcu(); | 189 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ |
190 | } | 190 | } |
191 | EXPORT_SYMBOL_GPL(nf_ct_extend_unregister); | 191 | EXPORT_SYMBOL_GPL(nf_ct_extend_unregister); |
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index 33fc0a443f3d..97a82ba75376 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c | |||
@@ -720,8 +720,8 @@ static bool tcp_in_window(const struct nf_conn *ct, | |||
720 | /* Caller must linearize skb at tcp header. */ | 720 | /* Caller must linearize skb at tcp header. */ |
721 | void nf_conntrack_tcp_update(const struct sk_buff *skb, | 721 | void nf_conntrack_tcp_update(const struct sk_buff *skb, |
722 | unsigned int dataoff, | 722 | unsigned int dataoff, |
723 | struct nf_conn *ct, | 723 | struct nf_conn *ct, int dir, |
724 | int dir) | 724 | s16 offset) |
725 | { | 725 | { |
726 | const struct tcphdr *tcph = (const void *)skb->data + dataoff; | 726 | const struct tcphdr *tcph = (const void *)skb->data + dataoff; |
727 | const struct ip_ct_tcp_state *sender = &ct->proto.tcp.seen[dir]; | 727 | const struct ip_ct_tcp_state *sender = &ct->proto.tcp.seen[dir]; |
@@ -734,7 +734,7 @@ void nf_conntrack_tcp_update(const struct sk_buff *skb, | |||
734 | /* | 734 | /* |
735 | * We have to worry for the ack in the reply packet only... | 735 | * We have to worry for the ack in the reply packet only... |
736 | */ | 736 | */ |
737 | if (after(end, ct->proto.tcp.seen[dir].td_end)) | 737 | if (ct->proto.tcp.seen[dir].td_end + offset == end) |
738 | ct->proto.tcp.seen[dir].td_end = end; | 738 | ct->proto.tcp.seen[dir].td_end = end; |
739 | ct->proto.tcp.last_end = end; | 739 | ct->proto.tcp.last_end = end; |
740 | spin_unlock_bh(&ct->lock); | 740 | spin_unlock_bh(&ct->lock); |
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c index 0b7139f3dd78..fc581800698e 100644 --- a/net/netfilter/xt_conntrack.c +++ b/net/netfilter/xt_conntrack.c | |||
@@ -129,7 +129,7 @@ conntrack_addrcmp(const union nf_inet_addr *kaddr, | |||
129 | 129 | ||
130 | static inline bool | 130 | static inline bool |
131 | conntrack_mt_origsrc(const struct nf_conn *ct, | 131 | conntrack_mt_origsrc(const struct nf_conn *ct, |
132 | const struct xt_conntrack_mtinfo1 *info, | 132 | const struct xt_conntrack_mtinfo2 *info, |
133 | u_int8_t family) | 133 | u_int8_t family) |
134 | { | 134 | { |
135 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3, | 135 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3, |
@@ -138,7 +138,7 @@ conntrack_mt_origsrc(const struct nf_conn *ct, | |||
138 | 138 | ||
139 | static inline bool | 139 | static inline bool |
140 | conntrack_mt_origdst(const struct nf_conn *ct, | 140 | conntrack_mt_origdst(const struct nf_conn *ct, |
141 | const struct xt_conntrack_mtinfo1 *info, | 141 | const struct xt_conntrack_mtinfo2 *info, |
142 | u_int8_t family) | 142 | u_int8_t family) |
143 | { | 143 | { |
144 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3, | 144 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3, |
@@ -147,7 +147,7 @@ conntrack_mt_origdst(const struct nf_conn *ct, | |||
147 | 147 | ||
148 | static inline bool | 148 | static inline bool |
149 | conntrack_mt_replsrc(const struct nf_conn *ct, | 149 | conntrack_mt_replsrc(const struct nf_conn *ct, |
150 | const struct xt_conntrack_mtinfo1 *info, | 150 | const struct xt_conntrack_mtinfo2 *info, |
151 | u_int8_t family) | 151 | u_int8_t family) |
152 | { | 152 | { |
153 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3, | 153 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3, |
@@ -156,7 +156,7 @@ conntrack_mt_replsrc(const struct nf_conn *ct, | |||
156 | 156 | ||
157 | static inline bool | 157 | static inline bool |
158 | conntrack_mt_repldst(const struct nf_conn *ct, | 158 | conntrack_mt_repldst(const struct nf_conn *ct, |
159 | const struct xt_conntrack_mtinfo1 *info, | 159 | const struct xt_conntrack_mtinfo2 *info, |
160 | u_int8_t family) | 160 | u_int8_t family) |
161 | { | 161 | { |
162 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3, | 162 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3, |
@@ -164,7 +164,7 @@ conntrack_mt_repldst(const struct nf_conn *ct, | |||
164 | } | 164 | } |
165 | 165 | ||
166 | static inline bool | 166 | static inline bool |
167 | ct_proto_port_check(const struct xt_conntrack_mtinfo1 *info, | 167 | ct_proto_port_check(const struct xt_conntrack_mtinfo2 *info, |
168 | const struct nf_conn *ct) | 168 | const struct nf_conn *ct) |
169 | { | 169 | { |
170 | const struct nf_conntrack_tuple *tuple; | 170 | const struct nf_conntrack_tuple *tuple; |
@@ -204,7 +204,7 @@ ct_proto_port_check(const struct xt_conntrack_mtinfo1 *info, | |||
204 | static bool | 204 | static bool |
205 | conntrack_mt(const struct sk_buff *skb, const struct xt_match_param *par) | 205 | conntrack_mt(const struct sk_buff *skb, const struct xt_match_param *par) |
206 | { | 206 | { |
207 | const struct xt_conntrack_mtinfo1 *info = par->matchinfo; | 207 | const struct xt_conntrack_mtinfo2 *info = par->matchinfo; |
208 | enum ip_conntrack_info ctinfo; | 208 | enum ip_conntrack_info ctinfo; |
209 | const struct nf_conn *ct; | 209 | const struct nf_conn *ct; |
210 | unsigned int statebit; | 210 | unsigned int statebit; |
@@ -278,6 +278,16 @@ conntrack_mt(const struct sk_buff *skb, const struct xt_match_param *par) | |||
278 | return true; | 278 | return true; |
279 | } | 279 | } |
280 | 280 | ||
281 | static bool | ||
282 | conntrack_mt_v1(const struct sk_buff *skb, const struct xt_match_param *par) | ||
283 | { | ||
284 | const struct xt_conntrack_mtinfo2 *const *info = par->matchinfo; | ||
285 | struct xt_match_param newpar = *par; | ||
286 | |||
287 | newpar.matchinfo = *info; | ||
288 | return conntrack_mt(skb, &newpar); | ||
289 | } | ||
290 | |||
281 | static bool conntrack_mt_check(const struct xt_mtchk_param *par) | 291 | static bool conntrack_mt_check(const struct xt_mtchk_param *par) |
282 | { | 292 | { |
283 | if (nf_ct_l3proto_try_module_get(par->family) < 0) { | 293 | if (nf_ct_l3proto_try_module_get(par->family) < 0) { |
@@ -288,11 +298,45 @@ static bool conntrack_mt_check(const struct xt_mtchk_param *par) | |||
288 | return true; | 298 | return true; |
289 | } | 299 | } |
290 | 300 | ||
301 | static bool conntrack_mt_check_v1(const struct xt_mtchk_param *par) | ||
302 | { | ||
303 | struct xt_conntrack_mtinfo1 *info = par->matchinfo; | ||
304 | struct xt_conntrack_mtinfo2 *up; | ||
305 | int ret = conntrack_mt_check(par); | ||
306 | |||
307 | if (ret < 0) | ||
308 | return ret; | ||
309 | |||
310 | up = kmalloc(sizeof(*up), GFP_KERNEL); | ||
311 | if (up == NULL) { | ||
312 | nf_ct_l3proto_module_put(par->family); | ||
313 | return -ENOMEM; | ||
314 | } | ||
315 | |||
316 | /* | ||
317 | * The strategy here is to minimize the overhead of v1 matching, | ||
318 | * by prebuilding a v2 struct and putting the pointer into the | ||
319 | * v1 dataspace. | ||
320 | */ | ||
321 | memcpy(up, info, offsetof(typeof(*info), state_mask)); | ||
322 | up->state_mask = info->state_mask; | ||
323 | up->status_mask = info->status_mask; | ||
324 | *(void **)info = up; | ||
325 | return true; | ||
326 | } | ||
327 | |||
291 | static void conntrack_mt_destroy(const struct xt_mtdtor_param *par) | 328 | static void conntrack_mt_destroy(const struct xt_mtdtor_param *par) |
292 | { | 329 | { |
293 | nf_ct_l3proto_module_put(par->family); | 330 | nf_ct_l3proto_module_put(par->family); |
294 | } | 331 | } |
295 | 332 | ||
333 | static void conntrack_mt_destroy_v1(const struct xt_mtdtor_param *par) | ||
334 | { | ||
335 | struct xt_conntrack_mtinfo2 **info = par->matchinfo; | ||
336 | kfree(*info); | ||
337 | conntrack_mt_destroy(par); | ||
338 | } | ||
339 | |||
296 | #ifdef CONFIG_COMPAT | 340 | #ifdef CONFIG_COMPAT |
297 | struct compat_xt_conntrack_info | 341 | struct compat_xt_conntrack_info |
298 | { | 342 | { |
@@ -363,6 +407,16 @@ static struct xt_match conntrack_mt_reg[] __read_mostly = { | |||
363 | .revision = 1, | 407 | .revision = 1, |
364 | .family = NFPROTO_UNSPEC, | 408 | .family = NFPROTO_UNSPEC, |
365 | .matchsize = sizeof(struct xt_conntrack_mtinfo1), | 409 | .matchsize = sizeof(struct xt_conntrack_mtinfo1), |
410 | .match = conntrack_mt_v1, | ||
411 | .checkentry = conntrack_mt_check_v1, | ||
412 | .destroy = conntrack_mt_destroy_v1, | ||
413 | .me = THIS_MODULE, | ||
414 | }, | ||
415 | { | ||
416 | .name = "conntrack", | ||
417 | .revision = 2, | ||
418 | .family = NFPROTO_UNSPEC, | ||
419 | .matchsize = sizeof(struct xt_conntrack_mtinfo2), | ||
366 | .match = conntrack_mt, | 420 | .match = conntrack_mt, |
367 | .checkentry = conntrack_mt_check, | 421 | .checkentry = conntrack_mt_check, |
368 | .destroy = conntrack_mt_destroy, | 422 | .destroy = conntrack_mt_destroy, |
diff --git a/net/netfilter/xt_osf.c b/net/netfilter/xt_osf.c index 863e40977a4d..0f482e2440b4 100644 --- a/net/netfilter/xt_osf.c +++ b/net/netfilter/xt_osf.c | |||
@@ -330,7 +330,8 @@ static bool xt_osf_match_packet(const struct sk_buff *skb, | |||
330 | fcount++; | 330 | fcount++; |
331 | 331 | ||
332 | if (info->flags & XT_OSF_LOG) | 332 | if (info->flags & XT_OSF_LOG) |
333 | nf_log_packet(p->hooknum, 0, skb, p->in, p->out, NULL, | 333 | nf_log_packet(p->family, p->hooknum, skb, |
334 | p->in, p->out, NULL, | ||
334 | "%s [%s:%s] : %pi4:%d -> %pi4:%d hops=%d\n", | 335 | "%s [%s:%s] : %pi4:%d -> %pi4:%d hops=%d\n", |
335 | f->genre, f->version, f->subtype, | 336 | f->genre, f->version, f->subtype, |
336 | &ip->saddr, ntohs(tcp->source), | 337 | &ip->saddr, ntohs(tcp->source), |
@@ -345,7 +346,7 @@ static bool xt_osf_match_packet(const struct sk_buff *skb, | |||
345 | rcu_read_unlock(); | 346 | rcu_read_unlock(); |
346 | 347 | ||
347 | if (!fcount && (info->flags & XT_OSF_LOG)) | 348 | if (!fcount && (info->flags & XT_OSF_LOG)) |
348 | nf_log_packet(p->hooknum, 0, skb, p->in, p->out, NULL, | 349 | nf_log_packet(p->family, p->hooknum, skb, p->in, p->out, NULL, |
349 | "Remote OS is not known: %pi4:%u -> %pi4:%u\n", | 350 | "Remote OS is not known: %pi4:%u -> %pi4:%u\n", |
350 | &ip->saddr, ntohs(tcp->source), | 351 | &ip->saddr, ntohs(tcp->source), |
351 | &ip->daddr, ntohs(tcp->dest)); | 352 | &ip->daddr, ntohs(tcp->dest)); |
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c index b0e582f2d37a..16e6c4378ff1 100644 --- a/net/netlabel/netlabel_kapi.c +++ b/net/netlabel/netlabel_kapi.c | |||
@@ -151,7 +151,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain, | |||
151 | addr6 = addr; | 151 | addr6 = addr; |
152 | mask6 = mask; | 152 | mask6 = mask; |
153 | map6 = kzalloc(sizeof(*map6), GFP_ATOMIC); | 153 | map6 = kzalloc(sizeof(*map6), GFP_ATOMIC); |
154 | if (map4 == NULL) | 154 | if (map6 == NULL) |
155 | goto cfg_unlbl_map_add_failure; | 155 | goto cfg_unlbl_map_add_failure; |
156 | map6->type = NETLBL_NLTYPE_UNLABELED; | 156 | map6->type = NETLBL_NLTYPE_UNLABELED; |
157 | ipv6_addr_copy(&map6->list.addr, addr6); | 157 | ipv6_addr_copy(&map6->list.addr, addr6); |
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c index 80a322d77909..b0d6ddd82a9d 100644 --- a/net/phonet/pn_dev.c +++ b/net/phonet/pn_dev.c | |||
@@ -69,10 +69,27 @@ static struct phonet_device *__phonet_get(struct net_device *dev) | |||
69 | return NULL; | 69 | return NULL; |
70 | } | 70 | } |
71 | 71 | ||
72 | static void __phonet_device_free(struct phonet_device *pnd) | 72 | static void phonet_device_destroy(struct net_device *dev) |
73 | { | 73 | { |
74 | list_del(&pnd->list); | 74 | struct phonet_device_list *pndevs = phonet_device_list(dev_net(dev)); |
75 | kfree(pnd); | 75 | struct phonet_device *pnd; |
76 | |||
77 | ASSERT_RTNL(); | ||
78 | |||
79 | spin_lock_bh(&pndevs->lock); | ||
80 | pnd = __phonet_get(dev); | ||
81 | if (pnd) | ||
82 | list_del(&pnd->list); | ||
83 | spin_unlock_bh(&pndevs->lock); | ||
84 | |||
85 | if (pnd) { | ||
86 | u8 addr; | ||
87 | |||
88 | for (addr = find_first_bit(pnd->addrs, 64); addr < 64; | ||
89 | addr = find_next_bit(pnd->addrs, 64, 1+addr)) | ||
90 | phonet_address_notify(RTM_DELADDR, dev, addr); | ||
91 | kfree(pnd); | ||
92 | } | ||
76 | } | 93 | } |
77 | 94 | ||
78 | struct net_device *phonet_device_get(struct net *net) | 95 | struct net_device *phonet_device_get(struct net *net) |
@@ -126,8 +143,10 @@ int phonet_address_del(struct net_device *dev, u8 addr) | |||
126 | pnd = __phonet_get(dev); | 143 | pnd = __phonet_get(dev); |
127 | if (!pnd || !test_and_clear_bit(addr >> 2, pnd->addrs)) | 144 | if (!pnd || !test_and_clear_bit(addr >> 2, pnd->addrs)) |
128 | err = -EADDRNOTAVAIL; | 145 | err = -EADDRNOTAVAIL; |
129 | else if (bitmap_empty(pnd->addrs, 64)) | 146 | else if (bitmap_empty(pnd->addrs, 64)) { |
130 | __phonet_device_free(pnd); | 147 | list_del(&pnd->list); |
148 | kfree(pnd); | ||
149 | } | ||
131 | spin_unlock_bh(&pndevs->lock); | 150 | spin_unlock_bh(&pndevs->lock); |
132 | return err; | 151 | return err; |
133 | } | 152 | } |
@@ -181,18 +200,8 @@ static int phonet_device_notify(struct notifier_block *me, unsigned long what, | |||
181 | { | 200 | { |
182 | struct net_device *dev = arg; | 201 | struct net_device *dev = arg; |
183 | 202 | ||
184 | if (what == NETDEV_UNREGISTER) { | 203 | if (what == NETDEV_UNREGISTER) |
185 | struct phonet_device_list *pndevs; | 204 | phonet_device_destroy(dev); |
186 | struct phonet_device *pnd; | ||
187 | |||
188 | /* Destroy phonet-specific device data */ | ||
189 | pndevs = phonet_device_list(dev_net(dev)); | ||
190 | spin_lock_bh(&pndevs->lock); | ||
191 | pnd = __phonet_get(dev); | ||
192 | if (pnd) | ||
193 | __phonet_device_free(pnd); | ||
194 | spin_unlock_bh(&pndevs->lock); | ||
195 | } | ||
196 | return 0; | 205 | return 0; |
197 | 206 | ||
198 | } | 207 | } |
@@ -218,11 +227,12 @@ static int phonet_init_net(struct net *net) | |||
218 | static void phonet_exit_net(struct net *net) | 227 | static void phonet_exit_net(struct net *net) |
219 | { | 228 | { |
220 | struct phonet_net *pnn = net_generic(net, phonet_net_id); | 229 | struct phonet_net *pnn = net_generic(net, phonet_net_id); |
221 | struct phonet_device *pnd, *n; | 230 | struct net_device *dev; |
222 | |||
223 | list_for_each_entry_safe(pnd, n, &pnn->pndevs.list, list) | ||
224 | __phonet_device_free(pnd); | ||
225 | 231 | ||
232 | rtnl_lock(); | ||
233 | for_each_netdev(net, dev) | ||
234 | phonet_device_destroy(dev); | ||
235 | rtnl_unlock(); | ||
226 | kfree(pnn); | 236 | kfree(pnn); |
227 | } | 237 | } |
228 | 238 | ||
diff --git a/net/phonet/pn_netlink.c b/net/phonet/pn_netlink.c index cec4e5951681..f8b4cee434c2 100644 --- a/net/phonet/pn_netlink.c +++ b/net/phonet/pn_netlink.c | |||
@@ -32,7 +32,7 @@ | |||
32 | static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr, | 32 | static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr, |
33 | u32 pid, u32 seq, int event); | 33 | u32 pid, u32 seq, int event); |
34 | 34 | ||
35 | static void rtmsg_notify(int event, struct net_device *dev, u8 addr) | 35 | void phonet_address_notify(int event, struct net_device *dev, u8 addr) |
36 | { | 36 | { |
37 | struct sk_buff *skb; | 37 | struct sk_buff *skb; |
38 | int err = -ENOBUFS; | 38 | int err = -ENOBUFS; |
@@ -94,7 +94,7 @@ static int addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *attr) | |||
94 | else | 94 | else |
95 | err = phonet_address_del(dev, pnaddr); | 95 | err = phonet_address_del(dev, pnaddr); |
96 | if (!err) | 96 | if (!err) |
97 | rtmsg_notify(nlh->nlmsg_type, dev, pnaddr); | 97 | phonet_address_notify(nlh->nlmsg_type, dev, pnaddr); |
98 | return err; | 98 | return err; |
99 | } | 99 | } |
100 | 100 | ||
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 79693fe2001e..2fc4a1724eb8 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c | |||
@@ -549,6 +549,10 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) | |||
549 | swprev = !!(rfkill->state & RFKILL_BLOCK_SW); | 549 | swprev = !!(rfkill->state & RFKILL_BLOCK_SW); |
550 | hwprev = !!(rfkill->state & RFKILL_BLOCK_HW); | 550 | hwprev = !!(rfkill->state & RFKILL_BLOCK_HW); |
551 | __rfkill_set_sw_state(rfkill, sw); | 551 | __rfkill_set_sw_state(rfkill, sw); |
552 | if (hw) | ||
553 | rfkill->state |= RFKILL_BLOCK_HW; | ||
554 | else | ||
555 | rfkill->state &= ~RFKILL_BLOCK_HW; | ||
552 | 556 | ||
553 | spin_unlock_irqrestore(&rfkill->lock, flags); | 557 | spin_unlock_irqrestore(&rfkill->lock, flags); |
554 | 558 | ||
@@ -648,15 +652,26 @@ static ssize_t rfkill_state_store(struct device *dev, | |||
648 | struct device_attribute *attr, | 652 | struct device_attribute *attr, |
649 | const char *buf, size_t count) | 653 | const char *buf, size_t count) |
650 | { | 654 | { |
651 | /* | 655 | struct rfkill *rfkill = to_rfkill(dev); |
652 | * The intention was that userspace can only take control over | 656 | unsigned long state; |
653 | * a given device when/if rfkill-input doesn't control it due | 657 | int err; |
654 | * to user_claim. Since user_claim is currently unsupported, | 658 | |
655 | * we never support changing the state from userspace -- this | 659 | if (!capable(CAP_NET_ADMIN)) |
656 | * can be implemented again later. | 660 | return -EPERM; |
657 | */ | 661 | |
662 | err = strict_strtoul(buf, 0, &state); | ||
663 | if (err) | ||
664 | return err; | ||
665 | |||
666 | if (state != RFKILL_USER_STATE_SOFT_BLOCKED && | ||
667 | state != RFKILL_USER_STATE_UNBLOCKED) | ||
668 | return -EINVAL; | ||
669 | |||
670 | mutex_lock(&rfkill_global_mutex); | ||
671 | rfkill_set_block(rfkill, state == RFKILL_USER_STATE_SOFT_BLOCKED); | ||
672 | mutex_unlock(&rfkill_global_mutex); | ||
658 | 673 | ||
659 | return -EPERM; | 674 | return err ?: count; |
660 | } | 675 | } |
661 | 676 | ||
662 | static ssize_t rfkill_claim_show(struct device *dev, | 677 | static ssize_t rfkill_claim_show(struct device *dev, |
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 6bd8e93869ed..f0a76f6bca71 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -92,23 +92,21 @@ static void rose_set_lockdep_key(struct net_device *dev) | |||
92 | /* | 92 | /* |
93 | * Convert a ROSE address into text. | 93 | * Convert a ROSE address into text. |
94 | */ | 94 | */ |
95 | const char *rose2asc(const rose_address *addr) | 95 | char *rose2asc(char *buf, const rose_address *addr) |
96 | { | 96 | { |
97 | static char buffer[11]; | ||
98 | |||
99 | if (addr->rose_addr[0] == 0x00 && addr->rose_addr[1] == 0x00 && | 97 | if (addr->rose_addr[0] == 0x00 && addr->rose_addr[1] == 0x00 && |
100 | addr->rose_addr[2] == 0x00 && addr->rose_addr[3] == 0x00 && | 98 | addr->rose_addr[2] == 0x00 && addr->rose_addr[3] == 0x00 && |
101 | addr->rose_addr[4] == 0x00) { | 99 | addr->rose_addr[4] == 0x00) { |
102 | strcpy(buffer, "*"); | 100 | strcpy(buf, "*"); |
103 | } else { | 101 | } else { |
104 | sprintf(buffer, "%02X%02X%02X%02X%02X", addr->rose_addr[0] & 0xFF, | 102 | sprintf(buf, "%02X%02X%02X%02X%02X", addr->rose_addr[0] & 0xFF, |
105 | addr->rose_addr[1] & 0xFF, | 103 | addr->rose_addr[1] & 0xFF, |
106 | addr->rose_addr[2] & 0xFF, | 104 | addr->rose_addr[2] & 0xFF, |
107 | addr->rose_addr[3] & 0xFF, | 105 | addr->rose_addr[3] & 0xFF, |
108 | addr->rose_addr[4] & 0xFF); | 106 | addr->rose_addr[4] & 0xFF); |
109 | } | 107 | } |
110 | 108 | ||
111 | return buffer; | 109 | return buf; |
112 | } | 110 | } |
113 | 111 | ||
114 | /* | 112 | /* |
@@ -1437,7 +1435,7 @@ static void rose_info_stop(struct seq_file *seq, void *v) | |||
1437 | 1435 | ||
1438 | static int rose_info_show(struct seq_file *seq, void *v) | 1436 | static int rose_info_show(struct seq_file *seq, void *v) |
1439 | { | 1437 | { |
1440 | char buf[11]; | 1438 | char buf[11], rsbuf[11]; |
1441 | 1439 | ||
1442 | if (v == SEQ_START_TOKEN) | 1440 | if (v == SEQ_START_TOKEN) |
1443 | seq_puts(seq, | 1441 | seq_puts(seq, |
@@ -1455,8 +1453,8 @@ static int rose_info_show(struct seq_file *seq, void *v) | |||
1455 | devname = dev->name; | 1453 | devname = dev->name; |
1456 | 1454 | ||
1457 | seq_printf(seq, "%-10s %-9s ", | 1455 | seq_printf(seq, "%-10s %-9s ", |
1458 | rose2asc(&rose->dest_addr), | 1456 | rose2asc(rsbuf, &rose->dest_addr), |
1459 | ax2asc(buf, &rose->dest_call)); | 1457 | ax2asc(buf, &rose->dest_call)); |
1460 | 1458 | ||
1461 | if (ax25cmp(&rose->source_call, &null_ax25_address) == 0) | 1459 | if (ax25cmp(&rose->source_call, &null_ax25_address) == 0) |
1462 | callsign = "??????-?"; | 1460 | callsign = "??????-?"; |
@@ -1465,7 +1463,7 @@ static int rose_info_show(struct seq_file *seq, void *v) | |||
1465 | 1463 | ||
1466 | seq_printf(seq, | 1464 | seq_printf(seq, |
1467 | "%-10s %-9s %-5s %3.3X %05d %d %d %d %d %3lu %3lu %3lu %3lu %3lu %3lu/%03lu %5d %5d %ld\n", | 1465 | "%-10s %-9s %-5s %3.3X %05d %d %d %d %d %3lu %3lu %3lu %3lu %3lu %3lu/%03lu %5d %5d %ld\n", |
1468 | rose2asc(&rose->source_addr), | 1466 | rose2asc(rsbuf, &rose->source_addr), |
1469 | callsign, | 1467 | callsign, |
1470 | devname, | 1468 | devname, |
1471 | rose->lci & 0x0FFF, | 1469 | rose->lci & 0x0FFF, |
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c index a81066a1010a..9478d9b3d977 100644 --- a/net/rose/rose_route.c +++ b/net/rose/rose_route.c | |||
@@ -1104,6 +1104,7 @@ static void rose_node_stop(struct seq_file *seq, void *v) | |||
1104 | 1104 | ||
1105 | static int rose_node_show(struct seq_file *seq, void *v) | 1105 | static int rose_node_show(struct seq_file *seq, void *v) |
1106 | { | 1106 | { |
1107 | char rsbuf[11]; | ||
1107 | int i; | 1108 | int i; |
1108 | 1109 | ||
1109 | if (v == SEQ_START_TOKEN) | 1110 | if (v == SEQ_START_TOKEN) |
@@ -1112,13 +1113,13 @@ static int rose_node_show(struct seq_file *seq, void *v) | |||
1112 | const struct rose_node *rose_node = v; | 1113 | const struct rose_node *rose_node = v; |
1113 | /* if (rose_node->loopback) { | 1114 | /* if (rose_node->loopback) { |
1114 | seq_printf(seq, "%-10s %04d 1 loopback\n", | 1115 | seq_printf(seq, "%-10s %04d 1 loopback\n", |
1115 | rose2asc(&rose_node->address), | 1116 | rose2asc(rsbuf, &rose_node->address), |
1116 | rose_node->mask); | 1117 | rose_node->mask); |
1117 | } else { */ | 1118 | } else { */ |
1118 | seq_printf(seq, "%-10s %04d %d", | 1119 | seq_printf(seq, "%-10s %04d %d", |
1119 | rose2asc(&rose_node->address), | 1120 | rose2asc(rsbuf, &rose_node->address), |
1120 | rose_node->mask, | 1121 | rose_node->mask, |
1121 | rose_node->count); | 1122 | rose_node->count); |
1122 | 1123 | ||
1123 | for (i = 0; i < rose_node->count; i++) | 1124 | for (i = 0; i < rose_node->count; i++) |
1124 | seq_printf(seq, " %05d", | 1125 | seq_printf(seq, " %05d", |
@@ -1267,7 +1268,7 @@ static void rose_route_stop(struct seq_file *seq, void *v) | |||
1267 | 1268 | ||
1268 | static int rose_route_show(struct seq_file *seq, void *v) | 1269 | static int rose_route_show(struct seq_file *seq, void *v) |
1269 | { | 1270 | { |
1270 | char buf[11]; | 1271 | char buf[11], rsbuf[11]; |
1271 | 1272 | ||
1272 | if (v == SEQ_START_TOKEN) | 1273 | if (v == SEQ_START_TOKEN) |
1273 | seq_puts(seq, | 1274 | seq_puts(seq, |
@@ -1279,7 +1280,7 @@ static int rose_route_show(struct seq_file *seq, void *v) | |||
1279 | seq_printf(seq, | 1280 | seq_printf(seq, |
1280 | "%3.3X %-10s %-9s %05d ", | 1281 | "%3.3X %-10s %-9s %05d ", |
1281 | rose_route->lci1, | 1282 | rose_route->lci1, |
1282 | rose2asc(&rose_route->src_addr), | 1283 | rose2asc(rsbuf, &rose_route->src_addr), |
1283 | ax2asc(buf, &rose_route->src_call), | 1284 | ax2asc(buf, &rose_route->src_call), |
1284 | rose_route->neigh1->number); | 1285 | rose_route->neigh1->number); |
1285 | else | 1286 | else |
@@ -1289,10 +1290,10 @@ static int rose_route_show(struct seq_file *seq, void *v) | |||
1289 | if (rose_route->neigh2) | 1290 | if (rose_route->neigh2) |
1290 | seq_printf(seq, | 1291 | seq_printf(seq, |
1291 | "%3.3X %-10s %-9s %05d\n", | 1292 | "%3.3X %-10s %-9s %05d\n", |
1292 | rose_route->lci2, | 1293 | rose_route->lci2, |
1293 | rose2asc(&rose_route->dest_addr), | 1294 | rose2asc(rsbuf, &rose_route->dest_addr), |
1294 | ax2asc(buf, &rose_route->dest_call), | 1295 | ax2asc(buf, &rose_route->dest_call), |
1295 | rose_route->neigh2->number); | 1296 | rose_route->neigh2->number); |
1296 | else | 1297 | else |
1297 | seq_puts(seq, | 1298 | seq_puts(seq, |
1298 | "000 * * 00000\n"); | 1299 | "000 * * 00000\n"); |
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c index eac5e7bb7365..bfe493ebf27c 100644 --- a/net/rxrpc/af_rxrpc.c +++ b/net/rxrpc/af_rxrpc.c | |||
@@ -63,7 +63,7 @@ static void rxrpc_write_space(struct sock *sk) | |||
63 | _enter("%p", sk); | 63 | _enter("%p", sk); |
64 | read_lock(&sk->sk_callback_lock); | 64 | read_lock(&sk->sk_callback_lock); |
65 | if (rxrpc_writable(sk)) { | 65 | if (rxrpc_writable(sk)) { |
66 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 66 | if (sk_has_sleeper(sk)) |
67 | wake_up_interruptible(sk->sk_sleep); | 67 | wake_up_interruptible(sk->sk_sleep); |
68 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); | 68 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); |
69 | } | 69 | } |
@@ -588,7 +588,7 @@ static unsigned int rxrpc_poll(struct file *file, struct socket *sock, | |||
588 | unsigned int mask; | 588 | unsigned int mask; |
589 | struct sock *sk = sock->sk; | 589 | struct sock *sk = sock->sk; |
590 | 590 | ||
591 | poll_wait(file, sk->sk_sleep, wait); | 591 | sock_poll_wait(file, sk->sk_sleep, wait); |
592 | mask = 0; | 592 | mask = 0; |
593 | 593 | ||
594 | /* the socket is readable if there are any messages waiting on the Rx | 594 | /* the socket is readable if there are any messages waiting on the Rx |
diff --git a/net/sctp/output.c b/net/sctp/output.c index b76411444515..b94c21190566 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c | |||
@@ -407,7 +407,7 @@ int sctp_packet_transmit(struct sctp_packet *packet) | |||
407 | } | 407 | } |
408 | dst = dst_clone(tp->dst); | 408 | dst = dst_clone(tp->dst); |
409 | skb_dst_set(nskb, dst); | 409 | skb_dst_set(nskb, dst); |
410 | if (dst) | 410 | if (!dst) |
411 | goto no_route; | 411 | goto no_route; |
412 | 412 | ||
413 | /* Build the SCTP header. */ | 413 | /* Build the SCTP header. */ |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 35ba035970a2..971890dbfea0 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -6652,21 +6652,6 @@ static void sctp_wait_for_close(struct sock *sk, long timeout) | |||
6652 | finish_wait(sk->sk_sleep, &wait); | 6652 | finish_wait(sk->sk_sleep, &wait); |
6653 | } | 6653 | } |
6654 | 6654 | ||
6655 | static void sctp_sock_rfree_frag(struct sk_buff *skb) | ||
6656 | { | ||
6657 | struct sk_buff *frag; | ||
6658 | |||
6659 | if (!skb->data_len) | ||
6660 | goto done; | ||
6661 | |||
6662 | /* Don't forget the fragments. */ | ||
6663 | skb_walk_frags(skb, frag) | ||
6664 | sctp_sock_rfree_frag(frag); | ||
6665 | |||
6666 | done: | ||
6667 | sctp_sock_rfree(skb); | ||
6668 | } | ||
6669 | |||
6670 | static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk) | 6655 | static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk) |
6671 | { | 6656 | { |
6672 | struct sk_buff *frag; | 6657 | struct sk_buff *frag; |
@@ -6776,7 +6761,6 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk, | |||
6776 | sctp_skb_for_each(skb, &oldsk->sk_receive_queue, tmp) { | 6761 | sctp_skb_for_each(skb, &oldsk->sk_receive_queue, tmp) { |
6777 | event = sctp_skb2event(skb); | 6762 | event = sctp_skb2event(skb); |
6778 | if (event->asoc == assoc) { | 6763 | if (event->asoc == assoc) { |
6779 | sctp_sock_rfree_frag(skb); | ||
6780 | __skb_unlink(skb, &oldsk->sk_receive_queue); | 6764 | __skb_unlink(skb, &oldsk->sk_receive_queue); |
6781 | __skb_queue_tail(&newsk->sk_receive_queue, skb); | 6765 | __skb_queue_tail(&newsk->sk_receive_queue, skb); |
6782 | sctp_skb_set_owner_r_frag(skb, newsk); | 6766 | sctp_skb_set_owner_r_frag(skb, newsk); |
@@ -6807,7 +6791,6 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk, | |||
6807 | sctp_skb_for_each(skb, &oldsp->pd_lobby, tmp) { | 6791 | sctp_skb_for_each(skb, &oldsp->pd_lobby, tmp) { |
6808 | event = sctp_skb2event(skb); | 6792 | event = sctp_skb2event(skb); |
6809 | if (event->asoc == assoc) { | 6793 | if (event->asoc == assoc) { |
6810 | sctp_sock_rfree_frag(skb); | ||
6811 | __skb_unlink(skb, &oldsp->pd_lobby); | 6794 | __skb_unlink(skb, &oldsp->pd_lobby); |
6812 | __skb_queue_tail(queue, skb); | 6795 | __skb_queue_tail(queue, skb); |
6813 | sctp_skb_set_owner_r_frag(skb, newsk); | 6796 | sctp_skb_set_owner_r_frag(skb, newsk); |
@@ -6822,15 +6805,11 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk, | |||
6822 | 6805 | ||
6823 | } | 6806 | } |
6824 | 6807 | ||
6825 | sctp_skb_for_each(skb, &assoc->ulpq.reasm, tmp) { | 6808 | sctp_skb_for_each(skb, &assoc->ulpq.reasm, tmp) |
6826 | sctp_sock_rfree_frag(skb); | ||
6827 | sctp_skb_set_owner_r_frag(skb, newsk); | 6809 | sctp_skb_set_owner_r_frag(skb, newsk); |
6828 | } | ||
6829 | 6810 | ||
6830 | sctp_skb_for_each(skb, &assoc->ulpq.lobby, tmp) { | 6811 | sctp_skb_for_each(skb, &assoc->ulpq.lobby, tmp) |
6831 | sctp_sock_rfree_frag(skb); | ||
6832 | sctp_skb_set_owner_r_frag(skb, newsk); | 6812 | sctp_skb_set_owner_r_frag(skb, newsk); |
6833 | } | ||
6834 | 6813 | ||
6835 | /* Set the type of socket to indicate that it is peeled off from the | 6814 | /* Set the type of socket to indicate that it is peeled off from the |
6836 | * original UDP-style socket or created with the accept() call on a | 6815 | * original UDP-style socket or created with the accept() call on a |
diff --git a/net/socket.c b/net/socket.c index 791d71a36a93..6d4716559047 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -736,7 +736,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page, | |||
736 | if (more) | 736 | if (more) |
737 | flags |= MSG_MORE; | 737 | flags |= MSG_MORE; |
738 | 738 | ||
739 | return sock->ops->sendpage(sock, page, offset, size, flags); | 739 | return kernel_sendpage(sock, page, offset, size, flags); |
740 | } | 740 | } |
741 | 741 | ||
742 | static ssize_t sock_splice_read(struct file *file, loff_t *ppos, | 742 | static ssize_t sock_splice_read(struct file *file, loff_t *ppos, |
diff --git a/net/sunrpc/Makefile b/net/sunrpc/Makefile index db73fd2a3f0e..9d2fca5ad14a 100644 --- a/net/sunrpc/Makefile +++ b/net/sunrpc/Makefile | |||
@@ -10,7 +10,7 @@ obj-$(CONFIG_SUNRPC_XPRT_RDMA) += xprtrdma/ | |||
10 | sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ | 10 | sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ |
11 | auth.o auth_null.o auth_unix.o auth_generic.o \ | 11 | auth.o auth_null.o auth_unix.o auth_generic.o \ |
12 | svc.o svcsock.o svcauth.o svcauth_unix.o \ | 12 | svc.o svcsock.o svcauth.o svcauth_unix.o \ |
13 | rpcb_clnt.o timer.o xdr.o \ | 13 | addr.o rpcb_clnt.o timer.o xdr.o \ |
14 | sunrpc_syms.o cache.o rpc_pipe.o \ | 14 | sunrpc_syms.o cache.o rpc_pipe.o \ |
15 | svc_xprt.o | 15 | svc_xprt.o |
16 | sunrpc-$(CONFIG_NFS_V4_1) += backchannel_rqst.o bc_svc.o | 16 | sunrpc-$(CONFIG_NFS_V4_1) += backchannel_rqst.o bc_svc.o |
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c new file mode 100644 index 000000000000..22e8fd89477f --- /dev/null +++ b/net/sunrpc/addr.c | |||
@@ -0,0 +1,364 @@ | |||
1 | /* | ||
2 | * Copyright 2009, Oracle. All rights reserved. | ||
3 | * | ||
4 | * Convert socket addresses to presentation addresses and universal | ||
5 | * addresses, and vice versa. | ||
6 | * | ||
7 | * Universal addresses are introduced by RFC 1833 and further refined by | ||
8 | * recent RFCs describing NFSv4. The universal address format is part | ||
9 | * of the external (network) interface provided by rpcbind version 3 | ||
10 | * and 4, and by NFSv4. Such an address is a string containing a | ||
11 | * presentation format IP address followed by a port number in | ||
12 | * "hibyte.lobyte" format. | ||
13 | * | ||
14 | * IPv6 addresses can also include a scope ID, typically denoted by | ||
15 | * a '%' followed by a device name or a non-negative integer. Refer to | ||
16 | * RFC 4291, Section 2.2 for details on IPv6 presentation formats. | ||
17 | */ | ||
18 | |||
19 | #include <net/ipv6.h> | ||
20 | #include <linux/sunrpc/clnt.h> | ||
21 | |||
22 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
23 | |||
24 | static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, | ||
25 | char *buf, const int buflen) | ||
26 | { | ||
27 | const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; | ||
28 | const struct in6_addr *addr = &sin6->sin6_addr; | ||
29 | |||
30 | /* | ||
31 | * RFC 4291, Section 2.2.2 | ||
32 | * | ||
33 | * Shorthanded ANY address | ||
34 | */ | ||
35 | if (ipv6_addr_any(addr)) | ||
36 | return snprintf(buf, buflen, "::"); | ||
37 | |||
38 | /* | ||
39 | * RFC 4291, Section 2.2.2 | ||
40 | * | ||
41 | * Shorthanded loopback address | ||
42 | */ | ||
43 | if (ipv6_addr_loopback(addr)) | ||
44 | return snprintf(buf, buflen, "::1"); | ||
45 | |||
46 | /* | ||
47 | * RFC 4291, Section 2.2.3 | ||
48 | * | ||
49 | * Special presentation address format for mapped v4 | ||
50 | * addresses. | ||
51 | */ | ||
52 | if (ipv6_addr_v4mapped(addr)) | ||
53 | return snprintf(buf, buflen, "::ffff:%pI4", | ||
54 | &addr->s6_addr32[3]); | ||
55 | |||
56 | /* | ||
57 | * RFC 4291, Section 2.2.1 | ||
58 | * | ||
59 | * To keep the result as short as possible, especially | ||
60 | * since we don't shorthand, we don't want leading zeros | ||
61 | * in each halfword, so avoid %pI6. | ||
62 | */ | ||
63 | return snprintf(buf, buflen, "%x:%x:%x:%x:%x:%x:%x:%x", | ||
64 | ntohs(addr->s6_addr16[0]), ntohs(addr->s6_addr16[1]), | ||
65 | ntohs(addr->s6_addr16[2]), ntohs(addr->s6_addr16[3]), | ||
66 | ntohs(addr->s6_addr16[4]), ntohs(addr->s6_addr16[5]), | ||
67 | ntohs(addr->s6_addr16[6]), ntohs(addr->s6_addr16[7])); | ||
68 | } | ||
69 | |||
70 | static size_t rpc_ntop6(const struct sockaddr *sap, | ||
71 | char *buf, const size_t buflen) | ||
72 | { | ||
73 | const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; | ||
74 | char scopebuf[IPV6_SCOPE_ID_LEN]; | ||
75 | size_t len; | ||
76 | int rc; | ||
77 | |||
78 | len = rpc_ntop6_noscopeid(sap, buf, buflen); | ||
79 | if (unlikely(len == 0)) | ||
80 | return len; | ||
81 | |||
82 | if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) && | ||
83 | !(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_SITELOCAL)) | ||
84 | return len; | ||
85 | |||
86 | rc = snprintf(scopebuf, sizeof(scopebuf), "%c%u", | ||
87 | IPV6_SCOPE_DELIMITER, sin6->sin6_scope_id); | ||
88 | if (unlikely((size_t)rc > sizeof(scopebuf))) | ||
89 | return 0; | ||
90 | |||
91 | len += rc; | ||
92 | if (unlikely(len > buflen)) | ||
93 | return 0; | ||
94 | |||
95 | strcat(buf, scopebuf); | ||
96 | return len; | ||
97 | } | ||
98 | |||
99 | #else /* !(defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)) */ | ||
100 | |||
101 | static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, | ||
102 | char *buf, const int buflen) | ||
103 | { | ||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | static size_t rpc_ntop6(const struct sockaddr *sap, | ||
108 | char *buf, const size_t buflen) | ||
109 | { | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | #endif /* !(defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)) */ | ||
114 | |||
115 | static int rpc_ntop4(const struct sockaddr *sap, | ||
116 | char *buf, const size_t buflen) | ||
117 | { | ||
118 | const struct sockaddr_in *sin = (struct sockaddr_in *)sap; | ||
119 | |||
120 | return snprintf(buf, buflen, "%pI4", &sin->sin_addr); | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * rpc_ntop - construct a presentation address in @buf | ||
125 | * @sap: socket address | ||
126 | * @buf: construction area | ||
127 | * @buflen: size of @buf, in bytes | ||
128 | * | ||
129 | * Plants a %NUL-terminated string in @buf and returns the length | ||
130 | * of the string, excluding the %NUL. Otherwise zero is returned. | ||
131 | */ | ||
132 | size_t rpc_ntop(const struct sockaddr *sap, char *buf, const size_t buflen) | ||
133 | { | ||
134 | switch (sap->sa_family) { | ||
135 | case AF_INET: | ||
136 | return rpc_ntop4(sap, buf, buflen); | ||
137 | case AF_INET6: | ||
138 | return rpc_ntop6(sap, buf, buflen); | ||
139 | } | ||
140 | |||
141 | return 0; | ||
142 | } | ||
143 | EXPORT_SYMBOL_GPL(rpc_ntop); | ||
144 | |||
145 | static size_t rpc_pton4(const char *buf, const size_t buflen, | ||
146 | struct sockaddr *sap, const size_t salen) | ||
147 | { | ||
148 | struct sockaddr_in *sin = (struct sockaddr_in *)sap; | ||
149 | u8 *addr = (u8 *)&sin->sin_addr.s_addr; | ||
150 | |||
151 | if (buflen > INET_ADDRSTRLEN || salen < sizeof(struct sockaddr_in)) | ||
152 | return 0; | ||
153 | |||
154 | memset(sap, 0, sizeof(struct sockaddr_in)); | ||
155 | |||
156 | if (in4_pton(buf, buflen, addr, '\0', NULL) == 0) | ||
157 | return 0; | ||
158 | |||
159 | sin->sin_family = AF_INET; | ||
160 | return sizeof(struct sockaddr_in);; | ||
161 | } | ||
162 | |||
163 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
164 | static int rpc_parse_scope_id(const char *buf, const size_t buflen, | ||
165 | const char *delim, struct sockaddr_in6 *sin6) | ||
166 | { | ||
167 | char *p; | ||
168 | size_t len; | ||
169 | |||
170 | if ((buf + buflen) == delim) | ||
171 | return 1; | ||
172 | |||
173 | if (*delim != IPV6_SCOPE_DELIMITER) | ||
174 | return 0; | ||
175 | |||
176 | if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) && | ||
177 | !(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_SITELOCAL)) | ||
178 | return 0; | ||
179 | |||
180 | len = (buf + buflen) - delim - 1; | ||
181 | p = kstrndup(delim + 1, len, GFP_KERNEL); | ||
182 | if (p) { | ||
183 | unsigned long scope_id = 0; | ||
184 | struct net_device *dev; | ||
185 | |||
186 | dev = dev_get_by_name(&init_net, p); | ||
187 | if (dev != NULL) { | ||
188 | scope_id = dev->ifindex; | ||
189 | dev_put(dev); | ||
190 | } else { | ||
191 | if (strict_strtoul(p, 10, &scope_id) == 0) { | ||
192 | kfree(p); | ||
193 | return 0; | ||
194 | } | ||
195 | } | ||
196 | |||
197 | kfree(p); | ||
198 | |||
199 | sin6->sin6_scope_id = scope_id; | ||
200 | return 1; | ||
201 | } | ||
202 | |||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static size_t rpc_pton6(const char *buf, const size_t buflen, | ||
207 | struct sockaddr *sap, const size_t salen) | ||
208 | { | ||
209 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; | ||
210 | u8 *addr = (u8 *)&sin6->sin6_addr.in6_u; | ||
211 | const char *delim; | ||
212 | |||
213 | if (buflen > (INET6_ADDRSTRLEN + IPV6_SCOPE_ID_LEN) || | ||
214 | salen < sizeof(struct sockaddr_in6)) | ||
215 | return 0; | ||
216 | |||
217 | memset(sap, 0, sizeof(struct sockaddr_in6)); | ||
218 | |||
219 | if (in6_pton(buf, buflen, addr, IPV6_SCOPE_DELIMITER, &delim) == 0) | ||
220 | return 0; | ||
221 | |||
222 | if (!rpc_parse_scope_id(buf, buflen, delim, sin6)) | ||
223 | return 0; | ||
224 | |||
225 | sin6->sin6_family = AF_INET6; | ||
226 | return sizeof(struct sockaddr_in6); | ||
227 | } | ||
228 | #else | ||
229 | static size_t rpc_pton6(const char *buf, const size_t buflen, | ||
230 | struct sockaddr *sap, const size_t salen) | ||
231 | { | ||
232 | return 0; | ||
233 | } | ||
234 | #endif | ||
235 | |||
236 | /** | ||
237 | * rpc_pton - Construct a sockaddr in @sap | ||
238 | * @buf: C string containing presentation format IP address | ||
239 | * @buflen: length of presentation address in bytes | ||
240 | * @sap: buffer into which to plant socket address | ||
241 | * @salen: size of buffer in bytes | ||
242 | * | ||
243 | * Returns the size of the socket address if successful; otherwise | ||
244 | * zero is returned. | ||
245 | * | ||
246 | * Plants a socket address in @sap and returns the size of the | ||
247 | * socket address, if successful. Returns zero if an error | ||
248 | * occurred. | ||
249 | */ | ||
250 | size_t rpc_pton(const char *buf, const size_t buflen, | ||
251 | struct sockaddr *sap, const size_t salen) | ||
252 | { | ||
253 | unsigned int i; | ||
254 | |||
255 | for (i = 0; i < buflen; i++) | ||
256 | if (buf[i] == ':') | ||
257 | return rpc_pton6(buf, buflen, sap, salen); | ||
258 | return rpc_pton4(buf, buflen, sap, salen); | ||
259 | } | ||
260 | EXPORT_SYMBOL_GPL(rpc_pton); | ||
261 | |||
262 | /** | ||
263 | * rpc_sockaddr2uaddr - Construct a universal address string from @sap. | ||
264 | * @sap: socket address | ||
265 | * | ||
266 | * Returns a %NUL-terminated string in dynamically allocated memory; | ||
267 | * otherwise NULL is returned if an error occurred. Caller must | ||
268 | * free the returned string. | ||
269 | */ | ||
270 | char *rpc_sockaddr2uaddr(const struct sockaddr *sap) | ||
271 | { | ||
272 | char portbuf[RPCBIND_MAXUADDRPLEN]; | ||
273 | char addrbuf[RPCBIND_MAXUADDRLEN]; | ||
274 | unsigned short port; | ||
275 | |||
276 | switch (sap->sa_family) { | ||
277 | case AF_INET: | ||
278 | if (rpc_ntop4(sap, addrbuf, sizeof(addrbuf)) == 0) | ||
279 | return NULL; | ||
280 | port = ntohs(((struct sockaddr_in *)sap)->sin_port); | ||
281 | break; | ||
282 | case AF_INET6: | ||
283 | if (rpc_ntop6_noscopeid(sap, addrbuf, sizeof(addrbuf)) == 0) | ||
284 | return NULL; | ||
285 | port = ntohs(((struct sockaddr_in6 *)sap)->sin6_port); | ||
286 | break; | ||
287 | default: | ||
288 | return NULL; | ||
289 | } | ||
290 | |||
291 | if (snprintf(portbuf, sizeof(portbuf), | ||
292 | ".%u.%u", port >> 8, port & 0xff) > (int)sizeof(portbuf)) | ||
293 | return NULL; | ||
294 | |||
295 | if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) > sizeof(addrbuf)) | ||
296 | return NULL; | ||
297 | |||
298 | return kstrdup(addrbuf, GFP_KERNEL); | ||
299 | } | ||
300 | EXPORT_SYMBOL_GPL(rpc_sockaddr2uaddr); | ||
301 | |||
302 | /** | ||
303 | * rpc_uaddr2sockaddr - convert a universal address to a socket address. | ||
304 | * @uaddr: C string containing universal address to convert | ||
305 | * @uaddr_len: length of universal address string | ||
306 | * @sap: buffer into which to plant socket address | ||
307 | * @salen: size of buffer | ||
308 | * | ||
309 | * Returns the size of the socket address if successful; otherwise | ||
310 | * zero is returned. | ||
311 | */ | ||
312 | size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len, | ||
313 | struct sockaddr *sap, const size_t salen) | ||
314 | { | ||
315 | char *c, buf[RPCBIND_MAXUADDRLEN]; | ||
316 | unsigned long portlo, porthi; | ||
317 | unsigned short port; | ||
318 | |||
319 | if (uaddr_len > sizeof(buf)) | ||
320 | return 0; | ||
321 | |||
322 | memcpy(buf, uaddr, uaddr_len); | ||
323 | |||
324 | buf[uaddr_len] = '\n'; | ||
325 | buf[uaddr_len + 1] = '\0'; | ||
326 | |||
327 | c = strrchr(buf, '.'); | ||
328 | if (unlikely(c == NULL)) | ||
329 | return 0; | ||
330 | if (unlikely(strict_strtoul(c + 1, 10, &portlo) != 0)) | ||
331 | return 0; | ||
332 | if (unlikely(portlo > 255)) | ||
333 | return 0; | ||
334 | |||
335 | c[0] = '\n'; | ||
336 | c[1] = '\0'; | ||
337 | |||
338 | c = strrchr(buf, '.'); | ||
339 | if (unlikely(c == NULL)) | ||
340 | return 0; | ||
341 | if (unlikely(strict_strtoul(c + 1, 10, &porthi) != 0)) | ||
342 | return 0; | ||
343 | if (unlikely(porthi > 255)) | ||
344 | return 0; | ||
345 | |||
346 | port = (unsigned short)((porthi << 8) | portlo); | ||
347 | |||
348 | c[0] = '\0'; | ||
349 | |||
350 | if (rpc_pton(buf, strlen(buf), sap, salen) == 0) | ||
351 | return 0; | ||
352 | |||
353 | switch (sap->sa_family) { | ||
354 | case AF_INET: | ||
355 | ((struct sockaddr_in *)sap)->sin_port = htons(port); | ||
356 | return sizeof(struct sockaddr_in); | ||
357 | case AF_INET6: | ||
358 | ((struct sockaddr_in6 *)sap)->sin6_port = htons(port); | ||
359 | return sizeof(struct sockaddr_in6); | ||
360 | } | ||
361 | |||
362 | return 0; | ||
363 | } | ||
364 | EXPORT_SYMBOL_GPL(rpc_uaddr2sockaddr); | ||
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 66d458fc6920..fc6a43ccd950 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -89,8 +89,8 @@ static struct rpc_wait_queue pipe_version_rpc_waitqueue; | |||
89 | static DECLARE_WAIT_QUEUE_HEAD(pipe_version_waitqueue); | 89 | static DECLARE_WAIT_QUEUE_HEAD(pipe_version_waitqueue); |
90 | 90 | ||
91 | static void gss_free_ctx(struct gss_cl_ctx *); | 91 | static void gss_free_ctx(struct gss_cl_ctx *); |
92 | static struct rpc_pipe_ops gss_upcall_ops_v0; | 92 | static const struct rpc_pipe_ops gss_upcall_ops_v0; |
93 | static struct rpc_pipe_ops gss_upcall_ops_v1; | 93 | static const struct rpc_pipe_ops gss_upcall_ops_v1; |
94 | 94 | ||
95 | static inline struct gss_cl_ctx * | 95 | static inline struct gss_cl_ctx * |
96 | gss_get_ctx(struct gss_cl_ctx *ctx) | 96 | gss_get_ctx(struct gss_cl_ctx *ctx) |
@@ -777,7 +777,7 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor) | |||
777 | * that we supported only the old pipe. So we instead create | 777 | * that we supported only the old pipe. So we instead create |
778 | * the new pipe first. | 778 | * the new pipe first. |
779 | */ | 779 | */ |
780 | gss_auth->dentry[1] = rpc_mkpipe(clnt->cl_dentry, | 780 | gss_auth->dentry[1] = rpc_mkpipe(clnt->cl_path.dentry, |
781 | "gssd", | 781 | "gssd", |
782 | clnt, &gss_upcall_ops_v1, | 782 | clnt, &gss_upcall_ops_v1, |
783 | RPC_PIPE_WAIT_FOR_OPEN); | 783 | RPC_PIPE_WAIT_FOR_OPEN); |
@@ -786,7 +786,7 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor) | |||
786 | goto err_put_mech; | 786 | goto err_put_mech; |
787 | } | 787 | } |
788 | 788 | ||
789 | gss_auth->dentry[0] = rpc_mkpipe(clnt->cl_dentry, | 789 | gss_auth->dentry[0] = rpc_mkpipe(clnt->cl_path.dentry, |
790 | gss_auth->mech->gm_name, | 790 | gss_auth->mech->gm_name, |
791 | clnt, &gss_upcall_ops_v0, | 791 | clnt, &gss_upcall_ops_v0, |
792 | RPC_PIPE_WAIT_FOR_OPEN); | 792 | RPC_PIPE_WAIT_FOR_OPEN); |
@@ -1507,7 +1507,7 @@ static const struct rpc_credops gss_nullops = { | |||
1507 | .crunwrap_resp = gss_unwrap_resp, | 1507 | .crunwrap_resp = gss_unwrap_resp, |
1508 | }; | 1508 | }; |
1509 | 1509 | ||
1510 | static struct rpc_pipe_ops gss_upcall_ops_v0 = { | 1510 | static const struct rpc_pipe_ops gss_upcall_ops_v0 = { |
1511 | .upcall = gss_pipe_upcall, | 1511 | .upcall = gss_pipe_upcall, |
1512 | .downcall = gss_pipe_downcall, | 1512 | .downcall = gss_pipe_downcall, |
1513 | .destroy_msg = gss_pipe_destroy_msg, | 1513 | .destroy_msg = gss_pipe_destroy_msg, |
@@ -1515,7 +1515,7 @@ static struct rpc_pipe_ops gss_upcall_ops_v0 = { | |||
1515 | .release_pipe = gss_pipe_release, | 1515 | .release_pipe = gss_pipe_release, |
1516 | }; | 1516 | }; |
1517 | 1517 | ||
1518 | static struct rpc_pipe_ops gss_upcall_ops_v1 = { | 1518 | static const struct rpc_pipe_ops gss_upcall_ops_v1 = { |
1519 | .upcall = gss_pipe_upcall, | 1519 | .upcall = gss_pipe_upcall, |
1520 | .downcall = gss_pipe_downcall, | 1520 | .downcall = gss_pipe_downcall, |
1521 | .destroy_msg = gss_pipe_destroy_msg, | 1521 | .destroy_msg = gss_pipe_destroy_msg, |
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 2278a50c6444..2e6a148d277c 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c | |||
@@ -181,6 +181,11 @@ static void rsi_request(struct cache_detail *cd, | |||
181 | (*bpp)[-1] = '\n'; | 181 | (*bpp)[-1] = '\n'; |
182 | } | 182 | } |
183 | 183 | ||
184 | static int rsi_upcall(struct cache_detail *cd, struct cache_head *h) | ||
185 | { | ||
186 | return sunrpc_cache_pipe_upcall(cd, h, rsi_request); | ||
187 | } | ||
188 | |||
184 | 189 | ||
185 | static int rsi_parse(struct cache_detail *cd, | 190 | static int rsi_parse(struct cache_detail *cd, |
186 | char *mesg, int mlen) | 191 | char *mesg, int mlen) |
@@ -270,7 +275,7 @@ static struct cache_detail rsi_cache = { | |||
270 | .hash_table = rsi_table, | 275 | .hash_table = rsi_table, |
271 | .name = "auth.rpcsec.init", | 276 | .name = "auth.rpcsec.init", |
272 | .cache_put = rsi_put, | 277 | .cache_put = rsi_put, |
273 | .cache_request = rsi_request, | 278 | .cache_upcall = rsi_upcall, |
274 | .cache_parse = rsi_parse, | 279 | .cache_parse = rsi_parse, |
275 | .match = rsi_match, | 280 | .match = rsi_match, |
276 | .init = rsi_init, | 281 | .init = rsi_init, |
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index bbd31f1215e7..ade8a7e99cd3 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
@@ -27,10 +27,12 @@ | |||
27 | #include <linux/net.h> | 27 | #include <linux/net.h> |
28 | #include <linux/workqueue.h> | 28 | #include <linux/workqueue.h> |
29 | #include <linux/mutex.h> | 29 | #include <linux/mutex.h> |
30 | #include <linux/pagemap.h> | ||
30 | #include <asm/ioctls.h> | 31 | #include <asm/ioctls.h> |
31 | #include <linux/sunrpc/types.h> | 32 | #include <linux/sunrpc/types.h> |
32 | #include <linux/sunrpc/cache.h> | 33 | #include <linux/sunrpc/cache.h> |
33 | #include <linux/sunrpc/stats.h> | 34 | #include <linux/sunrpc/stats.h> |
35 | #include <linux/sunrpc/rpc_pipe_fs.h> | ||
34 | 36 | ||
35 | #define RPCDBG_FACILITY RPCDBG_CACHE | 37 | #define RPCDBG_FACILITY RPCDBG_CACHE |
36 | 38 | ||
@@ -175,7 +177,12 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail, | |||
175 | } | 177 | } |
176 | EXPORT_SYMBOL_GPL(sunrpc_cache_update); | 178 | EXPORT_SYMBOL_GPL(sunrpc_cache_update); |
177 | 179 | ||
178 | static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h); | 180 | static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h) |
181 | { | ||
182 | if (!cd->cache_upcall) | ||
183 | return -EINVAL; | ||
184 | return cd->cache_upcall(cd, h); | ||
185 | } | ||
179 | 186 | ||
180 | static inline int cache_is_valid(struct cache_detail *detail, struct cache_head *h) | 187 | static inline int cache_is_valid(struct cache_detail *detail, struct cache_head *h) |
181 | { | 188 | { |
@@ -192,6 +199,7 @@ static inline int cache_is_valid(struct cache_detail *detail, struct cache_head | |||
192 | return 0; | 199 | return 0; |
193 | } | 200 | } |
194 | } | 201 | } |
202 | |||
195 | /* | 203 | /* |
196 | * This is the generic cache management routine for all | 204 | * This is the generic cache management routine for all |
197 | * the authentication caches. | 205 | * the authentication caches. |
@@ -297,76 +305,11 @@ static DEFINE_SPINLOCK(cache_list_lock); | |||
297 | static struct cache_detail *current_detail; | 305 | static struct cache_detail *current_detail; |
298 | static int current_index; | 306 | static int current_index; |
299 | 307 | ||
300 | static const struct file_operations cache_file_operations; | ||
301 | static const struct file_operations content_file_operations; | ||
302 | static const struct file_operations cache_flush_operations; | ||
303 | |||
304 | static void do_cache_clean(struct work_struct *work); | 308 | static void do_cache_clean(struct work_struct *work); |
305 | static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean); | 309 | static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean); |
306 | 310 | ||
307 | static void remove_cache_proc_entries(struct cache_detail *cd) | 311 | static void sunrpc_init_cache_detail(struct cache_detail *cd) |
308 | { | ||
309 | if (cd->proc_ent == NULL) | ||
310 | return; | ||
311 | if (cd->flush_ent) | ||
312 | remove_proc_entry("flush", cd->proc_ent); | ||
313 | if (cd->channel_ent) | ||
314 | remove_proc_entry("channel", cd->proc_ent); | ||
315 | if (cd->content_ent) | ||
316 | remove_proc_entry("content", cd->proc_ent); | ||
317 | cd->proc_ent = NULL; | ||
318 | remove_proc_entry(cd->name, proc_net_rpc); | ||
319 | } | ||
320 | |||
321 | #ifdef CONFIG_PROC_FS | ||
322 | static int create_cache_proc_entries(struct cache_detail *cd) | ||
323 | { | ||
324 | struct proc_dir_entry *p; | ||
325 | |||
326 | cd->proc_ent = proc_mkdir(cd->name, proc_net_rpc); | ||
327 | if (cd->proc_ent == NULL) | ||
328 | goto out_nomem; | ||
329 | cd->channel_ent = cd->content_ent = NULL; | ||
330 | |||
331 | p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR, | ||
332 | cd->proc_ent, &cache_flush_operations, cd); | ||
333 | cd->flush_ent = p; | ||
334 | if (p == NULL) | ||
335 | goto out_nomem; | ||
336 | |||
337 | if (cd->cache_request || cd->cache_parse) { | ||
338 | p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR, | ||
339 | cd->proc_ent, &cache_file_operations, cd); | ||
340 | cd->channel_ent = p; | ||
341 | if (p == NULL) | ||
342 | goto out_nomem; | ||
343 | } | ||
344 | if (cd->cache_show) { | ||
345 | p = proc_create_data("content", S_IFREG|S_IRUSR|S_IWUSR, | ||
346 | cd->proc_ent, &content_file_operations, cd); | ||
347 | cd->content_ent = p; | ||
348 | if (p == NULL) | ||
349 | goto out_nomem; | ||
350 | } | ||
351 | return 0; | ||
352 | out_nomem: | ||
353 | remove_cache_proc_entries(cd); | ||
354 | return -ENOMEM; | ||
355 | } | ||
356 | #else /* CONFIG_PROC_FS */ | ||
357 | static int create_cache_proc_entries(struct cache_detail *cd) | ||
358 | { | ||
359 | return 0; | ||
360 | } | ||
361 | #endif | ||
362 | |||
363 | int cache_register(struct cache_detail *cd) | ||
364 | { | 312 | { |
365 | int ret; | ||
366 | |||
367 | ret = create_cache_proc_entries(cd); | ||
368 | if (ret) | ||
369 | return ret; | ||
370 | rwlock_init(&cd->hash_lock); | 313 | rwlock_init(&cd->hash_lock); |
371 | INIT_LIST_HEAD(&cd->queue); | 314 | INIT_LIST_HEAD(&cd->queue); |
372 | spin_lock(&cache_list_lock); | 315 | spin_lock(&cache_list_lock); |
@@ -380,11 +323,9 @@ int cache_register(struct cache_detail *cd) | |||
380 | 323 | ||
381 | /* start the cleaning process */ | 324 | /* start the cleaning process */ |
382 | schedule_delayed_work(&cache_cleaner, 0); | 325 | schedule_delayed_work(&cache_cleaner, 0); |
383 | return 0; | ||
384 | } | 326 | } |
385 | EXPORT_SYMBOL_GPL(cache_register); | ||
386 | 327 | ||
387 | void cache_unregister(struct cache_detail *cd) | 328 | static void sunrpc_destroy_cache_detail(struct cache_detail *cd) |
388 | { | 329 | { |
389 | cache_purge(cd); | 330 | cache_purge(cd); |
390 | spin_lock(&cache_list_lock); | 331 | spin_lock(&cache_list_lock); |
@@ -399,7 +340,6 @@ void cache_unregister(struct cache_detail *cd) | |||
399 | list_del_init(&cd->others); | 340 | list_del_init(&cd->others); |
400 | write_unlock(&cd->hash_lock); | 341 | write_unlock(&cd->hash_lock); |
401 | spin_unlock(&cache_list_lock); | 342 | spin_unlock(&cache_list_lock); |
402 | remove_cache_proc_entries(cd); | ||
403 | if (list_empty(&cache_list)) { | 343 | if (list_empty(&cache_list)) { |
404 | /* module must be being unloaded so its safe to kill the worker */ | 344 | /* module must be being unloaded so its safe to kill the worker */ |
405 | cancel_delayed_work_sync(&cache_cleaner); | 345 | cancel_delayed_work_sync(&cache_cleaner); |
@@ -408,7 +348,6 @@ void cache_unregister(struct cache_detail *cd) | |||
408 | out: | 348 | out: |
409 | printk(KERN_ERR "nfsd: failed to unregister %s cache\n", cd->name); | 349 | printk(KERN_ERR "nfsd: failed to unregister %s cache\n", cd->name); |
410 | } | 350 | } |
411 | EXPORT_SYMBOL_GPL(cache_unregister); | ||
412 | 351 | ||
413 | /* clean cache tries to find something to clean | 352 | /* clean cache tries to find something to clean |
414 | * and cleans it. | 353 | * and cleans it. |
@@ -703,18 +642,18 @@ struct cache_reader { | |||
703 | int offset; /* if non-0, we have a refcnt on next request */ | 642 | int offset; /* if non-0, we have a refcnt on next request */ |
704 | }; | 643 | }; |
705 | 644 | ||
706 | static ssize_t | 645 | static ssize_t cache_read(struct file *filp, char __user *buf, size_t count, |
707 | cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos) | 646 | loff_t *ppos, struct cache_detail *cd) |
708 | { | 647 | { |
709 | struct cache_reader *rp = filp->private_data; | 648 | struct cache_reader *rp = filp->private_data; |
710 | struct cache_request *rq; | 649 | struct cache_request *rq; |
711 | struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data; | 650 | struct inode *inode = filp->f_path.dentry->d_inode; |
712 | int err; | 651 | int err; |
713 | 652 | ||
714 | if (count == 0) | 653 | if (count == 0) |
715 | return 0; | 654 | return 0; |
716 | 655 | ||
717 | mutex_lock(&queue_io_mutex); /* protect against multiple concurrent | 656 | mutex_lock(&inode->i_mutex); /* protect against multiple concurrent |
718 | * readers on this file */ | 657 | * readers on this file */ |
719 | again: | 658 | again: |
720 | spin_lock(&queue_lock); | 659 | spin_lock(&queue_lock); |
@@ -727,7 +666,7 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos) | |||
727 | } | 666 | } |
728 | if (rp->q.list.next == &cd->queue) { | 667 | if (rp->q.list.next == &cd->queue) { |
729 | spin_unlock(&queue_lock); | 668 | spin_unlock(&queue_lock); |
730 | mutex_unlock(&queue_io_mutex); | 669 | mutex_unlock(&inode->i_mutex); |
731 | BUG_ON(rp->offset); | 670 | BUG_ON(rp->offset); |
732 | return 0; | 671 | return 0; |
733 | } | 672 | } |
@@ -774,49 +713,90 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos) | |||
774 | } | 713 | } |
775 | if (err == -EAGAIN) | 714 | if (err == -EAGAIN) |
776 | goto again; | 715 | goto again; |
777 | mutex_unlock(&queue_io_mutex); | 716 | mutex_unlock(&inode->i_mutex); |
778 | return err ? err : count; | 717 | return err ? err : count; |
779 | } | 718 | } |
780 | 719 | ||
781 | static char write_buf[8192]; /* protected by queue_io_mutex */ | 720 | static ssize_t cache_do_downcall(char *kaddr, const char __user *buf, |
721 | size_t count, struct cache_detail *cd) | ||
722 | { | ||
723 | ssize_t ret; | ||
782 | 724 | ||
783 | static ssize_t | 725 | if (copy_from_user(kaddr, buf, count)) |
784 | cache_write(struct file *filp, const char __user *buf, size_t count, | 726 | return -EFAULT; |
785 | loff_t *ppos) | 727 | kaddr[count] = '\0'; |
728 | ret = cd->cache_parse(cd, kaddr, count); | ||
729 | if (!ret) | ||
730 | ret = count; | ||
731 | return ret; | ||
732 | } | ||
733 | |||
734 | static ssize_t cache_slow_downcall(const char __user *buf, | ||
735 | size_t count, struct cache_detail *cd) | ||
786 | { | 736 | { |
787 | int err; | 737 | static char write_buf[8192]; /* protected by queue_io_mutex */ |
788 | struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data; | 738 | ssize_t ret = -EINVAL; |
789 | 739 | ||
790 | if (count == 0) | ||
791 | return 0; | ||
792 | if (count >= sizeof(write_buf)) | 740 | if (count >= sizeof(write_buf)) |
793 | return -EINVAL; | 741 | goto out; |
794 | |||
795 | mutex_lock(&queue_io_mutex); | 742 | mutex_lock(&queue_io_mutex); |
743 | ret = cache_do_downcall(write_buf, buf, count, cd); | ||
744 | mutex_unlock(&queue_io_mutex); | ||
745 | out: | ||
746 | return ret; | ||
747 | } | ||
796 | 748 | ||
797 | if (copy_from_user(write_buf, buf, count)) { | 749 | static ssize_t cache_downcall(struct address_space *mapping, |
798 | mutex_unlock(&queue_io_mutex); | 750 | const char __user *buf, |
799 | return -EFAULT; | 751 | size_t count, struct cache_detail *cd) |
800 | } | 752 | { |
801 | write_buf[count] = '\0'; | 753 | struct page *page; |
802 | if (cd->cache_parse) | 754 | char *kaddr; |
803 | err = cd->cache_parse(cd, write_buf, count); | 755 | ssize_t ret = -ENOMEM; |
804 | else | 756 | |
805 | err = -EINVAL; | 757 | if (count >= PAGE_CACHE_SIZE) |
758 | goto out_slow; | ||
759 | |||
760 | page = find_or_create_page(mapping, 0, GFP_KERNEL); | ||
761 | if (!page) | ||
762 | goto out_slow; | ||
763 | |||
764 | kaddr = kmap(page); | ||
765 | ret = cache_do_downcall(kaddr, buf, count, cd); | ||
766 | kunmap(page); | ||
767 | unlock_page(page); | ||
768 | page_cache_release(page); | ||
769 | return ret; | ||
770 | out_slow: | ||
771 | return cache_slow_downcall(buf, count, cd); | ||
772 | } | ||
806 | 773 | ||
807 | mutex_unlock(&queue_io_mutex); | 774 | static ssize_t cache_write(struct file *filp, const char __user *buf, |
808 | return err ? err : count; | 775 | size_t count, loff_t *ppos, |
776 | struct cache_detail *cd) | ||
777 | { | ||
778 | struct address_space *mapping = filp->f_mapping; | ||
779 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
780 | ssize_t ret = -EINVAL; | ||
781 | |||
782 | if (!cd->cache_parse) | ||
783 | goto out; | ||
784 | |||
785 | mutex_lock(&inode->i_mutex); | ||
786 | ret = cache_downcall(mapping, buf, count, cd); | ||
787 | mutex_unlock(&inode->i_mutex); | ||
788 | out: | ||
789 | return ret; | ||
809 | } | 790 | } |
810 | 791 | ||
811 | static DECLARE_WAIT_QUEUE_HEAD(queue_wait); | 792 | static DECLARE_WAIT_QUEUE_HEAD(queue_wait); |
812 | 793 | ||
813 | static unsigned int | 794 | static unsigned int cache_poll(struct file *filp, poll_table *wait, |
814 | cache_poll(struct file *filp, poll_table *wait) | 795 | struct cache_detail *cd) |
815 | { | 796 | { |
816 | unsigned int mask; | 797 | unsigned int mask; |
817 | struct cache_reader *rp = filp->private_data; | 798 | struct cache_reader *rp = filp->private_data; |
818 | struct cache_queue *cq; | 799 | struct cache_queue *cq; |
819 | struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data; | ||
820 | 800 | ||
821 | poll_wait(filp, &queue_wait, wait); | 801 | poll_wait(filp, &queue_wait, wait); |
822 | 802 | ||
@@ -838,14 +818,13 @@ cache_poll(struct file *filp, poll_table *wait) | |||
838 | return mask; | 818 | return mask; |
839 | } | 819 | } |
840 | 820 | ||
841 | static int | 821 | static int cache_ioctl(struct inode *ino, struct file *filp, |
842 | cache_ioctl(struct inode *ino, struct file *filp, | 822 | unsigned int cmd, unsigned long arg, |
843 | unsigned int cmd, unsigned long arg) | 823 | struct cache_detail *cd) |
844 | { | 824 | { |
845 | int len = 0; | 825 | int len = 0; |
846 | struct cache_reader *rp = filp->private_data; | 826 | struct cache_reader *rp = filp->private_data; |
847 | struct cache_queue *cq; | 827 | struct cache_queue *cq; |
848 | struct cache_detail *cd = PDE(ino)->data; | ||
849 | 828 | ||
850 | if (cmd != FIONREAD || !rp) | 829 | if (cmd != FIONREAD || !rp) |
851 | return -EINVAL; | 830 | return -EINVAL; |
@@ -868,15 +847,15 @@ cache_ioctl(struct inode *ino, struct file *filp, | |||
868 | return put_user(len, (int __user *)arg); | 847 | return put_user(len, (int __user *)arg); |
869 | } | 848 | } |
870 | 849 | ||
871 | static int | 850 | static int cache_open(struct inode *inode, struct file *filp, |
872 | cache_open(struct inode *inode, struct file *filp) | 851 | struct cache_detail *cd) |
873 | { | 852 | { |
874 | struct cache_reader *rp = NULL; | 853 | struct cache_reader *rp = NULL; |
875 | 854 | ||
855 | if (!cd || !try_module_get(cd->owner)) | ||
856 | return -EACCES; | ||
876 | nonseekable_open(inode, filp); | 857 | nonseekable_open(inode, filp); |
877 | if (filp->f_mode & FMODE_READ) { | 858 | if (filp->f_mode & FMODE_READ) { |
878 | struct cache_detail *cd = PDE(inode)->data; | ||
879 | |||
880 | rp = kmalloc(sizeof(*rp), GFP_KERNEL); | 859 | rp = kmalloc(sizeof(*rp), GFP_KERNEL); |
881 | if (!rp) | 860 | if (!rp) |
882 | return -ENOMEM; | 861 | return -ENOMEM; |
@@ -891,11 +870,10 @@ cache_open(struct inode *inode, struct file *filp) | |||
891 | return 0; | 870 | return 0; |
892 | } | 871 | } |
893 | 872 | ||
894 | static int | 873 | static int cache_release(struct inode *inode, struct file *filp, |
895 | cache_release(struct inode *inode, struct file *filp) | 874 | struct cache_detail *cd) |
896 | { | 875 | { |
897 | struct cache_reader *rp = filp->private_data; | 876 | struct cache_reader *rp = filp->private_data; |
898 | struct cache_detail *cd = PDE(inode)->data; | ||
899 | 877 | ||
900 | if (rp) { | 878 | if (rp) { |
901 | spin_lock(&queue_lock); | 879 | spin_lock(&queue_lock); |
@@ -919,23 +897,12 @@ cache_release(struct inode *inode, struct file *filp) | |||
919 | cd->last_close = get_seconds(); | 897 | cd->last_close = get_seconds(); |
920 | atomic_dec(&cd->readers); | 898 | atomic_dec(&cd->readers); |
921 | } | 899 | } |
900 | module_put(cd->owner); | ||
922 | return 0; | 901 | return 0; |
923 | } | 902 | } |
924 | 903 | ||
925 | 904 | ||
926 | 905 | ||
927 | static const struct file_operations cache_file_operations = { | ||
928 | .owner = THIS_MODULE, | ||
929 | .llseek = no_llseek, | ||
930 | .read = cache_read, | ||
931 | .write = cache_write, | ||
932 | .poll = cache_poll, | ||
933 | .ioctl = cache_ioctl, /* for FIONREAD */ | ||
934 | .open = cache_open, | ||
935 | .release = cache_release, | ||
936 | }; | ||
937 | |||
938 | |||
939 | static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch) | 906 | static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch) |
940 | { | 907 | { |
941 | struct cache_queue *cq; | 908 | struct cache_queue *cq; |
@@ -1036,15 +1003,21 @@ static void warn_no_listener(struct cache_detail *detail) | |||
1036 | if (detail->last_warn != detail->last_close) { | 1003 | if (detail->last_warn != detail->last_close) { |
1037 | detail->last_warn = detail->last_close; | 1004 | detail->last_warn = detail->last_close; |
1038 | if (detail->warn_no_listener) | 1005 | if (detail->warn_no_listener) |
1039 | detail->warn_no_listener(detail); | 1006 | detail->warn_no_listener(detail, detail->last_close != 0); |
1040 | } | 1007 | } |
1041 | } | 1008 | } |
1042 | 1009 | ||
1043 | /* | 1010 | /* |
1044 | * register an upcall request to user-space. | 1011 | * register an upcall request to user-space and queue it up for read() by the |
1012 | * upcall daemon. | ||
1013 | * | ||
1045 | * Each request is at most one page long. | 1014 | * Each request is at most one page long. |
1046 | */ | 1015 | */ |
1047 | static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h) | 1016 | int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h, |
1017 | void (*cache_request)(struct cache_detail *, | ||
1018 | struct cache_head *, | ||
1019 | char **, | ||
1020 | int *)) | ||
1048 | { | 1021 | { |
1049 | 1022 | ||
1050 | char *buf; | 1023 | char *buf; |
@@ -1052,9 +1025,6 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h) | |||
1052 | char *bp; | 1025 | char *bp; |
1053 | int len; | 1026 | int len; |
1054 | 1027 | ||
1055 | if (detail->cache_request == NULL) | ||
1056 | return -EINVAL; | ||
1057 | |||
1058 | if (atomic_read(&detail->readers) == 0 && | 1028 | if (atomic_read(&detail->readers) == 0 && |
1059 | detail->last_close < get_seconds() - 30) { | 1029 | detail->last_close < get_seconds() - 30) { |
1060 | warn_no_listener(detail); | 1030 | warn_no_listener(detail); |
@@ -1073,7 +1043,7 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h) | |||
1073 | 1043 | ||
1074 | bp = buf; len = PAGE_SIZE; | 1044 | bp = buf; len = PAGE_SIZE; |
1075 | 1045 | ||
1076 | detail->cache_request(detail, h, &bp, &len); | 1046 | cache_request(detail, h, &bp, &len); |
1077 | 1047 | ||
1078 | if (len < 0) { | 1048 | if (len < 0) { |
1079 | kfree(buf); | 1049 | kfree(buf); |
@@ -1091,6 +1061,7 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h) | |||
1091 | wake_up(&queue_wait); | 1061 | wake_up(&queue_wait); |
1092 | return 0; | 1062 | return 0; |
1093 | } | 1063 | } |
1064 | EXPORT_SYMBOL_GPL(sunrpc_cache_pipe_upcall); | ||
1094 | 1065 | ||
1095 | /* | 1066 | /* |
1096 | * parse a message from user-space and pass it | 1067 | * parse a message from user-space and pass it |
@@ -1258,11 +1229,13 @@ static const struct seq_operations cache_content_op = { | |||
1258 | .show = c_show, | 1229 | .show = c_show, |
1259 | }; | 1230 | }; |
1260 | 1231 | ||
1261 | static int content_open(struct inode *inode, struct file *file) | 1232 | static int content_open(struct inode *inode, struct file *file, |
1233 | struct cache_detail *cd) | ||
1262 | { | 1234 | { |
1263 | struct handle *han; | 1235 | struct handle *han; |
1264 | struct cache_detail *cd = PDE(inode)->data; | ||
1265 | 1236 | ||
1237 | if (!cd || !try_module_get(cd->owner)) | ||
1238 | return -EACCES; | ||
1266 | han = __seq_open_private(file, &cache_content_op, sizeof(*han)); | 1239 | han = __seq_open_private(file, &cache_content_op, sizeof(*han)); |
1267 | if (han == NULL) | 1240 | if (han == NULL) |
1268 | return -ENOMEM; | 1241 | return -ENOMEM; |
@@ -1271,17 +1244,33 @@ static int content_open(struct inode *inode, struct file *file) | |||
1271 | return 0; | 1244 | return 0; |
1272 | } | 1245 | } |
1273 | 1246 | ||
1274 | static const struct file_operations content_file_operations = { | 1247 | static int content_release(struct inode *inode, struct file *file, |
1275 | .open = content_open, | 1248 | struct cache_detail *cd) |
1276 | .read = seq_read, | 1249 | { |
1277 | .llseek = seq_lseek, | 1250 | int ret = seq_release_private(inode, file); |
1278 | .release = seq_release_private, | 1251 | module_put(cd->owner); |
1279 | }; | 1252 | return ret; |
1253 | } | ||
1254 | |||
1255 | static int open_flush(struct inode *inode, struct file *file, | ||
1256 | struct cache_detail *cd) | ||
1257 | { | ||
1258 | if (!cd || !try_module_get(cd->owner)) | ||
1259 | return -EACCES; | ||
1260 | return nonseekable_open(inode, file); | ||
1261 | } | ||
1262 | |||
1263 | static int release_flush(struct inode *inode, struct file *file, | ||
1264 | struct cache_detail *cd) | ||
1265 | { | ||
1266 | module_put(cd->owner); | ||
1267 | return 0; | ||
1268 | } | ||
1280 | 1269 | ||
1281 | static ssize_t read_flush(struct file *file, char __user *buf, | 1270 | static ssize_t read_flush(struct file *file, char __user *buf, |
1282 | size_t count, loff_t *ppos) | 1271 | size_t count, loff_t *ppos, |
1272 | struct cache_detail *cd) | ||
1283 | { | 1273 | { |
1284 | struct cache_detail *cd = PDE(file->f_path.dentry->d_inode)->data; | ||
1285 | char tbuf[20]; | 1274 | char tbuf[20]; |
1286 | unsigned long p = *ppos; | 1275 | unsigned long p = *ppos; |
1287 | size_t len; | 1276 | size_t len; |
@@ -1299,10 +1288,10 @@ static ssize_t read_flush(struct file *file, char __user *buf, | |||
1299 | return len; | 1288 | return len; |
1300 | } | 1289 | } |
1301 | 1290 | ||
1302 | static ssize_t write_flush(struct file * file, const char __user * buf, | 1291 | static ssize_t write_flush(struct file *file, const char __user *buf, |
1303 | size_t count, loff_t *ppos) | 1292 | size_t count, loff_t *ppos, |
1293 | struct cache_detail *cd) | ||
1304 | { | 1294 | { |
1305 | struct cache_detail *cd = PDE(file->f_path.dentry->d_inode)->data; | ||
1306 | char tbuf[20]; | 1295 | char tbuf[20]; |
1307 | char *ep; | 1296 | char *ep; |
1308 | long flushtime; | 1297 | long flushtime; |
@@ -1323,8 +1312,343 @@ static ssize_t write_flush(struct file * file, const char __user * buf, | |||
1323 | return count; | 1312 | return count; |
1324 | } | 1313 | } |
1325 | 1314 | ||
1326 | static const struct file_operations cache_flush_operations = { | 1315 | static ssize_t cache_read_procfs(struct file *filp, char __user *buf, |
1327 | .open = nonseekable_open, | 1316 | size_t count, loff_t *ppos) |
1328 | .read = read_flush, | 1317 | { |
1329 | .write = write_flush, | 1318 | struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data; |
1319 | |||
1320 | return cache_read(filp, buf, count, ppos, cd); | ||
1321 | } | ||
1322 | |||
1323 | static ssize_t cache_write_procfs(struct file *filp, const char __user *buf, | ||
1324 | size_t count, loff_t *ppos) | ||
1325 | { | ||
1326 | struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data; | ||
1327 | |||
1328 | return cache_write(filp, buf, count, ppos, cd); | ||
1329 | } | ||
1330 | |||
1331 | static unsigned int cache_poll_procfs(struct file *filp, poll_table *wait) | ||
1332 | { | ||
1333 | struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data; | ||
1334 | |||
1335 | return cache_poll(filp, wait, cd); | ||
1336 | } | ||
1337 | |||
1338 | static int cache_ioctl_procfs(struct inode *inode, struct file *filp, | ||
1339 | unsigned int cmd, unsigned long arg) | ||
1340 | { | ||
1341 | struct cache_detail *cd = PDE(inode)->data; | ||
1342 | |||
1343 | return cache_ioctl(inode, filp, cmd, arg, cd); | ||
1344 | } | ||
1345 | |||
1346 | static int cache_open_procfs(struct inode *inode, struct file *filp) | ||
1347 | { | ||
1348 | struct cache_detail *cd = PDE(inode)->data; | ||
1349 | |||
1350 | return cache_open(inode, filp, cd); | ||
1351 | } | ||
1352 | |||
1353 | static int cache_release_procfs(struct inode *inode, struct file *filp) | ||
1354 | { | ||
1355 | struct cache_detail *cd = PDE(inode)->data; | ||
1356 | |||
1357 | return cache_release(inode, filp, cd); | ||
1358 | } | ||
1359 | |||
1360 | static const struct file_operations cache_file_operations_procfs = { | ||
1361 | .owner = THIS_MODULE, | ||
1362 | .llseek = no_llseek, | ||
1363 | .read = cache_read_procfs, | ||
1364 | .write = cache_write_procfs, | ||
1365 | .poll = cache_poll_procfs, | ||
1366 | .ioctl = cache_ioctl_procfs, /* for FIONREAD */ | ||
1367 | .open = cache_open_procfs, | ||
1368 | .release = cache_release_procfs, | ||
1330 | }; | 1369 | }; |
1370 | |||
1371 | static int content_open_procfs(struct inode *inode, struct file *filp) | ||
1372 | { | ||
1373 | struct cache_detail *cd = PDE(inode)->data; | ||
1374 | |||
1375 | return content_open(inode, filp, cd); | ||
1376 | } | ||
1377 | |||
1378 | static int content_release_procfs(struct inode *inode, struct file *filp) | ||
1379 | { | ||
1380 | struct cache_detail *cd = PDE(inode)->data; | ||
1381 | |||
1382 | return content_release(inode, filp, cd); | ||
1383 | } | ||
1384 | |||
1385 | static const struct file_operations content_file_operations_procfs = { | ||
1386 | .open = content_open_procfs, | ||
1387 | .read = seq_read, | ||
1388 | .llseek = seq_lseek, | ||
1389 | .release = content_release_procfs, | ||
1390 | }; | ||
1391 | |||
1392 | static int open_flush_procfs(struct inode *inode, struct file *filp) | ||
1393 | { | ||
1394 | struct cache_detail *cd = PDE(inode)->data; | ||
1395 | |||
1396 | return open_flush(inode, filp, cd); | ||
1397 | } | ||
1398 | |||
1399 | static int release_flush_procfs(struct inode *inode, struct file *filp) | ||
1400 | { | ||
1401 | struct cache_detail *cd = PDE(inode)->data; | ||
1402 | |||
1403 | return release_flush(inode, filp, cd); | ||
1404 | } | ||
1405 | |||
1406 | static ssize_t read_flush_procfs(struct file *filp, char __user *buf, | ||
1407 | size_t count, loff_t *ppos) | ||
1408 | { | ||
1409 | struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data; | ||
1410 | |||
1411 | return read_flush(filp, buf, count, ppos, cd); | ||
1412 | } | ||
1413 | |||
1414 | static ssize_t write_flush_procfs(struct file *filp, | ||
1415 | const char __user *buf, | ||
1416 | size_t count, loff_t *ppos) | ||
1417 | { | ||
1418 | struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data; | ||
1419 | |||
1420 | return write_flush(filp, buf, count, ppos, cd); | ||
1421 | } | ||
1422 | |||
1423 | static const struct file_operations cache_flush_operations_procfs = { | ||
1424 | .open = open_flush_procfs, | ||
1425 | .read = read_flush_procfs, | ||
1426 | .write = write_flush_procfs, | ||
1427 | .release = release_flush_procfs, | ||
1428 | }; | ||
1429 | |||
1430 | static void remove_cache_proc_entries(struct cache_detail *cd) | ||
1431 | { | ||
1432 | if (cd->u.procfs.proc_ent == NULL) | ||
1433 | return; | ||
1434 | if (cd->u.procfs.flush_ent) | ||
1435 | remove_proc_entry("flush", cd->u.procfs.proc_ent); | ||
1436 | if (cd->u.procfs.channel_ent) | ||
1437 | remove_proc_entry("channel", cd->u.procfs.proc_ent); | ||
1438 | if (cd->u.procfs.content_ent) | ||
1439 | remove_proc_entry("content", cd->u.procfs.proc_ent); | ||
1440 | cd->u.procfs.proc_ent = NULL; | ||
1441 | remove_proc_entry(cd->name, proc_net_rpc); | ||
1442 | } | ||
1443 | |||
1444 | #ifdef CONFIG_PROC_FS | ||
1445 | static int create_cache_proc_entries(struct cache_detail *cd) | ||
1446 | { | ||
1447 | struct proc_dir_entry *p; | ||
1448 | |||
1449 | cd->u.procfs.proc_ent = proc_mkdir(cd->name, proc_net_rpc); | ||
1450 | if (cd->u.procfs.proc_ent == NULL) | ||
1451 | goto out_nomem; | ||
1452 | cd->u.procfs.channel_ent = NULL; | ||
1453 | cd->u.procfs.content_ent = NULL; | ||
1454 | |||
1455 | p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR, | ||
1456 | cd->u.procfs.proc_ent, | ||
1457 | &cache_flush_operations_procfs, cd); | ||
1458 | cd->u.procfs.flush_ent = p; | ||
1459 | if (p == NULL) | ||
1460 | goto out_nomem; | ||
1461 | |||
1462 | if (cd->cache_upcall || cd->cache_parse) { | ||
1463 | p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR, | ||
1464 | cd->u.procfs.proc_ent, | ||
1465 | &cache_file_operations_procfs, cd); | ||
1466 | cd->u.procfs.channel_ent = p; | ||
1467 | if (p == NULL) | ||
1468 | goto out_nomem; | ||
1469 | } | ||
1470 | if (cd->cache_show) { | ||
1471 | p = proc_create_data("content", S_IFREG|S_IRUSR|S_IWUSR, | ||
1472 | cd->u.procfs.proc_ent, | ||
1473 | &content_file_operations_procfs, cd); | ||
1474 | cd->u.procfs.content_ent = p; | ||
1475 | if (p == NULL) | ||
1476 | goto out_nomem; | ||
1477 | } | ||
1478 | return 0; | ||
1479 | out_nomem: | ||
1480 | remove_cache_proc_entries(cd); | ||
1481 | return -ENOMEM; | ||
1482 | } | ||
1483 | #else /* CONFIG_PROC_FS */ | ||
1484 | static int create_cache_proc_entries(struct cache_detail *cd) | ||
1485 | { | ||
1486 | return 0; | ||
1487 | } | ||
1488 | #endif | ||
1489 | |||
1490 | int cache_register(struct cache_detail *cd) | ||
1491 | { | ||
1492 | int ret; | ||
1493 | |||
1494 | sunrpc_init_cache_detail(cd); | ||
1495 | ret = create_cache_proc_entries(cd); | ||
1496 | if (ret) | ||
1497 | sunrpc_destroy_cache_detail(cd); | ||
1498 | return ret; | ||
1499 | } | ||
1500 | EXPORT_SYMBOL_GPL(cache_register); | ||
1501 | |||
1502 | void cache_unregister(struct cache_detail *cd) | ||
1503 | { | ||
1504 | remove_cache_proc_entries(cd); | ||
1505 | sunrpc_destroy_cache_detail(cd); | ||
1506 | } | ||
1507 | EXPORT_SYMBOL_GPL(cache_unregister); | ||
1508 | |||
1509 | static ssize_t cache_read_pipefs(struct file *filp, char __user *buf, | ||
1510 | size_t count, loff_t *ppos) | ||
1511 | { | ||
1512 | struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private; | ||
1513 | |||
1514 | return cache_read(filp, buf, count, ppos, cd); | ||
1515 | } | ||
1516 | |||
1517 | static ssize_t cache_write_pipefs(struct file *filp, const char __user *buf, | ||
1518 | size_t count, loff_t *ppos) | ||
1519 | { | ||
1520 | struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private; | ||
1521 | |||
1522 | return cache_write(filp, buf, count, ppos, cd); | ||
1523 | } | ||
1524 | |||
1525 | static unsigned int cache_poll_pipefs(struct file *filp, poll_table *wait) | ||
1526 | { | ||
1527 | struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private; | ||
1528 | |||
1529 | return cache_poll(filp, wait, cd); | ||
1530 | } | ||
1531 | |||
1532 | static int cache_ioctl_pipefs(struct inode *inode, struct file *filp, | ||
1533 | unsigned int cmd, unsigned long arg) | ||
1534 | { | ||
1535 | struct cache_detail *cd = RPC_I(inode)->private; | ||
1536 | |||
1537 | return cache_ioctl(inode, filp, cmd, arg, cd); | ||
1538 | } | ||
1539 | |||
1540 | static int cache_open_pipefs(struct inode *inode, struct file *filp) | ||
1541 | { | ||
1542 | struct cache_detail *cd = RPC_I(inode)->private; | ||
1543 | |||
1544 | return cache_open(inode, filp, cd); | ||
1545 | } | ||
1546 | |||
1547 | static int cache_release_pipefs(struct inode *inode, struct file *filp) | ||
1548 | { | ||
1549 | struct cache_detail *cd = RPC_I(inode)->private; | ||
1550 | |||
1551 | return cache_release(inode, filp, cd); | ||
1552 | } | ||
1553 | |||
1554 | const struct file_operations cache_file_operations_pipefs = { | ||
1555 | .owner = THIS_MODULE, | ||
1556 | .llseek = no_llseek, | ||
1557 | .read = cache_read_pipefs, | ||
1558 | .write = cache_write_pipefs, | ||
1559 | .poll = cache_poll_pipefs, | ||
1560 | .ioctl = cache_ioctl_pipefs, /* for FIONREAD */ | ||
1561 | .open = cache_open_pipefs, | ||
1562 | .release = cache_release_pipefs, | ||
1563 | }; | ||
1564 | |||
1565 | static int content_open_pipefs(struct inode *inode, struct file *filp) | ||
1566 | { | ||
1567 | struct cache_detail *cd = RPC_I(inode)->private; | ||
1568 | |||
1569 | return content_open(inode, filp, cd); | ||
1570 | } | ||
1571 | |||
1572 | static int content_release_pipefs(struct inode *inode, struct file *filp) | ||
1573 | { | ||
1574 | struct cache_detail *cd = RPC_I(inode)->private; | ||
1575 | |||
1576 | return content_release(inode, filp, cd); | ||
1577 | } | ||
1578 | |||
1579 | const struct file_operations content_file_operations_pipefs = { | ||
1580 | .open = content_open_pipefs, | ||
1581 | .read = seq_read, | ||
1582 | .llseek = seq_lseek, | ||
1583 | .release = content_release_pipefs, | ||
1584 | }; | ||
1585 | |||
1586 | static int open_flush_pipefs(struct inode *inode, struct file *filp) | ||
1587 | { | ||
1588 | struct cache_detail *cd = RPC_I(inode)->private; | ||
1589 | |||
1590 | return open_flush(inode, filp, cd); | ||
1591 | } | ||
1592 | |||
1593 | static int release_flush_pipefs(struct inode *inode, struct file *filp) | ||
1594 | { | ||
1595 | struct cache_detail *cd = RPC_I(inode)->private; | ||
1596 | |||
1597 | return release_flush(inode, filp, cd); | ||
1598 | } | ||
1599 | |||
1600 | static ssize_t read_flush_pipefs(struct file *filp, char __user *buf, | ||
1601 | size_t count, loff_t *ppos) | ||
1602 | { | ||
1603 | struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private; | ||
1604 | |||
1605 | return read_flush(filp, buf, count, ppos, cd); | ||
1606 | } | ||
1607 | |||
1608 | static ssize_t write_flush_pipefs(struct file *filp, | ||
1609 | const char __user *buf, | ||
1610 | size_t count, loff_t *ppos) | ||
1611 | { | ||
1612 | struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private; | ||
1613 | |||
1614 | return write_flush(filp, buf, count, ppos, cd); | ||
1615 | } | ||
1616 | |||
1617 | const struct file_operations cache_flush_operations_pipefs = { | ||
1618 | .open = open_flush_pipefs, | ||
1619 | .read = read_flush_pipefs, | ||
1620 | .write = write_flush_pipefs, | ||
1621 | .release = release_flush_pipefs, | ||
1622 | }; | ||
1623 | |||
1624 | int sunrpc_cache_register_pipefs(struct dentry *parent, | ||
1625 | const char *name, mode_t umode, | ||
1626 | struct cache_detail *cd) | ||
1627 | { | ||
1628 | struct qstr q; | ||
1629 | struct dentry *dir; | ||
1630 | int ret = 0; | ||
1631 | |||
1632 | sunrpc_init_cache_detail(cd); | ||
1633 | q.name = name; | ||
1634 | q.len = strlen(name); | ||
1635 | q.hash = full_name_hash(q.name, q.len); | ||
1636 | dir = rpc_create_cache_dir(parent, &q, umode, cd); | ||
1637 | if (!IS_ERR(dir)) | ||
1638 | cd->u.pipefs.dir = dir; | ||
1639 | else { | ||
1640 | sunrpc_destroy_cache_detail(cd); | ||
1641 | ret = PTR_ERR(dir); | ||
1642 | } | ||
1643 | return ret; | ||
1644 | } | ||
1645 | EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); | ||
1646 | |||
1647 | void sunrpc_cache_unregister_pipefs(struct cache_detail *cd) | ||
1648 | { | ||
1649 | rpc_remove_cache_dir(cd->u.pipefs.dir); | ||
1650 | cd->u.pipefs.dir = NULL; | ||
1651 | sunrpc_destroy_cache_detail(cd); | ||
1652 | } | ||
1653 | EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs); | ||
1654 | |||
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 5bc2f45bddf0..c1e467e1b07d 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -27,8 +27,9 @@ | |||
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/kallsyms.h> | 28 | #include <linux/kallsyms.h> |
29 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
30 | #include <linux/namei.h> | ||
31 | #include <linux/mount.h> | ||
30 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
31 | #include <linux/smp_lock.h> | ||
32 | #include <linux/utsname.h> | 33 | #include <linux/utsname.h> |
33 | #include <linux/workqueue.h> | 34 | #include <linux/workqueue.h> |
34 | #include <linux/in6.h> | 35 | #include <linux/in6.h> |
@@ -98,33 +99,49 @@ static int | |||
98 | rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) | 99 | rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) |
99 | { | 100 | { |
100 | static uint32_t clntid; | 101 | static uint32_t clntid; |
102 | struct nameidata nd; | ||
103 | struct path path; | ||
104 | char name[15]; | ||
105 | struct qstr q = { | ||
106 | .name = name, | ||
107 | }; | ||
101 | int error; | 108 | int error; |
102 | 109 | ||
103 | clnt->cl_vfsmnt = ERR_PTR(-ENOENT); | 110 | clnt->cl_path.mnt = ERR_PTR(-ENOENT); |
104 | clnt->cl_dentry = ERR_PTR(-ENOENT); | 111 | clnt->cl_path.dentry = ERR_PTR(-ENOENT); |
105 | if (dir_name == NULL) | 112 | if (dir_name == NULL) |
106 | return 0; | 113 | return 0; |
107 | 114 | ||
108 | clnt->cl_vfsmnt = rpc_get_mount(); | 115 | path.mnt = rpc_get_mount(); |
109 | if (IS_ERR(clnt->cl_vfsmnt)) | 116 | if (IS_ERR(path.mnt)) |
110 | return PTR_ERR(clnt->cl_vfsmnt); | 117 | return PTR_ERR(path.mnt); |
118 | error = vfs_path_lookup(path.mnt->mnt_root, path.mnt, dir_name, 0, &nd); | ||
119 | if (error) | ||
120 | goto err; | ||
111 | 121 | ||
112 | for (;;) { | 122 | for (;;) { |
113 | snprintf(clnt->cl_pathname, sizeof(clnt->cl_pathname), | 123 | q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); |
114 | "%s/clnt%x", dir_name, | 124 | name[sizeof(name) - 1] = '\0'; |
115 | (unsigned int)clntid++); | 125 | q.hash = full_name_hash(q.name, q.len); |
116 | clnt->cl_pathname[sizeof(clnt->cl_pathname) - 1] = '\0'; | 126 | path.dentry = rpc_create_client_dir(nd.path.dentry, &q, clnt); |
117 | clnt->cl_dentry = rpc_mkdir(clnt->cl_pathname, clnt); | 127 | if (!IS_ERR(path.dentry)) |
118 | if (!IS_ERR(clnt->cl_dentry)) | 128 | break; |
119 | return 0; | 129 | error = PTR_ERR(path.dentry); |
120 | error = PTR_ERR(clnt->cl_dentry); | ||
121 | if (error != -EEXIST) { | 130 | if (error != -EEXIST) { |
122 | printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n", | 131 | printk(KERN_INFO "RPC: Couldn't create pipefs entry" |
123 | clnt->cl_pathname, error); | 132 | " %s/%s, error %d\n", |
124 | rpc_put_mount(); | 133 | dir_name, name, error); |
125 | return error; | 134 | goto err_path_put; |
126 | } | 135 | } |
127 | } | 136 | } |
137 | path_put(&nd.path); | ||
138 | clnt->cl_path = path; | ||
139 | return 0; | ||
140 | err_path_put: | ||
141 | path_put(&nd.path); | ||
142 | err: | ||
143 | rpc_put_mount(); | ||
144 | return error; | ||
128 | } | 145 | } |
129 | 146 | ||
130 | static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, struct rpc_xprt *xprt) | 147 | static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, struct rpc_xprt *xprt) |
@@ -232,8 +249,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru | |||
232 | return clnt; | 249 | return clnt; |
233 | 250 | ||
234 | out_no_auth: | 251 | out_no_auth: |
235 | if (!IS_ERR(clnt->cl_dentry)) { | 252 | if (!IS_ERR(clnt->cl_path.dentry)) { |
236 | rpc_rmdir(clnt->cl_dentry); | 253 | rpc_remove_client_dir(clnt->cl_path.dentry); |
237 | rpc_put_mount(); | 254 | rpc_put_mount(); |
238 | } | 255 | } |
239 | out_no_path: | 256 | out_no_path: |
@@ -424,8 +441,8 @@ rpc_free_client(struct kref *kref) | |||
424 | 441 | ||
425 | dprintk("RPC: destroying %s client for %s\n", | 442 | dprintk("RPC: destroying %s client for %s\n", |
426 | clnt->cl_protname, clnt->cl_server); | 443 | clnt->cl_protname, clnt->cl_server); |
427 | if (!IS_ERR(clnt->cl_dentry)) { | 444 | if (!IS_ERR(clnt->cl_path.dentry)) { |
428 | rpc_rmdir(clnt->cl_dentry); | 445 | rpc_remove_client_dir(clnt->cl_path.dentry); |
429 | rpc_put_mount(); | 446 | rpc_put_mount(); |
430 | } | 447 | } |
431 | if (clnt->cl_parent != clnt) { | 448 | if (clnt->cl_parent != clnt) { |
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 9ced0628d69c..7f676bdf70d3 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/sunrpc/clnt.h> | 26 | #include <linux/sunrpc/clnt.h> |
27 | #include <linux/workqueue.h> | 27 | #include <linux/workqueue.h> |
28 | #include <linux/sunrpc/rpc_pipe_fs.h> | 28 | #include <linux/sunrpc/rpc_pipe_fs.h> |
29 | #include <linux/sunrpc/cache.h> | ||
29 | 30 | ||
30 | static struct vfsmount *rpc_mount __read_mostly; | 31 | static struct vfsmount *rpc_mount __read_mostly; |
31 | static int rpc_mount_count; | 32 | static int rpc_mount_count; |
@@ -125,7 +126,7 @@ static void | |||
125 | rpc_close_pipes(struct inode *inode) | 126 | rpc_close_pipes(struct inode *inode) |
126 | { | 127 | { |
127 | struct rpc_inode *rpci = RPC_I(inode); | 128 | struct rpc_inode *rpci = RPC_I(inode); |
128 | struct rpc_pipe_ops *ops; | 129 | const struct rpc_pipe_ops *ops; |
129 | int need_release; | 130 | int need_release; |
130 | 131 | ||
131 | mutex_lock(&inode->i_mutex); | 132 | mutex_lock(&inode->i_mutex); |
@@ -398,66 +399,12 @@ static const struct file_operations rpc_info_operations = { | |||
398 | 399 | ||
399 | 400 | ||
400 | /* | 401 | /* |
401 | * We have a single directory with 1 node in it. | ||
402 | */ | ||
403 | enum { | ||
404 | RPCAUTH_Root = 1, | ||
405 | RPCAUTH_lockd, | ||
406 | RPCAUTH_mount, | ||
407 | RPCAUTH_nfs, | ||
408 | RPCAUTH_portmap, | ||
409 | RPCAUTH_statd, | ||
410 | RPCAUTH_nfsd4_cb, | ||
411 | RPCAUTH_RootEOF | ||
412 | }; | ||
413 | |||
414 | /* | ||
415 | * Description of fs contents. | 402 | * Description of fs contents. |
416 | */ | 403 | */ |
417 | struct rpc_filelist { | 404 | struct rpc_filelist { |
418 | char *name; | 405 | const char *name; |
419 | const struct file_operations *i_fop; | 406 | const struct file_operations *i_fop; |
420 | int mode; | 407 | umode_t mode; |
421 | }; | ||
422 | |||
423 | static struct rpc_filelist files[] = { | ||
424 | [RPCAUTH_lockd] = { | ||
425 | .name = "lockd", | ||
426 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
427 | }, | ||
428 | [RPCAUTH_mount] = { | ||
429 | .name = "mount", | ||
430 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
431 | }, | ||
432 | [RPCAUTH_nfs] = { | ||
433 | .name = "nfs", | ||
434 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
435 | }, | ||
436 | [RPCAUTH_portmap] = { | ||
437 | .name = "portmap", | ||
438 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
439 | }, | ||
440 | [RPCAUTH_statd] = { | ||
441 | .name = "statd", | ||
442 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
443 | }, | ||
444 | [RPCAUTH_nfsd4_cb] = { | ||
445 | .name = "nfsd4_cb", | ||
446 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
447 | }, | ||
448 | }; | ||
449 | |||
450 | enum { | ||
451 | RPCAUTH_info = 2, | ||
452 | RPCAUTH_EOF | ||
453 | }; | ||
454 | |||
455 | static struct rpc_filelist authfiles[] = { | ||
456 | [RPCAUTH_info] = { | ||
457 | .name = "info", | ||
458 | .i_fop = &rpc_info_operations, | ||
459 | .mode = S_IFREG | S_IRUSR, | ||
460 | }, | ||
461 | }; | 408 | }; |
462 | 409 | ||
463 | struct vfsmount *rpc_get_mount(void) | 410 | struct vfsmount *rpc_get_mount(void) |
@@ -469,11 +416,13 @@ struct vfsmount *rpc_get_mount(void) | |||
469 | return ERR_PTR(err); | 416 | return ERR_PTR(err); |
470 | return rpc_mount; | 417 | return rpc_mount; |
471 | } | 418 | } |
419 | EXPORT_SYMBOL_GPL(rpc_get_mount); | ||
472 | 420 | ||
473 | void rpc_put_mount(void) | 421 | void rpc_put_mount(void) |
474 | { | 422 | { |
475 | simple_release_fs(&rpc_mount, &rpc_mount_count); | 423 | simple_release_fs(&rpc_mount, &rpc_mount_count); |
476 | } | 424 | } |
425 | EXPORT_SYMBOL_GPL(rpc_put_mount); | ||
477 | 426 | ||
478 | static int rpc_delete_dentry(struct dentry *dentry) | 427 | static int rpc_delete_dentry(struct dentry *dentry) |
479 | { | 428 | { |
@@ -484,39 +433,8 @@ static const struct dentry_operations rpc_dentry_operations = { | |||
484 | .d_delete = rpc_delete_dentry, | 433 | .d_delete = rpc_delete_dentry, |
485 | }; | 434 | }; |
486 | 435 | ||
487 | static int | ||
488 | rpc_lookup_parent(char *path, struct nameidata *nd) | ||
489 | { | ||
490 | struct vfsmount *mnt; | ||
491 | |||
492 | if (path[0] == '\0') | ||
493 | return -ENOENT; | ||
494 | |||
495 | mnt = rpc_get_mount(); | ||
496 | if (IS_ERR(mnt)) { | ||
497 | printk(KERN_WARNING "%s: %s failed to mount " | ||
498 | "pseudofilesystem \n", __FILE__, __func__); | ||
499 | return PTR_ERR(mnt); | ||
500 | } | ||
501 | |||
502 | if (vfs_path_lookup(mnt->mnt_root, mnt, path, LOOKUP_PARENT, nd)) { | ||
503 | printk(KERN_WARNING "%s: %s failed to find path %s\n", | ||
504 | __FILE__, __func__, path); | ||
505 | rpc_put_mount(); | ||
506 | return -ENOENT; | ||
507 | } | ||
508 | return 0; | ||
509 | } | ||
510 | |||
511 | static void | ||
512 | rpc_release_path(struct nameidata *nd) | ||
513 | { | ||
514 | path_put(&nd->path); | ||
515 | rpc_put_mount(); | ||
516 | } | ||
517 | |||
518 | static struct inode * | 436 | static struct inode * |
519 | rpc_get_inode(struct super_block *sb, int mode) | 437 | rpc_get_inode(struct super_block *sb, umode_t mode) |
520 | { | 438 | { |
521 | struct inode *inode = new_inode(sb); | 439 | struct inode *inode = new_inode(sb); |
522 | if (!inode) | 440 | if (!inode) |
@@ -534,212 +452,274 @@ rpc_get_inode(struct super_block *sb, int mode) | |||
534 | return inode; | 452 | return inode; |
535 | } | 453 | } |
536 | 454 | ||
537 | /* | 455 | static int __rpc_create_common(struct inode *dir, struct dentry *dentry, |
538 | * FIXME: This probably has races. | 456 | umode_t mode, |
539 | */ | 457 | const struct file_operations *i_fop, |
540 | static void rpc_depopulate(struct dentry *parent, | 458 | void *private) |
541 | unsigned long start, unsigned long eof) | ||
542 | { | 459 | { |
543 | struct inode *dir = parent->d_inode; | 460 | struct inode *inode; |
544 | struct list_head *pos, *next; | ||
545 | struct dentry *dentry, *dvec[10]; | ||
546 | int n = 0; | ||
547 | 461 | ||
548 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_CHILD); | 462 | BUG_ON(!d_unhashed(dentry)); |
549 | repeat: | 463 | inode = rpc_get_inode(dir->i_sb, mode); |
550 | spin_lock(&dcache_lock); | 464 | if (!inode) |
551 | list_for_each_safe(pos, next, &parent->d_subdirs) { | 465 | goto out_err; |
552 | dentry = list_entry(pos, struct dentry, d_u.d_child); | 466 | inode->i_ino = iunique(dir->i_sb, 100); |
553 | if (!dentry->d_inode || | 467 | if (i_fop) |
554 | dentry->d_inode->i_ino < start || | 468 | inode->i_fop = i_fop; |
555 | dentry->d_inode->i_ino >= eof) | 469 | if (private) |
556 | continue; | 470 | rpc_inode_setowner(inode, private); |
557 | spin_lock(&dentry->d_lock); | 471 | d_add(dentry, inode); |
558 | if (!d_unhashed(dentry)) { | 472 | return 0; |
559 | dget_locked(dentry); | 473 | out_err: |
560 | __d_drop(dentry); | 474 | printk(KERN_WARNING "%s: %s failed to allocate inode for dentry %s\n", |
561 | spin_unlock(&dentry->d_lock); | 475 | __FILE__, __func__, dentry->d_name.name); |
562 | dvec[n++] = dentry; | 476 | dput(dentry); |
563 | if (n == ARRAY_SIZE(dvec)) | 477 | return -ENOMEM; |
564 | break; | ||
565 | } else | ||
566 | spin_unlock(&dentry->d_lock); | ||
567 | } | ||
568 | spin_unlock(&dcache_lock); | ||
569 | if (n) { | ||
570 | do { | ||
571 | dentry = dvec[--n]; | ||
572 | if (S_ISREG(dentry->d_inode->i_mode)) | ||
573 | simple_unlink(dir, dentry); | ||
574 | else if (S_ISDIR(dentry->d_inode->i_mode)) | ||
575 | simple_rmdir(dir, dentry); | ||
576 | d_delete(dentry); | ||
577 | dput(dentry); | ||
578 | } while (n); | ||
579 | goto repeat; | ||
580 | } | ||
581 | mutex_unlock(&dir->i_mutex); | ||
582 | } | 478 | } |
583 | 479 | ||
584 | static int | 480 | static int __rpc_create(struct inode *dir, struct dentry *dentry, |
585 | rpc_populate(struct dentry *parent, | 481 | umode_t mode, |
586 | struct rpc_filelist *files, | 482 | const struct file_operations *i_fop, |
587 | int start, int eof) | 483 | void *private) |
588 | { | 484 | { |
589 | struct inode *inode, *dir = parent->d_inode; | 485 | int err; |
590 | void *private = RPC_I(dir)->private; | ||
591 | struct dentry *dentry; | ||
592 | int mode, i; | ||
593 | 486 | ||
594 | mutex_lock(&dir->i_mutex); | 487 | err = __rpc_create_common(dir, dentry, S_IFREG | mode, i_fop, private); |
595 | for (i = start; i < eof; i++) { | 488 | if (err) |
596 | dentry = d_alloc_name(parent, files[i].name); | 489 | return err; |
597 | if (!dentry) | 490 | fsnotify_create(dir, dentry); |
598 | goto out_bad; | ||
599 | dentry->d_op = &rpc_dentry_operations; | ||
600 | mode = files[i].mode; | ||
601 | inode = rpc_get_inode(dir->i_sb, mode); | ||
602 | if (!inode) { | ||
603 | dput(dentry); | ||
604 | goto out_bad; | ||
605 | } | ||
606 | inode->i_ino = i; | ||
607 | if (files[i].i_fop) | ||
608 | inode->i_fop = files[i].i_fop; | ||
609 | if (private) | ||
610 | rpc_inode_setowner(inode, private); | ||
611 | if (S_ISDIR(mode)) | ||
612 | inc_nlink(dir); | ||
613 | d_add(dentry, inode); | ||
614 | fsnotify_create(dir, dentry); | ||
615 | } | ||
616 | mutex_unlock(&dir->i_mutex); | ||
617 | return 0; | 491 | return 0; |
618 | out_bad: | ||
619 | mutex_unlock(&dir->i_mutex); | ||
620 | printk(KERN_WARNING "%s: %s failed to populate directory %s\n", | ||
621 | __FILE__, __func__, parent->d_name.name); | ||
622 | return -ENOMEM; | ||
623 | } | 492 | } |
624 | 493 | ||
625 | static int | 494 | static int __rpc_mkdir(struct inode *dir, struct dentry *dentry, |
626 | __rpc_mkdir(struct inode *dir, struct dentry *dentry) | 495 | umode_t mode, |
496 | const struct file_operations *i_fop, | ||
497 | void *private) | ||
627 | { | 498 | { |
628 | struct inode *inode; | 499 | int err; |
629 | 500 | ||
630 | inode = rpc_get_inode(dir->i_sb, S_IFDIR | S_IRUGO | S_IXUGO); | 501 | err = __rpc_create_common(dir, dentry, S_IFDIR | mode, i_fop, private); |
631 | if (!inode) | 502 | if (err) |
632 | goto out_err; | 503 | return err; |
633 | inode->i_ino = iunique(dir->i_sb, 100); | ||
634 | d_instantiate(dentry, inode); | ||
635 | inc_nlink(dir); | 504 | inc_nlink(dir); |
636 | fsnotify_mkdir(dir, dentry); | 505 | fsnotify_mkdir(dir, dentry); |
637 | return 0; | 506 | return 0; |
638 | out_err: | ||
639 | printk(KERN_WARNING "%s: %s failed to allocate inode for dentry %s\n", | ||
640 | __FILE__, __func__, dentry->d_name.name); | ||
641 | return -ENOMEM; | ||
642 | } | 507 | } |
643 | 508 | ||
644 | static int | 509 | static int __rpc_mkpipe(struct inode *dir, struct dentry *dentry, |
645 | __rpc_rmdir(struct inode *dir, struct dentry *dentry) | 510 | umode_t mode, |
511 | const struct file_operations *i_fop, | ||
512 | void *private, | ||
513 | const struct rpc_pipe_ops *ops, | ||
514 | int flags) | ||
646 | { | 515 | { |
647 | int error; | 516 | struct rpc_inode *rpci; |
648 | error = simple_rmdir(dir, dentry); | 517 | int err; |
649 | if (!error) | 518 | |
650 | d_delete(dentry); | 519 | err = __rpc_create_common(dir, dentry, S_IFIFO | mode, i_fop, private); |
651 | return error; | 520 | if (err) |
521 | return err; | ||
522 | rpci = RPC_I(dentry->d_inode); | ||
523 | rpci->nkern_readwriters = 1; | ||
524 | rpci->private = private; | ||
525 | rpci->flags = flags; | ||
526 | rpci->ops = ops; | ||
527 | fsnotify_create(dir, dentry); | ||
528 | return 0; | ||
652 | } | 529 | } |
653 | 530 | ||
654 | static struct dentry * | 531 | static int __rpc_rmdir(struct inode *dir, struct dentry *dentry) |
655 | rpc_lookup_create(struct dentry *parent, const char *name, int len, int exclusive) | 532 | { |
533 | int ret; | ||
534 | |||
535 | dget(dentry); | ||
536 | ret = simple_rmdir(dir, dentry); | ||
537 | d_delete(dentry); | ||
538 | dput(dentry); | ||
539 | return ret; | ||
540 | } | ||
541 | |||
542 | static int __rpc_unlink(struct inode *dir, struct dentry *dentry) | ||
543 | { | ||
544 | int ret; | ||
545 | |||
546 | dget(dentry); | ||
547 | ret = simple_unlink(dir, dentry); | ||
548 | d_delete(dentry); | ||
549 | dput(dentry); | ||
550 | return ret; | ||
551 | } | ||
552 | |||
553 | static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry) | ||
554 | { | ||
555 | struct inode *inode = dentry->d_inode; | ||
556 | struct rpc_inode *rpci = RPC_I(inode); | ||
557 | |||
558 | rpci->nkern_readwriters--; | ||
559 | if (rpci->nkern_readwriters != 0) | ||
560 | return 0; | ||
561 | rpc_close_pipes(inode); | ||
562 | return __rpc_unlink(dir, dentry); | ||
563 | } | ||
564 | |||
565 | static struct dentry *__rpc_lookup_create(struct dentry *parent, | ||
566 | struct qstr *name) | ||
656 | { | 567 | { |
657 | struct inode *dir = parent->d_inode; | ||
658 | struct dentry *dentry; | 568 | struct dentry *dentry; |
659 | 569 | ||
660 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); | 570 | dentry = d_lookup(parent, name); |
661 | dentry = lookup_one_len(name, parent, len); | 571 | if (!dentry) { |
662 | if (IS_ERR(dentry)) | 572 | dentry = d_alloc(parent, name); |
663 | goto out_err; | 573 | if (!dentry) { |
574 | dentry = ERR_PTR(-ENOMEM); | ||
575 | goto out_err; | ||
576 | } | ||
577 | } | ||
664 | if (!dentry->d_inode) | 578 | if (!dentry->d_inode) |
665 | dentry->d_op = &rpc_dentry_operations; | 579 | dentry->d_op = &rpc_dentry_operations; |
666 | else if (exclusive) { | ||
667 | dput(dentry); | ||
668 | dentry = ERR_PTR(-EEXIST); | ||
669 | goto out_err; | ||
670 | } | ||
671 | return dentry; | ||
672 | out_err: | 580 | out_err: |
673 | mutex_unlock(&dir->i_mutex); | ||
674 | return dentry; | 581 | return dentry; |
675 | } | 582 | } |
676 | 583 | ||
677 | static struct dentry * | 584 | static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, |
678 | rpc_lookup_negative(char *path, struct nameidata *nd) | 585 | struct qstr *name) |
679 | { | 586 | { |
680 | struct dentry *dentry; | 587 | struct dentry *dentry; |
681 | int error; | ||
682 | 588 | ||
683 | if ((error = rpc_lookup_parent(path, nd)) != 0) | 589 | dentry = __rpc_lookup_create(parent, name); |
684 | return ERR_PTR(error); | 590 | if (dentry->d_inode == NULL) |
685 | dentry = rpc_lookup_create(nd->path.dentry, nd->last.name, nd->last.len, | 591 | return dentry; |
686 | 1); | 592 | dput(dentry); |
687 | if (IS_ERR(dentry)) | 593 | return ERR_PTR(-EEXIST); |
688 | rpc_release_path(nd); | ||
689 | return dentry; | ||
690 | } | 594 | } |
691 | 595 | ||
692 | /** | 596 | /* |
693 | * rpc_mkdir - Create a new directory in rpc_pipefs | 597 | * FIXME: This probably has races. |
694 | * @path: path from the rpc_pipefs root to the new directory | ||
695 | * @rpc_client: rpc client to associate with this directory | ||
696 | * | ||
697 | * This creates a directory at the given @path associated with | ||
698 | * @rpc_clnt, which will contain a file named "info" with some basic | ||
699 | * information about the client, together with any "pipes" that may | ||
700 | * later be created using rpc_mkpipe(). | ||
701 | */ | 598 | */ |
702 | struct dentry * | 599 | static void __rpc_depopulate(struct dentry *parent, |
703 | rpc_mkdir(char *path, struct rpc_clnt *rpc_client) | 600 | const struct rpc_filelist *files, |
601 | int start, int eof) | ||
704 | { | 602 | { |
705 | struct nameidata nd; | 603 | struct inode *dir = parent->d_inode; |
706 | struct dentry *dentry; | 604 | struct dentry *dentry; |
707 | struct inode *dir; | 605 | struct qstr name; |
606 | int i; | ||
607 | |||
608 | for (i = start; i < eof; i++) { | ||
609 | name.name = files[i].name; | ||
610 | name.len = strlen(files[i].name); | ||
611 | name.hash = full_name_hash(name.name, name.len); | ||
612 | dentry = d_lookup(parent, &name); | ||
613 | |||
614 | if (dentry == NULL) | ||
615 | continue; | ||
616 | if (dentry->d_inode == NULL) | ||
617 | goto next; | ||
618 | switch (dentry->d_inode->i_mode & S_IFMT) { | ||
619 | default: | ||
620 | BUG(); | ||
621 | case S_IFREG: | ||
622 | __rpc_unlink(dir, dentry); | ||
623 | break; | ||
624 | case S_IFDIR: | ||
625 | __rpc_rmdir(dir, dentry); | ||
626 | } | ||
627 | next: | ||
628 | dput(dentry); | ||
629 | } | ||
630 | } | ||
631 | |||
632 | static void rpc_depopulate(struct dentry *parent, | ||
633 | const struct rpc_filelist *files, | ||
634 | int start, int eof) | ||
635 | { | ||
636 | struct inode *dir = parent->d_inode; | ||
637 | |||
638 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_CHILD); | ||
639 | __rpc_depopulate(parent, files, start, eof); | ||
640 | mutex_unlock(&dir->i_mutex); | ||
641 | } | ||
642 | |||
643 | static int rpc_populate(struct dentry *parent, | ||
644 | const struct rpc_filelist *files, | ||
645 | int start, int eof, | ||
646 | void *private) | ||
647 | { | ||
648 | struct inode *dir = parent->d_inode; | ||
649 | struct dentry *dentry; | ||
650 | int i, err; | ||
651 | |||
652 | mutex_lock(&dir->i_mutex); | ||
653 | for (i = start; i < eof; i++) { | ||
654 | struct qstr q; | ||
655 | |||
656 | q.name = files[i].name; | ||
657 | q.len = strlen(files[i].name); | ||
658 | q.hash = full_name_hash(q.name, q.len); | ||
659 | dentry = __rpc_lookup_create_exclusive(parent, &q); | ||
660 | err = PTR_ERR(dentry); | ||
661 | if (IS_ERR(dentry)) | ||
662 | goto out_bad; | ||
663 | switch (files[i].mode & S_IFMT) { | ||
664 | default: | ||
665 | BUG(); | ||
666 | case S_IFREG: | ||
667 | err = __rpc_create(dir, dentry, | ||
668 | files[i].mode, | ||
669 | files[i].i_fop, | ||
670 | private); | ||
671 | break; | ||
672 | case S_IFDIR: | ||
673 | err = __rpc_mkdir(dir, dentry, | ||
674 | files[i].mode, | ||
675 | NULL, | ||
676 | private); | ||
677 | } | ||
678 | if (err != 0) | ||
679 | goto out_bad; | ||
680 | } | ||
681 | mutex_unlock(&dir->i_mutex); | ||
682 | return 0; | ||
683 | out_bad: | ||
684 | __rpc_depopulate(parent, files, start, eof); | ||
685 | mutex_unlock(&dir->i_mutex); | ||
686 | printk(KERN_WARNING "%s: %s failed to populate directory %s\n", | ||
687 | __FILE__, __func__, parent->d_name.name); | ||
688 | return err; | ||
689 | } | ||
690 | |||
691 | static struct dentry *rpc_mkdir_populate(struct dentry *parent, | ||
692 | struct qstr *name, umode_t mode, void *private, | ||
693 | int (*populate)(struct dentry *, void *), void *args_populate) | ||
694 | { | ||
695 | struct dentry *dentry; | ||
696 | struct inode *dir = parent->d_inode; | ||
708 | int error; | 697 | int error; |
709 | 698 | ||
710 | dentry = rpc_lookup_negative(path, &nd); | 699 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
700 | dentry = __rpc_lookup_create_exclusive(parent, name); | ||
711 | if (IS_ERR(dentry)) | 701 | if (IS_ERR(dentry)) |
712 | return dentry; | 702 | goto out; |
713 | dir = nd.path.dentry->d_inode; | 703 | error = __rpc_mkdir(dir, dentry, mode, NULL, private); |
714 | if ((error = __rpc_mkdir(dir, dentry)) != 0) | 704 | if (error != 0) |
715 | goto err_dput; | 705 | goto out_err; |
716 | RPC_I(dentry->d_inode)->private = rpc_client; | 706 | if (populate != NULL) { |
717 | error = rpc_populate(dentry, authfiles, | 707 | error = populate(dentry, args_populate); |
718 | RPCAUTH_info, RPCAUTH_EOF); | 708 | if (error) |
719 | if (error) | 709 | goto err_rmdir; |
720 | goto err_depopulate; | 710 | } |
721 | dget(dentry); | ||
722 | out: | 711 | out: |
723 | mutex_unlock(&dir->i_mutex); | 712 | mutex_unlock(&dir->i_mutex); |
724 | rpc_release_path(&nd); | ||
725 | return dentry; | 713 | return dentry; |
726 | err_depopulate: | 714 | err_rmdir: |
727 | rpc_depopulate(dentry, RPCAUTH_info, RPCAUTH_EOF); | ||
728 | __rpc_rmdir(dir, dentry); | 715 | __rpc_rmdir(dir, dentry); |
729 | err_dput: | 716 | out_err: |
730 | dput(dentry); | ||
731 | printk(KERN_WARNING "%s: %s() failed to create directory %s (errno = %d)\n", | ||
732 | __FILE__, __func__, path, error); | ||
733 | dentry = ERR_PTR(error); | 717 | dentry = ERR_PTR(error); |
734 | goto out; | 718 | goto out; |
735 | } | 719 | } |
736 | 720 | ||
737 | /** | 721 | static int rpc_rmdir_depopulate(struct dentry *dentry, |
738 | * rpc_rmdir - Remove a directory created with rpc_mkdir() | 722 | void (*depopulate)(struct dentry *)) |
739 | * @dentry: directory to remove | ||
740 | */ | ||
741 | int | ||
742 | rpc_rmdir(struct dentry *dentry) | ||
743 | { | 723 | { |
744 | struct dentry *parent; | 724 | struct dentry *parent; |
745 | struct inode *dir; | 725 | struct inode *dir; |
@@ -748,9 +728,9 @@ rpc_rmdir(struct dentry *dentry) | |||
748 | parent = dget_parent(dentry); | 728 | parent = dget_parent(dentry); |
749 | dir = parent->d_inode; | 729 | dir = parent->d_inode; |
750 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); | 730 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
751 | rpc_depopulate(dentry, RPCAUTH_info, RPCAUTH_EOF); | 731 | if (depopulate != NULL) |
732 | depopulate(dentry); | ||
752 | error = __rpc_rmdir(dir, dentry); | 733 | error = __rpc_rmdir(dir, dentry); |
753 | dput(dentry); | ||
754 | mutex_unlock(&dir->i_mutex); | 734 | mutex_unlock(&dir->i_mutex); |
755 | dput(parent); | 735 | dput(parent); |
756 | return error; | 736 | return error; |
@@ -776,50 +756,54 @@ rpc_rmdir(struct dentry *dentry) | |||
776 | * The @private argument passed here will be available to all these methods | 756 | * The @private argument passed here will be available to all these methods |
777 | * from the file pointer, via RPC_I(file->f_dentry->d_inode)->private. | 757 | * from the file pointer, via RPC_I(file->f_dentry->d_inode)->private. |
778 | */ | 758 | */ |
779 | struct dentry * | 759 | struct dentry *rpc_mkpipe(struct dentry *parent, const char *name, |
780 | rpc_mkpipe(struct dentry *parent, const char *name, void *private, struct rpc_pipe_ops *ops, int flags) | 760 | void *private, const struct rpc_pipe_ops *ops, |
761 | int flags) | ||
781 | { | 762 | { |
782 | struct dentry *dentry; | 763 | struct dentry *dentry; |
783 | struct inode *dir, *inode; | 764 | struct inode *dir = parent->d_inode; |
784 | struct rpc_inode *rpci; | 765 | umode_t umode = S_IFIFO | S_IRUSR | S_IWUSR; |
766 | struct qstr q; | ||
767 | int err; | ||
768 | |||
769 | if (ops->upcall == NULL) | ||
770 | umode &= ~S_IRUGO; | ||
771 | if (ops->downcall == NULL) | ||
772 | umode &= ~S_IWUGO; | ||
773 | |||
774 | q.name = name; | ||
775 | q.len = strlen(name); | ||
776 | q.hash = full_name_hash(q.name, q.len), | ||
785 | 777 | ||
786 | dentry = rpc_lookup_create(parent, name, strlen(name), 0); | 778 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
779 | dentry = __rpc_lookup_create(parent, &q); | ||
787 | if (IS_ERR(dentry)) | 780 | if (IS_ERR(dentry)) |
788 | return dentry; | 781 | goto out; |
789 | dir = parent->d_inode; | ||
790 | if (dentry->d_inode) { | 782 | if (dentry->d_inode) { |
791 | rpci = RPC_I(dentry->d_inode); | 783 | struct rpc_inode *rpci = RPC_I(dentry->d_inode); |
792 | if (rpci->private != private || | 784 | if (rpci->private != private || |
793 | rpci->ops != ops || | 785 | rpci->ops != ops || |
794 | rpci->flags != flags) { | 786 | rpci->flags != flags) { |
795 | dput (dentry); | 787 | dput (dentry); |
796 | dentry = ERR_PTR(-EBUSY); | 788 | err = -EBUSY; |
789 | goto out_err; | ||
797 | } | 790 | } |
798 | rpci->nkern_readwriters++; | 791 | rpci->nkern_readwriters++; |
799 | goto out; | 792 | goto out; |
800 | } | 793 | } |
801 | inode = rpc_get_inode(dir->i_sb, S_IFIFO | S_IRUSR | S_IWUSR); | 794 | |
802 | if (!inode) | 795 | err = __rpc_mkpipe(dir, dentry, umode, &rpc_pipe_fops, |
803 | goto err_dput; | 796 | private, ops, flags); |
804 | inode->i_ino = iunique(dir->i_sb, 100); | 797 | if (err) |
805 | inode->i_fop = &rpc_pipe_fops; | 798 | goto out_err; |
806 | d_instantiate(dentry, inode); | ||
807 | rpci = RPC_I(inode); | ||
808 | rpci->private = private; | ||
809 | rpci->flags = flags; | ||
810 | rpci->ops = ops; | ||
811 | rpci->nkern_readwriters = 1; | ||
812 | fsnotify_create(dir, dentry); | ||
813 | dget(dentry); | ||
814 | out: | 799 | out: |
815 | mutex_unlock(&dir->i_mutex); | 800 | mutex_unlock(&dir->i_mutex); |
816 | return dentry; | 801 | return dentry; |
817 | err_dput: | 802 | out_err: |
818 | dput(dentry); | 803 | dentry = ERR_PTR(err); |
819 | dentry = ERR_PTR(-ENOMEM); | ||
820 | printk(KERN_WARNING "%s: %s() failed to create pipe %s/%s (errno = %d)\n", | 804 | printk(KERN_WARNING "%s: %s() failed to create pipe %s/%s (errno = %d)\n", |
821 | __FILE__, __func__, parent->d_name.name, name, | 805 | __FILE__, __func__, parent->d_name.name, name, |
822 | -ENOMEM); | 806 | err); |
823 | goto out; | 807 | goto out; |
824 | } | 808 | } |
825 | EXPORT_SYMBOL_GPL(rpc_mkpipe); | 809 | EXPORT_SYMBOL_GPL(rpc_mkpipe); |
@@ -842,19 +826,107 @@ rpc_unlink(struct dentry *dentry) | |||
842 | parent = dget_parent(dentry); | 826 | parent = dget_parent(dentry); |
843 | dir = parent->d_inode; | 827 | dir = parent->d_inode; |
844 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); | 828 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
845 | if (--RPC_I(dentry->d_inode)->nkern_readwriters == 0) { | 829 | error = __rpc_rmpipe(dir, dentry); |
846 | rpc_close_pipes(dentry->d_inode); | ||
847 | error = simple_unlink(dir, dentry); | ||
848 | if (!error) | ||
849 | d_delete(dentry); | ||
850 | } | ||
851 | dput(dentry); | ||
852 | mutex_unlock(&dir->i_mutex); | 830 | mutex_unlock(&dir->i_mutex); |
853 | dput(parent); | 831 | dput(parent); |
854 | return error; | 832 | return error; |
855 | } | 833 | } |
856 | EXPORT_SYMBOL_GPL(rpc_unlink); | 834 | EXPORT_SYMBOL_GPL(rpc_unlink); |
857 | 835 | ||
836 | enum { | ||
837 | RPCAUTH_info, | ||
838 | RPCAUTH_EOF | ||
839 | }; | ||
840 | |||
841 | static const struct rpc_filelist authfiles[] = { | ||
842 | [RPCAUTH_info] = { | ||
843 | .name = "info", | ||
844 | .i_fop = &rpc_info_operations, | ||
845 | .mode = S_IFREG | S_IRUSR, | ||
846 | }, | ||
847 | }; | ||
848 | |||
849 | static int rpc_clntdir_populate(struct dentry *dentry, void *private) | ||
850 | { | ||
851 | return rpc_populate(dentry, | ||
852 | authfiles, RPCAUTH_info, RPCAUTH_EOF, | ||
853 | private); | ||
854 | } | ||
855 | |||
856 | static void rpc_clntdir_depopulate(struct dentry *dentry) | ||
857 | { | ||
858 | rpc_depopulate(dentry, authfiles, RPCAUTH_info, RPCAUTH_EOF); | ||
859 | } | ||
860 | |||
861 | /** | ||
862 | * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs | ||
863 | * @path: path from the rpc_pipefs root to the new directory | ||
864 | * @rpc_client: rpc client to associate with this directory | ||
865 | * | ||
866 | * This creates a directory at the given @path associated with | ||
867 | * @rpc_clnt, which will contain a file named "info" with some basic | ||
868 | * information about the client, together with any "pipes" that may | ||
869 | * later be created using rpc_mkpipe(). | ||
870 | */ | ||
871 | struct dentry *rpc_create_client_dir(struct dentry *dentry, | ||
872 | struct qstr *name, | ||
873 | struct rpc_clnt *rpc_client) | ||
874 | { | ||
875 | return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, NULL, | ||
876 | rpc_clntdir_populate, rpc_client); | ||
877 | } | ||
878 | |||
879 | /** | ||
880 | * rpc_remove_client_dir - Remove a directory created with rpc_create_client_dir() | ||
881 | * @dentry: directory to remove | ||
882 | */ | ||
883 | int rpc_remove_client_dir(struct dentry *dentry) | ||
884 | { | ||
885 | return rpc_rmdir_depopulate(dentry, rpc_clntdir_depopulate); | ||
886 | } | ||
887 | |||
888 | static const struct rpc_filelist cache_pipefs_files[3] = { | ||
889 | [0] = { | ||
890 | .name = "channel", | ||
891 | .i_fop = &cache_file_operations_pipefs, | ||
892 | .mode = S_IFREG|S_IRUSR|S_IWUSR, | ||
893 | }, | ||
894 | [1] = { | ||
895 | .name = "content", | ||
896 | .i_fop = &content_file_operations_pipefs, | ||
897 | .mode = S_IFREG|S_IRUSR, | ||
898 | }, | ||
899 | [2] = { | ||
900 | .name = "flush", | ||
901 | .i_fop = &cache_flush_operations_pipefs, | ||
902 | .mode = S_IFREG|S_IRUSR|S_IWUSR, | ||
903 | }, | ||
904 | }; | ||
905 | |||
906 | static int rpc_cachedir_populate(struct dentry *dentry, void *private) | ||
907 | { | ||
908 | return rpc_populate(dentry, | ||
909 | cache_pipefs_files, 0, 3, | ||
910 | private); | ||
911 | } | ||
912 | |||
913 | static void rpc_cachedir_depopulate(struct dentry *dentry) | ||
914 | { | ||
915 | rpc_depopulate(dentry, cache_pipefs_files, 0, 3); | ||
916 | } | ||
917 | |||
918 | struct dentry *rpc_create_cache_dir(struct dentry *parent, struct qstr *name, | ||
919 | mode_t umode, struct cache_detail *cd) | ||
920 | { | ||
921 | return rpc_mkdir_populate(parent, name, umode, NULL, | ||
922 | rpc_cachedir_populate, cd); | ||
923 | } | ||
924 | |||
925 | void rpc_remove_cache_dir(struct dentry *dentry) | ||
926 | { | ||
927 | rpc_rmdir_depopulate(dentry, rpc_cachedir_depopulate); | ||
928 | } | ||
929 | |||
858 | /* | 930 | /* |
859 | * populate the filesystem | 931 | * populate the filesystem |
860 | */ | 932 | */ |
@@ -866,6 +938,51 @@ static struct super_operations s_ops = { | |||
866 | 938 | ||
867 | #define RPCAUTH_GSSMAGIC 0x67596969 | 939 | #define RPCAUTH_GSSMAGIC 0x67596969 |
868 | 940 | ||
941 | /* | ||
942 | * We have a single directory with 1 node in it. | ||
943 | */ | ||
944 | enum { | ||
945 | RPCAUTH_lockd, | ||
946 | RPCAUTH_mount, | ||
947 | RPCAUTH_nfs, | ||
948 | RPCAUTH_portmap, | ||
949 | RPCAUTH_statd, | ||
950 | RPCAUTH_nfsd4_cb, | ||
951 | RPCAUTH_cache, | ||
952 | RPCAUTH_RootEOF | ||
953 | }; | ||
954 | |||
955 | static const struct rpc_filelist files[] = { | ||
956 | [RPCAUTH_lockd] = { | ||
957 | .name = "lockd", | ||
958 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
959 | }, | ||
960 | [RPCAUTH_mount] = { | ||
961 | .name = "mount", | ||
962 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
963 | }, | ||
964 | [RPCAUTH_nfs] = { | ||
965 | .name = "nfs", | ||
966 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
967 | }, | ||
968 | [RPCAUTH_portmap] = { | ||
969 | .name = "portmap", | ||
970 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
971 | }, | ||
972 | [RPCAUTH_statd] = { | ||
973 | .name = "statd", | ||
974 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
975 | }, | ||
976 | [RPCAUTH_nfsd4_cb] = { | ||
977 | .name = "nfsd4_cb", | ||
978 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
979 | }, | ||
980 | [RPCAUTH_cache] = { | ||
981 | .name = "cache", | ||
982 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, | ||
983 | }, | ||
984 | }; | ||
985 | |||
869 | static int | 986 | static int |
870 | rpc_fill_super(struct super_block *sb, void *data, int silent) | 987 | rpc_fill_super(struct super_block *sb, void *data, int silent) |
871 | { | 988 | { |
@@ -886,7 +1003,7 @@ rpc_fill_super(struct super_block *sb, void *data, int silent) | |||
886 | iput(inode); | 1003 | iput(inode); |
887 | return -ENOMEM; | 1004 | return -ENOMEM; |
888 | } | 1005 | } |
889 | if (rpc_populate(root, files, RPCAUTH_Root + 1, RPCAUTH_RootEOF)) | 1006 | if (rpc_populate(root, files, RPCAUTH_lockd, RPCAUTH_RootEOF, NULL)) |
890 | goto out; | 1007 | goto out; |
891 | sb->s_root = root; | 1008 | sb->s_root = root; |
892 | return 0; | 1009 | return 0; |
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index beee6da33035..830faf4d9997 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
@@ -75,6 +75,37 @@ enum { | |||
75 | #define RPCB_OWNER_STRING "0" | 75 | #define RPCB_OWNER_STRING "0" |
76 | #define RPCB_MAXOWNERLEN sizeof(RPCB_OWNER_STRING) | 76 | #define RPCB_MAXOWNERLEN sizeof(RPCB_OWNER_STRING) |
77 | 77 | ||
78 | /* | ||
79 | * XDR data type sizes | ||
80 | */ | ||
81 | #define RPCB_program_sz (1) | ||
82 | #define RPCB_version_sz (1) | ||
83 | #define RPCB_protocol_sz (1) | ||
84 | #define RPCB_port_sz (1) | ||
85 | #define RPCB_boolean_sz (1) | ||
86 | |||
87 | #define RPCB_netid_sz (1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN)) | ||
88 | #define RPCB_addr_sz (1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN)) | ||
89 | #define RPCB_ownerstring_sz (1 + XDR_QUADLEN(RPCB_MAXOWNERLEN)) | ||
90 | |||
91 | /* | ||
92 | * XDR argument and result sizes | ||
93 | */ | ||
94 | #define RPCB_mappingargs_sz (RPCB_program_sz + RPCB_version_sz + \ | ||
95 | RPCB_protocol_sz + RPCB_port_sz) | ||
96 | #define RPCB_getaddrargs_sz (RPCB_program_sz + RPCB_version_sz + \ | ||
97 | RPCB_netid_sz + RPCB_addr_sz + \ | ||
98 | RPCB_ownerstring_sz) | ||
99 | |||
100 | #define RPCB_getportres_sz RPCB_port_sz | ||
101 | #define RPCB_setres_sz RPCB_boolean_sz | ||
102 | |||
103 | /* | ||
104 | * Note that RFC 1833 does not put any size restrictions on the | ||
105 | * address string returned by the remote rpcbind database. | ||
106 | */ | ||
107 | #define RPCB_getaddrres_sz RPCB_addr_sz | ||
108 | |||
78 | static void rpcb_getport_done(struct rpc_task *, void *); | 109 | static void rpcb_getport_done(struct rpc_task *, void *); |
79 | static void rpcb_map_release(void *data); | 110 | static void rpcb_map_release(void *data); |
80 | static struct rpc_program rpcb_program; | 111 | static struct rpc_program rpcb_program; |
@@ -122,6 +153,7 @@ static void rpcb_map_release(void *data) | |||
122 | 153 | ||
123 | rpcb_wake_rpcbind_waiters(map->r_xprt, map->r_status); | 154 | rpcb_wake_rpcbind_waiters(map->r_xprt, map->r_status); |
124 | xprt_put(map->r_xprt); | 155 | xprt_put(map->r_xprt); |
156 | kfree(map->r_addr); | ||
125 | kfree(map); | 157 | kfree(map); |
126 | } | 158 | } |
127 | 159 | ||
@@ -268,12 +300,9 @@ static int rpcb_register_inet4(const struct sockaddr *sap, | |||
268 | const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; | 300 | const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; |
269 | struct rpcbind_args *map = msg->rpc_argp; | 301 | struct rpcbind_args *map = msg->rpc_argp; |
270 | unsigned short port = ntohs(sin->sin_port); | 302 | unsigned short port = ntohs(sin->sin_port); |
271 | char buf[32]; | 303 | int result; |
272 | 304 | ||
273 | /* Construct AF_INET universal address */ | 305 | map->r_addr = rpc_sockaddr2uaddr(sap); |
274 | snprintf(buf, sizeof(buf), "%pI4.%u.%u", | ||
275 | &sin->sin_addr.s_addr, port >> 8, port & 0xff); | ||
276 | map->r_addr = buf; | ||
277 | 306 | ||
278 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " | 307 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " |
279 | "local rpcbind\n", (port ? "" : "un"), | 308 | "local rpcbind\n", (port ? "" : "un"), |
@@ -284,7 +313,9 @@ static int rpcb_register_inet4(const struct sockaddr *sap, | |||
284 | if (port) | 313 | if (port) |
285 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; | 314 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; |
286 | 315 | ||
287 | return rpcb_register_call(RPCBVERS_4, msg); | 316 | result = rpcb_register_call(RPCBVERS_4, msg); |
317 | kfree(map->r_addr); | ||
318 | return result; | ||
288 | } | 319 | } |
289 | 320 | ||
290 | /* | 321 | /* |
@@ -296,16 +327,9 @@ static int rpcb_register_inet6(const struct sockaddr *sap, | |||
296 | const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap; | 327 | const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap; |
297 | struct rpcbind_args *map = msg->rpc_argp; | 328 | struct rpcbind_args *map = msg->rpc_argp; |
298 | unsigned short port = ntohs(sin6->sin6_port); | 329 | unsigned short port = ntohs(sin6->sin6_port); |
299 | char buf[64]; | 330 | int result; |
300 | 331 | ||
301 | /* Construct AF_INET6 universal address */ | 332 | map->r_addr = rpc_sockaddr2uaddr(sap); |
302 | if (ipv6_addr_any(&sin6->sin6_addr)) | ||
303 | snprintf(buf, sizeof(buf), "::.%u.%u", | ||
304 | port >> 8, port & 0xff); | ||
305 | else | ||
306 | snprintf(buf, sizeof(buf), "%pI6.%u.%u", | ||
307 | &sin6->sin6_addr, port >> 8, port & 0xff); | ||
308 | map->r_addr = buf; | ||
309 | 333 | ||
310 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " | 334 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " |
311 | "local rpcbind\n", (port ? "" : "un"), | 335 | "local rpcbind\n", (port ? "" : "un"), |
@@ -316,7 +340,9 @@ static int rpcb_register_inet6(const struct sockaddr *sap, | |||
316 | if (port) | 340 | if (port) |
317 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; | 341 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; |
318 | 342 | ||
319 | return rpcb_register_call(RPCBVERS_4, msg); | 343 | result = rpcb_register_call(RPCBVERS_4, msg); |
344 | kfree(map->r_addr); | ||
345 | return result; | ||
320 | } | 346 | } |
321 | 347 | ||
322 | static int rpcb_unregister_all_protofamilies(struct rpc_message *msg) | 348 | static int rpcb_unregister_all_protofamilies(struct rpc_message *msg) |
@@ -428,7 +454,7 @@ int rpcb_getport_sync(struct sockaddr_in *sin, u32 prog, u32 vers, int prot) | |||
428 | struct rpc_message msg = { | 454 | struct rpc_message msg = { |
429 | .rpc_proc = &rpcb_procedures2[RPCBPROC_GETPORT], | 455 | .rpc_proc = &rpcb_procedures2[RPCBPROC_GETPORT], |
430 | .rpc_argp = &map, | 456 | .rpc_argp = &map, |
431 | .rpc_resp = &map.r_port, | 457 | .rpc_resp = &map, |
432 | }; | 458 | }; |
433 | struct rpc_clnt *rpcb_clnt; | 459 | struct rpc_clnt *rpcb_clnt; |
434 | int status; | 460 | int status; |
@@ -458,7 +484,7 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi | |||
458 | struct rpc_message msg = { | 484 | struct rpc_message msg = { |
459 | .rpc_proc = proc, | 485 | .rpc_proc = proc, |
460 | .rpc_argp = map, | 486 | .rpc_argp = map, |
461 | .rpc_resp = &map->r_port, | 487 | .rpc_resp = map, |
462 | }; | 488 | }; |
463 | struct rpc_task_setup task_setup_data = { | 489 | struct rpc_task_setup task_setup_data = { |
464 | .rpc_client = rpcb_clnt, | 490 | .rpc_client = rpcb_clnt, |
@@ -539,6 +565,7 @@ void rpcb_getport_async(struct rpc_task *task) | |||
539 | goto bailout_nofree; | 565 | goto bailout_nofree; |
540 | } | 566 | } |
541 | 567 | ||
568 | /* Parent transport's destination address */ | ||
542 | salen = rpc_peeraddr(clnt, sap, sizeof(addr)); | 569 | salen = rpc_peeraddr(clnt, sap, sizeof(addr)); |
543 | 570 | ||
544 | /* Don't ever use rpcbind v2 for AF_INET6 requests */ | 571 | /* Don't ever use rpcbind v2 for AF_INET6 requests */ |
@@ -589,11 +616,22 @@ void rpcb_getport_async(struct rpc_task *task) | |||
589 | map->r_prot = xprt->prot; | 616 | map->r_prot = xprt->prot; |
590 | map->r_port = 0; | 617 | map->r_port = 0; |
591 | map->r_xprt = xprt_get(xprt); | 618 | map->r_xprt = xprt_get(xprt); |
592 | map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID); | ||
593 | map->r_addr = rpc_peeraddr2str(rpcb_clnt, RPC_DISPLAY_UNIVERSAL_ADDR); | ||
594 | map->r_owner = ""; | ||
595 | map->r_status = -EIO; | 619 | map->r_status = -EIO; |
596 | 620 | ||
621 | switch (bind_version) { | ||
622 | case RPCBVERS_4: | ||
623 | case RPCBVERS_3: | ||
624 | map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID); | ||
625 | map->r_addr = rpc_sockaddr2uaddr(sap); | ||
626 | map->r_owner = ""; | ||
627 | break; | ||
628 | case RPCBVERS_2: | ||
629 | map->r_addr = NULL; | ||
630 | break; | ||
631 | default: | ||
632 | BUG(); | ||
633 | } | ||
634 | |||
597 | child = rpcb_call_async(rpcb_clnt, map, proc); | 635 | child = rpcb_call_async(rpcb_clnt, map, proc); |
598 | rpc_release_client(rpcb_clnt); | 636 | rpc_release_client(rpcb_clnt); |
599 | if (IS_ERR(child)) { | 637 | if (IS_ERR(child)) { |
@@ -656,176 +694,278 @@ static void rpcb_getport_done(struct rpc_task *child, void *data) | |||
656 | * XDR functions for rpcbind | 694 | * XDR functions for rpcbind |
657 | */ | 695 | */ |
658 | 696 | ||
659 | static int rpcb_encode_mapping(struct rpc_rqst *req, __be32 *p, | 697 | static int rpcb_enc_mapping(struct rpc_rqst *req, __be32 *p, |
660 | struct rpcbind_args *rpcb) | 698 | const struct rpcbind_args *rpcb) |
661 | { | 699 | { |
662 | dprintk("RPC: encoding rpcb request (%u, %u, %d, %u)\n", | 700 | struct rpc_task *task = req->rq_task; |
701 | struct xdr_stream xdr; | ||
702 | |||
703 | dprintk("RPC: %5u encoding PMAP_%s call (%u, %u, %d, %u)\n", | ||
704 | task->tk_pid, task->tk_msg.rpc_proc->p_name, | ||
663 | rpcb->r_prog, rpcb->r_vers, rpcb->r_prot, rpcb->r_port); | 705 | rpcb->r_prog, rpcb->r_vers, rpcb->r_prot, rpcb->r_port); |
706 | |||
707 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | ||
708 | |||
709 | p = xdr_reserve_space(&xdr, sizeof(__be32) * RPCB_mappingargs_sz); | ||
710 | if (unlikely(p == NULL)) | ||
711 | return -EIO; | ||
712 | |||
664 | *p++ = htonl(rpcb->r_prog); | 713 | *p++ = htonl(rpcb->r_prog); |
665 | *p++ = htonl(rpcb->r_vers); | 714 | *p++ = htonl(rpcb->r_vers); |
666 | *p++ = htonl(rpcb->r_prot); | 715 | *p++ = htonl(rpcb->r_prot); |
667 | *p++ = htonl(rpcb->r_port); | 716 | *p = htonl(rpcb->r_port); |
668 | 717 | ||
669 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); | ||
670 | return 0; | 718 | return 0; |
671 | } | 719 | } |
672 | 720 | ||
673 | static int rpcb_decode_getport(struct rpc_rqst *req, __be32 *p, | 721 | static int rpcb_dec_getport(struct rpc_rqst *req, __be32 *p, |
674 | unsigned short *portp) | 722 | struct rpcbind_args *rpcb) |
675 | { | 723 | { |
676 | *portp = (unsigned short) ntohl(*p++); | 724 | struct rpc_task *task = req->rq_task; |
677 | dprintk("RPC: rpcb getport result: %u\n", | 725 | struct xdr_stream xdr; |
678 | *portp); | 726 | unsigned long port; |
727 | |||
728 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | ||
729 | |||
730 | rpcb->r_port = 0; | ||
731 | |||
732 | p = xdr_inline_decode(&xdr, sizeof(__be32)); | ||
733 | if (unlikely(p == NULL)) | ||
734 | return -EIO; | ||
735 | |||
736 | port = ntohl(*p); | ||
737 | dprintk("RPC: %5u PMAP_%s result: %lu\n", task->tk_pid, | ||
738 | task->tk_msg.rpc_proc->p_name, port); | ||
739 | if (unlikely(port > USHORT_MAX)) | ||
740 | return -EIO; | ||
741 | |||
742 | rpcb->r_port = port; | ||
679 | return 0; | 743 | return 0; |
680 | } | 744 | } |
681 | 745 | ||
682 | static int rpcb_decode_set(struct rpc_rqst *req, __be32 *p, | 746 | static int rpcb_dec_set(struct rpc_rqst *req, __be32 *p, |
683 | unsigned int *boolp) | 747 | unsigned int *boolp) |
684 | { | 748 | { |
685 | *boolp = (unsigned int) ntohl(*p++); | 749 | struct rpc_task *task = req->rq_task; |
686 | dprintk("RPC: rpcb set/unset call %s\n", | 750 | struct xdr_stream xdr; |
751 | |||
752 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | ||
753 | |||
754 | p = xdr_inline_decode(&xdr, sizeof(__be32)); | ||
755 | if (unlikely(p == NULL)) | ||
756 | return -EIO; | ||
757 | |||
758 | *boolp = 0; | ||
759 | if (*p) | ||
760 | *boolp = 1; | ||
761 | |||
762 | dprintk("RPC: %5u RPCB_%s call %s\n", | ||
763 | task->tk_pid, task->tk_msg.rpc_proc->p_name, | ||
687 | (*boolp ? "succeeded" : "failed")); | 764 | (*boolp ? "succeeded" : "failed")); |
688 | return 0; | 765 | return 0; |
689 | } | 766 | } |
690 | 767 | ||
691 | static int rpcb_encode_getaddr(struct rpc_rqst *req, __be32 *p, | 768 | static int encode_rpcb_string(struct xdr_stream *xdr, const char *string, |
692 | struct rpcbind_args *rpcb) | 769 | const u32 maxstrlen) |
693 | { | 770 | { |
694 | dprintk("RPC: encoding rpcb request (%u, %u, %s)\n", | 771 | u32 len; |
695 | rpcb->r_prog, rpcb->r_vers, rpcb->r_addr); | 772 | __be32 *p; |
696 | *p++ = htonl(rpcb->r_prog); | ||
697 | *p++ = htonl(rpcb->r_vers); | ||
698 | 773 | ||
699 | p = xdr_encode_string(p, rpcb->r_netid); | 774 | if (unlikely(string == NULL)) |
700 | p = xdr_encode_string(p, rpcb->r_addr); | 775 | return -EIO; |
701 | p = xdr_encode_string(p, rpcb->r_owner); | 776 | len = strlen(string); |
777 | if (unlikely(len > maxstrlen)) | ||
778 | return -EIO; | ||
702 | 779 | ||
703 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); | 780 | p = xdr_reserve_space(xdr, sizeof(__be32) + len); |
781 | if (unlikely(p == NULL)) | ||
782 | return -EIO; | ||
783 | xdr_encode_opaque(p, string, len); | ||
704 | 784 | ||
705 | return 0; | 785 | return 0; |
706 | } | 786 | } |
707 | 787 | ||
708 | static int rpcb_decode_getaddr(struct rpc_rqst *req, __be32 *p, | 788 | static int rpcb_enc_getaddr(struct rpc_rqst *req, __be32 *p, |
709 | unsigned short *portp) | 789 | const struct rpcbind_args *rpcb) |
710 | { | 790 | { |
711 | char *addr; | 791 | struct rpc_task *task = req->rq_task; |
712 | u32 addr_len; | 792 | struct xdr_stream xdr; |
713 | int c, i, f, first, val; | ||
714 | 793 | ||
715 | *portp = 0; | 794 | dprintk("RPC: %5u encoding RPCB_%s call (%u, %u, '%s', '%s')\n", |
716 | addr_len = ntohl(*p++); | 795 | task->tk_pid, task->tk_msg.rpc_proc->p_name, |
796 | rpcb->r_prog, rpcb->r_vers, | ||
797 | rpcb->r_netid, rpcb->r_addr); | ||
717 | 798 | ||
718 | if (addr_len == 0) { | 799 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
719 | dprintk("RPC: rpcb_decode_getaddr: " | ||
720 | "service is not registered\n"); | ||
721 | return 0; | ||
722 | } | ||
723 | 800 | ||
724 | /* | 801 | p = xdr_reserve_space(&xdr, |
725 | * Simple sanity check. | 802 | sizeof(__be32) * (RPCB_program_sz + RPCB_version_sz)); |
726 | */ | 803 | if (unlikely(p == NULL)) |
727 | if (addr_len > RPCBIND_MAXUADDRLEN) | 804 | return -EIO; |
728 | goto out_err; | 805 | *p++ = htonl(rpcb->r_prog); |
729 | 806 | *p = htonl(rpcb->r_vers); | |
730 | /* | ||
731 | * Start at the end and walk backwards until the first dot | ||
732 | * is encountered. When the second dot is found, we have | ||
733 | * both parts of the port number. | ||
734 | */ | ||
735 | addr = (char *)p; | ||
736 | val = 0; | ||
737 | first = 1; | ||
738 | f = 1; | ||
739 | for (i = addr_len - 1; i > 0; i--) { | ||
740 | c = addr[i]; | ||
741 | if (c >= '0' && c <= '9') { | ||
742 | val += (c - '0') * f; | ||
743 | f *= 10; | ||
744 | } else if (c == '.') { | ||
745 | if (first) { | ||
746 | *portp = val; | ||
747 | val = first = 0; | ||
748 | f = 1; | ||
749 | } else { | ||
750 | *portp |= (val << 8); | ||
751 | break; | ||
752 | } | ||
753 | } | ||
754 | } | ||
755 | 807 | ||
756 | /* | 808 | if (encode_rpcb_string(&xdr, rpcb->r_netid, RPCBIND_MAXNETIDLEN)) |
757 | * Simple sanity check. If we never saw a dot in the reply, | 809 | return -EIO; |
758 | * then this was probably just garbage. | 810 | if (encode_rpcb_string(&xdr, rpcb->r_addr, RPCBIND_MAXUADDRLEN)) |
759 | */ | 811 | return -EIO; |
760 | if (first) | 812 | if (encode_rpcb_string(&xdr, rpcb->r_owner, RPCB_MAXOWNERLEN)) |
761 | goto out_err; | 813 | return -EIO; |
762 | 814 | ||
763 | dprintk("RPC: rpcb_decode_getaddr port=%u\n", *portp); | ||
764 | return 0; | 815 | return 0; |
765 | |||
766 | out_err: | ||
767 | dprintk("RPC: rpcbind server returned malformed reply\n"); | ||
768 | return -EIO; | ||
769 | } | 816 | } |
770 | 817 | ||
771 | #define RPCB_program_sz (1u) | 818 | static int rpcb_dec_getaddr(struct rpc_rqst *req, __be32 *p, |
772 | #define RPCB_version_sz (1u) | 819 | struct rpcbind_args *rpcb) |
773 | #define RPCB_protocol_sz (1u) | 820 | { |
774 | #define RPCB_port_sz (1u) | 821 | struct sockaddr_storage address; |
775 | #define RPCB_boolean_sz (1u) | 822 | struct sockaddr *sap = (struct sockaddr *)&address; |
823 | struct rpc_task *task = req->rq_task; | ||
824 | struct xdr_stream xdr; | ||
825 | u32 len; | ||
776 | 826 | ||
777 | #define RPCB_netid_sz (1+XDR_QUADLEN(RPCBIND_MAXNETIDLEN)) | 827 | rpcb->r_port = 0; |
778 | #define RPCB_addr_sz (1+XDR_QUADLEN(RPCBIND_MAXUADDRLEN)) | ||
779 | #define RPCB_ownerstring_sz (1+XDR_QUADLEN(RPCB_MAXOWNERLEN)) | ||
780 | 828 | ||
781 | #define RPCB_mappingargs_sz RPCB_program_sz+RPCB_version_sz+ \ | 829 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
782 | RPCB_protocol_sz+RPCB_port_sz | ||
783 | #define RPCB_getaddrargs_sz RPCB_program_sz+RPCB_version_sz+ \ | ||
784 | RPCB_netid_sz+RPCB_addr_sz+ \ | ||
785 | RPCB_ownerstring_sz | ||
786 | 830 | ||
787 | #define RPCB_setres_sz RPCB_boolean_sz | 831 | p = xdr_inline_decode(&xdr, sizeof(__be32)); |
788 | #define RPCB_getportres_sz RPCB_port_sz | 832 | if (unlikely(p == NULL)) |
789 | 833 | goto out_fail; | |
790 | /* | 834 | len = ntohl(*p); |
791 | * Note that RFC 1833 does not put any size restrictions on the | ||
792 | * address string returned by the remote rpcbind database. | ||
793 | */ | ||
794 | #define RPCB_getaddrres_sz RPCB_addr_sz | ||
795 | 835 | ||
796 | #define PROC(proc, argtype, restype) \ | 836 | /* |
797 | [RPCBPROC_##proc] = { \ | 837 | * If the returned universal address is a null string, |
798 | .p_proc = RPCBPROC_##proc, \ | 838 | * the requested RPC service was not registered. |
799 | .p_encode = (kxdrproc_t) rpcb_encode_##argtype, \ | 839 | */ |
800 | .p_decode = (kxdrproc_t) rpcb_decode_##restype, \ | 840 | if (len == 0) { |
801 | .p_arglen = RPCB_##argtype##args_sz, \ | 841 | dprintk("RPC: %5u RPCB reply: program not registered\n", |
802 | .p_replen = RPCB_##restype##res_sz, \ | 842 | task->tk_pid); |
803 | .p_statidx = RPCBPROC_##proc, \ | 843 | return 0; |
804 | .p_timer = 0, \ | ||
805 | .p_name = #proc, \ | ||
806 | } | 844 | } |
807 | 845 | ||
846 | if (unlikely(len > RPCBIND_MAXUADDRLEN)) | ||
847 | goto out_fail; | ||
848 | |||
849 | p = xdr_inline_decode(&xdr, len); | ||
850 | if (unlikely(p == NULL)) | ||
851 | goto out_fail; | ||
852 | dprintk("RPC: %5u RPCB_%s reply: %s\n", task->tk_pid, | ||
853 | task->tk_msg.rpc_proc->p_name, (char *)p); | ||
854 | |||
855 | if (rpc_uaddr2sockaddr((char *)p, len, sap, sizeof(address)) == 0) | ||
856 | goto out_fail; | ||
857 | rpcb->r_port = rpc_get_port(sap); | ||
858 | |||
859 | return 0; | ||
860 | |||
861 | out_fail: | ||
862 | dprintk("RPC: %5u malformed RPCB_%s reply\n", | ||
863 | task->tk_pid, task->tk_msg.rpc_proc->p_name); | ||
864 | return -EIO; | ||
865 | } | ||
866 | |||
808 | /* | 867 | /* |
809 | * Not all rpcbind procedures described in RFC 1833 are implemented | 868 | * Not all rpcbind procedures described in RFC 1833 are implemented |
810 | * since the Linux kernel RPC code requires only these. | 869 | * since the Linux kernel RPC code requires only these. |
811 | */ | 870 | */ |
871 | |||
812 | static struct rpc_procinfo rpcb_procedures2[] = { | 872 | static struct rpc_procinfo rpcb_procedures2[] = { |
813 | PROC(SET, mapping, set), | 873 | [RPCBPROC_SET] = { |
814 | PROC(UNSET, mapping, set), | 874 | .p_proc = RPCBPROC_SET, |
815 | PROC(GETPORT, mapping, getport), | 875 | .p_encode = (kxdrproc_t)rpcb_enc_mapping, |
876 | .p_decode = (kxdrproc_t)rpcb_dec_set, | ||
877 | .p_arglen = RPCB_mappingargs_sz, | ||
878 | .p_replen = RPCB_setres_sz, | ||
879 | .p_statidx = RPCBPROC_SET, | ||
880 | .p_timer = 0, | ||
881 | .p_name = "SET", | ||
882 | }, | ||
883 | [RPCBPROC_UNSET] = { | ||
884 | .p_proc = RPCBPROC_UNSET, | ||
885 | .p_encode = (kxdrproc_t)rpcb_enc_mapping, | ||
886 | .p_decode = (kxdrproc_t)rpcb_dec_set, | ||
887 | .p_arglen = RPCB_mappingargs_sz, | ||
888 | .p_replen = RPCB_setres_sz, | ||
889 | .p_statidx = RPCBPROC_UNSET, | ||
890 | .p_timer = 0, | ||
891 | .p_name = "UNSET", | ||
892 | }, | ||
893 | [RPCBPROC_GETPORT] = { | ||
894 | .p_proc = RPCBPROC_GETPORT, | ||
895 | .p_encode = (kxdrproc_t)rpcb_enc_mapping, | ||
896 | .p_decode = (kxdrproc_t)rpcb_dec_getport, | ||
897 | .p_arglen = RPCB_mappingargs_sz, | ||
898 | .p_replen = RPCB_getportres_sz, | ||
899 | .p_statidx = RPCBPROC_GETPORT, | ||
900 | .p_timer = 0, | ||
901 | .p_name = "GETPORT", | ||
902 | }, | ||
816 | }; | 903 | }; |
817 | 904 | ||
818 | static struct rpc_procinfo rpcb_procedures3[] = { | 905 | static struct rpc_procinfo rpcb_procedures3[] = { |
819 | PROC(SET, getaddr, set), | 906 | [RPCBPROC_SET] = { |
820 | PROC(UNSET, getaddr, set), | 907 | .p_proc = RPCBPROC_SET, |
821 | PROC(GETADDR, getaddr, getaddr), | 908 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, |
909 | .p_decode = (kxdrproc_t)rpcb_dec_set, | ||
910 | .p_arglen = RPCB_getaddrargs_sz, | ||
911 | .p_replen = RPCB_setres_sz, | ||
912 | .p_statidx = RPCBPROC_SET, | ||
913 | .p_timer = 0, | ||
914 | .p_name = "SET", | ||
915 | }, | ||
916 | [RPCBPROC_UNSET] = { | ||
917 | .p_proc = RPCBPROC_UNSET, | ||
918 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, | ||
919 | .p_decode = (kxdrproc_t)rpcb_dec_set, | ||
920 | .p_arglen = RPCB_getaddrargs_sz, | ||
921 | .p_replen = RPCB_setres_sz, | ||
922 | .p_statidx = RPCBPROC_UNSET, | ||
923 | .p_timer = 0, | ||
924 | .p_name = "UNSET", | ||
925 | }, | ||
926 | [RPCBPROC_GETADDR] = { | ||
927 | .p_proc = RPCBPROC_GETADDR, | ||
928 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, | ||
929 | .p_decode = (kxdrproc_t)rpcb_dec_getaddr, | ||
930 | .p_arglen = RPCB_getaddrargs_sz, | ||
931 | .p_replen = RPCB_getaddrres_sz, | ||
932 | .p_statidx = RPCBPROC_GETADDR, | ||
933 | .p_timer = 0, | ||
934 | .p_name = "GETADDR", | ||
935 | }, | ||
822 | }; | 936 | }; |
823 | 937 | ||
824 | static struct rpc_procinfo rpcb_procedures4[] = { | 938 | static struct rpc_procinfo rpcb_procedures4[] = { |
825 | PROC(SET, getaddr, set), | 939 | [RPCBPROC_SET] = { |
826 | PROC(UNSET, getaddr, set), | 940 | .p_proc = RPCBPROC_SET, |
827 | PROC(GETADDR, getaddr, getaddr), | 941 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, |
828 | PROC(GETVERSADDR, getaddr, getaddr), | 942 | .p_decode = (kxdrproc_t)rpcb_dec_set, |
943 | .p_arglen = RPCB_getaddrargs_sz, | ||
944 | .p_replen = RPCB_setres_sz, | ||
945 | .p_statidx = RPCBPROC_SET, | ||
946 | .p_timer = 0, | ||
947 | .p_name = "SET", | ||
948 | }, | ||
949 | [RPCBPROC_UNSET] = { | ||
950 | .p_proc = RPCBPROC_UNSET, | ||
951 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, | ||
952 | .p_decode = (kxdrproc_t)rpcb_dec_set, | ||
953 | .p_arglen = RPCB_getaddrargs_sz, | ||
954 | .p_replen = RPCB_setres_sz, | ||
955 | .p_statidx = RPCBPROC_UNSET, | ||
956 | .p_timer = 0, | ||
957 | .p_name = "UNSET", | ||
958 | }, | ||
959 | [RPCBPROC_GETADDR] = { | ||
960 | .p_proc = RPCBPROC_GETADDR, | ||
961 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, | ||
962 | .p_decode = (kxdrproc_t)rpcb_dec_getaddr, | ||
963 | .p_arglen = RPCB_getaddrargs_sz, | ||
964 | .p_replen = RPCB_getaddrres_sz, | ||
965 | .p_statidx = RPCBPROC_GETADDR, | ||
966 | .p_timer = 0, | ||
967 | .p_name = "GETADDR", | ||
968 | }, | ||
829 | }; | 969 | }; |
830 | 970 | ||
831 | static struct rpcb_info rpcb_next_version[] = { | 971 | static struct rpcb_info rpcb_next_version[] = { |
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 1102ce1251f7..8f459abe97cf 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/mempool.h> | 17 | #include <linux/mempool.h> |
18 | #include <linux/smp.h> | 18 | #include <linux/smp.h> |
19 | #include <linux/smp_lock.h> | ||
20 | #include <linux/spinlock.h> | 19 | #include <linux/spinlock.h> |
21 | #include <linux/mutex.h> | 20 | #include <linux/mutex.h> |
22 | 21 | ||
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index 843629f55763..8cce92189019 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c | |||
@@ -66,7 +66,8 @@ cleanup_sunrpc(void) | |||
66 | #ifdef CONFIG_PROC_FS | 66 | #ifdef CONFIG_PROC_FS |
67 | rpc_proc_exit(); | 67 | rpc_proc_exit(); |
68 | #endif | 68 | #endif |
69 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ | ||
69 | } | 70 | } |
70 | MODULE_LICENSE("GPL"); | 71 | MODULE_LICENSE("GPL"); |
71 | module_init(init_sunrpc); | 72 | fs_initcall(init_sunrpc); /* Ensure we're initialised before nfs */ |
72 | module_exit(cleanup_sunrpc); | 73 | module_exit(cleanup_sunrpc); |
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 6f33d33cc064..27d44332f017 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c | |||
@@ -5,6 +5,7 @@ | |||
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
8 | #include <linux/smp_lock.h> | ||
8 | #include <linux/errno.h> | 9 | #include <linux/errno.h> |
9 | #include <linux/freezer.h> | 10 | #include <linux/freezer.h> |
10 | #include <linux/kthread.h> | 11 | #include <linux/kthread.h> |
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 799ff6ef28b8..117f68a8aa40 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c | |||
@@ -171,6 +171,11 @@ static void ip_map_request(struct cache_detail *cd, | |||
171 | (*bpp)[-1] = '\n'; | 171 | (*bpp)[-1] = '\n'; |
172 | } | 172 | } |
173 | 173 | ||
174 | static int ip_map_upcall(struct cache_detail *cd, struct cache_head *h) | ||
175 | { | ||
176 | return sunrpc_cache_pipe_upcall(cd, h, ip_map_request); | ||
177 | } | ||
178 | |||
174 | static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr); | 179 | static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr); |
175 | static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t expiry); | 180 | static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t expiry); |
176 | 181 | ||
@@ -289,7 +294,7 @@ struct cache_detail ip_map_cache = { | |||
289 | .hash_table = ip_table, | 294 | .hash_table = ip_table, |
290 | .name = "auth.unix.ip", | 295 | .name = "auth.unix.ip", |
291 | .cache_put = ip_map_put, | 296 | .cache_put = ip_map_put, |
292 | .cache_request = ip_map_request, | 297 | .cache_upcall = ip_map_upcall, |
293 | .cache_parse = ip_map_parse, | 298 | .cache_parse = ip_map_parse, |
294 | .cache_show = ip_map_show, | 299 | .cache_show = ip_map_show, |
295 | .match = ip_map_match, | 300 | .match = ip_map_match, |
@@ -523,6 +528,11 @@ static void unix_gid_request(struct cache_detail *cd, | |||
523 | (*bpp)[-1] = '\n'; | 528 | (*bpp)[-1] = '\n'; |
524 | } | 529 | } |
525 | 530 | ||
531 | static int unix_gid_upcall(struct cache_detail *cd, struct cache_head *h) | ||
532 | { | ||
533 | return sunrpc_cache_pipe_upcall(cd, h, unix_gid_request); | ||
534 | } | ||
535 | |||
526 | static struct unix_gid *unix_gid_lookup(uid_t uid); | 536 | static struct unix_gid *unix_gid_lookup(uid_t uid); |
527 | extern struct cache_detail unix_gid_cache; | 537 | extern struct cache_detail unix_gid_cache; |
528 | 538 | ||
@@ -622,7 +632,7 @@ struct cache_detail unix_gid_cache = { | |||
622 | .hash_table = gid_table, | 632 | .hash_table = gid_table, |
623 | .name = "auth.unix.gid", | 633 | .name = "auth.unix.gid", |
624 | .cache_put = unix_gid_put, | 634 | .cache_put = unix_gid_put, |
625 | .cache_request = unix_gid_request, | 635 | .cache_upcall = unix_gid_upcall, |
626 | .cache_parse = unix_gid_parse, | 636 | .cache_parse = unix_gid_parse, |
627 | .cache_show = unix_gid_show, | 637 | .cache_show = unix_gid_show, |
628 | .match = unix_gid_match, | 638 | .match = unix_gid_match, |
diff --git a/net/sunrpc/timer.c b/net/sunrpc/timer.c index 31becbf09263..dd824341c349 100644 --- a/net/sunrpc/timer.c +++ b/net/sunrpc/timer.c | |||
@@ -25,8 +25,13 @@ | |||
25 | #define RPC_RTO_INIT (HZ/5) | 25 | #define RPC_RTO_INIT (HZ/5) |
26 | #define RPC_RTO_MIN (HZ/10) | 26 | #define RPC_RTO_MIN (HZ/10) |
27 | 27 | ||
28 | void | 28 | /** |
29 | rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo) | 29 | * rpc_init_rtt - Initialize an RPC RTT estimator context |
30 | * @rt: context to initialize | ||
31 | * @timeo: initial timeout value, in jiffies | ||
32 | * | ||
33 | */ | ||
34 | void rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo) | ||
30 | { | 35 | { |
31 | unsigned long init = 0; | 36 | unsigned long init = 0; |
32 | unsigned i; | 37 | unsigned i; |
@@ -43,12 +48,16 @@ rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo) | |||
43 | } | 48 | } |
44 | EXPORT_SYMBOL_GPL(rpc_init_rtt); | 49 | EXPORT_SYMBOL_GPL(rpc_init_rtt); |
45 | 50 | ||
46 | /* | 51 | /** |
52 | * rpc_update_rtt - Update an RPC RTT estimator context | ||
53 | * @rt: context to update | ||
54 | * @timer: timer array index (request type) | ||
55 | * @m: recent actual RTT, in jiffies | ||
56 | * | ||
47 | * NB: When computing the smoothed RTT and standard deviation, | 57 | * NB: When computing the smoothed RTT and standard deviation, |
48 | * be careful not to produce negative intermediate results. | 58 | * be careful not to produce negative intermediate results. |
49 | */ | 59 | */ |
50 | void | 60 | void rpc_update_rtt(struct rpc_rtt *rt, unsigned timer, long m) |
51 | rpc_update_rtt(struct rpc_rtt *rt, unsigned timer, long m) | ||
52 | { | 61 | { |
53 | long *srtt, *sdrtt; | 62 | long *srtt, *sdrtt; |
54 | 63 | ||
@@ -79,21 +88,25 @@ rpc_update_rtt(struct rpc_rtt *rt, unsigned timer, long m) | |||
79 | } | 88 | } |
80 | EXPORT_SYMBOL_GPL(rpc_update_rtt); | 89 | EXPORT_SYMBOL_GPL(rpc_update_rtt); |
81 | 90 | ||
82 | /* | 91 | /** |
83 | * Estimate rto for an nfs rpc sent via. an unreliable datagram. | 92 | * rpc_calc_rto - Provide an estimated timeout value |
84 | * Use the mean and mean deviation of rtt for the appropriate type of rpc | 93 | * @rt: context to use for calculation |
85 | * for the frequent rpcs and a default for the others. | 94 | * @timer: timer array index (request type) |
86 | * The justification for doing "other" this way is that these rpcs | 95 | * |
87 | * happen so infrequently that timer est. would probably be stale. | 96 | * Estimate RTO for an NFS RPC sent via an unreliable datagram. Use |
88 | * Also, since many of these rpcs are | 97 | * the mean and mean deviation of RTT for the appropriate type of RPC |
89 | * non-idempotent, a conservative timeout is desired. | 98 | * for frequently issued RPCs, and a fixed default for the others. |
99 | * | ||
100 | * The justification for doing "other" this way is that these RPCs | ||
101 | * happen so infrequently that timer estimation would probably be | ||
102 | * stale. Also, since many of these RPCs are non-idempotent, a | ||
103 | * conservative timeout is desired. | ||
104 | * | ||
90 | * getattr, lookup, | 105 | * getattr, lookup, |
91 | * read, write, commit - A+4D | 106 | * read, write, commit - A+4D |
92 | * other - timeo | 107 | * other - timeo |
93 | */ | 108 | */ |
94 | 109 | unsigned long rpc_calc_rto(struct rpc_rtt *rt, unsigned timer) | |
95 | unsigned long | ||
96 | rpc_calc_rto(struct rpc_rtt *rt, unsigned timer) | ||
97 | { | 110 | { |
98 | unsigned long res; | 111 | unsigned long res; |
99 | 112 | ||
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 406e26de584e..8bd690c48b69 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c | |||
@@ -24,7 +24,7 @@ xdr_encode_netobj(__be32 *p, const struct xdr_netobj *obj) | |||
24 | unsigned int quadlen = XDR_QUADLEN(obj->len); | 24 | unsigned int quadlen = XDR_QUADLEN(obj->len); |
25 | 25 | ||
26 | p[quadlen] = 0; /* zero trailing bytes */ | 26 | p[quadlen] = 0; /* zero trailing bytes */ |
27 | *p++ = htonl(obj->len); | 27 | *p++ = cpu_to_be32(obj->len); |
28 | memcpy(p, obj->data, obj->len); | 28 | memcpy(p, obj->data, obj->len); |
29 | return p + XDR_QUADLEN(obj->len); | 29 | return p + XDR_QUADLEN(obj->len); |
30 | } | 30 | } |
@@ -35,7 +35,7 @@ xdr_decode_netobj(__be32 *p, struct xdr_netobj *obj) | |||
35 | { | 35 | { |
36 | unsigned int len; | 36 | unsigned int len; |
37 | 37 | ||
38 | if ((len = ntohl(*p++)) > XDR_MAX_NETOBJ) | 38 | if ((len = be32_to_cpu(*p++)) > XDR_MAX_NETOBJ) |
39 | return NULL; | 39 | return NULL; |
40 | obj->len = len; | 40 | obj->len = len; |
41 | obj->data = (u8 *) p; | 41 | obj->data = (u8 *) p; |
@@ -83,7 +83,7 @@ EXPORT_SYMBOL_GPL(xdr_encode_opaque_fixed); | |||
83 | */ | 83 | */ |
84 | __be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int nbytes) | 84 | __be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int nbytes) |
85 | { | 85 | { |
86 | *p++ = htonl(nbytes); | 86 | *p++ = cpu_to_be32(nbytes); |
87 | return xdr_encode_opaque_fixed(p, ptr, nbytes); | 87 | return xdr_encode_opaque_fixed(p, ptr, nbytes); |
88 | } | 88 | } |
89 | EXPORT_SYMBOL_GPL(xdr_encode_opaque); | 89 | EXPORT_SYMBOL_GPL(xdr_encode_opaque); |
@@ -101,7 +101,7 @@ xdr_decode_string_inplace(__be32 *p, char **sp, | |||
101 | { | 101 | { |
102 | u32 len; | 102 | u32 len; |
103 | 103 | ||
104 | len = ntohl(*p++); | 104 | len = be32_to_cpu(*p++); |
105 | if (len > maxlen) | 105 | if (len > maxlen) |
106 | return NULL; | 106 | return NULL; |
107 | *lenp = len; | 107 | *lenp = len; |
@@ -771,7 +771,7 @@ xdr_decode_word(struct xdr_buf *buf, unsigned int base, u32 *obj) | |||
771 | status = read_bytes_from_xdr_buf(buf, base, &raw, sizeof(*obj)); | 771 | status = read_bytes_from_xdr_buf(buf, base, &raw, sizeof(*obj)); |
772 | if (status) | 772 | if (status) |
773 | return status; | 773 | return status; |
774 | *obj = ntohl(raw); | 774 | *obj = be32_to_cpu(raw); |
775 | return 0; | 775 | return 0; |
776 | } | 776 | } |
777 | EXPORT_SYMBOL_GPL(xdr_decode_word); | 777 | EXPORT_SYMBOL_GPL(xdr_decode_word); |
@@ -779,7 +779,7 @@ EXPORT_SYMBOL_GPL(xdr_decode_word); | |||
779 | int | 779 | int |
780 | xdr_encode_word(struct xdr_buf *buf, unsigned int base, u32 obj) | 780 | xdr_encode_word(struct xdr_buf *buf, unsigned int base, u32 obj) |
781 | { | 781 | { |
782 | __be32 raw = htonl(obj); | 782 | __be32 raw = cpu_to_be32(obj); |
783 | 783 | ||
784 | return write_bytes_to_xdr_buf(buf, base, &raw, sizeof(obj)); | 784 | return write_bytes_to_xdr_buf(buf, base, &raw, sizeof(obj)); |
785 | } | 785 | } |
diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c index 1dd6123070e9..9a63f669ece4 100644 --- a/net/sunrpc/xprtrdma/transport.c +++ b/net/sunrpc/xprtrdma/transport.c | |||
@@ -168,47 +168,25 @@ static struct rpc_xprt_ops xprt_rdma_procs; /* forward reference */ | |||
168 | static void | 168 | static void |
169 | xprt_rdma_format_addresses(struct rpc_xprt *xprt) | 169 | xprt_rdma_format_addresses(struct rpc_xprt *xprt) |
170 | { | 170 | { |
171 | struct sockaddr_in *addr = (struct sockaddr_in *) | 171 | struct sockaddr *sap = (struct sockaddr *) |
172 | &rpcx_to_rdmad(xprt).addr; | 172 | &rpcx_to_rdmad(xprt).addr; |
173 | char *buf; | 173 | struct sockaddr_in *sin = (struct sockaddr_in *)sap; |
174 | char buf[64]; | ||
174 | 175 | ||
175 | buf = kzalloc(20, GFP_KERNEL); | 176 | (void)rpc_ntop(sap, buf, sizeof(buf)); |
176 | if (buf) | 177 | xprt->address_strings[RPC_DISPLAY_ADDR] = kstrdup(buf, GFP_KERNEL); |
177 | snprintf(buf, 20, "%pI4", &addr->sin_addr.s_addr); | ||
178 | xprt->address_strings[RPC_DISPLAY_ADDR] = buf; | ||
179 | 178 | ||
180 | buf = kzalloc(8, GFP_KERNEL); | 179 | (void)snprintf(buf, sizeof(buf), "%u", rpc_get_port(sap)); |
181 | if (buf) | 180 | xprt->address_strings[RPC_DISPLAY_PORT] = kstrdup(buf, GFP_KERNEL); |
182 | snprintf(buf, 8, "%u", ntohs(addr->sin_port)); | ||
183 | xprt->address_strings[RPC_DISPLAY_PORT] = buf; | ||
184 | 181 | ||
185 | xprt->address_strings[RPC_DISPLAY_PROTO] = "rdma"; | 182 | xprt->address_strings[RPC_DISPLAY_PROTO] = "rdma"; |
186 | 183 | ||
187 | buf = kzalloc(48, GFP_KERNEL); | 184 | (void)snprintf(buf, sizeof(buf), "%02x%02x%02x%02x", |
188 | if (buf) | 185 | NIPQUAD(sin->sin_addr.s_addr)); |
189 | snprintf(buf, 48, "addr=%pI4 port=%u proto=%s", | 186 | xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = kstrdup(buf, GFP_KERNEL); |
190 | &addr->sin_addr.s_addr, | 187 | |
191 | ntohs(addr->sin_port), "rdma"); | 188 | (void)snprintf(buf, sizeof(buf), "%4hx", rpc_get_port(sap)); |
192 | xprt->address_strings[RPC_DISPLAY_ALL] = buf; | 189 | xprt->address_strings[RPC_DISPLAY_HEX_PORT] = kstrdup(buf, GFP_KERNEL); |
193 | |||
194 | buf = kzalloc(10, GFP_KERNEL); | ||
195 | if (buf) | ||
196 | snprintf(buf, 10, "%02x%02x%02x%02x", | ||
197 | NIPQUAD(addr->sin_addr.s_addr)); | ||
198 | xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = buf; | ||
199 | |||
200 | buf = kzalloc(8, GFP_KERNEL); | ||
201 | if (buf) | ||
202 | snprintf(buf, 8, "%4hx", ntohs(addr->sin_port)); | ||
203 | xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf; | ||
204 | |||
205 | buf = kzalloc(30, GFP_KERNEL); | ||
206 | if (buf) | ||
207 | snprintf(buf, 30, "%pI4.%u.%u", | ||
208 | &addr->sin_addr.s_addr, | ||
209 | ntohs(addr->sin_port) >> 8, | ||
210 | ntohs(addr->sin_port) & 0xff); | ||
211 | xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf; | ||
212 | 190 | ||
213 | /* netid */ | 191 | /* netid */ |
214 | xprt->address_strings[RPC_DISPLAY_NETID] = "rdma"; | 192 | xprt->address_strings[RPC_DISPLAY_NETID] = "rdma"; |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 83c73c4d017a..62438f3a914d 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -248,8 +248,8 @@ struct sock_xprt { | |||
248 | * Connection of transports | 248 | * Connection of transports |
249 | */ | 249 | */ |
250 | struct delayed_work connect_worker; | 250 | struct delayed_work connect_worker; |
251 | struct sockaddr_storage addr; | 251 | struct sockaddr_storage srcaddr; |
252 | unsigned short port; | 252 | unsigned short srcport; |
253 | 253 | ||
254 | /* | 254 | /* |
255 | * UDP socket buffer size parameters | 255 | * UDP socket buffer size parameters |
@@ -296,117 +296,60 @@ static inline struct sockaddr_in6 *xs_addr_in6(struct rpc_xprt *xprt) | |||
296 | return (struct sockaddr_in6 *) &xprt->addr; | 296 | return (struct sockaddr_in6 *) &xprt->addr; |
297 | } | 297 | } |
298 | 298 | ||
299 | static void xs_format_ipv4_peer_addresses(struct rpc_xprt *xprt, | 299 | static void xs_format_common_peer_addresses(struct rpc_xprt *xprt) |
300 | const char *protocol, | ||
301 | const char *netid) | ||
302 | { | 300 | { |
303 | struct sockaddr_in *addr = xs_addr_in(xprt); | 301 | struct sockaddr *sap = xs_addr(xprt); |
304 | char *buf; | 302 | struct sockaddr_in6 *sin6; |
303 | struct sockaddr_in *sin; | ||
304 | char buf[128]; | ||
305 | 305 | ||
306 | buf = kzalloc(20, GFP_KERNEL); | 306 | (void)rpc_ntop(sap, buf, sizeof(buf)); |
307 | if (buf) { | 307 | xprt->address_strings[RPC_DISPLAY_ADDR] = kstrdup(buf, GFP_KERNEL); |
308 | snprintf(buf, 20, "%pI4", &addr->sin_addr.s_addr); | ||
309 | } | ||
310 | xprt->address_strings[RPC_DISPLAY_ADDR] = buf; | ||
311 | |||
312 | buf = kzalloc(8, GFP_KERNEL); | ||
313 | if (buf) { | ||
314 | snprintf(buf, 8, "%u", | ||
315 | ntohs(addr->sin_port)); | ||
316 | } | ||
317 | xprt->address_strings[RPC_DISPLAY_PORT] = buf; | ||
318 | |||
319 | xprt->address_strings[RPC_DISPLAY_PROTO] = protocol; | ||
320 | |||
321 | buf = kzalloc(48, GFP_KERNEL); | ||
322 | if (buf) { | ||
323 | snprintf(buf, 48, "addr=%pI4 port=%u proto=%s", | ||
324 | &addr->sin_addr.s_addr, | ||
325 | ntohs(addr->sin_port), | ||
326 | protocol); | ||
327 | } | ||
328 | xprt->address_strings[RPC_DISPLAY_ALL] = buf; | ||
329 | |||
330 | buf = kzalloc(10, GFP_KERNEL); | ||
331 | if (buf) { | ||
332 | snprintf(buf, 10, "%02x%02x%02x%02x", | ||
333 | NIPQUAD(addr->sin_addr.s_addr)); | ||
334 | } | ||
335 | xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = buf; | ||
336 | 308 | ||
337 | buf = kzalloc(8, GFP_KERNEL); | 309 | switch (sap->sa_family) { |
338 | if (buf) { | 310 | case AF_INET: |
339 | snprintf(buf, 8, "%4hx", | 311 | sin = xs_addr_in(xprt); |
340 | ntohs(addr->sin_port)); | 312 | (void)snprintf(buf, sizeof(buf), "%02x%02x%02x%02x", |
341 | } | 313 | NIPQUAD(sin->sin_addr.s_addr)); |
342 | xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf; | 314 | break; |
343 | 315 | case AF_INET6: | |
344 | buf = kzalloc(30, GFP_KERNEL); | 316 | sin6 = xs_addr_in6(xprt); |
345 | if (buf) { | 317 | (void)snprintf(buf, sizeof(buf), "%pi6", &sin6->sin6_addr); |
346 | snprintf(buf, 30, "%pI4.%u.%u", | 318 | break; |
347 | &addr->sin_addr.s_addr, | 319 | default: |
348 | ntohs(addr->sin_port) >> 8, | 320 | BUG(); |
349 | ntohs(addr->sin_port) & 0xff); | ||
350 | } | 321 | } |
351 | xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf; | 322 | xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = kstrdup(buf, GFP_KERNEL); |
352 | |||
353 | xprt->address_strings[RPC_DISPLAY_NETID] = netid; | ||
354 | } | 323 | } |
355 | 324 | ||
356 | static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt, | 325 | static void xs_format_common_peer_ports(struct rpc_xprt *xprt) |
357 | const char *protocol, | ||
358 | const char *netid) | ||
359 | { | 326 | { |
360 | struct sockaddr_in6 *addr = xs_addr_in6(xprt); | 327 | struct sockaddr *sap = xs_addr(xprt); |
361 | char *buf; | 328 | char buf[128]; |
362 | 329 | ||
363 | buf = kzalloc(40, GFP_KERNEL); | 330 | (void)snprintf(buf, sizeof(buf), "%u", rpc_get_port(sap)); |
364 | if (buf) { | 331 | xprt->address_strings[RPC_DISPLAY_PORT] = kstrdup(buf, GFP_KERNEL); |
365 | snprintf(buf, 40, "%pI6",&addr->sin6_addr); | ||
366 | } | ||
367 | xprt->address_strings[RPC_DISPLAY_ADDR] = buf; | ||
368 | 332 | ||
369 | buf = kzalloc(8, GFP_KERNEL); | 333 | (void)snprintf(buf, sizeof(buf), "%4hx", rpc_get_port(sap)); |
370 | if (buf) { | 334 | xprt->address_strings[RPC_DISPLAY_HEX_PORT] = kstrdup(buf, GFP_KERNEL); |
371 | snprintf(buf, 8, "%u", | 335 | } |
372 | ntohs(addr->sin6_port)); | ||
373 | } | ||
374 | xprt->address_strings[RPC_DISPLAY_PORT] = buf; | ||
375 | 336 | ||
337 | static void xs_format_peer_addresses(struct rpc_xprt *xprt, | ||
338 | const char *protocol, | ||
339 | const char *netid) | ||
340 | { | ||
376 | xprt->address_strings[RPC_DISPLAY_PROTO] = protocol; | 341 | xprt->address_strings[RPC_DISPLAY_PROTO] = protocol; |
342 | xprt->address_strings[RPC_DISPLAY_NETID] = netid; | ||
343 | xs_format_common_peer_addresses(xprt); | ||
344 | xs_format_common_peer_ports(xprt); | ||
345 | } | ||
377 | 346 | ||
378 | buf = kzalloc(64, GFP_KERNEL); | 347 | static void xs_update_peer_port(struct rpc_xprt *xprt) |
379 | if (buf) { | 348 | { |
380 | snprintf(buf, 64, "addr=%pI6 port=%u proto=%s", | 349 | kfree(xprt->address_strings[RPC_DISPLAY_HEX_PORT]); |
381 | &addr->sin6_addr, | 350 | kfree(xprt->address_strings[RPC_DISPLAY_PORT]); |
382 | ntohs(addr->sin6_port), | ||
383 | protocol); | ||
384 | } | ||
385 | xprt->address_strings[RPC_DISPLAY_ALL] = buf; | ||
386 | |||
387 | buf = kzalloc(36, GFP_KERNEL); | ||
388 | if (buf) | ||
389 | snprintf(buf, 36, "%pi6", &addr->sin6_addr); | ||
390 | |||
391 | xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = buf; | ||
392 | |||
393 | buf = kzalloc(8, GFP_KERNEL); | ||
394 | if (buf) { | ||
395 | snprintf(buf, 8, "%4hx", | ||
396 | ntohs(addr->sin6_port)); | ||
397 | } | ||
398 | xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf; | ||
399 | |||
400 | buf = kzalloc(50, GFP_KERNEL); | ||
401 | if (buf) { | ||
402 | snprintf(buf, 50, "%pI6.%u.%u", | ||
403 | &addr->sin6_addr, | ||
404 | ntohs(addr->sin6_port) >> 8, | ||
405 | ntohs(addr->sin6_port) & 0xff); | ||
406 | } | ||
407 | xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf; | ||
408 | 351 | ||
409 | xprt->address_strings[RPC_DISPLAY_NETID] = netid; | 352 | xs_format_common_peer_ports(xprt); |
410 | } | 353 | } |
411 | 354 | ||
412 | static void xs_free_peer_addresses(struct rpc_xprt *xprt) | 355 | static void xs_free_peer_addresses(struct rpc_xprt *xprt) |
@@ -1587,25 +1530,15 @@ static unsigned short xs_get_random_port(void) | |||
1587 | */ | 1530 | */ |
1588 | static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) | 1531 | static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) |
1589 | { | 1532 | { |
1590 | struct sockaddr *addr = xs_addr(xprt); | ||
1591 | |||
1592 | dprintk("RPC: setting port for xprt %p to %u\n", xprt, port); | 1533 | dprintk("RPC: setting port for xprt %p to %u\n", xprt, port); |
1593 | 1534 | ||
1594 | switch (addr->sa_family) { | 1535 | rpc_set_port(xs_addr(xprt), port); |
1595 | case AF_INET: | 1536 | xs_update_peer_port(xprt); |
1596 | ((struct sockaddr_in *)addr)->sin_port = htons(port); | ||
1597 | break; | ||
1598 | case AF_INET6: | ||
1599 | ((struct sockaddr_in6 *)addr)->sin6_port = htons(port); | ||
1600 | break; | ||
1601 | default: | ||
1602 | BUG(); | ||
1603 | } | ||
1604 | } | 1537 | } |
1605 | 1538 | ||
1606 | static unsigned short xs_get_srcport(struct sock_xprt *transport, struct socket *sock) | 1539 | static unsigned short xs_get_srcport(struct sock_xprt *transport, struct socket *sock) |
1607 | { | 1540 | { |
1608 | unsigned short port = transport->port; | 1541 | unsigned short port = transport->srcport; |
1609 | 1542 | ||
1610 | if (port == 0 && transport->xprt.resvport) | 1543 | if (port == 0 && transport->xprt.resvport) |
1611 | port = xs_get_random_port(); | 1544 | port = xs_get_random_port(); |
@@ -1614,8 +1547,8 @@ static unsigned short xs_get_srcport(struct sock_xprt *transport, struct socket | |||
1614 | 1547 | ||
1615 | static unsigned short xs_next_srcport(struct sock_xprt *transport, struct socket *sock, unsigned short port) | 1548 | static unsigned short xs_next_srcport(struct sock_xprt *transport, struct socket *sock, unsigned short port) |
1616 | { | 1549 | { |
1617 | if (transport->port != 0) | 1550 | if (transport->srcport != 0) |
1618 | transport->port = 0; | 1551 | transport->srcport = 0; |
1619 | if (!transport->xprt.resvport) | 1552 | if (!transport->xprt.resvport) |
1620 | return 0; | 1553 | return 0; |
1621 | if (port <= xprt_min_resvport || port > xprt_max_resvport) | 1554 | if (port <= xprt_min_resvport || port > xprt_max_resvport) |
@@ -1633,7 +1566,7 @@ static int xs_bind4(struct sock_xprt *transport, struct socket *sock) | |||
1633 | unsigned short port = xs_get_srcport(transport, sock); | 1566 | unsigned short port = xs_get_srcport(transport, sock); |
1634 | unsigned short last; | 1567 | unsigned short last; |
1635 | 1568 | ||
1636 | sa = (struct sockaddr_in *)&transport->addr; | 1569 | sa = (struct sockaddr_in *)&transport->srcaddr; |
1637 | myaddr.sin_addr = sa->sin_addr; | 1570 | myaddr.sin_addr = sa->sin_addr; |
1638 | do { | 1571 | do { |
1639 | myaddr.sin_port = htons(port); | 1572 | myaddr.sin_port = htons(port); |
@@ -1642,7 +1575,7 @@ static int xs_bind4(struct sock_xprt *transport, struct socket *sock) | |||
1642 | if (port == 0) | 1575 | if (port == 0) |
1643 | break; | 1576 | break; |
1644 | if (err == 0) { | 1577 | if (err == 0) { |
1645 | transport->port = port; | 1578 | transport->srcport = port; |
1646 | break; | 1579 | break; |
1647 | } | 1580 | } |
1648 | last = port; | 1581 | last = port; |
@@ -1666,7 +1599,7 @@ static int xs_bind6(struct sock_xprt *transport, struct socket *sock) | |||
1666 | unsigned short port = xs_get_srcport(transport, sock); | 1599 | unsigned short port = xs_get_srcport(transport, sock); |
1667 | unsigned short last; | 1600 | unsigned short last; |
1668 | 1601 | ||
1669 | sa = (struct sockaddr_in6 *)&transport->addr; | 1602 | sa = (struct sockaddr_in6 *)&transport->srcaddr; |
1670 | myaddr.sin6_addr = sa->sin6_addr; | 1603 | myaddr.sin6_addr = sa->sin6_addr; |
1671 | do { | 1604 | do { |
1672 | myaddr.sin6_port = htons(port); | 1605 | myaddr.sin6_port = htons(port); |
@@ -1675,7 +1608,7 @@ static int xs_bind6(struct sock_xprt *transport, struct socket *sock) | |||
1675 | if (port == 0) | 1608 | if (port == 0) |
1676 | break; | 1609 | break; |
1677 | if (err == 0) { | 1610 | if (err == 0) { |
1678 | transport->port = port; | 1611 | transport->srcport = port; |
1679 | break; | 1612 | break; |
1680 | } | 1613 | } |
1681 | last = port; | 1614 | last = port; |
@@ -1780,8 +1713,11 @@ static void xs_udp_connect_worker4(struct work_struct *work) | |||
1780 | goto out; | 1713 | goto out; |
1781 | } | 1714 | } |
1782 | 1715 | ||
1783 | dprintk("RPC: worker connecting xprt %p to address: %s\n", | 1716 | dprintk("RPC: worker connecting xprt %p via %s to " |
1784 | xprt, xprt->address_strings[RPC_DISPLAY_ALL]); | 1717 | "%s (port %s)\n", xprt, |
1718 | xprt->address_strings[RPC_DISPLAY_PROTO], | ||
1719 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
1720 | xprt->address_strings[RPC_DISPLAY_PORT]); | ||
1785 | 1721 | ||
1786 | xs_udp_finish_connecting(xprt, sock); | 1722 | xs_udp_finish_connecting(xprt, sock); |
1787 | status = 0; | 1723 | status = 0; |
@@ -1822,8 +1758,11 @@ static void xs_udp_connect_worker6(struct work_struct *work) | |||
1822 | goto out; | 1758 | goto out; |
1823 | } | 1759 | } |
1824 | 1760 | ||
1825 | dprintk("RPC: worker connecting xprt %p to address: %s\n", | 1761 | dprintk("RPC: worker connecting xprt %p via %s to " |
1826 | xprt, xprt->address_strings[RPC_DISPLAY_ALL]); | 1762 | "%s (port %s)\n", xprt, |
1763 | xprt->address_strings[RPC_DISPLAY_PROTO], | ||
1764 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
1765 | xprt->address_strings[RPC_DISPLAY_PORT]); | ||
1827 | 1766 | ||
1828 | xs_udp_finish_connecting(xprt, sock); | 1767 | xs_udp_finish_connecting(xprt, sock); |
1829 | status = 0; | 1768 | status = 0; |
@@ -1948,8 +1887,11 @@ static void xs_tcp_setup_socket(struct rpc_xprt *xprt, | |||
1948 | goto out_eagain; | 1887 | goto out_eagain; |
1949 | } | 1888 | } |
1950 | 1889 | ||
1951 | dprintk("RPC: worker connecting xprt %p to address: %s\n", | 1890 | dprintk("RPC: worker connecting xprt %p via %s to " |
1952 | xprt, xprt->address_strings[RPC_DISPLAY_ALL]); | 1891 | "%s (port %s)\n", xprt, |
1892 | xprt->address_strings[RPC_DISPLAY_PROTO], | ||
1893 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
1894 | xprt->address_strings[RPC_DISPLAY_PORT]); | ||
1953 | 1895 | ||
1954 | status = xs_tcp_finish_connecting(xprt, sock); | 1896 | status = xs_tcp_finish_connecting(xprt, sock); |
1955 | dprintk("RPC: %p connect status %d connected %d sock state %d\n", | 1897 | dprintk("RPC: %p connect status %d connected %d sock state %d\n", |
@@ -2120,7 +2062,7 @@ static void xs_udp_print_stats(struct rpc_xprt *xprt, struct seq_file *seq) | |||
2120 | struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); | 2062 | struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); |
2121 | 2063 | ||
2122 | seq_printf(seq, "\txprt:\tudp %u %lu %lu %lu %lu %Lu %Lu\n", | 2064 | seq_printf(seq, "\txprt:\tudp %u %lu %lu %lu %lu %Lu %Lu\n", |
2123 | transport->port, | 2065 | transport->srcport, |
2124 | xprt->stat.bind_count, | 2066 | xprt->stat.bind_count, |
2125 | xprt->stat.sends, | 2067 | xprt->stat.sends, |
2126 | xprt->stat.recvs, | 2068 | xprt->stat.recvs, |
@@ -2144,7 +2086,7 @@ static void xs_tcp_print_stats(struct rpc_xprt *xprt, struct seq_file *seq) | |||
2144 | idle_time = (long)(jiffies - xprt->last_used) / HZ; | 2086 | idle_time = (long)(jiffies - xprt->last_used) / HZ; |
2145 | 2087 | ||
2146 | seq_printf(seq, "\txprt:\ttcp %u %lu %lu %lu %ld %lu %lu %lu %Lu %Lu\n", | 2088 | seq_printf(seq, "\txprt:\ttcp %u %lu %lu %lu %ld %lu %lu %lu %Lu %Lu\n", |
2147 | transport->port, | 2089 | transport->srcport, |
2148 | xprt->stat.bind_count, | 2090 | xprt->stat.bind_count, |
2149 | xprt->stat.connect_count, | 2091 | xprt->stat.connect_count, |
2150 | xprt->stat.connect_time, | 2092 | xprt->stat.connect_time, |
@@ -2223,7 +2165,7 @@ static struct rpc_xprt *xs_setup_xprt(struct xprt_create *args, | |||
2223 | memcpy(&xprt->addr, args->dstaddr, args->addrlen); | 2165 | memcpy(&xprt->addr, args->dstaddr, args->addrlen); |
2224 | xprt->addrlen = args->addrlen; | 2166 | xprt->addrlen = args->addrlen; |
2225 | if (args->srcaddr) | 2167 | if (args->srcaddr) |
2226 | memcpy(&new->addr, args->srcaddr, args->addrlen); | 2168 | memcpy(&new->srcaddr, args->srcaddr, args->addrlen); |
2227 | 2169 | ||
2228 | return xprt; | 2170 | return xprt; |
2229 | } | 2171 | } |
@@ -2272,7 +2214,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) | |||
2272 | 2214 | ||
2273 | INIT_DELAYED_WORK(&transport->connect_worker, | 2215 | INIT_DELAYED_WORK(&transport->connect_worker, |
2274 | xs_udp_connect_worker4); | 2216 | xs_udp_connect_worker4); |
2275 | xs_format_ipv4_peer_addresses(xprt, "udp", RPCBIND_NETID_UDP); | 2217 | xs_format_peer_addresses(xprt, "udp", RPCBIND_NETID_UDP); |
2276 | break; | 2218 | break; |
2277 | case AF_INET6: | 2219 | case AF_INET6: |
2278 | if (((struct sockaddr_in6 *)addr)->sin6_port != htons(0)) | 2220 | if (((struct sockaddr_in6 *)addr)->sin6_port != htons(0)) |
@@ -2280,15 +2222,22 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) | |||
2280 | 2222 | ||
2281 | INIT_DELAYED_WORK(&transport->connect_worker, | 2223 | INIT_DELAYED_WORK(&transport->connect_worker, |
2282 | xs_udp_connect_worker6); | 2224 | xs_udp_connect_worker6); |
2283 | xs_format_ipv6_peer_addresses(xprt, "udp", RPCBIND_NETID_UDP6); | 2225 | xs_format_peer_addresses(xprt, "udp", RPCBIND_NETID_UDP6); |
2284 | break; | 2226 | break; |
2285 | default: | 2227 | default: |
2286 | kfree(xprt); | 2228 | kfree(xprt); |
2287 | return ERR_PTR(-EAFNOSUPPORT); | 2229 | return ERR_PTR(-EAFNOSUPPORT); |
2288 | } | 2230 | } |
2289 | 2231 | ||
2290 | dprintk("RPC: set up transport to address %s\n", | 2232 | if (xprt_bound(xprt)) |
2291 | xprt->address_strings[RPC_DISPLAY_ALL]); | 2233 | dprintk("RPC: set up xprt to %s (port %s) via %s\n", |
2234 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
2235 | xprt->address_strings[RPC_DISPLAY_PORT], | ||
2236 | xprt->address_strings[RPC_DISPLAY_PROTO]); | ||
2237 | else | ||
2238 | dprintk("RPC: set up xprt to %s (autobind) via %s\n", | ||
2239 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
2240 | xprt->address_strings[RPC_DISPLAY_PROTO]); | ||
2292 | 2241 | ||
2293 | if (try_module_get(THIS_MODULE)) | 2242 | if (try_module_get(THIS_MODULE)) |
2294 | return xprt; | 2243 | return xprt; |
@@ -2337,23 +2286,33 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) | |||
2337 | if (((struct sockaddr_in *)addr)->sin_port != htons(0)) | 2286 | if (((struct sockaddr_in *)addr)->sin_port != htons(0)) |
2338 | xprt_set_bound(xprt); | 2287 | xprt_set_bound(xprt); |
2339 | 2288 | ||
2340 | INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_connect_worker4); | 2289 | INIT_DELAYED_WORK(&transport->connect_worker, |
2341 | xs_format_ipv4_peer_addresses(xprt, "tcp", RPCBIND_NETID_TCP); | 2290 | xs_tcp_connect_worker4); |
2291 | xs_format_peer_addresses(xprt, "tcp", RPCBIND_NETID_TCP); | ||
2342 | break; | 2292 | break; |
2343 | case AF_INET6: | 2293 | case AF_INET6: |
2344 | if (((struct sockaddr_in6 *)addr)->sin6_port != htons(0)) | 2294 | if (((struct sockaddr_in6 *)addr)->sin6_port != htons(0)) |
2345 | xprt_set_bound(xprt); | 2295 | xprt_set_bound(xprt); |
2346 | 2296 | ||
2347 | INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_connect_worker6); | 2297 | INIT_DELAYED_WORK(&transport->connect_worker, |
2348 | xs_format_ipv6_peer_addresses(xprt, "tcp", RPCBIND_NETID_TCP6); | 2298 | xs_tcp_connect_worker6); |
2299 | xs_format_peer_addresses(xprt, "tcp", RPCBIND_NETID_TCP6); | ||
2349 | break; | 2300 | break; |
2350 | default: | 2301 | default: |
2351 | kfree(xprt); | 2302 | kfree(xprt); |
2352 | return ERR_PTR(-EAFNOSUPPORT); | 2303 | return ERR_PTR(-EAFNOSUPPORT); |
2353 | } | 2304 | } |
2354 | 2305 | ||
2355 | dprintk("RPC: set up transport to address %s\n", | 2306 | if (xprt_bound(xprt)) |
2356 | xprt->address_strings[RPC_DISPLAY_ALL]); | 2307 | dprintk("RPC: set up xprt to %s (port %s) via %s\n", |
2308 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
2309 | xprt->address_strings[RPC_DISPLAY_PORT], | ||
2310 | xprt->address_strings[RPC_DISPLAY_PROTO]); | ||
2311 | else | ||
2312 | dprintk("RPC: set up xprt to %s (autobind) via %s\n", | ||
2313 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
2314 | xprt->address_strings[RPC_DISPLAY_PROTO]); | ||
2315 | |||
2357 | 2316 | ||
2358 | if (try_module_get(THIS_MODULE)) | 2317 | if (try_module_get(THIS_MODULE)) |
2359 | return xprt; | 2318 | return xprt; |
@@ -2412,3 +2371,55 @@ void cleanup_socket_xprt(void) | |||
2412 | xprt_unregister_transport(&xs_udp_transport); | 2371 | xprt_unregister_transport(&xs_udp_transport); |
2413 | xprt_unregister_transport(&xs_tcp_transport); | 2372 | xprt_unregister_transport(&xs_tcp_transport); |
2414 | } | 2373 | } |
2374 | |||
2375 | static int param_set_uint_minmax(const char *val, struct kernel_param *kp, | ||
2376 | unsigned int min, unsigned int max) | ||
2377 | { | ||
2378 | unsigned long num; | ||
2379 | int ret; | ||
2380 | |||
2381 | if (!val) | ||
2382 | return -EINVAL; | ||
2383 | ret = strict_strtoul(val, 0, &num); | ||
2384 | if (ret == -EINVAL || num < min || num > max) | ||
2385 | return -EINVAL; | ||
2386 | *((unsigned int *)kp->arg) = num; | ||
2387 | return 0; | ||
2388 | } | ||
2389 | |||
2390 | static int param_set_portnr(const char *val, struct kernel_param *kp) | ||
2391 | { | ||
2392 | return param_set_uint_minmax(val, kp, | ||
2393 | RPC_MIN_RESVPORT, | ||
2394 | RPC_MAX_RESVPORT); | ||
2395 | } | ||
2396 | |||
2397 | static int param_get_portnr(char *buffer, struct kernel_param *kp) | ||
2398 | { | ||
2399 | return param_get_uint(buffer, kp); | ||
2400 | } | ||
2401 | #define param_check_portnr(name, p) \ | ||
2402 | __param_check(name, p, unsigned int); | ||
2403 | |||
2404 | module_param_named(min_resvport, xprt_min_resvport, portnr, 0644); | ||
2405 | module_param_named(max_resvport, xprt_max_resvport, portnr, 0644); | ||
2406 | |||
2407 | static int param_set_slot_table_size(const char *val, struct kernel_param *kp) | ||
2408 | { | ||
2409 | return param_set_uint_minmax(val, kp, | ||
2410 | RPC_MIN_SLOT_TABLE, | ||
2411 | RPC_MAX_SLOT_TABLE); | ||
2412 | } | ||
2413 | |||
2414 | static int param_get_slot_table_size(char *buffer, struct kernel_param *kp) | ||
2415 | { | ||
2416 | return param_get_uint(buffer, kp); | ||
2417 | } | ||
2418 | #define param_check_slot_table_size(name, p) \ | ||
2419 | __param_check(name, p, unsigned int); | ||
2420 | |||
2421 | module_param_named(tcp_slot_table_entries, xprt_tcp_slot_table_entries, | ||
2422 | slot_table_size, 0644); | ||
2423 | module_param_named(udp_slot_table_entries, xprt_udp_slot_table_entries, | ||
2424 | slot_table_size, 0644); | ||
2425 | |||
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 36d4e44d6233..fc3ebb906911 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -315,7 +315,7 @@ static void unix_write_space(struct sock *sk) | |||
315 | { | 315 | { |
316 | read_lock(&sk->sk_callback_lock); | 316 | read_lock(&sk->sk_callback_lock); |
317 | if (unix_writable(sk)) { | 317 | if (unix_writable(sk)) { |
318 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 318 | if (sk_has_sleeper(sk)) |
319 | wake_up_interruptible_sync(sk->sk_sleep); | 319 | wake_up_interruptible_sync(sk->sk_sleep); |
320 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); | 320 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); |
321 | } | 321 | } |
@@ -1985,7 +1985,7 @@ static unsigned int unix_poll(struct file *file, struct socket *sock, poll_table | |||
1985 | struct sock *sk = sock->sk; | 1985 | struct sock *sk = sock->sk; |
1986 | unsigned int mask; | 1986 | unsigned int mask; |
1987 | 1987 | ||
1988 | poll_wait(file, sk->sk_sleep, wait); | 1988 | sock_poll_wait(file, sk->sk_sleep, wait); |
1989 | mask = 0; | 1989 | mask = 0; |
1990 | 1990 | ||
1991 | /* exceptional events? */ | 1991 | /* exceptional events? */ |
@@ -2022,7 +2022,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock, | |||
2022 | struct sock *sk = sock->sk, *other; | 2022 | struct sock *sk = sock->sk, *other; |
2023 | unsigned int mask, writable; | 2023 | unsigned int mask, writable; |
2024 | 2024 | ||
2025 | poll_wait(file, sk->sk_sleep, wait); | 2025 | sock_poll_wait(file, sk->sk_sleep, wait); |
2026 | mask = 0; | 2026 | mask = 0; |
2027 | 2027 | ||
2028 | /* exceptional events? */ | 2028 | /* exceptional events? */ |
@@ -2053,7 +2053,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock, | |||
2053 | other = unix_peer_get(sk); | 2053 | other = unix_peer_get(sk); |
2054 | if (other) { | 2054 | if (other) { |
2055 | if (unix_peer(other) != sk) { | 2055 | if (unix_peer(other) != sk) { |
2056 | poll_wait(file, &unix_sk(other)->peer_wait, | 2056 | sock_poll_wait(file, &unix_sk(other)->peer_wait, |
2057 | wait); | 2057 | wait); |
2058 | if (unix_recvq_full(other)) | 2058 | if (unix_recvq_full(other)) |
2059 | writable = 0; | 2059 | writable = 0; |
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c index 466e2d22d256..258daa80ad92 100644 --- a/net/wanrouter/wanmain.c +++ b/net/wanrouter/wanmain.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/kernel.h> | 48 | #include <linux/kernel.h> |
49 | #include <linux/module.h> /* support for loadable modules */ | 49 | #include <linux/module.h> /* support for loadable modules */ |
50 | #include <linux/slab.h> /* kmalloc(), kfree() */ | 50 | #include <linux/slab.h> /* kmalloc(), kfree() */ |
51 | #include <linux/smp_lock.h> | ||
51 | #include <linux/mm.h> | 52 | #include <linux/mm.h> |
52 | #include <linux/string.h> /* inline mem*, str* functions */ | 53 | #include <linux/string.h> /* inline mem*, str* functions */ |
53 | 54 | ||
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 241bddd0b4f1..634496b3ed77 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -447,6 +447,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
447 | 447 | ||
448 | rdev = __cfg80211_drv_from_info(info); | 448 | rdev = __cfg80211_drv_from_info(info); |
449 | if (IS_ERR(rdev)) { | 449 | if (IS_ERR(rdev)) { |
450 | mutex_unlock(&cfg80211_mutex); | ||
450 | result = PTR_ERR(rdev); | 451 | result = PTR_ERR(rdev); |
451 | goto unlock; | 452 | goto unlock; |
452 | } | 453 | } |
@@ -996,7 +997,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info) | |||
996 | 997 | ||
997 | if (IS_ERR(hdr)) { | 998 | if (IS_ERR(hdr)) { |
998 | err = PTR_ERR(hdr); | 999 | err = PTR_ERR(hdr); |
999 | goto out; | 1000 | goto free_msg; |
1000 | } | 1001 | } |
1001 | 1002 | ||
1002 | cookie.msg = msg; | 1003 | cookie.msg = msg; |
@@ -1010,7 +1011,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info) | |||
1010 | &cookie, get_key_callback); | 1011 | &cookie, get_key_callback); |
1011 | 1012 | ||
1012 | if (err) | 1013 | if (err) |
1013 | goto out; | 1014 | goto free_msg; |
1014 | 1015 | ||
1015 | if (cookie.error) | 1016 | if (cookie.error) |
1016 | goto nla_put_failure; | 1017 | goto nla_put_failure; |
@@ -1021,6 +1022,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info) | |||
1021 | 1022 | ||
1022 | nla_put_failure: | 1023 | nla_put_failure: |
1023 | err = -ENOBUFS; | 1024 | err = -ENOBUFS; |
1025 | free_msg: | ||
1024 | nlmsg_free(msg); | 1026 | nlmsg_free(msg); |
1025 | out: | 1027 | out: |
1026 | cfg80211_put_dev(drv); | 1028 | cfg80211_put_dev(drv); |
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 5e14371cda70..75a406d33619 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -1089,17 +1089,18 @@ static void handle_reg_beacon(struct wiphy *wiphy, | |||
1089 | 1089 | ||
1090 | chan->beacon_found = true; | 1090 | chan->beacon_found = true; |
1091 | 1091 | ||
1092 | if (wiphy->disable_beacon_hints) | ||
1093 | return; | ||
1094 | |||
1092 | chan_before.center_freq = chan->center_freq; | 1095 | chan_before.center_freq = chan->center_freq; |
1093 | chan_before.flags = chan->flags; | 1096 | chan_before.flags = chan->flags; |
1094 | 1097 | ||
1095 | if ((chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) && | 1098 | if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) { |
1096 | !(chan->orig_flags & IEEE80211_CHAN_PASSIVE_SCAN)) { | ||
1097 | chan->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; | 1099 | chan->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; |
1098 | channel_changed = true; | 1100 | channel_changed = true; |
1099 | } | 1101 | } |
1100 | 1102 | ||
1101 | if ((chan->flags & IEEE80211_CHAN_NO_IBSS) && | 1103 | if (chan->flags & IEEE80211_CHAN_NO_IBSS) { |
1102 | !(chan->orig_flags & IEEE80211_CHAN_NO_IBSS)) { | ||
1103 | chan->flags &= ~IEEE80211_CHAN_NO_IBSS; | 1104 | chan->flags &= ~IEEE80211_CHAN_NO_IBSS; |
1104 | channel_changed = true; | 1105 | channel_changed = true; |
1105 | } | 1106 | } |
diff --git a/net/wireless/reg.h b/net/wireless/reg.h index e37829a49dc4..4e167a8e11be 100644 --- a/net/wireless/reg.h +++ b/net/wireless/reg.h | |||
@@ -30,7 +30,8 @@ int set_regdom(const struct ieee80211_regdomain *rd); | |||
30 | * non-radar 5 GHz channels. | 30 | * non-radar 5 GHz channels. |
31 | * | 31 | * |
32 | * Drivers do not need to call this, cfg80211 will do it for after a scan | 32 | * Drivers do not need to call this, cfg80211 will do it for after a scan |
33 | * on a newly found BSS. | 33 | * on a newly found BSS. If you cannot make use of this feature you can |
34 | * set the wiphy->disable_beacon_hints to true. | ||
34 | */ | 35 | */ |
35 | int regulatory_hint_found_beacon(struct wiphy *wiphy, | 36 | int regulatory_hint_found_beacon(struct wiphy *wiphy, |
36 | struct ieee80211_channel *beacon_chan, | 37 | struct ieee80211_channel *beacon_chan, |
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index e95b638b919f..7e595ce24eeb 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
@@ -35,8 +35,6 @@ void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted) | |||
35 | else | 35 | else |
36 | nl80211_send_scan_done(wiphy_to_dev(request->wiphy), dev); | 36 | nl80211_send_scan_done(wiphy_to_dev(request->wiphy), dev); |
37 | 37 | ||
38 | wiphy_to_dev(request->wiphy)->scan_req = NULL; | ||
39 | |||
40 | #ifdef CONFIG_WIRELESS_EXT | 38 | #ifdef CONFIG_WIRELESS_EXT |
41 | if (!aborted) { | 39 | if (!aborted) { |
42 | memset(&wrqu, 0, sizeof(wrqu)); | 40 | memset(&wrqu, 0, sizeof(wrqu)); |
@@ -48,6 +46,7 @@ void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted) | |||
48 | dev_put(dev); | 46 | dev_put(dev); |
49 | 47 | ||
50 | out: | 48 | out: |
49 | wiphy_to_dev(request->wiphy)->scan_req = NULL; | ||
51 | kfree(request); | 50 | kfree(request); |
52 | } | 51 | } |
53 | EXPORT_SYMBOL(cfg80211_scan_done); | 52 | EXPORT_SYMBOL(cfg80211_scan_done); |
@@ -119,7 +118,7 @@ static int cmp_ies(u8 num, u8 *ies1, size_t len1, u8 *ies2, size_t len2) | |||
119 | 118 | ||
120 | if (!ie1 && !ie2) | 119 | if (!ie1 && !ie2) |
121 | return 0; | 120 | return 0; |
122 | if (!ie1) | 121 | if (!ie1 || !ie2) |
123 | return -1; | 122 | return -1; |
124 | 123 | ||
125 | r = memcmp(ie1 + 2, ie2 + 2, min(ie1[1], ie2[1])); | 124 | r = memcmp(ie1 + 2, ie2 + 2, min(ie1[1], ie2[1])); |
@@ -172,6 +171,8 @@ static bool is_mesh(struct cfg80211_bss *a, | |||
172 | ie = find_ie(WLAN_EID_MESH_CONFIG, | 171 | ie = find_ie(WLAN_EID_MESH_CONFIG, |
173 | a->information_elements, | 172 | a->information_elements, |
174 | a->len_information_elements); | 173 | a->len_information_elements); |
174 | if (!ie) | ||
175 | return false; | ||
175 | if (ie[1] != IEEE80211_MESH_CONFIG_LEN) | 176 | if (ie[1] != IEEE80211_MESH_CONFIG_LEN) |
176 | return false; | 177 | return false; |
177 | 178 | ||
@@ -366,7 +367,6 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev, | |||
366 | found = rb_find_bss(dev, res); | 367 | found = rb_find_bss(dev, res); |
367 | 368 | ||
368 | if (found) { | 369 | if (found) { |
369 | kref_get(&found->ref); | ||
370 | found->pub.beacon_interval = res->pub.beacon_interval; | 370 | found->pub.beacon_interval = res->pub.beacon_interval; |
371 | found->pub.tsf = res->pub.tsf; | 371 | found->pub.tsf = res->pub.tsf; |
372 | found->pub.signal = res->pub.signal; | 372 | found->pub.signal = res->pub.signal; |
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 21cdc872004e..5e6c072c64d3 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/errno.h> | 40 | #include <linux/errno.h> |
41 | #include <linux/kernel.h> | 41 | #include <linux/kernel.h> |
42 | #include <linux/sched.h> | 42 | #include <linux/sched.h> |
43 | #include <linux/smp_lock.h> | ||
43 | #include <linux/timer.h> | 44 | #include <linux/timer.h> |
44 | #include <linux/string.h> | 45 | #include <linux/string.h> |
45 | #include <linux/net.h> | 46 | #include <linux/net.h> |
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c index d31ccb487730..faf54c6bf96b 100644 --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c | |||
@@ -292,8 +292,8 @@ static struct xfrm_algo_desc ealg_list[] = { | |||
292 | } | 292 | } |
293 | }, | 293 | }, |
294 | { | 294 | { |
295 | .name = "cbc(cast128)", | 295 | .name = "cbc(cast5)", |
296 | .compat = "cast128", | 296 | .compat = "cast5", |
297 | 297 | ||
298 | .uinfo = { | 298 | .uinfo = { |
299 | .encr = { | 299 | .encr = { |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 5f1f86565f16..f2f7c638083e 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -668,22 +668,10 @@ static struct xfrm_state *__xfrm_state_lookup(struct net *net, xfrm_address_t *d | |||
668 | hlist_for_each_entry(x, entry, net->xfrm.state_byspi+h, byspi) { | 668 | hlist_for_each_entry(x, entry, net->xfrm.state_byspi+h, byspi) { |
669 | if (x->props.family != family || | 669 | if (x->props.family != family || |
670 | x->id.spi != spi || | 670 | x->id.spi != spi || |
671 | x->id.proto != proto) | 671 | x->id.proto != proto || |
672 | xfrm_addr_cmp(&x->id.daddr, daddr, family)) | ||
672 | continue; | 673 | continue; |
673 | 674 | ||
674 | switch (family) { | ||
675 | case AF_INET: | ||
676 | if (x->id.daddr.a4 != daddr->a4) | ||
677 | continue; | ||
678 | break; | ||
679 | case AF_INET6: | ||
680 | if (!ipv6_addr_equal((struct in6_addr *)daddr, | ||
681 | (struct in6_addr *) | ||
682 | x->id.daddr.a6)) | ||
683 | continue; | ||
684 | break; | ||
685 | } | ||
686 | |||
687 | xfrm_state_hold(x); | 675 | xfrm_state_hold(x); |
688 | return x; | 676 | return x; |
689 | } | 677 | } |
@@ -699,26 +687,11 @@ static struct xfrm_state *__xfrm_state_lookup_byaddr(struct net *net, xfrm_addre | |||
699 | 687 | ||
700 | hlist_for_each_entry(x, entry, net->xfrm.state_bysrc+h, bysrc) { | 688 | hlist_for_each_entry(x, entry, net->xfrm.state_bysrc+h, bysrc) { |
701 | if (x->props.family != family || | 689 | if (x->props.family != family || |
702 | x->id.proto != proto) | 690 | x->id.proto != proto || |
691 | xfrm_addr_cmp(&x->id.daddr, daddr, family) || | ||
692 | xfrm_addr_cmp(&x->props.saddr, saddr, family)) | ||
703 | continue; | 693 | continue; |
704 | 694 | ||
705 | switch (family) { | ||
706 | case AF_INET: | ||
707 | if (x->id.daddr.a4 != daddr->a4 || | ||
708 | x->props.saddr.a4 != saddr->a4) | ||
709 | continue; | ||
710 | break; | ||
711 | case AF_INET6: | ||
712 | if (!ipv6_addr_equal((struct in6_addr *)daddr, | ||
713 | (struct in6_addr *) | ||
714 | x->id.daddr.a6) || | ||
715 | !ipv6_addr_equal((struct in6_addr *)saddr, | ||
716 | (struct in6_addr *) | ||
717 | x->props.saddr.a6)) | ||
718 | continue; | ||
719 | break; | ||
720 | } | ||
721 | |||
722 | xfrm_state_hold(x); | 695 | xfrm_state_hold(x); |
723 | return x; | 696 | return x; |
724 | } | 697 | } |
@@ -1001,25 +974,11 @@ static struct xfrm_state *__find_acq_core(struct net *net, unsigned short family | |||
1001 | x->props.family != family || | 974 | x->props.family != family || |
1002 | x->km.state != XFRM_STATE_ACQ || | 975 | x->km.state != XFRM_STATE_ACQ || |
1003 | x->id.spi != 0 || | 976 | x->id.spi != 0 || |
1004 | x->id.proto != proto) | 977 | x->id.proto != proto || |
978 | xfrm_addr_cmp(&x->id.daddr, daddr, family) || | ||
979 | xfrm_addr_cmp(&x->props.saddr, saddr, family)) | ||
1005 | continue; | 980 | continue; |
1006 | 981 | ||
1007 | switch (family) { | ||
1008 | case AF_INET: | ||
1009 | if (x->id.daddr.a4 != daddr->a4 || | ||
1010 | x->props.saddr.a4 != saddr->a4) | ||
1011 | continue; | ||
1012 | break; | ||
1013 | case AF_INET6: | ||
1014 | if (!ipv6_addr_equal((struct in6_addr *)x->id.daddr.a6, | ||
1015 | (struct in6_addr *)daddr) || | ||
1016 | !ipv6_addr_equal((struct in6_addr *) | ||
1017 | x->props.saddr.a6, | ||
1018 | (struct in6_addr *)saddr)) | ||
1019 | continue; | ||
1020 | break; | ||
1021 | } | ||
1022 | |||
1023 | xfrm_state_hold(x); | 982 | xfrm_state_hold(x); |
1024 | return x; | 983 | return x; |
1025 | } | 984 | } |