dfs.c (c900529f3d9161bfde5cca0754f83b4d3c3e0220) dfs.c (390c08fd3eeb3ebd0e9576de8b6eec8eae2d595d)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2022 Paulo Alcantara <palcantara@suse.de>
4 */
5
6#include "cifsproto.h"
7#include "cifs_debug.h"
8#include "dns_resolve.h"

--- 249 unchanged lines hidden (view full) ---

258 dfs_put_root_smb_sessions(&mnt_ctx->dfs_ses_list);
259 }
260
261out:
262 kfree(origin_fullpath);
263 return rc;
264}
265
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2022 Paulo Alcantara <palcantara@suse.de>
4 */
5
6#include "cifsproto.h"
7#include "cifs_debug.h"
8#include "dns_resolve.h"

--- 249 unchanged lines hidden (view full) ---

258 dfs_put_root_smb_sessions(&mnt_ctx->dfs_ses_list);
259 }
260
261out:
262 kfree(origin_fullpath);
263 return rc;
264}
265
266/* Resolve UNC hostname in @ctx->source and set ip addr in @ctx->dstaddr */
266/*
267 * If @ctx->dfs_automount, then update @ctx->dstaddr earlier with the DFS root
268 * server from where we'll start following any referrals. Otherwise rely on the
269 * value provided by mount(2) as the user might not have dns_resolver key set up
270 * and therefore failing to upcall to resolve UNC hostname under @ctx->source.
271 */
267static int update_fs_context_dstaddr(struct smb3_fs_context *ctx)
268{
269 struct sockaddr *addr = (struct sockaddr *)&ctx->dstaddr;
272static int update_fs_context_dstaddr(struct smb3_fs_context *ctx)
273{
274 struct sockaddr *addr = (struct sockaddr *)&ctx->dstaddr;
270 int rc;
275 int rc = 0;
271
276
272 rc = dns_resolve_server_name_to_ip(ctx->source, addr, NULL);
273 if (!rc)
274 cifs_set_port(addr, ctx->port);
277 if (!ctx->nodfs && ctx->dfs_automount) {
278 rc = dns_resolve_server_name_to_ip(ctx->source, addr, NULL);
279 if (!rc)
280 cifs_set_port(addr, ctx->port);
281 ctx->dfs_automount = false;
282 }
275 return rc;
276}
277
278int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx, bool *isdfs)
279{
280 struct smb3_fs_context *ctx = mnt_ctx->fs_ctx;
281 bool nodfs = ctx->nodfs;
282 int rc;

--- 343 unchanged lines hidden ---
283 return rc;
284}
285
286int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx, bool *isdfs)
287{
288 struct smb3_fs_context *ctx = mnt_ctx->fs_ctx;
289 bool nodfs = ctx->nodfs;
290 int rc;

--- 343 unchanged lines hidden ---