David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 1 | /* AFS Cache Manager Service |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
| 3 | * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/init.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 14 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/sched.h> |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 16 | #include <linux/ip.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include "internal.h" |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 18 | #include "afs_cm.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 20 | static int afs_deliver_cb_init_call_back_state(struct afs_call *); |
| 21 | static int afs_deliver_cb_init_call_back_state3(struct afs_call *); |
| 22 | static int afs_deliver_cb_probe(struct afs_call *); |
| 23 | static int afs_deliver_cb_callback(struct afs_call *); |
| 24 | static int afs_deliver_cb_probe_uuid(struct afs_call *); |
| 25 | static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 26 | static void afs_cm_destructor(struct afs_call *); |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 27 | static void SRXAFSCB_CallBack(struct work_struct *); |
| 28 | static void SRXAFSCB_InitCallBackState(struct work_struct *); |
| 29 | static void SRXAFSCB_Probe(struct work_struct *); |
| 30 | static void SRXAFSCB_ProbeUuid(struct work_struct *); |
| 31 | static void SRXAFSCB_TellMeAboutYourself(struct work_struct *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 33 | #define CM_NAME(name) \ |
| 34 | const char afs_SRXCB##name##_name[] __tracepoint_string = \ |
| 35 | "CB." #name |
| 36 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 37 | /* |
| 38 | * CB.CallBack operation type |
| 39 | */ |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 40 | static CM_NAME(CallBack); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 41 | static const struct afs_call_type afs_SRXCBCallBack = { |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 42 | .name = afs_SRXCBCallBack_name, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 43 | .deliver = afs_deliver_cb_callback, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 44 | .destructor = afs_cm_destructor, |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 45 | .work = SRXAFSCB_CallBack, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | }; |
| 47 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 48 | /* |
| 49 | * CB.InitCallBackState operation type |
| 50 | */ |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 51 | static CM_NAME(InitCallBackState); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 52 | static const struct afs_call_type afs_SRXCBInitCallBackState = { |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 53 | .name = afs_SRXCBInitCallBackState_name, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 54 | .deliver = afs_deliver_cb_init_call_back_state, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 55 | .destructor = afs_cm_destructor, |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 56 | .work = SRXAFSCB_InitCallBackState, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 59 | /* |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 60 | * CB.InitCallBackState3 operation type |
| 61 | */ |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 62 | static CM_NAME(InitCallBackState3); |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 63 | static const struct afs_call_type afs_SRXCBInitCallBackState3 = { |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 64 | .name = afs_SRXCBInitCallBackState3_name, |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 65 | .deliver = afs_deliver_cb_init_call_back_state3, |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 66 | .destructor = afs_cm_destructor, |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 67 | .work = SRXAFSCB_InitCallBackState, |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 71 | * CB.Probe operation type |
| 72 | */ |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 73 | static CM_NAME(Probe); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 74 | static const struct afs_call_type afs_SRXCBProbe = { |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 75 | .name = afs_SRXCBProbe_name, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 76 | .deliver = afs_deliver_cb_probe, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 77 | .destructor = afs_cm_destructor, |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 78 | .work = SRXAFSCB_Probe, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 79 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | /* |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 82 | * CB.ProbeUuid operation type |
| 83 | */ |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 84 | static CM_NAME(ProbeUuid); |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 85 | static const struct afs_call_type afs_SRXCBProbeUuid = { |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 86 | .name = afs_SRXCBProbeUuid_name, |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 87 | .deliver = afs_deliver_cb_probe_uuid, |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 88 | .destructor = afs_cm_destructor, |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 89 | .work = SRXAFSCB_ProbeUuid, |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | /* |
David Howells | 7c80bcc | 2008-04-29 01:03:21 -0700 | [diff] [blame] | 93 | * CB.TellMeAboutYourself operation type |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 94 | */ |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 95 | static CM_NAME(TellMeAboutYourself); |
David Howells | 7c80bcc | 2008-04-29 01:03:21 -0700 | [diff] [blame] | 96 | static const struct afs_call_type afs_SRXCBTellMeAboutYourself = { |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 97 | .name = afs_SRXCBTellMeAboutYourself_name, |
David Howells | 7c80bcc | 2008-04-29 01:03:21 -0700 | [diff] [blame] | 98 | .deliver = afs_deliver_cb_tell_me_about_yourself, |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 99 | .destructor = afs_cm_destructor, |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 100 | .work = SRXAFSCB_TellMeAboutYourself, |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 104 | * route an incoming cache manager call |
| 105 | * - return T if supported, F if not |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 107 | bool afs_cm_incoming_call(struct afs_call *call) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | { |
David Howells | 50a2c95 | 2016-10-13 08:27:10 +0100 | [diff] [blame] | 109 | _enter("{CB.OP %u}", call->operation_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
David Howells | 50a2c95 | 2016-10-13 08:27:10 +0100 | [diff] [blame] | 111 | switch (call->operation_ID) { |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 112 | case CBCallBack: |
| 113 | call->type = &afs_SRXCBCallBack; |
| 114 | return true; |
| 115 | case CBInitCallBackState: |
| 116 | call->type = &afs_SRXCBInitCallBackState; |
| 117 | return true; |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 118 | case CBInitCallBackState3: |
| 119 | call->type = &afs_SRXCBInitCallBackState3; |
| 120 | return true; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 121 | case CBProbe: |
| 122 | call->type = &afs_SRXCBProbe; |
| 123 | return true; |
David Howells | f4b3526 | 2017-11-02 15:27:48 +0000 | [diff] [blame] | 124 | case CBProbeUuid: |
| 125 | call->type = &afs_SRXCBProbeUuid; |
| 126 | return true; |
David Howells | 7c80bcc | 2008-04-29 01:03:21 -0700 | [diff] [blame] | 127 | case CBTellMeAboutYourself: |
| 128 | call->type = &afs_SRXCBTellMeAboutYourself; |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 129 | return true; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 130 | default: |
| 131 | return false; |
| 132 | } |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 133 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | /* |
David Howells | 428edad | 2018-05-12 00:28:58 +0100 | [diff] [blame] | 136 | * Clean up a cache manager call. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 138 | static void afs_cm_destructor(struct afs_call *call) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | { |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 140 | kfree(call->buffer); |
| 141 | call->buffer = NULL; |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 142 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | /* |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 145 | * The server supplied a list of callbacks that it wanted to break. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 147 | static void SRXAFSCB_CallBack(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | { |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 149 | struct afs_call *call = container_of(work, struct afs_call, work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 151 | _enter(""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
David Howells | 428edad | 2018-05-12 00:28:58 +0100 | [diff] [blame] | 153 | /* We need to break the callbacks before sending the reply as the |
| 154 | * server holds up change visibility till it receives our reply so as |
| 155 | * to maintain cache coherency. |
| 156 | */ |
David Howells | a86b06d | 2018-05-11 23:45:40 +0100 | [diff] [blame] | 157 | if (call->cm_server) |
| 158 | afs_break_callbacks(call->cm_server, call->count, call->request); |
David Howells | 428edad | 2018-05-12 00:28:58 +0100 | [diff] [blame] | 159 | |
| 160 | afs_send_empty_reply(call); |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 161 | afs_put_call(call); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | _leave(""); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 163 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 166 | * deliver request data to a CB.CallBack call |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | */ |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 168 | static int afs_deliver_cb_callback(struct afs_call *call) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | { |
David Howells | 5cf9dd5 | 2018-04-09 21:12:31 +0100 | [diff] [blame] | 170 | struct afs_callback_break *cb; |
David Howells | 8324f0b | 2016-08-30 09:49:29 +0100 | [diff] [blame] | 171 | struct sockaddr_rxrpc srx; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 172 | __be32 *bp; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 173 | int ret, loop; |
| 174 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 175 | _enter("{%u}", call->unmarshall); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 176 | |
| 177 | switch (call->unmarshall) { |
| 178 | case 0: |
| 179 | call->offset = 0; |
| 180 | call->unmarshall++; |
| 181 | |
| 182 | /* extract the FID array and its count in two steps */ |
| 183 | case 1: |
| 184 | _debug("extract FID count"); |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 185 | ret = afs_extract_data(call, &call->tmp, 4, true); |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 186 | if (ret < 0) |
| 187 | return ret; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 188 | |
| 189 | call->count = ntohl(call->tmp); |
| 190 | _debug("FID count: %u", call->count); |
| 191 | if (call->count > AFSCBMAX) |
David Howells | 5f702c8 | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 192 | return afs_protocol_error(call, -EBADMSG); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 193 | |
Kees Cook | 6da2ec5 | 2018-06-12 13:55:00 -0700 | [diff] [blame] | 194 | call->buffer = kmalloc(array3_size(call->count, 3, 4), |
| 195 | GFP_KERNEL); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 196 | if (!call->buffer) |
| 197 | return -ENOMEM; |
| 198 | call->offset = 0; |
| 199 | call->unmarshall++; |
| 200 | |
| 201 | case 2: |
| 202 | _debug("extract FID array"); |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 203 | ret = afs_extract_data(call, call->buffer, |
| 204 | call->count * 3 * 4, true); |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 205 | if (ret < 0) |
| 206 | return ret; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 207 | |
| 208 | _debug("unmarshall FID array"); |
| 209 | call->request = kcalloc(call->count, |
David Howells | 5cf9dd5 | 2018-04-09 21:12:31 +0100 | [diff] [blame] | 210 | sizeof(struct afs_callback_break), |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 211 | GFP_KERNEL); |
| 212 | if (!call->request) |
| 213 | return -ENOMEM; |
| 214 | |
| 215 | cb = call->request; |
| 216 | bp = call->buffer; |
| 217 | for (loop = call->count; loop > 0; loop--, cb++) { |
| 218 | cb->fid.vid = ntohl(*bp++); |
| 219 | cb->fid.vnode = ntohl(*bp++); |
| 220 | cb->fid.unique = ntohl(*bp++); |
David Howells | 5cf9dd5 | 2018-04-09 21:12:31 +0100 | [diff] [blame] | 221 | cb->cb.type = AFSCM_CB_UNTYPED; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | call->offset = 0; |
| 225 | call->unmarshall++; |
| 226 | |
| 227 | /* extract the callback array and its count in two steps */ |
| 228 | case 3: |
| 229 | _debug("extract CB count"); |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 230 | ret = afs_extract_data(call, &call->tmp, 4, true); |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 231 | if (ret < 0) |
| 232 | return ret; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 233 | |
Marc Dionne | bcd8927 | 2017-03-16 16:27:44 +0000 | [diff] [blame] | 234 | call->count2 = ntohl(call->tmp); |
| 235 | _debug("CB count: %u", call->count2); |
| 236 | if (call->count2 != call->count && call->count2 != 0) |
David Howells | 5f702c8 | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 237 | return afs_protocol_error(call, -EBADMSG); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 238 | call->offset = 0; |
| 239 | call->unmarshall++; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 240 | |
| 241 | case 4: |
| 242 | _debug("extract CB array"); |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 243 | ret = afs_extract_data(call, call->buffer, |
Marc Dionne | bcd8927 | 2017-03-16 16:27:44 +0000 | [diff] [blame] | 244 | call->count2 * 3 * 4, false); |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 245 | if (ret < 0) |
| 246 | return ret; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 247 | |
| 248 | _debug("unmarshall CB array"); |
| 249 | cb = call->request; |
| 250 | bp = call->buffer; |
Marc Dionne | bcd8927 | 2017-03-16 16:27:44 +0000 | [diff] [blame] | 251 | for (loop = call->count2; loop > 0; loop--, cb++) { |
David Howells | 5cf9dd5 | 2018-04-09 21:12:31 +0100 | [diff] [blame] | 252 | cb->cb.version = ntohl(*bp++); |
| 253 | cb->cb.expiry = ntohl(*bp++); |
| 254 | cb->cb.type = ntohl(*bp++); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 255 | } |
| 256 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 257 | call->offset = 0; |
| 258 | call->unmarshall++; |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 259 | case 5: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | break; |
| 261 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
David Howells | 98bf40c | 2017-11-02 15:27:53 +0000 | [diff] [blame] | 263 | if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING)) |
| 264 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 266 | /* we'll need the file server record as that tells us which set of |
| 267 | * vnodes to operate upon */ |
David Howells | 98bf40c | 2017-11-02 15:27:53 +0000 | [diff] [blame] | 268 | rxrpc_kernel_get_peer(call->net->socket, call->rxcall, &srx); |
David Howells | a86b06d | 2018-05-11 23:45:40 +0100 | [diff] [blame] | 269 | call->cm_server = afs_find_server(call->net, &srx); |
| 270 | if (!call->cm_server) |
David Howells | 3709a39 | 2018-05-11 22:59:42 +0100 | [diff] [blame] | 271 | trace_afs_cm_no_server(call, &srx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 273 | return afs_queue_call_work(call); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 274 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 277 | * allow the fileserver to request callback state (re-)initialisation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 279 | static void SRXAFSCB_InitCallBackState(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | { |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 281 | struct afs_call *call = container_of(work, struct afs_call, work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | |
David Howells | d0676a1 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 283 | _enter("{%p}", call->cm_server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
David Howells | a86b06d | 2018-05-11 23:45:40 +0100 | [diff] [blame] | 285 | if (call->cm_server) |
| 286 | afs_init_callback_state(call->cm_server); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 287 | afs_send_empty_reply(call); |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 288 | afs_put_call(call); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 289 | _leave(""); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 290 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 293 | * deliver request data to a CB.InitCallBackState call |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | */ |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 295 | static int afs_deliver_cb_init_call_back_state(struct afs_call *call) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | { |
David Howells | 8324f0b | 2016-08-30 09:49:29 +0100 | [diff] [blame] | 297 | struct sockaddr_rxrpc srx; |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 298 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 300 | _enter(""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 302 | rxrpc_kernel_get_peer(call->net->socket, call->rxcall, &srx); |
David Howells | 8324f0b | 2016-08-30 09:49:29 +0100 | [diff] [blame] | 303 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 304 | ret = afs_extract_data(call, NULL, 0, false); |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 305 | if (ret < 0) |
| 306 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 308 | /* we'll need the file server record as that tells us which set of |
| 309 | * vnodes to operate upon */ |
David Howells | a86b06d | 2018-05-11 23:45:40 +0100 | [diff] [blame] | 310 | call->cm_server = afs_find_server(call->net, &srx); |
| 311 | if (!call->cm_server) |
David Howells | 3709a39 | 2018-05-11 22:59:42 +0100 | [diff] [blame] | 312 | trace_afs_cm_no_server(call, &srx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 314 | return afs_queue_call_work(call); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 315 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | /* |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 318 | * deliver request data to a CB.InitCallBackState3 call |
| 319 | */ |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 320 | static int afs_deliver_cb_init_call_back_state3(struct afs_call *call) |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 321 | { |
Christoph Hellwig | 41bb26f | 2017-05-28 08:56:46 +0300 | [diff] [blame] | 322 | struct afs_uuid *r; |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 323 | unsigned loop; |
| 324 | __be32 *b; |
| 325 | int ret; |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 326 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 327 | _enter(""); |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 328 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 329 | _enter("{%u}", call->unmarshall); |
| 330 | |
| 331 | switch (call->unmarshall) { |
| 332 | case 0: |
| 333 | call->offset = 0; |
Kees Cook | 6da2ec5 | 2018-06-12 13:55:00 -0700 | [diff] [blame] | 334 | call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL); |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 335 | if (!call->buffer) |
| 336 | return -ENOMEM; |
| 337 | call->unmarshall++; |
| 338 | |
| 339 | case 1: |
| 340 | _debug("extract UUID"); |
| 341 | ret = afs_extract_data(call, call->buffer, |
| 342 | 11 * sizeof(__be32), false); |
| 343 | switch (ret) { |
| 344 | case 0: break; |
| 345 | case -EAGAIN: return 0; |
| 346 | default: return ret; |
| 347 | } |
| 348 | |
| 349 | _debug("unmarshall UUID"); |
Christoph Hellwig | 41bb26f | 2017-05-28 08:56:46 +0300 | [diff] [blame] | 350 | call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL); |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 351 | if (!call->request) |
| 352 | return -ENOMEM; |
| 353 | |
| 354 | b = call->buffer; |
| 355 | r = call->request; |
David Howells | ff54877 | 2017-02-10 16:34:07 +0000 | [diff] [blame] | 356 | r->time_low = b[0]; |
| 357 | r->time_mid = htons(ntohl(b[1])); |
| 358 | r->time_hi_and_version = htons(ntohl(b[2])); |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 359 | r->clock_seq_hi_and_reserved = ntohl(b[3]); |
| 360 | r->clock_seq_low = ntohl(b[4]); |
| 361 | |
| 362 | for (loop = 0; loop < 6; loop++) |
| 363 | r->node[loop] = ntohl(b[loop + 5]); |
| 364 | |
| 365 | call->offset = 0; |
| 366 | call->unmarshall++; |
| 367 | |
| 368 | case 2: |
| 369 | break; |
| 370 | } |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 371 | |
David Howells | 98bf40c | 2017-11-02 15:27:53 +0000 | [diff] [blame] | 372 | if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING)) |
| 373 | return -EIO; |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 374 | |
| 375 | /* we'll need the file server record as that tells us which set of |
| 376 | * vnodes to operate upon */ |
David Howells | 001ab5a67 | 2018-05-11 23:21:35 +0100 | [diff] [blame] | 377 | rcu_read_lock(); |
David Howells | a86b06d | 2018-05-11 23:45:40 +0100 | [diff] [blame] | 378 | call->cm_server = afs_find_server_by_uuid(call->net, call->request); |
David Howells | 001ab5a67 | 2018-05-11 23:21:35 +0100 | [diff] [blame] | 379 | rcu_read_unlock(); |
David Howells | a86b06d | 2018-05-11 23:45:40 +0100 | [diff] [blame] | 380 | if (!call->cm_server) |
David Howells | 3709a39 | 2018-05-11 22:59:42 +0100 | [diff] [blame] | 381 | trace_afs_cm_no_server_u(call, call->request); |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 382 | |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 383 | return afs_queue_call_work(call); |
David Howells | c35eccb | 2007-04-26 15:58:49 -0700 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 387 | * allow the fileserver to see if the cache manager is still alive |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 389 | static void SRXAFSCB_Probe(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | { |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 391 | struct afs_call *call = container_of(work, struct afs_call, work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 393 | _enter(""); |
| 394 | afs_send_empty_reply(call); |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 395 | afs_put_call(call); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 396 | _leave(""); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 397 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 400 | * deliver request data to a CB.Probe call |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | */ |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 402 | static int afs_deliver_cb_probe(struct afs_call *call) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | { |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 404 | int ret; |
| 405 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 406 | _enter(""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 408 | ret = afs_extract_data(call, NULL, 0, false); |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 409 | if (ret < 0) |
| 410 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
David Howells | 98bf40c | 2017-11-02 15:27:53 +0000 | [diff] [blame] | 412 | if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING)) |
| 413 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 415 | return afs_queue_call_work(call); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 416 | } |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 417 | |
| 418 | /* |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 419 | * allow the fileserver to quickly find out if the fileserver has been rebooted |
| 420 | */ |
| 421 | static void SRXAFSCB_ProbeUuid(struct work_struct *work) |
| 422 | { |
| 423 | struct afs_call *call = container_of(work, struct afs_call, work); |
Christoph Hellwig | 41bb26f | 2017-05-28 08:56:46 +0300 | [diff] [blame] | 424 | struct afs_uuid *r = call->request; |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 425 | |
| 426 | struct { |
| 427 | __be32 match; |
| 428 | } reply; |
| 429 | |
| 430 | _enter(""); |
| 431 | |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 432 | if (memcmp(r, &call->net->uuid, sizeof(call->net->uuid)) == 0) |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 433 | reply.match = htonl(0); |
| 434 | else |
| 435 | reply.match = htonl(1); |
| 436 | |
| 437 | afs_send_simple_reply(call, &reply, sizeof(reply)); |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 438 | afs_put_call(call); |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 439 | _leave(""); |
| 440 | } |
| 441 | |
| 442 | /* |
| 443 | * deliver request data to a CB.ProbeUuid call |
| 444 | */ |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 445 | static int afs_deliver_cb_probe_uuid(struct afs_call *call) |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 446 | { |
Christoph Hellwig | 41bb26f | 2017-05-28 08:56:46 +0300 | [diff] [blame] | 447 | struct afs_uuid *r; |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 448 | unsigned loop; |
| 449 | __be32 *b; |
| 450 | int ret; |
| 451 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 452 | _enter("{%u}", call->unmarshall); |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 453 | |
| 454 | switch (call->unmarshall) { |
| 455 | case 0: |
| 456 | call->offset = 0; |
Kees Cook | 6da2ec5 | 2018-06-12 13:55:00 -0700 | [diff] [blame] | 457 | call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL); |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 458 | if (!call->buffer) |
| 459 | return -ENOMEM; |
| 460 | call->unmarshall++; |
| 461 | |
| 462 | case 1: |
| 463 | _debug("extract UUID"); |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 464 | ret = afs_extract_data(call, call->buffer, |
| 465 | 11 * sizeof(__be32), false); |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 466 | switch (ret) { |
| 467 | case 0: break; |
| 468 | case -EAGAIN: return 0; |
| 469 | default: return ret; |
| 470 | } |
| 471 | |
| 472 | _debug("unmarshall UUID"); |
Christoph Hellwig | 41bb26f | 2017-05-28 08:56:46 +0300 | [diff] [blame] | 473 | call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL); |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 474 | if (!call->request) |
| 475 | return -ENOMEM; |
| 476 | |
| 477 | b = call->buffer; |
| 478 | r = call->request; |
David Howells | fe342cf | 2018-04-09 21:12:31 +0100 | [diff] [blame] | 479 | r->time_low = b[0]; |
| 480 | r->time_mid = htons(ntohl(b[1])); |
| 481 | r->time_hi_and_version = htons(ntohl(b[2])); |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 482 | r->clock_seq_hi_and_reserved = ntohl(b[3]); |
| 483 | r->clock_seq_low = ntohl(b[4]); |
| 484 | |
| 485 | for (loop = 0; loop < 6; loop++) |
| 486 | r->node[loop] = ntohl(b[loop + 5]); |
| 487 | |
| 488 | call->offset = 0; |
| 489 | call->unmarshall++; |
| 490 | |
| 491 | case 2: |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 492 | break; |
| 493 | } |
| 494 | |
David Howells | 98bf40c | 2017-11-02 15:27:53 +0000 | [diff] [blame] | 495 | if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING)) |
| 496 | return -EIO; |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 497 | |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 498 | return afs_queue_call_work(call); |
David Howells | 9396d49 | 2008-04-29 01:03:22 -0700 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | /* |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 502 | * allow the fileserver to ask about the cache manager's capabilities |
| 503 | */ |
David Howells | 7c80bcc | 2008-04-29 01:03:21 -0700 | [diff] [blame] | 504 | static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work) |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 505 | { |
| 506 | struct afs_interface *ifs; |
| 507 | struct afs_call *call = container_of(work, struct afs_call, work); |
| 508 | int loop, nifs; |
| 509 | |
| 510 | struct { |
| 511 | struct /* InterfaceAddr */ { |
| 512 | __be32 nifs; |
| 513 | __be32 uuid[11]; |
| 514 | __be32 ifaddr[32]; |
| 515 | __be32 netmask[32]; |
| 516 | __be32 mtu[32]; |
| 517 | } ia; |
| 518 | struct /* Capabilities */ { |
| 519 | __be32 capcount; |
| 520 | __be32 caps[1]; |
| 521 | } cap; |
| 522 | } reply; |
| 523 | |
| 524 | _enter(""); |
| 525 | |
| 526 | nifs = 0; |
| 527 | ifs = kcalloc(32, sizeof(*ifs), GFP_KERNEL); |
| 528 | if (ifs) { |
David Howells | 5b86d4f | 2018-05-18 11:46:15 +0100 | [diff] [blame] | 529 | nifs = afs_get_ipv4_interfaces(call->net, ifs, 32, false); |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 530 | if (nifs < 0) { |
| 531 | kfree(ifs); |
| 532 | ifs = NULL; |
| 533 | nifs = 0; |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | memset(&reply, 0, sizeof(reply)); |
| 538 | reply.ia.nifs = htonl(nifs); |
| 539 | |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 540 | reply.ia.uuid[0] = call->net->uuid.time_low; |
| 541 | reply.ia.uuid[1] = htonl(ntohs(call->net->uuid.time_mid)); |
| 542 | reply.ia.uuid[2] = htonl(ntohs(call->net->uuid.time_hi_and_version)); |
| 543 | reply.ia.uuid[3] = htonl((s8) call->net->uuid.clock_seq_hi_and_reserved); |
| 544 | reply.ia.uuid[4] = htonl((s8) call->net->uuid.clock_seq_low); |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 545 | for (loop = 0; loop < 6; loop++) |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 546 | reply.ia.uuid[loop + 5] = htonl((s8) call->net->uuid.node[loop]); |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 547 | |
| 548 | if (ifs) { |
| 549 | for (loop = 0; loop < nifs; loop++) { |
| 550 | reply.ia.ifaddr[loop] = ifs[loop].address.s_addr; |
| 551 | reply.ia.netmask[loop] = ifs[loop].netmask.s_addr; |
| 552 | reply.ia.mtu[loop] = htonl(ifs[loop].mtu); |
| 553 | } |
Patrick McHardy | 5b35fad | 2007-05-03 03:27:39 -0700 | [diff] [blame] | 554 | kfree(ifs); |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | reply.cap.capcount = htonl(1); |
| 558 | reply.cap.caps[0] = htonl(AFS_CAP_ERROR_TRANSLATION); |
| 559 | afs_send_simple_reply(call, &reply, sizeof(reply)); |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 560 | afs_put_call(call); |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 561 | _leave(""); |
| 562 | } |
| 563 | |
| 564 | /* |
David Howells | 7c80bcc | 2008-04-29 01:03:21 -0700 | [diff] [blame] | 565 | * deliver request data to a CB.TellMeAboutYourself call |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 566 | */ |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 567 | static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *call) |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 568 | { |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 569 | int ret; |
| 570 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 571 | _enter(""); |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 572 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 573 | ret = afs_extract_data(call, NULL, 0, false); |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 574 | if (ret < 0) |
| 575 | return ret; |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 576 | |
David Howells | 98bf40c | 2017-11-02 15:27:53 +0000 | [diff] [blame] | 577 | if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING)) |
| 578 | return -EIO; |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 579 | |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 580 | return afs_queue_call_work(call); |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 581 | } |