summaryrefslogtreecommitdiff
path: root/fs/afs/cell.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2017-11-02 15:27:47 +0000
committerDavid Howells <dhowells@redhat.com>2017-11-13 15:38:17 +0000
commit4d9df9868f31df6725481135c10ac6419ce58d44 (patch)
treec4fcbe437438c940485d438ad5c5871ab20d3288 /fs/afs/cell.c
parentad6a942a9e74edea8a4a126a1e434feff6a6d5c2 (diff)
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/cell.c')
-rw-r--r--fs/afs/cell.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/fs/afs/cell.c b/fs/afs/cell.c
index 2224e335eed7..5523fa3c05d9 100644
--- a/fs/afs/cell.c
+++ b/fs/afs/cell.c
@@ -31,7 +31,7 @@ static struct afs_cell *afs_cell_alloc(struct afs_net *net,
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);
@@ -61,6 +61,14 @@ static struct afs_cell *afs_cell_alloc(struct afs_net *net,
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);
@@ -83,6 +91,7 @@ static struct afs_cell *afs_cell_alloc(struct afs_net *net,
/* 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);
@@ -95,10 +104,13 @@ static struct afs_cell *afs_cell_alloc(struct afs_net *net,
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);