aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
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");