libceph: use TYPE_LEGACY for entity addrs instead of TYPE_NONE
Going forward, we'll have different address types so let's use the addr2 TYPE_LEGACY for internal tracking rather than TYPE_NONE. Also, make ceph_pr_addr print the address type value as well. Signed-off-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
2f9800c899
commit
d3c3c0a841
|
@ -218,16 +218,23 @@ static inline void ceph_encode_timespec64(struct ceph_timespec *tv,
|
||||||
/*
|
/*
|
||||||
* sockaddr_storage <-> ceph_sockaddr
|
* sockaddr_storage <-> ceph_sockaddr
|
||||||
*/
|
*/
|
||||||
|
#define CEPH_ENTITY_ADDR_TYPE_NONE 0
|
||||||
|
#define CEPH_ENTITY_ADDR_TYPE_LEGACY __cpu_to_le32(1)
|
||||||
|
|
||||||
static inline void ceph_encode_addr(struct ceph_entity_addr *a)
|
static inline void ceph_encode_addr(struct ceph_entity_addr *a)
|
||||||
{
|
{
|
||||||
__be16 ss_family = htons(a->in_addr.ss_family);
|
__be16 ss_family = htons(a->in_addr.ss_family);
|
||||||
a->in_addr.ss_family = *(__u16 *)&ss_family;
|
a->in_addr.ss_family = *(__u16 *)&ss_family;
|
||||||
|
|
||||||
|
/* Banner addresses require TYPE_NONE */
|
||||||
|
a->type = CEPH_ENTITY_ADDR_TYPE_NONE;
|
||||||
}
|
}
|
||||||
static inline void ceph_decode_addr(struct ceph_entity_addr *a)
|
static inline void ceph_decode_addr(struct ceph_entity_addr *a)
|
||||||
{
|
{
|
||||||
__be16 ss_family = *(__be16 *)&a->in_addr.ss_family;
|
__be16 ss_family = *(__be16 *)&a->in_addr.ss_family;
|
||||||
a->in_addr.ss_family = ntohs(ss_family);
|
a->in_addr.ss_family = ntohs(ss_family);
|
||||||
WARN_ON(a->in_addr.ss_family == 512);
|
WARN_ON(a->in_addr.ss_family == 512);
|
||||||
|
a->type = CEPH_ENTITY_ADDR_TYPE_LEGACY;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ceph_decode_entity_addr(void **p, void *end,
|
extern int ceph_decode_entity_addr(void **p, void *end,
|
||||||
|
|
|
@ -21,17 +21,6 @@ ceph_decode_entity_addr_versioned(void **p, void *end,
|
||||||
|
|
||||||
ceph_decode_copy_safe(p, end, &addr->type, sizeof(addr->type), bad);
|
ceph_decode_copy_safe(p, end, &addr->type, sizeof(addr->type), bad);
|
||||||
|
|
||||||
/*
|
|
||||||
* TYPE_NONE == 0
|
|
||||||
* TYPE_LEGACY == 1
|
|
||||||
*
|
|
||||||
* Clients that don't support ADDR2 always send TYPE_NONE.
|
|
||||||
* For now, since all we support is msgr1, just set this to 0
|
|
||||||
* when we get a TYPE_LEGACY type.
|
|
||||||
*/
|
|
||||||
if (addr->type == cpu_to_le32(1))
|
|
||||||
addr->type = 0;
|
|
||||||
|
|
||||||
ceph_decode_copy_safe(p, end, &addr->nonce, sizeof(addr->nonce), bad);
|
ceph_decode_copy_safe(p, end, &addr->nonce, sizeof(addr->nonce), bad);
|
||||||
|
|
||||||
ceph_decode_32_safe(p, end, addr_len, bad);
|
ceph_decode_32_safe(p, end, addr_len, bad);
|
||||||
|
@ -61,7 +50,12 @@ ceph_decode_entity_addr_legacy(void **p, void *end,
|
||||||
|
|
||||||
/* Skip rest of type field */
|
/* Skip rest of type field */
|
||||||
ceph_decode_skip_n(p, end, 3, bad);
|
ceph_decode_skip_n(p, end, 3, bad);
|
||||||
addr->type = 0;
|
|
||||||
|
/*
|
||||||
|
* Clients that don't support ADDR2 always send TYPE_NONE, change it
|
||||||
|
* to TYPE_LEGACY for forward compatibility.
|
||||||
|
*/
|
||||||
|
addr->type = CEPH_ENTITY_ADDR_TYPE_LEGACY;
|
||||||
ceph_decode_copy_safe(p, end, &addr->nonce, sizeof(addr->nonce), bad);
|
ceph_decode_copy_safe(p, end, &addr->nonce, sizeof(addr->nonce), bad);
|
||||||
memset(&addr->in_addr, 0, sizeof(addr->in_addr));
|
memset(&addr->in_addr, 0, sizeof(addr->in_addr));
|
||||||
ceph_decode_copy_safe(p, end, &addr->in_addr,
|
ceph_decode_copy_safe(p, end, &addr->in_addr,
|
||||||
|
|
|
@ -199,12 +199,14 @@ const char *ceph_pr_addr(const struct ceph_entity_addr *addr)
|
||||||
|
|
||||||
switch (ss.ss_family) {
|
switch (ss.ss_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
snprintf(s, MAX_ADDR_STR_LEN, "%pI4:%hu", &in4->sin_addr,
|
snprintf(s, MAX_ADDR_STR_LEN, "(%d)%pI4:%hu",
|
||||||
|
le32_to_cpu(addr->type), &in4->sin_addr,
|
||||||
ntohs(in4->sin_port));
|
ntohs(in4->sin_port));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
snprintf(s, MAX_ADDR_STR_LEN, "[%pI6c]:%hu", &in6->sin6_addr,
|
snprintf(s, MAX_ADDR_STR_LEN, "(%d)[%pI6c]:%hu",
|
||||||
|
le32_to_cpu(addr->type), &in6->sin6_addr,
|
||||||
ntohs(in6->sin6_port));
|
ntohs(in6->sin6_port));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1982,6 +1984,7 @@ int ceph_parse_ips(const char *c, const char *end,
|
||||||
}
|
}
|
||||||
|
|
||||||
addr_set_port(&addr[i], port);
|
addr_set_port(&addr[i], port);
|
||||||
|
addr[i].type = CEPH_ENTITY_ADDR_TYPE_LEGACY;
|
||||||
|
|
||||||
dout("parse_ips got %s\n", ceph_pr_addr(&addr[i]));
|
dout("parse_ips got %s\n", ceph_pr_addr(&addr[i]));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue