aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2008-12-04 14:20:08 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-01-06 11:53:49 -0500
commitbc995801a09d1fead0bec1356bfd836911c8eed7 (patch)
treeb7a2faad59bfa92db4057c23fcf7d31b70d20611 /fs/lockd
parent6999fb4016b2604c2f8a65586bba4a62a4b24ce7 (diff)
NLM: Support IPv6 scope IDs in nlm_display_address()
Scope ID support is needed since the kernel's NSM implementation is about to use these displayed addresses as a mon_name in some cases. When nsm_use_hostnames is zero, without scope ID support NSM will fail to handle peers that contact us via a link-local address. Link-local addresses do not work without an interface ID, which is stored in the sockaddr's sin6_scope_id field. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/host.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index beb5da810167..012e49aaecd1 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -105,22 +105,31 @@ static void nlm_clear_port(struct sockaddr *sap)
105 } 105 }
106} 106}
107 107
108static void nlm_display_ipv6_address(const struct sockaddr *sap, char *buf,
109 const size_t len)
110{
111 const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
112
113 if (ipv6_addr_v4mapped(&sin6->sin6_addr))
114 snprintf(buf, len, "%pI4", &sin6->sin6_addr.s6_addr32[3]);
115 else if (sin6->sin6_scope_id != 0)
116 snprintf(buf, len, "%pI6%%%u", &sin6->sin6_addr,
117 sin6->sin6_scope_id);
118 else
119 snprintf(buf, len, "%pI6", &sin6->sin6_addr);
120}
121
108static void nlm_display_address(const struct sockaddr *sap, 122static void nlm_display_address(const struct sockaddr *sap,
109 char *buf, const size_t len) 123 char *buf, const size_t len)
110{ 124{
111 const struct sockaddr_in *sin = (struct sockaddr_in *)sap; 125 const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
112 const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
113 126
114 switch (sap->sa_family) { 127 switch (sap->sa_family) {
115 case AF_INET: 128 case AF_INET:
116 snprintf(buf, len, "%pI4", &sin->sin_addr.s_addr); 129 snprintf(buf, len, "%pI4", &sin->sin_addr.s_addr);
117 break; 130 break;
118 case AF_INET6: 131 case AF_INET6:
119 if (ipv6_addr_v4mapped(&sin6->sin6_addr)) 132 nlm_display_ipv6_address(sap, buf, len);
120 snprintf(buf, len, "%pI4",
121 &sin6->sin6_addr.s6_addr32[3]);
122 else
123 snprintf(buf, len, "%pI6", &sin6->sin6_addr);
124 break; 133 break;
125 default: 134 default:
126 snprintf(buf, len, "unsupported address family"); 135 snprintf(buf, len, "unsupported address family");