Page MenuHomeFreeBSD

D48547.id149594.diff
No OneTemporary

D48547.id149594.diff

diff --git a/sys/rpc/auth_none.c b/sys/rpc/auth_none.c
--- a/sys/rpc/auth_none.c
+++ b/sys/rpc/auth_none.c
@@ -115,9 +115,7 @@
if (!XDR_PUTBYTES(xdrs, ap->mclient, ap->mcnt))
return (FALSE);
- xdrmbuf_append(xdrs, args);
-
- return (TRUE);
+ return (xdr_putmbuf(xdrs, args));
}
/* All these unused parameters are required to keep ANSI-C from grumbling */
diff --git a/sys/rpc/auth_unix.c b/sys/rpc/auth_unix.c
--- a/sys/rpc/auth_unix.c
+++ b/sys/rpc/auth_unix.c
@@ -251,7 +251,7 @@
if (!XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos))
return (FALSE);
- xdrmbuf_append(xdrs, args);
+ xdr_putmbuf(xdrs, args);
return (TRUE);
}
diff --git a/sys/rpc/rpcsec_gss/rpcsec_gss.c b/sys/rpc/rpcsec_gss/rpcsec_gss.c
--- a/sys/rpc/rpcsec_gss/rpcsec_gss.c
+++ b/sys/rpc/rpcsec_gss/rpcsec_gss.c
@@ -547,7 +547,7 @@
_rpc_gss_set_error(RPC_GSS_ER_SYSTEMERROR, ENOMEM);
return (FALSE);
}
- xdrmbuf_append(xdrs, args);
+ xdr_putmbuf(xdrs, args);
return (TRUE);
} else {
/*
@@ -596,14 +596,14 @@
}
if (gd->gd_state != RPCSEC_GSS_ESTABLISHED ||
gd->gd_cred.gc_svc == rpc_gss_svc_none) {
- xdrmbuf_append(xdrs, args);
+ xdr_putmbuf(xdrs, args);
return (TRUE);
} else {
if (!xdr_rpc_gss_wrap_data(&args,
gd->gd_ctx, gd->gd_qop, gd->gd_cred.gc_svc,
seq))
return (FALSE);
- xdrmbuf_append(xdrs, args);
+ xdr_putmbuf(xdrs, args);
return (TRUE);
}
}
diff --git a/sys/rpc/rpcsec_tls/auth_tls.c b/sys/rpc/rpcsec_tls/auth_tls.c
--- a/sys/rpc/rpcsec_tls/auth_tls.c
+++ b/sys/rpc/rpcsec_tls/auth_tls.c
@@ -124,7 +124,7 @@
if (!XDR_PUTBYTES(xdrs, ap->mclient, ap->mcnt))
return (FALSE);
- xdrmbuf_append(xdrs, args);
+ xdr_putmbuf(xdrs, args);
return (TRUE);
}
diff --git a/sys/rpc/svc_dg.c b/sys/rpc/svc_dg.c
--- a/sys/rpc/svc_dg.c
+++ b/sys/rpc/svc_dg.c
@@ -240,7 +240,7 @@
if (!xdr_replymsg(&xdrs, msg))
stat = FALSE;
else
- xdrmbuf_append(&xdrs, m);
+ xdr_putmbuf(&xdrs, m);
} else {
stat = xdr_replymsg(&xdrs, msg);
}
diff --git a/sys/rpc/svc_vc.c b/sys/rpc/svc_vc.c
--- a/sys/rpc/svc_vc.c
+++ b/sys/rpc/svc_vc.c
@@ -1001,7 +1001,7 @@
if (!xdr_replymsg(&xdrs, msg))
stat = FALSE;
else
- xdrmbuf_append(&xdrs, m);
+ xdr_putmbuf(&xdrs, m);
} else {
stat = xdr_replymsg(&xdrs, msg);
}
@@ -1085,7 +1085,7 @@
if (!xdr_replymsg(&xdrs, msg))
stat = FALSE;
else
- xdrmbuf_append(&xdrs, m);
+ xdr_putmbuf(&xdrs, m);
} else {
stat = xdr_replymsg(&xdrs, msg);
}
diff --git a/sys/rpc/xdr.h b/sys/rpc/xdr.h
--- a/sys/rpc/xdr.h
+++ b/sys/rpc/xdr.h
@@ -40,6 +40,8 @@
#define _KRPC_XDR_H
#include <sys/cdefs.h>
+struct mbuf;
+
/*
* XDR provides a conventional way for converting between C data
* types and an external bit-string representation. Library supplied
@@ -105,6 +107,8 @@
bool_t (*x_getbytes)(struct XDR *, char *, u_int);
/* put some bytes to " */
bool_t (*x_putbytes)(struct XDR *, const char *, u_int);
+ /* put mbuf or copy its bytes */
+ bool_t (*x_putmbuf)(struct XDR *, struct mbuf *);
/* returns bytes off from beginning */
u_int (*x_getpostn)(struct XDR *);
/* lets you reposition the stream */
@@ -190,6 +194,11 @@
#define xdr_putbytes(xdrs, addr, len) \
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
+#define XDR_PUTMBUF(xdrs, mbuf) \
+ (*(xdrs)->x_ops->x_putmbuf)(xdrs, mbuf)
+#define xdr_putmbuf(xdrs, mbuf) \
+ (*(xdrs)->x_ops->x_putmbuf)(xdrs, mbuf)
+
#define XDR_GETPOS(xdrs) \
(*(xdrs)->x_ops->x_getpostn)(xdrs)
#define xdr_getpos(xdrs) \
@@ -359,9 +368,7 @@
extern void xdrmem_create(XDR *, char *, u_int, enum xdr_op);
/* XDR using mbufs */
-struct mbuf;
extern void xdrmbuf_create(XDR *, struct mbuf *, enum xdr_op);
-extern void xdrmbuf_append(XDR *, struct mbuf *);
extern struct mbuf * xdrmbuf_getall(XDR *);
/* XDR pseudo records for tcp */
diff --git a/sys/xdr/xdr_mbuf.c b/sys/xdr/xdr_mbuf.c
--- a/sys/xdr/xdr_mbuf.c
+++ b/sys/xdr/xdr_mbuf.c
@@ -40,6 +40,7 @@
static bool_t xdrmbuf_putlong(XDR *, const long *);
static bool_t xdrmbuf_getbytes(XDR *, char *, u_int);
static bool_t xdrmbuf_putbytes(XDR *, const char *, u_int);
+static bool_t xdrmbuf_putmbuf(XDR *, struct mbuf *);
/* XXX: w/64-bit pointers, u_int not enough! */
static u_int xdrmbuf_getpos(XDR *);
static bool_t xdrmbuf_setpos(XDR *, u_int);
@@ -50,6 +51,7 @@
.x_putlong = xdrmbuf_putlong,
.x_getbytes = xdrmbuf_getbytes,
.x_putbytes = xdrmbuf_putbytes,
+ .x_putmbuf = xdrmbuf_putmbuf,
.x_getpostn = xdrmbuf_getpos,
.x_setpostn = xdrmbuf_setpos,
.x_inline = xdrmbuf_inline,
@@ -78,17 +80,17 @@
}
}
-void
-xdrmbuf_append(XDR *xdrs, struct mbuf *madd)
+/*
+ * Append mbuf. Always succeds and we own mbuf.
+ */
+static bool_t
+xdrmbuf_putmbuf(XDR *xdrs, struct mbuf *madd)
{
struct mbuf *m;
- KASSERT(xdrs->x_ops == &xdrmbuf_ops && xdrs->x_op == XDR_ENCODE,
- ("xdrmbuf_append: invalid XDR stream"));
-
if (m_length(madd, NULL) == 0) {
m_freem(madd);
- return;
+ return (TRUE);
}
m = (struct mbuf *) xdrs->x_private;
@@ -97,6 +99,8 @@
m = m_last(madd);
xdrs->x_private = m;
xdrs->x_handy = m->m_len;
+
+ return (TRUE);
}
struct mbuf *

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 23, 6:07 PM (32 m, 22 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16054623
Default Alt Text
D48547.id149594.diff (5 KB)

Event Timeline