net/sunrpc/auth_gss/gss_rpc_xdr.c

Source file repositories/reference/linux-study-clean/net/sunrpc/auth_gss/gss_rpc_xdr.c

File Facts

System
Linux kernel
Corpus path
net/sunrpc/auth_gss/gss_rpc_xdr.c
Extension
.c
Size
18350 bytes
Lines
896
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

if (unlikely(p == NULL)) {
			err = -ENOSPC;
			goto free_creds;
		}

		length = be32_to_cpup(p);
		p = xdr_inline_decode(xdr, length);
		if (unlikely(p == NULL)) {
			err = -ENOSPC;
			goto free_creds;
		}

		if (length == sizeof(CREDS_VALUE) &&
		    memcmp(p, CREDS_VALUE, sizeof(CREDS_VALUE)) == 0) {
			/* We have creds here. parse them */
			err = gssx_dec_linux_creds(xdr, creds);
			if (err)
				goto free_creds;
			oa->data[0].value.len = 1; /* presence */
		} else {
			/* consume uninteresting buffer */
			err = gssx_dec_buffer(xdr, &dummy);
			if (err)
				goto free_creds;
		}
	}
	return 0;

free_creds:
	kfree(creds);
free_oa:
	kfree(oa->data);
	oa->data = NULL;
	return err;
}

static int gssx_dec_status(struct xdr_stream *xdr,
			   struct gssx_status *status)
{
	__be32 *p;
	int err;

	/* status->major_status */
	p = xdr_inline_decode(xdr, 8);
	if (unlikely(p == NULL))
		return -ENOSPC;
	p = xdr_decode_hyper(p, &status->major_status);

	/* status->mech */
	err = gssx_dec_buffer(xdr, &status->mech);
	if (err)
		return err;

	/* status->minor_status */
	p = xdr_inline_decode(xdr, 8);
	if (unlikely(p == NULL)) {
		err = -ENOSPC;
		goto out_free_mech;
	}
	p = xdr_decode_hyper(p, &status->minor_status);

	/* status->major_status_string */
	err = gssx_dec_buffer(xdr, &status->major_status_string);
	if (err)
		goto out_free_mech;

	/* status->minor_status_string */
	err = gssx_dec_buffer(xdr, &status->minor_status_string);
	if (err)
		goto out_free_major_status_string;

	/* status->server_ctx */
	err = gssx_dec_buffer(xdr, &status->server_ctx);
	if (err)
		goto out_free_minor_status_string;

	/* we assume we have no options for now, so simply consume them */
	/* status->options */
	err = dummy_dec_opt_array(xdr, &status->options);
	if (err)
		goto out_free_server_ctx;

	return 0;

out_free_server_ctx:
	kfree(status->server_ctx.data);
	status->server_ctx.data = NULL;
out_free_minor_status_string:
	kfree(status->minor_status_string.data);
	status->minor_status_string.data = NULL;

Annotation

Implementation Notes