Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 127441
b: refs/heads/master
c: bc99580
h: refs/heads/master
i:
  127439: 2bd4ae5
v: v3
  • Loading branch information
Chuck Lever authored and J. Bruce Fields committed Jan 6, 2009
1 parent efbe8e7 commit cb36653
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6999fb4016b2604c2f8a65586bba4a62a4b24ce7
refs/heads/master: bc995801a09d1fead0bec1356bfd836911c8eed7
21 changes: 15 additions & 6 deletions trunk/fs/lockd/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,31 @@ static void nlm_clear_port(struct sockaddr *sap)
}
}

static void nlm_display_ipv6_address(const struct sockaddr *sap, char *buf,
const size_t len)
{
const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;

if (ipv6_addr_v4mapped(&sin6->sin6_addr))
snprintf(buf, len, "%pI4", &sin6->sin6_addr.s6_addr32[3]);
else if (sin6->sin6_scope_id != 0)
snprintf(buf, len, "%pI6%%%u", &sin6->sin6_addr,
sin6->sin6_scope_id);
else
snprintf(buf, len, "%pI6", &sin6->sin6_addr);
}

static void nlm_display_address(const struct sockaddr *sap,
char *buf, const size_t len)
{
const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;

switch (sap->sa_family) {
case AF_INET:
snprintf(buf, len, "%pI4", &sin->sin_addr.s_addr);
break;
case AF_INET6:
if (ipv6_addr_v4mapped(&sin6->sin6_addr))
snprintf(buf, len, "%pI4",
&sin6->sin6_addr.s6_addr32[3]);
else
snprintf(buf, len, "%pI6", &sin6->sin6_addr);
nlm_display_ipv6_address(sap, buf, len);
break;
default:
snprintf(buf, len, "unsupported address family");
Expand Down
10 changes: 9 additions & 1 deletion trunk/include/linux/lockd/lockd.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ struct nlm_host {
char *h_addrbuf; /* address eyecatcher */
};

/*
* The largest string sm_addrbuf should hold is a full-size IPv6 address
* (no "::" anywhere) with a scope ID. The buffer size is computed to
* hold eight groups of colon-separated four-hex-digit numbers, a
* percent sign, a scope id (at most 32 bits, in decimal), and NUL.
*/
#define NSM_ADDRBUF ((8 * 4 + 7) + (1 + 10) + 1)

struct nsm_handle {
struct list_head sm_link;
atomic_t sm_count;
Expand All @@ -76,7 +84,7 @@ struct nsm_handle {
size_t sm_addrlen;
unsigned int sm_monitored : 1,
sm_sticky : 1; /* don't unmonitor */
char sm_addrbuf[48]; /* address eyecatcher */
char sm_addrbuf[NSM_ADDRBUF];
};

/*
Expand Down

0 comments on commit cb36653

Please sign in to comment.