char keyname[4 + AFS_MAXCELLNAME + 1], *cp, *dp, *next;
char *dvllist = NULL, *_vllist = NULL;
char delimiter = ':';
- int ret;
+ int ret, i;
_enter("%*.*s,%s", namelen, namelen, name ?: "", vllist);
INIT_LIST_HEAD(&cell->vl_list);
spin_lock_init(&cell->vl_lock);
+ for (i = 0; i < AFS_CELL_MAX_ADDRS; i++) {
+ struct sockaddr_rxrpc *srx = &cell->vl_addrs[i];
+ srx->srx_family = AF_RXRPC;
+ srx->srx_service = VL_SERVICE;
+ srx->transport_type = SOCK_DGRAM;
+ srx->transport.sin.sin_port = htons(AFS_VL_PORT);
+ }
+
/* if the ip address is invalid, try dns query */
if (!vllist || strlen(vllist) < 7) {
ret = dns_query("afsdb", name, namelen, "ipv4", &dvllist, NULL);
/* fill in the VL server list from the rest of the string */
do {
+ struct sockaddr_rxrpc *srx = &cell->vl_addrs[cell->vl_naddrs];
unsigned a, b, c, d;
next = strchr(_vllist, delimiter);
if (a > 255 || b > 255 || c > 255 || d > 255)
goto bad_address;
- cell->vl_addrs[cell->vl_naddrs++].s_addr =
+ srx->transport_len = sizeof(struct sockaddr_in);
+ srx->transport.sin.sin_family = AF_INET;
+ srx->transport.sin.sin_addr.s_addr =
htonl((a << 24) | (b << 16) | (c << 8) | d);
- } while (cell->vl_naddrs < AFS_CELL_MAX_ADDRS && (_vllist = next));
+ } while (cell->vl_naddrs++,
+ cell->vl_naddrs < AFS_CELL_MAX_ADDRS && (_vllist = next));
/* create a key to represent an anonymous user */
memcpy(keyname, "afs@", 4);
call->key = key;
call->reply = vnode;
call->reply2 = volsync;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
call->reply = vnode;
call->reply2 = NULL; /* volsync */
call->reply3 = req;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
call->operation_ID = FSFETCHDATA64;
/* marshall the parameters */
call->reply = vnode;
call->reply2 = NULL; /* volsync */
call->reply3 = req;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
call->operation_ID = FSFETCHDATA;
/* marshall the parameters */
if (!call)
return -ENOMEM;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
call->reply2 = newfid;
call->reply3 = newstatus;
call->reply4 = newcb;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
call->key = key;
call->reply = vnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
call->key = key;
call->reply = dvnode;
call->reply2 = vnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
call->reply = vnode;
call->reply2 = newfid;
call->reply3 = newstatus;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
call->key = key;
call->reply = orig_dvnode;
call->reply2 = new_dvnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
call->wb = wb;
call->key = wb->key;
call->reply = vnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
call->mapping = vnode->vfs_inode.i_mapping;
call->first = first;
call->last = last;
call->wb = wb;
call->key = wb->key;
call->reply = vnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
call->mapping = vnode->vfs_inode.i_mapping;
call->first = first;
call->last = last;
call->key = key;
call->reply = vnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
call->store_version = vnode->status.data_version + 1;
call->operation_ID = FSSTOREDATA;
call->key = key;
call->reply = vnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
call->store_version = vnode->status.data_version + 1;
call->operation_ID = FSSTOREDATA;
call->key = key;
call->reply = vnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
call->operation_ID = FSSTORESTATUS;
/* marshall the parameters */
call->reply = vnode;
call->reply2 = vs;
call->reply3 = tmpbuf;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
call->key = key;
call->reply = vnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
call->key = key;
call->reply = vnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
call->key = key;
call->reply = vnode;
- call->service_id = FS_SERVICE;
- call->port = htons(AFS_FS_PORT);
/* marshall the parameters */
bp = call->request;
bool async; /* T if asynchronous */
bool upgrade; /* T to request service upgrade */
u16 service_id; /* RxRPC service ID to call */
- __be16 port; /* target UDP port */
u32 operation_ID; /* operation ID for an incoming call */
u32 count; /* count for use in unmarshalling */
__be32 tmp; /* place to extract temporary data */
spinlock_t vl_lock; /* vl_list lock */
unsigned short vl_naddrs; /* number of VL servers in addr list */
unsigned short vl_curr_svix; /* current server index */
- struct in_addr vl_addrs[AFS_CELL_MAX_ADDRS]; /* cell VL server addresses */
+ struct sockaddr_rxrpc vl_addrs[AFS_CELL_MAX_ADDRS]; /* cell VL server addresses */
char name[0]; /* cell name - must go last */
};
#define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */
afs_volid_t vid[3]; /* volume IDs for R/W, R/O and Bak volumes */
- struct in_addr servers[8]; /* fileserver addresses */
+ struct sockaddr_rxrpc servers[8]; /* fileserver addresses */
time_t rtime; /* last retrieval time */
};
struct afs_server {
atomic_t usage;
time64_t time_of_death; /* time at which put reduced usage to 0 */
- struct in_addr addr; /* server address */
+ struct sockaddr_rxrpc addr; /* server address */
struct afs_net *net; /* Network namespace in which the server resides */
struct afs_cell *cell; /* cell in which server resides */
struct list_head link; /* link in cell's server list */
extern void afs_charge_preallocation(struct work_struct *);
extern void afs_put_call(struct afs_call *);
extern int afs_queue_call_work(struct afs_call *);
-extern int afs_make_call(struct in_addr *, struct afs_call *, gfp_t, bool);
+extern int afs_make_call(struct sockaddr_rxrpc *, struct afs_call *, gfp_t, bool);
extern struct afs_call *afs_alloc_flat_call(struct afs_net *,
const struct afs_call_type *,
size_t, size_t);
extern void afs_server_timer(struct timer_list *);
extern struct afs_server *afs_lookup_server(struct afs_cell *,
- const struct in_addr *);
+ struct sockaddr_rxrpc *);
extern struct afs_server *afs_find_server(struct afs_net *,
const struct sockaddr_rxrpc *);
extern void afs_put_server(struct afs_net *, struct afs_server *);
* vlclient.c
*/
extern int afs_vl_get_entry_by_name(struct afs_net *,
- struct in_addr *, struct key *,
+ struct sockaddr_rxrpc *, struct key *,
const char *, struct afs_cache_vlocation *,
bool);
extern int afs_vl_get_entry_by_id(struct afs_net *,
- struct in_addr *, struct key *,
+ struct sockaddr_rxrpc *, struct key *,
afs_volid_t, afs_voltype_t,
struct afs_cache_vlocation *, bool);
*/
static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v)
{
- struct in_addr *addr = v;
+ struct sockaddr_rxrpc *addr = v;
/* display header on line 1 */
- if (v == (struct in_addr *) 1) {
+ if (v == (void *)1) {
seq_puts(m, "ADDRESS\n");
return 0;
}
/* display one cell per line on subsequent lines */
- seq_printf(m, "%pI4\n", &addr->s_addr);
+ seq_printf(m, "%pISp\n", &addr->transport);
return 0;
}
{
struct afs_cell *cell = m->private;
struct afs_server *server = list_entry(v, struct afs_server, link);
- char ipaddr[20];
+ char ipaddr[64];
/* display header on line 1 */
if (v == &cell->servers) {
}
/* display one cell per line on subsequent lines */
- sprintf(ipaddr, "%pI4", &server->addr);
+ sprintf(ipaddr, "%pISp", &server->addr.transport);
seq_printf(m, "%3d %-15.15s %5d\n",
atomic_read(&server->usage), ipaddr, server->fs_state);
/*
* initiate a call
*/
-int afs_make_call(struct in_addr *addr, struct afs_call *call, gfp_t gfp,
- bool async)
+int afs_make_call(struct sockaddr_rxrpc *srx, struct afs_call *call,
+ gfp_t gfp, bool async)
{
- struct sockaddr_rxrpc srx;
struct rxrpc_call *rxcall;
struct msghdr msg;
struct kvec iov[1];
u32 abort_code;
int ret;
- _enter("%x,{%d},", addr->s_addr, ntohs(call->port));
+ _enter(",{%pISp},", &srx->transport);
ASSERT(call->type != NULL);
ASSERT(call->type->name != NULL);
call->async = async;
- memset(&srx, 0, sizeof(srx));
- srx.srx_family = AF_RXRPC;
- srx.srx_service = call->service_id;
- srx.transport_type = SOCK_DGRAM;
- srx.transport_len = sizeof(srx.transport.sin);
- srx.transport.sin.sin_family = AF_INET;
- srx.transport.sin.sin_port = call->port;
- memcpy(&srx.transport.sin.sin_addr, addr, 4);
-
/* Work out the length we're going to transmit. This is awkward for
* calls such as FS.StoreData where there's an extra injection of data
* after the initial fixed part.
}
/* create a call */
- rxcall = rxrpc_kernel_begin_call(call->net->socket, &srx, call->key,
+ rxcall = rxrpc_kernel_begin_call(call->net->socket, srx, call->key,
(unsigned long)call,
tx_total_len, gfp,
(async ?
#include <linux/sched.h>
#include <linux/slab.h>
+#include "afs_fs.h"
#include "internal.h"
static unsigned afs_server_timeout = 10; /* server timeout in seconds */
struct afs_server *xserver;
struct afs_net *net = server->cell->net;
struct rb_node **pp, *p;
- int ret;
+ int ret, diff;
_enter("%p", server);
p = *pp;
_debug("- consider %p", p);
xserver = rb_entry(p, struct afs_server, master_rb);
- if (server->addr.s_addr < xserver->addr.s_addr)
+ diff = memcmp(&server->addr, &xserver->addr, sizeof(server->addr));
+ if (diff < 0)
pp = &(*pp)->rb_left;
- else if (server->addr.s_addr > xserver->addr.s_addr)
+ else if (diff > 0)
pp = &(*pp)->rb_right;
else
goto error;
* allocate a new server record
*/
static struct afs_server *afs_alloc_server(struct afs_cell *cell,
- const struct in_addr *addr)
+ const struct sockaddr_rxrpc *addr)
{
struct afs_server *server;
INIT_DELAYED_WORK(&server->cb_break_work,
afs_dispatch_give_up_callbacks);
- memcpy(&server->addr, addr, sizeof(struct in_addr));
- server->addr.s_addr = addr->s_addr;
+ server->addr = *addr;
afs_inc_servers_outstanding(cell->net);
_leave(" = %p{%d}", server, atomic_read(&server->usage));
} else {
* get an FS-server record for a cell
*/
struct afs_server *afs_lookup_server(struct afs_cell *cell,
- const struct in_addr *addr)
+ struct sockaddr_rxrpc *addr)
{
struct afs_server *server, *candidate;
- _enter("%p,%pI4", cell, &addr->s_addr);
+ _enter("%p,%pIS", cell, &addr->transport);
/* quick scan of the list to see if we already have the server */
read_lock(&cell->servers_lock);
list_for_each_entry(server, &cell->servers, link) {
- if (server->addr.s_addr == addr->s_addr)
+ if (memcmp(&server->addr, addr, sizeof(*addr)) == 0)
goto found_server_quickly;
}
read_unlock(&cell->servers_lock);
/* check the cell's server list again */
list_for_each_entry(server, &cell->servers, link) {
- if (server->addr.s_addr == addr->s_addr)
+ if (memcmp(&server->addr, addr, sizeof(*addr)) == 0)
goto found_server;
}
{
struct afs_server *server = NULL;
struct rb_node *p;
- struct in_addr addr = srx->transport.sin.sin_addr;
+ int diff;
- _enter("{%d,%pI4}", srx->transport.family, &addr.s_addr);
+ _enter("{%d,%pIS}", srx->transport.family, &srx->transport);
if (srx->transport.family != AF_INET) {
WARN(true, "AFS does not yes support non-IPv4 addresses\n");
_debug("- consider %p", p);
- if (addr.s_addr < server->addr.s_addr) {
+ diff = memcmp(srx, &server->addr, sizeof(*srx));
+ if (diff < 0) {
p = p->rb_left;
- } else if (addr.s_addr > server->addr.s_addr) {
+ } else if (diff > 0) {
p = p->rb_right;
} else {
afs_get_server(server);
server = NULL;
found:
read_unlock(&net->servers_lock);
- ASSERTIFCMP(server, server->addr.s_addr, ==, addr.s_addr);
_leave(" = %p", server);
return server;
}
#include <linux/gfp.h>
#include <linux/init.h>
#include <linux/sched.h>
+#include "afs_fs.h"
#include "internal.h"
/*
bp++; /* type */
entry->nservers = ntohl(*bp++);
- for (loop = 0; loop < 8; loop++)
- entry->servers[loop].s_addr = *bp++;
+ for (loop = 0; loop < 8; loop++) {
+ entry->servers[loop].srx_family = AF_RXRPC;
+ entry->servers[loop].srx_service = FS_SERVICE;
+ entry->servers[loop].transport_type = SOCK_DGRAM;
+ entry->servers[loop].transport_len = sizeof(entry->servers[loop].transport.sin);
+ entry->servers[loop].transport.sin.sin_family = AF_INET;
+ entry->servers[loop].transport.sin.sin_port = htons(AFS_FS_PORT);
+ entry->servers[loop].transport.sin.sin_addr.s_addr = *bp++;
+ }
bp += 8; /* partition IDs */
* dispatch a get volume entry by name operation
*/
int afs_vl_get_entry_by_name(struct afs_net *net,
- struct in_addr *addr,
+ struct sockaddr_rxrpc *addr,
struct key *key,
const char *volname,
struct afs_cache_vlocation *entry,
call->key = key;
call->reply = entry;
- call->service_id = VL_SERVICE;
- call->port = htons(AFS_VL_PORT);
/* marshall the parameters */
bp = call->request;
* dispatch a get volume entry by ID operation
*/
int afs_vl_get_entry_by_id(struct afs_net *net,
- struct in_addr *addr,
+ struct sockaddr_rxrpc *addr,
struct key *key,
afs_volid_t volid,
afs_voltype_t voltype,
call->key = key;
call->reply = entry;
- call->service_id = VL_SERVICE;
- call->port = htons(AFS_VL_PORT);
/* marshall the parameters */
bp = call->request;
struct afs_cache_vlocation *vldb)
{
struct afs_cell *cell = vl->cell;
- struct in_addr addr;
int count, ret;
_enter("%s,%s", cell->name, vl->vldb.name);
down_write(&vl->cell->vl_sem);
ret = -ENOMEDIUM;
for (count = cell->vl_naddrs; count > 0; count--) {
- addr = cell->vl_addrs[cell->vl_curr_svix];
+ struct sockaddr_rxrpc *addr = &cell->vl_addrs[cell->vl_curr_svix];
- _debug("CellServ[%hu]: %08x", cell->vl_curr_svix, addr.s_addr);
+ _debug("CellServ[%hu]: %pIS", cell->vl_curr_svix, &addr->transport);
/* attempt to access the VL server */
- ret = afs_vl_get_entry_by_name(cell->net, &addr, key,
+ ret = afs_vl_get_entry_by_name(cell->net, addr, key,
vl->vldb.name, vldb, false);
switch (ret) {
case 0:
struct afs_cache_vlocation *vldb)
{
struct afs_cell *cell = vl->cell;
- struct in_addr addr;
int count, ret;
_enter("%s,%x,%d,", cell->name, volid, voltype);
down_write(&vl->cell->vl_sem);
ret = -ENOMEDIUM;
for (count = cell->vl_naddrs; count > 0; count--) {
- addr = cell->vl_addrs[cell->vl_curr_svix];
+ struct sockaddr_rxrpc *addr = &cell->vl_addrs[cell->vl_curr_svix];
- _debug("CellServ[%hu]: %08x", cell->vl_curr_svix, addr.s_addr);
+ _debug("CellServ[%hu]: %pIS", cell->vl_curr_svix, &addr->transport);
/* attempt to access the VL server */
- ret = afs_vl_get_entry_by_id(cell->net, &addr, key, volid,
+ ret = afs_vl_get_entry_by_id(cell->net, addr, key, volid,
voltype, vldb, false);
switch (ret) {
case 0:
int ret;
/* try to look up a cached volume in the cell VL databases by ID */
- _debug("Locally Cached: %s %02x { %08x(%x) %08x(%x) %08x(%x) }",
- vl->vldb.name,
- vl->vldb.vidmask,
- ntohl(vl->vldb.servers[0].s_addr),
- vl->vldb.srvtmask[0],
- ntohl(vl->vldb.servers[1].s_addr),
- vl->vldb.srvtmask[1],
- ntohl(vl->vldb.servers[2].s_addr),
- vl->vldb.srvtmask[2]);
+ _debug("Locally Cached: %s %02x", vl->vldb.name, vl->vldb.vidmask);
_debug("Vids: %08x %08x %08x",
vl->vldb.vid[0],
static void afs_vlocation_apply_update(struct afs_vlocation *vl,
struct afs_cache_vlocation *vldb)
{
- _debug("Done VL Lookup: %s %02x { %08x(%x) %08x(%x) %08x(%x) }",
- vldb->name, vldb->vidmask,
- ntohl(vldb->servers[0].s_addr), vldb->srvtmask[0],
- ntohl(vldb->servers[1].s_addr), vldb->srvtmask[1],
- ntohl(vldb->servers[2].s_addr), vldb->srvtmask[2]);
+ _debug("Done VL Lookup: %s %02x", vldb->name, vldb->vidmask);
_debug("Vids: %08x %08x %08x",
vldb->vid[0], vldb->vid[1], vldb->vid[2]);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %p{%08x}",
- server, ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %p{%pIS}",
+ server, &server->addr.transport);
ret = afs_fs_fetch_file_status(server, key, vnode, NULL,
false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_fetch_data(server, key, vnode, desc,
false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_create(server, key, vnode, name, mode, newfid,
newstatus, newcb, false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_remove(server, key, vnode, name, isdir,
false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_link(server, key, dvnode, vnode, name,
false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_symlink(server, key, vnode, name, content,
newfid, newstatus, false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_rename(server, key, orig_dvnode, orig_name,
new_dvnode, new_name, false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_store_data(server, wb, first, last, offset, to,
false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_setattr(server, key, vnode, attr, false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_get_volume_status(server, key, vnode, vs, false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_set_lock(server, key, vnode, type, false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_extend_lock(server, key, vnode, false);
if (IS_ERR(server))
goto no_server;
- _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
+ _debug("USING SERVER: %pIS\n", &server->addr.transport);
ret = afs_fs_release_lock(server, key, vnode, false);
case 0:
afs_get_server(server);
up_read(&volume->server_sem);
- _leave(" = %p (picked %08x)",
- server, ntohl(server->addr.s_addr));
+ _leave(" = %p (picked %pIS)",
+ server, &server->addr.transport);
return server;
case -ENETUNREACH:
struct afs_volume *volume = vnode->volume;
unsigned loop;
- _enter("%s,%08x,%d",
- volume->vlocation->vldb.name, ntohl(server->addr.s_addr),
- result);
+ _enter("%s,%pIS,%d",
+ volume->vlocation->vldb.name, &server->addr.transport, result);
switch (result) {
/* success */