summaryrefslogtreecommitdiff
path: root/fs/afs/server.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2017-11-02 18:27:47 +0300
committerDavid Howells <dhowells@redhat.com>2017-11-13 18:38:17 +0300
commit4d9df9868f31df6725481135c10ac6419ce58d44 (patch)
treec4fcbe437438c940485d438ad5c5871ab20d3288 /fs/afs/server.c
parentad6a942a9e74edea8a4a126a1e434feff6a6d5c2 (diff)
downloadlinux-4d9df9868f31df6725481135c10ac6419ce58d44.tar.xz
afs: Keep and pass sockaddr_rxrpc addresses rather than in_addr
Keep and pass sockaddr_rxrpc addresses around rather than keeping and passing in_addr addresses to allow for the use of IPv6 and non-standard port numbers in future. This also allows the port and service_id fields to be removed from the afs_call struct. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs/server.c')
-rw-r--r--fs/afs/server.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/fs/afs/server.c b/fs/afs/server.c
index d8044be913f0..662f7fbf5d05 100644
--- a/fs/afs/server.c
+++ b/fs/afs/server.c
@@ -11,6 +11,7 @@
#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 */
@@ -42,7 +43,7 @@ static int afs_install_server(struct afs_server *server)
struct afs_server *xserver;
struct afs_net *net = server->cell->net;
struct rb_node **pp, *p;
- int ret;
+ int ret, diff;
_enter("%p", server);
@@ -55,9 +56,10 @@ static int afs_install_server(struct afs_server *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;
@@ -76,7 +78,7 @@ 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;
@@ -99,8 +101,7 @@ static struct afs_server *afs_alloc_server(struct afs_cell *cell,
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 {
@@ -113,17 +114,17 @@ static struct afs_server *afs_alloc_server(struct afs_cell *cell,
* 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);
@@ -138,7 +139,7 @@ struct afs_server *afs_lookup_server(struct afs_cell *cell,
/* 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;
}
@@ -195,9 +196,9 @@ struct afs_server *afs_find_server(struct afs_net *net,
{
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");
@@ -212,9 +213,10 @@ struct afs_server *afs_find_server(struct afs_net *net,
_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);
@@ -225,7 +227,6 @@ struct afs_server *afs_find_server(struct afs_net *net,
server = NULL;
found:
read_unlock(&net->servers_lock);
- ASSERTIFCMP(server, server->addr.s_addr, ==, addr.s_addr);
_leave(" = %p", server);
return server;
}