Skip to contentSkip to conversation

cld: use XDR for all messages

PATCH Applied Colin McCabe 3 participants 25 messages Jan 15, 2010 – Feb 10, 2010 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cld: use XDR for all messages

This patch moves CLD from using manual data serialization to using XDR (via rpcgen). Both the packet header and the message body are now serialized and deserialized using XDR. This makes it easy to have a variable-length packet header, as well as a variable-length message body.

This patch introduces a minor libcldc API change in struct cldc_call_opts.

v2 changes:
* Added __cld prefix to functions in cld_fmt.c

* When decoding CMT_GET messages, we should store the payload in the session structure, rather than in cldc_call_opts.

* Got rid of pkt_is_first, pkt_is_last, in favor of a flags-based approach.

* Killed CLD_MAX_PKT_MSG. It's more efficient to only allocate as much space as you need, rather than always allocating space for 128 packets in a message.

* Created CLD_MAX_PAYLOAD_SZ to mean the maximum size of the data that can be sent with GET or PUT. This is different (and smaller than!) the maximum message size.

* automake: Add cld_msg_rpc.h to BUILT_SOURCES

* automake: Add lib dir to INCLUDES

* automake: "make clean" now deletes XDR build products

---
 .gitignore             |    4 +
 include/Makefile.am    |    2 +-
 include/cld_common.h   |   10 +
 include/cld_fmt.h      |   89 +++++
 include/cld_msg.h      |  252 -------------
 include/cldc.h         |   36 +-
 lib/Makefile.am        |   19 +-
 lib/cld_fmt.c          |  193 ++++++++++
 lib/cld_msg_rpc.x      |  218 +++++++++++
 lib/cldc.c             |  966 +++++++++++++++++++++---------------------------
 lib/common.c           |    6 +-
 server/Makefile.am     |    9 +-
 server/cld.h           |   97 ++++--
 server/cldb.h          |    2 +-
 server/msg.c           |  304 ++++++----------
 server/server.c        |  743 ++++++++++++++++++++-----------------
 server/session.c       |  396 ++++++++++-----------
 test/Makefile.am       |    5 +-
 test/load-file-event.c |   14 +-
 test/save-file-event.c |    2 -
 tools/cldcli.c         |   22 +-
 21 files changed, 1777 insertions(+), 1612 deletions(-)
 create mode 100644 include/cld_fmt.h
 delete mode 100644 include/cld_msg.h
 create mode 100644 lib/cld_fmt.c
 create mode 100644 lib/cld_msg_rpc.x
.gitignore +4 -0
index 79a4cd3..805fa22 100644
@@ -32,5 +32,9 @@ cld-config.h*
 cscope.*
 ncscope.*
 
+# XDR files
+*_rpc.h
+*_rpc_xdr.c
+
 # ignore Doxygen output directory
 gendoc
include/Makefile.am +1 -1
index 888088c..f90d222 100644
@@ -1,5 +1,5 @@
 
 EXTRA_DIST = cld-private.h libtimer.h
 
-include_HEADERS = cldc.h cld_msg.h hail_log.h cld_common.h
+include_HEADERS = cldc.h hail_log.h cld_common.h cld_fmt.h
 
include/cld_common.h +10 -0
index 116ef93..217d1ad 100644
@@ -20,10 +20,20 @@
  */
 
 #include <stdint.h>
+#include <lib/cld_msg_rpc.h>
+
+#define CLD_ALIGN8(n) ((8 - ((n) & 7)) & 7)
 
 unsigned long long cld_sid2llu(const uint8_t *sid);
 void __cld_rand64(void *p);
 const char *cld_errstr(enum cle_err_codes ecode);
 int cld_readport(const char *fname);
 
+/*
+ *  * We use a unified format for sid so it can be searched in log files (* in
+ *  vi).
+ */
+#define SIDFMT   "%016llX"
+#define SIDARG(sid)  cld_sid2llu(sid)
+
 #endif /* __CLD_COMMON_H__ */
include/cld_fmt.h new file +89 -0

89 lines not on this page · raw message

include/cld_msg.h deleted +0 -252

252 lines not on this page · raw message

include/cldc.h +17 -19
index f1db7d2..330adb0 100644
@@ -19,10 +19,11 @@
  *
  */
 
+
 #include <sys/types.h>
 #include <stdbool.h>
 #include <glib.h>
-#include <cld_msg.h>
+#include <lib/cld_msg_rpc.h>
 #include <cld_common.h>
 #include <hail_log.h>
 
@@ -35,33 +36,30 @@ struct cldc_call_opts {
 	void		*private;
 
 	/* private; lib-owned */
-	enum cld_msg_ops op;
-	union {
-		struct {
-			struct cld_msg_get_resp resp;
-			const char *buf;
-			unsigned int size;
-			char inode_name[CLD_INODE_NAME_MAX];
-		} get;
-	} u;
+	struct cld_msg_get_resp resp;
 };
 
+void cldc_call_opts_get_data(struct cldc_call_opts *copts,
+			     char **data, size_t *data_len);
+
 struct cldc_pkt_info {
 	int		pkt_len;
+	int		hdr_len;
 	int		retries;
+	char		user[CLD_MAX_USERNAME];
 
 	/* must be at end of struct */
-	struct cld_packet pkt;
-	uint8_t		data[0];
+	char		data[0];
 };
 
 /** an outgoing message, from client to server */
 struct cldc_msg {
 	uint64_t	xid;
-
+	enum cld_msg_type type;
 	struct cldc_session *sess;
 
-	ssize_t		(*cb)(struct cldc_msg *, const void *, size_t, bool);
+	ssize_t		(*cb)(struct cldc_msg *, const void *, size_t,
+				enum cle_err_codes resp_rc);
 	void		*cb_private;
 
 	struct cldc_call_opts copts;
@@ -70,18 +68,15 @@ struct cldc_msg {
 
 	time_t		expire_time;
 
-	int		data_len;
 	int		n_pkts;
 
-	struct cldc_pkt_info *pkt_info[CLD_MAX_PKT_MSG];
-
 	/* must be at end of struct */
-	uint8_t		data[0];
+	struct cldc_pkt_info *pkt_info[0];
 };
 
 /** an open file handle associated with a session */
 struct cldc_fh {
-	uint64_t	fh_le;			/* fh id, LE */
+	uint64_t	fh;
 	struct cldc_session *sess;
 	bool		valid;
 };
@@ -128,8 +123,11 @@ struct cldc_session {
 
 	bool		confirmed;
 
+	enum cld_msg_type msg_buf_type;
 	unsigned int	msg_buf_len;
 	char		msg_buf[CLD_MAX_MSG_SZ];
+	char		payload[CLD_MAX_PAYLOAD_SZ];
+	char		inode_name_temp[CLD_INODE_NAME_MAX];
 };
 
 /** Information for a single CLD server host */
lib/Makefile.am +18 -1
index 68be429..6275ca6 100644
@@ -1,15 +1,31 @@
 
+BUILT_SOURCES		= cld_msg_rpc.h
+
 EXTRA_DIST =
 	libcldc.pc.in libcldc-uninstalled.pc.in
 
 INCLUDES		= -I$(top_srcdir)/include	\
 			  @GLIB_CFLAGS@
 
+mostlyclean-local:
+	-rm -f *_rpc.h *_rpc_xdr.c
+
+%_rpc.h: %_rpc.x
+	rpcgen -h $< > $@
+
+%_rpc_xdr.c: %_rpc.x
+	rpcgen -c $< > $@
+
 LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
 
 lib_LTLIBRARIES		= libcldc.la
 
-libcldc_la_SOURCES	= cldc.c cldc-udp.c cldc-dns.c common.c
+libcldc_la_SOURCES	= cldc.c \
+			cldc-udp.c \
+			cldc-dns.c \
+			common.c \
+			cld_fmt.c \
+			cld_msg_rpc_xdr.c
 
 libcldc_la_LDFLAGS = \
 	-version-info $(LIBCLDC_CURRENT):$(LIBCLDC_REVISION):$(LIBCLDC_AGE) \
@@ -21,3 +37,4 @@ noinst_LIBRARIES	= libtimer.a
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libcldc.pc
 
+include_HEADERS = cld_msg_rpc.h
lib/cld_fmt.c new file +193 -0

193 lines not on this page · raw message

lib/cld_msg_rpc.x new file +218 -0

218 lines not on this page · raw message

lib/cldc.c +415 -551

1,406 lines not on this page · raw message

lib/common.c +5 -1
index 276c805..27a3f4e 100644
@@ -26,7 +26,11 @@
 #include <errno.h>
 #include <glib.h>
 #include <cld-private.h>
-#include "cld_msg.h"
+#include <openssl/sha.h>
+#include <openssl/hmac.h>
+#include "cld_msg_rpc.h"
+#include <hail_log.h>
+#include <syslog.h>
 
 /* duplicated from tools/cldcli.c; put in common header somewhere? */
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
server/Makefile.am +7 -2
index faaf099..17771de 100644
@@ -1,13 +1,18 @@
 
-INCLUDES	= -I$(top_srcdir)/include @GLIB_CFLAGS@ \
+INCLUDES	= -I$(top_srcdir)/include \
+		  -I$(top_srcdir)/lib \
+		  @GLIB_CFLAGS@ \
 		  -DCLD_LIBDIR=\""$(libdir)"\" \
 		  -DCLD_LOCAL_STATE_DIR="\"$(localstatedir)\""
 
 sbin_PROGRAMS	= cld cldbadm
 
 cld_SOURCES	= cldb.h cld.h \
+		  ../lib/cld_fmt.c \
 		  ../lib/common.c \
-		  cldb.c msg.c server.c session.c util.c
+		  cldb.c msg.c server.c session.c util.c \
+		  ../lib/cld_msg_rpc_xdr.c
+
 cld_LDADD	= ../lib/libtimer.a \
 		  @CRYPTO_LIBS@ @GLIB_LIBS@ @DB4_LIBS@
 
server/cld.h +66 -31

139 lines not on this page · raw message

server/cldb.h +1 -1
index ac108ce..71dce95 100644
@@ -23,7 +23,7 @@
 #include <stdbool.h>
 #include <db.h>
 #include <cld-private.h>
-#include <cld_msg.h>
+#include <lib/cld_msg_rpc.h>
 
 typedef uint64_t cldino_t;
 
server/msg.c +111 -193

506 lines not on this page · raw message

server/server.c +407 -336

743 lines not on this page · raw message

server/session.c +187 -209

396 lines not on this page · raw message

test/Makefile.am +3 -2
index 20dba03..d8048a7 100644

Lines of this file are not shown. View the raw message.

test/load-file-event.c +9 -5
index 7b309b3..091e3a4 100644

Lines of this file are not shown. View the raw message.

test/save-file-event.c +0 -2
index 2b13bc8..03c6ca6 100644

Lines of this file are not shown. View the raw message.

tools/cldcli.c +16 -6
index a06473d..e4d5c7c 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.6.2.5

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 52 lines · Colin McCabe

This patch moves CLD from using manual data serialization to using XDR (via rpcgen). Both the packet header and the message body are now serialized and deserialized using XDR. This makes it easy to have a variable-length packet header, as well as a variable-length message body.

This patch introduces a minor libcldc API change in struct cldc_call_opts.

v2 changes:
* Added __cld prefix to functions in cld_fmt.c

* When decoding CMT_GET messages, we should store the payload in the session structure, rather than in cldc_call_opts.

* Got rid of pkt_is_first, pkt_is_last, in favor of a flags-based approach.

* Killed CLD_MAX_PKT_MSG. It's more efficient to only allocate as much space as you need, rather than always allocating space for 128 packets in a message.

* Created CLD_MAX_PAYLOAD_SZ to mean the maximum size of the data that can be sent with GET or PUT. This is different (and smaller than!) the maximum message size.

* automake: Add cld_msg_rpc.h to BUILT_SOURCES

* automake: Add lib dir to INCLUDES

* automake: "make clean" now deletes XDR build products

---
  .gitignore             |    4 +
  include/Makefile.am    |    2 +-
  include/cld_common.h   |   10 +
  include/cld_fmt.h      |   89 +++++
  include/cld_msg.h      |  252 -------------
  include/cldc.h         |   36 +-
  lib/Makefile.am        |   19 +-
  lib/cld_fmt.c          |  193 ++++++++++
  lib/cld_msg_rpc.x      |  218 +++++++++++
  lib/cldc.c             |  966 +++++++++++++++++++++---------------------------
  lib/common.c           |    6 +-
  server/Makefile.am     |    9 +-
  server/cld.h           |   97 ++++--
  server/cldb.h          |    2 +-
  server/msg.c           |  304 ++++++----------
  server/server.c        |  743 ++++++++++++++++++++-----------------
  server/session.c       |  396 ++++++++++-----------
  test/Makefile.am       |    5 +-
  test/load-file-event.c |   14 +-
  test/save-file-event.c |    2 -
  tools/cldcli.c         |   22 +-
  21 files changed, 1777 insertions(+), 1612 deletions(-)
Quoted 4 lines

create mode 100644 include/cld_fmt.h
delete mode 100644 include/cld_msg.h
create mode 100644 lib/cld_fmt.c
create mode 100644 lib/cld_msg_rpc.x

Looking good... we are definitely getting closer.

Currently, it still does not pass "make distcheck", which presages a lot of installation problems. Notably,

	#include <lib/cld_msg_rpc.h>

is not consistent with the rest of the headers, producing things such as "make distcheck" build breakage:

Quoted 3 lines

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../lib -I.. -I../../include -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -g -O2 -MT cldc.lo -MD -MP -MF .deps/cldc.Tpo -c ../../lib/cldc.c -fPIC -DPIC -o .libs/cldc.o In file included from ../../lib/cldc.c:37:
../../include/cldc.h:26:29: error: lib/cld_msg_rpc.h: No such file or directory

You will either need to move the header to $cld/include/ or update INCLUDES in various */Makefile.am files to reference $(top_srcdir)/lib (which I see you actually did, in a few cases).

Also, it would be nice if this did not introduce warnings. A big point with the testsuite, and minor point with compiler warnings, is that -- more than anything else -- we do not want to introduce regressions.

Jeff

#2 lore raw
Quoted 67 lines · Jeff Garzik
Quoted 60 lines · Colin McCabe

This patch moves CLD from using manual data serialization to using XDR (via
rpcgen). Both the packet header and the message body are now serialized and
deserialized using XDR. This makes it easy to have a variable-length packet
header, as well as a variable-length message body.

This patch introduces a minor libcldc API change in struct cldc_call_opts.

v2 changes:
* Added __cld prefix to functions in cld_fmt.c

* When decoding CMT_GET messages, we should store the payload in the session structure, rather than in cldc_call_opts.

* Got rid of pkt_is_first, pkt_is_last, in favor of a flags-based approach.

* Killed CLD_MAX_PKT_MSG. It's more efficient to only allocate as much space
as you need, rather than always allocating space for 128 packets in a message.

* Created CLD_MAX_PAYLOAD_SZ to mean the maximum size of the data that can be
sent with GET or PUT. This is different (and smaller than!) the maximum message size.

* automake: Add cld_msg_rpc.h to BUILT_SOURCES

* automake: Add lib dir to INCLUDES

* automake: "make clean" now deletes XDR build products

---
 .gitignore             |    4 +
 include/Makefile.am    |    2 +-
 include/cld_common.h   |   10 +
 include/cld_fmt.h      |   89 +++++
 include/cld_msg.h      |  252 -------------
 include/cldc.h         |   36 +-
 lib/Makefile.am        |   19 +-
 lib/cld_fmt.c          |  193 ++++++++++
 lib/cld_msg_rpc.x      |  218 +++++++++++
 lib/cldc.c             |  966
+++++++++++++++++++++---------------------------
 lib/common.c           |    6 +-
 server/Makefile.am     |    9 +-

 server/cld.h           |   97 ++++--
 server/cldb.h          |    2 +-
 server/msg.c           |  304 ++++++----------

 server/server.c        |  743 ++++++++++++++++++++----------------- server/session.c       |  396 ++++++++++----------- test/Makefile.am       |    5 +-
 test/load-file-event.c |   14 +-
 test/save-file-event.c |    2 -
 tools/cldcli.c         |   22 +-

Quoted 5 lines
 21 files changed, 1777 insertions(+), 1612 deletions(-)

 create mode 100644 include/cld_fmt.h
 delete mode 100644 include/cld_msg.h
 create mode 100644 lib/cld_fmt.c
 create mode 100644 lib/cld_msg_rpc.x

Quoted 7 lines

Looking good...  we are definitely getting closer.

Currently, it still does not pass "make distcheck", which presages a lot of installation problems.  Notably,
       #include <lib/cld_msg_rpc.h>
is not consistent with the rest of the headers, producing things such as "make distcheck" build breakage:

I guess distcheck is pretty important to run when making a change like this. For some reason I forgot to try that. :(

Quoted 13 lines
Quoted 8 lines

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../lib -I..

(quoted diff) +0 -3
-I../../include -pthread -I/usr/include/glib-2.0
-I/usr/lib64/glib-2.0/include -g -O2 -MT cldc.lo -MD -MP -MF .deps/cldc.Tpo
-c ../../lib/cldc.c  -fPIC -DPIC -o .libs/cldc.o

In file included from ../../lib/cldc.c:37:
../../include/cldc.h:26:29: error: lib/cld_msg_rpc.h: No such file or directory

You will either need to move the header to $cld/include/ or update INCLUDES in various */Makefile.am files to reference $(top_srcdir)/lib (which I see you actually did, in a few cases).

Quoted 3 lines

Also, it would be nice if this did not introduce warnings.  A big point with the testsuite, and minor point with compiler warnings, is that -- more than anything else -- we do not want to introduce regressions.

When I did "make all" with -Wall, the only warnings I saw were from the generated xdr serialization files. I'd like to figure out how to suppress those (we really should somehow tack -Wnone onto the CFLAGs of machine-generated files), but I haven't figured out how to do that yet.

I was thinking of doing it in a follow-on change, since this change is already pretty big.

Colin

#3 lore raw

Hi all,

I'm currently reworking this patch to address the concerns mentioned here (mostly autotools-related). I'm also going to separate it into multiple patches.

A few questions:

I would really like cld_msg_rpc.h to show up in "include," for consistency with the other headers.

Is it possible for cld_msg_rpc.x to live in lib/ and export the header into the include/ directory?
I've been reading everything I can about automake, but I still haven't been able to figure out if this kind of cross-directory dependency between two directories at the same depth is possible.

I really don't want to put cld_msg_rpc_xdr.c in include/. But so far I can't figure out how to have the header there, without the .c file...

Colin

Quoted 107 lines · Colin McCabe
Quoted 67 lines · Jeff Garzik
Quoted 60 lines · Colin McCabe

This patch moves CLD from using manual data serialization to using XDR (via
rpcgen). Both the packet header and the message body are now serialized and
deserialized using XDR. This makes it easy to have a variable-length packet
header, as well as a variable-length message body.

This patch introduces a minor libcldc API change in struct cldc_call_opts.

v2 changes:
* Added __cld prefix to functions in cld_fmt.c

* When decoding CMT_GET messages, we should store the payload in the session structure, rather than in cldc_call_opts.

* Got rid of pkt_is_first, pkt_is_last, in favor of a flags-based approach.

* Killed CLD_MAX_PKT_MSG. It's more efficient to only allocate as much space
as you need, rather than always allocating space for 128 packets in a message.

* Created CLD_MAX_PAYLOAD_SZ to mean the maximum size of the data that can be
sent with GET or PUT. This is different (and smaller than!) the maximum message size.

* automake: Add cld_msg_rpc.h to BUILT_SOURCES

* automake: Add lib dir to INCLUDES

* automake: "make clean" now deletes XDR build products

---
 .gitignore             |    4 +
 include/Makefile.am    |    2 +-
 include/cld_common.h   |   10 +
 include/cld_fmt.h      |   89 +++++
 include/cld_msg.h      |  252 -------------
 include/cldc.h         |   36 +-
 lib/Makefile.am        |   19 +-
 lib/cld_fmt.c          |  193 ++++++++++
 lib/cld_msg_rpc.x      |  218 +++++++++++
 lib/cldc.c             |  966
+++++++++++++++++++++---------------------------
 lib/common.c           |    6 +-
 server/Makefile.am     |    9 +-

 server/cld.h           |   97 ++++--
 server/cldb.h          |    2 +-
 server/msg.c           |  304 ++++++----------

 server/server.c        |  743 ++++++++++++++++++++----------------- server/session.c       |  396 ++++++++++----------- test/Makefile.am       |    5 +-
 test/load-file-event.c |   14 +-
 test/save-file-event.c |    2 -
 tools/cldcli.c         |   22 +-

Quoted 5 lines
 21 files changed, 1777 insertions(+), 1612 deletions(-)

 create mode 100644 include/cld_fmt.h
 delete mode 100644 include/cld_msg.h
 create mode 100644 lib/cld_fmt.c
 create mode 100644 lib/cld_msg_rpc.x

Quoted 7 lines

Looking good...  we are definitely getting closer.

Currently, it still does not pass "make distcheck", which presages a lot of installation problems.  Notably,
       #include <lib/cld_msg_rpc.h>
is not consistent with the rest of the headers, producing things such as "make distcheck" build breakage:

I guess distcheck is pretty important to run when making a change like this. For some reason I forgot to try that. :(

Quoted 13 lines
Quoted 8 lines

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../lib -I..

(quoted diff) +0 -3
-I../../include -pthread -I/usr/include/glib-2.0
-I/usr/lib64/glib-2.0/include -g -O2 -MT cldc.lo -MD -MP -MF .deps/cldc.Tpo
-c ../../lib/cldc.c  -fPIC -DPIC -o .libs/cldc.o

In file included from ../../lib/cldc.c:37:
../../include/cldc.h:26:29: error: lib/cld_msg_rpc.h: No such file or directory

You will either need to move the header to $cld/include/ or update INCLUDES in various */Makefile.am files to reference $(top_srcdir)/lib (which I see you actually did, in a few cases).

Quoted 3 lines

Also, it would be nice if this did not introduce warnings.  A big point with the testsuite, and minor point with compiler warnings, is that -- more than anything else -- we do not want to introduce regressions.

When I did "make all" with -Wall, the only warnings I saw were from the generated xdr serialization files. I'd like to figure out how to suppress those (we really should somehow tack -Wnone onto the CFLAGs of machine-generated files), but I haven't figured out how to do that yet.

I was thinking of doing it in a follow-on change, since this change is already pretty big.

Colin

#4 lore raw
Quoted 11 lines · Colin McCabe

Hi all,

I'm currently reworking this patch to address the concerns mentioned here (mostly autotools-related). I'm also going to separate it into multiple patches.

A few questions:

I would really like cld_msg_rpc.h to show up in "include," for consistency with the other headers.

Quoted 8 lines

Is it possible for cld_msg_rpc.x to live in lib/ and export the header into the include/ directory?
I've been reading everything I can about automake, but I still haven't been able to figure out if this kind of cross-directory dependency between two directories at the same depth is possible.

I really don't want to put cld_msg_rpc_xdr.c in include/. But so far I can't figure out how to have the header there, without the .c file...

Actually I poked at it this weekend, and was about to finish up. So hold off for another day, if you would.

The answer is, there are two different build environments to consider for headers: the in-tree build environment, and the installed-header build environment. That is why including "lib/foo.h" does not work, particularly in nested headers. You need to fiddle INCLUDES in Makefile.am to get the header path correct at build time, and then ensure that all headers are installed in the proper location (by default, $includedir) using include_HEADERS. That way, cld_msg_rpc* remains in lib/ while the other headers remain in include/

Also, while splitting this up, I noticed that ping_open is no longer set to true.

Jeff

#5 lore raw
Quoted 11 lines · Jeff Garzik

Actually I poked at it this weekend, and was about to finish up.  So hold off for another day, if you would.

The answer is, there are two different build environments to consider for
headers:  the in-tree build environment, and the installed-header build environment.  That is why including "lib/foo.h" does not work, particularly in nested headers.  You need to fiddle INCLUDES in Makefile.am to get the header path correct at build time, and then ensure that all headers are installed in the proper location (by default, $includedir) using include_HEADERS.  That way, cld_msg_rpc* remains in lib/ while the other headers remain in include/

We should probably also add an AC_CHECK_PROG(rpcgen, ...) to configure.ac

On an unrelated note, I just discovered "make check". I feel kind of silly that I didn't try that before. :)

Quoted 3 lines

Also, while splitting this up, I noticed that ping_open is no longer set to true.

Good catch. Clearly session_timeout should be setting that to true when it sends the PING message.

Colin

#6 lore raw

Oh, FYI, I am also folding cld_fmt.h into cld_common.h. One less header, and the contents of cld_fmt.h did not really seem to align perfectly with the implied mnemonic "cld format" IMO.

Jeff

#7 lore raw

That seems reasonable. All of those functions could be looked at as "common."

The intention was to group together a bunch of functions that were useful for packet formatting. Although the bulk of the formatting is done by XDR, there are some things that XDR doesn't do, like generating and checking SHA sums. cld_dump_buf and cld_pkt_hdr_to_str are purely for debugging purposes, but they seemed like something that would be generally useful for developers making packet format changes. I know that they were useful to me.

Colin

Quoted 10 lines · Jeff Garzik

Oh, FYI, I am also folding cld_fmt.h into cld_common.h.  One less header, and the contents of cld_fmt.h did not really seem to align perfectly with the implied mnemonic "cld format" IMO.

       Jeff

#8 lore raw
Quoted 9 lines · Colin McCabe

That seems reasonable. All of those functions could be looked at as "common."

The intention was to group together a bunch of functions that were useful for packet formatting. Although the bulk of the formatting is done by XDR, there are some things that XDR doesn't do, like generating and checking SHA sums. cld_dump_buf and cld_pkt_hdr_to_str are purely for debugging purposes, but they seemed like something that would be generally useful for developers making packet format changes. I know that they were useful to me.

I finally pushed out several changes split off from your main XDR patch, to the upstream cld git repo. It took longer than expected because I would make changes of my own along the way, which, each time, necessitated a rediff+rebuild between "current cld" working tree and "cld + xdr" working tree.

The attached patch is what remains to be split up and committed. I have definitely whittled it down, and along the way, moved and renamed some things on my own. With regards to cld_fmt.*, my main objection was to creating too many to-be-installed headers. One more header can be a pain for us and for users, while one more source file in cld/lib/ is no big deal.

Thus, the intention is to eliminate cld_fmt.h (newly renamed to cld_pkt.h) altogether, while keeping the arrangement you created in cld_fmt.c (newly renamed to lib/pkt.c).

I will continue whittling down the patch until it just contains the XDR changes themselves.

Jeff

.gitignore +4 -0
diff -X /garz/tmp/dontdiff -urNp cld/.gitignore cld.rpcgen/.gitignore
@@ -32,5 +32,9 @@ cld-config.h*
 cscope.*
 ncscope.*
 
+# XDR files
+*_rpc.h
+*_rpc_xdr.c
+
 # ignore Doxygen output directory
 gendoc
include/cldc.h +16 -19
diff -X /garz/tmp/dontdiff -urNp cld/include/cldc.h cld.rpcgen/include/cldc.h
@@ -22,7 +22,7 @@
 #include <sys/types.h>
 #include <stdbool.h>
 #include <glib.h>
-#include <cld_msg.h>
+#include <cld_msg_rpc.h>
 #include <cld_common.h>
 #include <hail_log.h>
 
@@ -35,33 +35,30 @@ struct cldc_call_opts {
 	void		*private;
 
 	/* private; lib-owned */
-	enum cld_msg_ops op;
-	union {
-		struct {
-			struct cld_msg_get_resp resp;
-			const char *buf;
-			unsigned int size;
-			char inode_name[CLD_INODE_NAME_MAX];
-		} get;
-	} u;
+	struct cld_msg_get_resp resp;
 };
 
+void cldc_call_opts_get_data(struct cldc_call_opts *copts,
+			     char **data, size_t *data_len);
+
 struct cldc_pkt_info {
 	int		pkt_len;
+	int		hdr_len;
 	int		retries;
+	char		user[CLD_MAX_USERNAME];
 
 	/* must be at end of struct */
-	struct cld_packet pkt;
-	uint8_t		data[0];
+	char		data[0];
 };
 
 /** an outgoing message, from client to server */
 struct cldc_msg {
 	uint64_t	xid;
-
+	enum cld_msg_op type;
 	struct cldc_session *sess;
 
-	ssize_t		(*cb)(struct cldc_msg *, const void *, size_t, bool);
+	ssize_t		(*cb)(struct cldc_msg *, const void *, size_t,
+				enum cle_err_codes resp_rc);
 	void		*cb_private;
 
 	struct cldc_call_opts copts;
@@ -70,18 +67,15 @@ struct cldc_msg {
 
 	time_t		expire_time;
 
-	int		data_len;
 	int		n_pkts;
 
-	struct cldc_pkt_info *pkt_info[CLD_MAX_PKT_MSG];
-
 	/* must be at end of struct */
-	uint8_t		data[0];
+	struct cldc_pkt_info *pkt_info[0];
 };
 
 /** an open file handle associated with a session */
 struct cldc_fh {
-	uint64_t	fh_le;			/* fh id, LE */
+	uint64_t	fh;
 	struct cldc_session *sess;
 	bool		valid;
 };
@@ -128,8 +122,11 @@ struct cldc_session {
 
 	bool		confirmed;
 
+	enum cld_msg_op msg_buf_type;
 	unsigned int	msg_buf_len;
 	char		msg_buf[CLD_MAX_MSG_SZ];
+	char		payload[CLD_MAX_PAYLOAD_SZ];
+	char		inode_name_temp[CLD_INODE_NAME_MAX];
 };
 
 /** Information for a single CLD server host */
include/cld_common.h +3 -3
diff -X /garz/tmp/dontdiff -urNp cld/include/cld_common.h cld.rpcgen/include/cld_common.h
@@ -3,7 +3,6 @@
 
 /*
  * Copyright 2009 Red Hat, Inc.
- * Copyright 2010, Colin McCabe
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +23,7 @@
 #include <stdbool.h>
 #include <string.h>
 #include <time.h>
+#include <cld_msg_rpc.h>
 
 #define CLD_ALIGN8(n) ((8 - ((n) & 7)) & 7)
 
@@ -90,8 +90,8 @@ extern int __cld_authcheck(struct hail_l
 extern int __cld_authsign(struct hail_log *log, const char *key,
 			  const void *buf, size_t buf_len, void *sha);
 
-/* Returns a constant string representing a message operation */
-extern const char *__cld_opstr(enum cld_msg_ops op);
+/* Returns a constant string representing a message type */
+extern const char *__cld_opstr(enum cld_msg_op type);
 
 /*
  * We use a unified format for sid so it can be searched in log files (* in vi).
include/cld_msg.h +0 -244

244 lines not on this page · raw message

include/cld_pkt.h +56 -0

56 lines not on this page · raw message

include/Makefile.am +1 -1
diff -X /garz/tmp/dontdiff -urNp cld/include/Makefile.am cld.rpcgen/include/Makefile.am
@@ -1,5 +1,5 @@
 
 EXTRA_DIST = cld-private.h
 
-include_HEADERS = cldc.h hail_log.h cld_common.h cld_msg.h
+include_HEADERS = cldc.h hail_log.h cld_common.h cld_pkt.h
 
lib/cldc.c +385 -462

1,273 lines not on this page · raw message

Binary files cld/lib/cldc-dns.o and cld.rpcgen/lib/cldc-dns.o differ Binary files cld/lib/cldc.o and cld.rpcgen/lib/cldc.o differ Binary files cld/lib/cldc-udp.o and cld.rpcgen/lib/cldc-udp.o differ

lib/cld_msg_rpc.x +218 -0

218 lines not on this page · raw message

Binary files cld/lib/cld_msg_rpc_xdr.o and cld.rpcgen/lib/cld_msg_rpc_xdr.o differ

lib/common.c +5 -1
diff -X /garz/tmp/dontdiff -urNp cld/lib/common.c cld.rpcgen/lib/common.c
@@ -26,7 +26,11 @@
 #include <errno.h>
 #include <glib.h>
 #include <cld-private.h>
-#include "cld_msg.h"
+#include <openssl/sha.h>
+#include <openssl/hmac.h>
+#include "cld_msg_rpc.h"
+#include <hail_log.h>
+#include <syslog.h>
 
 /* duplicated from tools/cldcli.c; put in common header somewhere? */
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

Binary files cld/lib/common.o and cld.rpcgen/lib/common.o differ Binary files cld/lib/libcldc.a and cld.rpcgen/lib/libcldc.a differ Binary files cld/lib/.libs/libcldc.a and cld.rpcgen/lib/.libs/libcldc.a differ Binary files cld/lib/libtimer.a and cld.rpcgen/lib/libtimer.a differ Binary files cld/lib/libtimer.o and cld.rpcgen/lib/libtimer.o differ

lib/Makefile.am +14 -1
diff -X /garz/tmp/dontdiff -urNp cld/lib/Makefile.am cld.rpcgen/lib/Makefile.am
@@ -1,10 +1,21 @@
 
+BUILT_SOURCES		= cld_msg_rpc.h
+
 EXTRA_DIST =
 	libcldc.pc.in libcldc-uninstalled.pc.in
 
 INCLUDES		= -I$(top_srcdir)/include	\
 			  @GLIB_CFLAGS@
 
+mostlyclean-local:
+	rm -f *_rpc.h *_rpc_xdr.c
+
+%_rpc.h: %_rpc.x
+	rpcgen -h $< > $@
+
+%_rpc_xdr.c: %_rpc.x
+	rpcgen -c $< > $@
+
 LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
 
 lib_LTLIBRARIES		= libcldc.la
@@ -15,7 +26,8 @@ libcldc_la_SOURCES	=	\
 	cldc-dns.c		\
 	common.c		\
 	libtimer.c		\
-	pkt.c
+	pkt.c			\
+	cld_msg_rpc_xdr.c
 
 libcldc_la_LDFLAGS = \
 	-version-info $(LIBCLDC_CURRENT):$(LIBCLDC_REVISION):$(LIBCLDC_AGE) \
@@ -25,3 +37,4 @@ libcldc_la_LDFLAGS = \
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libcldc.pc
 
+include_HEADERS = cld_msg_rpc.h
lib/pkt.c +98 -3

121 lines not on this page · raw message

Binary files cld/lib/pkt.o and cld.rpcgen/lib/pkt.o differ Binary files cld/server/cld and cld.rpcgen/server/cld differ Binary files cld/server/cldbadm and cld.rpcgen/server/cldbadm differ Binary files cld/server/cldbadm.o and cld.rpcgen/server/cldbadm.o differ

server/cldb.h +1 -1
diff -X /garz/tmp/dontdiff -urNp cld/server/cldb.h cld.rpcgen/server/cldb.h
@@ -23,7 +23,7 @@
 #include <stdbool.h>
 #include <db.h>
 #include <cld-private.h>
-#include <cld_msg.h>
+#include <cld_msg_rpc.h>
 
 typedef uint64_t cldino_t;
 

Binary files cld/server/cldb.o and cld.rpcgen/server/cldb.o differ

server/cld.h +66 -30

133 lines not on this page · raw message

Binary files cld/server/cld_msg_rpc_xdr.o and cld.rpcgen/server/cld_msg_rpc_xdr.o differ Binary files cld/server/common.o and cld.rpcgen/server/common.o differ Binary files cld/server/libtimer.o and cld.rpcgen/server/libtimer.o differ

server/Makefile.am +3 -1
diff -X /garz/tmp/dontdiff -urNp cld/server/Makefile.am cld.rpcgen/server/Makefile.am
@@ -1,5 +1,6 @@
 
 INCLUDES	= -I$(top_srcdir)/include	\
+		  -I$(top_srcdir)/lib		\
 		  @GLIB_CFLAGS@			\
 		  -DCLD_LIBDIR=\""$(libdir)"\"	\
 		  -DCLD_LOCAL_STATE_DIR="\"$(localstatedir)\""
@@ -8,7 +9,8 @@ sbin_PROGRAMS	= cld cldbadm
 
 cld_SOURCES	= cldb.h cld.h \
 		  ../lib/common.c ../lib/libtimer.c ../lib/pkt.c \
-		  cldb.c msg.c server.c session.c util.c
+		  cldb.c msg.c server.c session.c util.c \
+		  ../lib/cld_msg_rpc_xdr.c
 cld_LDADD	= @CRYPTO_LIBS@ @GLIB_LIBS@ @DB4_LIBS@
 
 cldbadm_SOURCES	= cldb.h cldbadm.c
server/msg.c +108 -191

628 lines not on this page · raw message

Binary files cld/server/msg.o and cld.rpcgen/server/msg.o differ Binary files cld/server/pkt.o and cld.rpcgen/server/pkt.o differ

server/server.c +405 -293

137 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Binary files cld/server/server.o and cld.rpcgen/server/server.o differ

server/session.c +182 -221

403 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Binary files cld/server/session.o and cld.rpcgen/server/session.o differ Binary files cld/server/util.o and cld.rpcgen/server/util.o differ Binary files cld/test/it-works and cld.rpcgen/test/it-works differ Binary files cld/test/it-works.o and cld.rpcgen/test/it-works.o differ Binary files cld/test/libtest.a and cld.rpcgen/test/libtest.a differ Binary files cld/test/load-file-event and cld.rpcgen/test/load-file-event differ

test/load-file-event.c +9 -3
diff -X /garz/tmp/dontdiff -urNp cld/test/load-file-event.c cld.rpcgen/test/load-file-event.c

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Binary files cld/test/load-file-event.o and cld.rpcgen/test/load-file-event.o differ Binary files cld/test/lock-file-event and cld.rpcgen/test/lock-file-event differ Binary files cld/test/lock-file-event.o and cld.rpcgen/test/lock-file-event.o differ

test/Makefile.am +1 -0
diff -X /garz/tmp/dontdiff -urNp cld/test/Makefile.am cld.rpcgen/test/Makefile.am

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Binary files cld/test/save-file-event and cld.rpcgen/test/save-file-event differ Binary files cld/test/save-file-event.o and cld.rpcgen/test/save-file-event.o differ Binary files cld/test/util.o and cld.rpcgen/test/util.o differ
Binary files cld/tools/cldcli and cld.rpcgen/tools/cldcli differ

tools/cldcli.c +16 -6
diff -X /garz/tmp/dontdiff -urNp cld/tools/cldcli.c cld.rpcgen/tools/cldcli.c

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Binary files cld/tools/cldcli.o and cld.rpcgen/tools/cldcli.o differ

tools/Makefile.am +1 -0
diff -X /garz/tmp/dontdiff -urNp cld/tools/Makefile.am cld.rpcgen/tools/Makefile.am

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#9 lore raw
Quoted 25 lines · Jeff Garzik
Quoted 11 lines · Colin McCabe

That seems reasonable. All of those functions could be looked at as "common."

The intention was to group together a bunch of functions that were useful for packet formatting. Although the bulk of the formatting is done by XDR, there are some things that XDR doesn't do, like generating and checking SHA sums. cld_dump_buf and cld_pkt_hdr_to_str are purely for debugging purposes, but they seemed like something that would be generally useful for developers making packet format changes. I know that they were useful to me.

I finally pushed out several changes split off from your main XDR patch, to the upstream cld git repo.  It took longer than expected because I would make changes of my own along the way, which, each time, necessitated a rediff+rebuild between "current cld" working tree and "cld + xdr" working tree.

The attached patch is what remains to be split up and committed.  I have definitely whittled it down, and along the way, moved and renamed some things on my own.  With regards to cld_fmt.*, my main objection was to creating too many to-be-installed headers.  One more header can be a pain for us and for users, while one more source file in cld/lib/ is no big deal.

Quoted 3 lines

Thus, the intention is to eliminate cld_fmt.h (newly renamed to cld_pkt.h) altogether, while keeping the arrangement you created in cld_fmt.c (newly renamed to lib/pkt.c).

Yeah, after I looked at the v2 patch I realized it wasn't separated out well enough.
So I was working on a v3 patch series that had the following changes:

1. kill CLD_MAX_PKT_MSG and add CLD_MAX_PAYLOAD_SZ
2. reformat Makefile.am files (to one file per line for nicer diffs)
3. move cld_msg macros into cld_common
4. some style issues
5. add cld_fmt.c (now called cld_pkt.c)
6. create cldc_call_opts_get_data and switch to using it in test/ and tool/
7. the big XDR changes.

It looks like 2, 3, 4, 5 have already come to pass (thanks Jeff!)

I just sent out #1 and another patch that is related to CLD_INODE_NAME_MAX I think I'll send out a patch for #6 soon.

Quoted 2 lines

I will continue whittling down the patch until it just contains the XDR changes themselves.

In tools/Makefile.am, I don't think you need $(top_srcdir)/lib any more, since cld_msg_rpc.h is now an installed header.

Colin

#10 lore raw
Quoted 6 lines · Colin McCabe
Quoted 2 lines · Jeff Garzik

I will continue whittling down the patch until it just contains the XDR changes themselves.

In tools/Makefile.am, I don't think you need $(top_srcdir)/lib any more, since cld_msg_rpc.h is now an installed header.

Build environment should always refer to the current in-tree header, not the installed header. The header might not be installed (yet, at build time), or it might be an older version of the header you need. Who knows what lives in system headers :)

Jeff

#11 lore raw
In reply to Colin McCabe

Attached is the XDR working tree, following
[master 2a73620] libcldc: cosmetic changes, preparing for upcoming XDR merge

.gitignore +4 -0
diff -X /garz/tmp/dontdiff -urNp cld/.gitignore cld.rpcgen/.gitignore
@@ -32,5 +32,9 @@ cld-config.h*
 cscope.*
 ncscope.*
 
+# XDR files
+*_rpc.h
+*_rpc_xdr.c
+
 # ignore Doxygen output directory
 gendoc
include/cldc.h +9 -15
diff -X /garz/tmp/dontdiff -urNp cld/include/cldc.h cld.rpcgen/include/cldc.h
@@ -22,7 +22,7 @@
 #include <sys/types.h>
 #include <stdbool.h>
 #include <glib.h>
-#include <cld_msg.h>
+#include <cld_msg_rpc.h>
 #include <cld_common.h>
 #include <hail_log.h>
 
@@ -35,23 +35,17 @@ struct cldc_call_opts {
 	void		*private;
 
 	/* private; lib-owned */
-	union {
-		struct {
-			const char *buf;
-			unsigned int size;
-			char inode_name[CLD_INODE_NAME_MAX + 1];
-		} get;
-	} u;
 	struct cld_msg_get_resp resp;
 };
 
 struct cldc_pkt_info {
 	int		pkt_len;
+	int		hdr_len;
 	int		retries;
+	char		user[CLD_MAX_USERNAME];
 
 	/* must be at end of struct */
-	struct cld_packet pkt;
-	uint8_t		data[0];
+	char		data[0];
 };
 
 /** an outgoing message, from client to server */
@@ -70,18 +64,15 @@ struct cldc_msg {
 
 	time_t		expire_time;
 
-	int		data_len;
 	int		n_pkts;
 
-	uint8_t		*data;
-
 	/* must be at end of struct */
 	struct cldc_pkt_info *pkt_info[0];
 };
 
 /** an open file handle associated with a session */
 struct cldc_fh {
-	uint64_t	fh_le;			/* fh id, LE */
+	uint64_t	fh;
 	struct cldc_session *sess;
 	bool		valid;
 };
@@ -128,8 +119,11 @@ struct cldc_session {
 
 	bool		confirmed;
 
+	enum cld_msg_op msg_buf_op;
 	unsigned int	msg_buf_len;
 	char		msg_buf[CLD_MAX_MSG_SZ];
+	char		payload[CLD_MAX_PAYLOAD_SZ];
+	char		inode_name_temp[CLD_INODE_NAME_MAX];
 };
 
 /** Information for a single CLD server host */
@@ -209,7 +203,7 @@ extern void cldc_dirent_cur_init(struct 
 extern void cldc_dirent_cur_fini(struct cld_dirent_cur *dc);
 extern char *cldc_dirent_name(struct cld_dirent_cur *dc);
 extern void cldc_call_opts_get_data(const struct cldc_call_opts *copts,
-				    const char **data, size_t *data_len);
+				    char **data, size_t *data_len);
 
 /* cldc-udp */
 extern void cldc_udp_free(struct cldc_udp *udp);
include/cld_common.h +1 -0
diff -X /garz/tmp/dontdiff -urNp cld/include/cld_common.h cld.rpcgen/include/cld_common.h
@@ -24,6 +24,7 @@
 #include <stdbool.h>
 #include <string.h>
 #include <time.h>
+#include <cld_msg_rpc.h>
 
 #define CLD_ALIGN8(n) ((8 - ((n) & 7)) & 7)
 
include/cld_msg.h +0 -245

245 lines not on this page · raw message

include/cld_pkt.h +56 -0

56 lines not on this page · raw message

include/Makefile.am +1 -1
diff -X /garz/tmp/dontdiff -urNp cld/include/Makefile.am cld.rpcgen/include/Makefile.am
@@ -1,5 +1,5 @@
 
 EXTRA_DIST = cld-private.h
 
-include_HEADERS = cldc.h hail_log.h cld_common.h cld_msg.h
+include_HEADERS = cldc.h hail_log.h cld_common.h cld_pkt.h
 
lib/cldc.c +285 -358

1,096 lines not on this page · raw message

lib/cld_msg_rpc.x +218 -0

218 lines not on this page · raw message

lib/common.c +5 -1
diff -X /garz/tmp/dontdiff -urNp cld/lib/common.c cld.rpcgen/lib/common.c
@@ -26,7 +26,11 @@
 #include <errno.h>
 #include <glib.h>
 #include <cld-private.h>
-#include "cld_msg.h"
+#include <openssl/sha.h>
+#include <openssl/hmac.h>
+#include "cld_msg_rpc.h"
+#include <hail_log.h>
+#include <syslog.h>
 
 /* duplicated from tools/cldcli.c; put in common header somewhere? */
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
lib/Makefile.am +14 -1
diff -X /garz/tmp/dontdiff -urNp cld/lib/Makefile.am cld.rpcgen/lib/Makefile.am
@@ -1,10 +1,21 @@
 
+BUILT_SOURCES		= cld_msg_rpc.h
+
 EXTRA_DIST =
 	libcldc.pc.in libcldc-uninstalled.pc.in
 
 INCLUDES		= -I$(top_srcdir)/include	\
 			  @GLIB_CFLAGS@
 
+mostlyclean-local:
+	rm -f *_rpc.h *_rpc_xdr.c
+
+%_rpc.h: %_rpc.x
+	rpcgen -h $< > $@
+
+%_rpc_xdr.c: %_rpc.x
+	rpcgen -c $< > $@
+
 LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
 
 lib_LTLIBRARIES		= libcldc.la
@@ -15,7 +26,8 @@ libcldc_la_SOURCES	=	\
 	cldc-dns.c		\
 	common.c		\
 	libtimer.c		\
-	pkt.c
+	pkt.c			\
+	cld_msg_rpc_xdr.c
 
 libcldc_la_LDFLAGS = \
 	-version-info $(LIBCLDC_CURRENT):$(LIBCLDC_REVISION):$(LIBCLDC_AGE) \
@@ -25,3 +37,4 @@ libcldc_la_LDFLAGS = \
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libcldc.pc
 
+include_HEADERS = cld_msg_rpc.h
lib/pkt.c +99 -1

113 lines not on this page · raw message

server/cldb.h +1 -1
diff -X /garz/tmp/dontdiff -urNp cld/server/cldb.h cld.rpcgen/server/cldb.h
@@ -23,7 +23,7 @@
 #include <stdbool.h>
 #include <db.h>
 #include <cld-private.h>
-#include <cld_msg.h>
+#include <cld_msg_rpc.h>
 
 typedef uint64_t cldino_t;
 
server/cld.h +66 -29

134 lines not on this page · raw message

server/Makefile.am +3 -1
diff -X /garz/tmp/dontdiff -urNp cld/server/Makefile.am cld.rpcgen/server/Makefile.am
@@ -1,5 +1,6 @@
 
 INCLUDES	= -I$(top_srcdir)/include	\
+		  -I$(top_srcdir)/lib		\
 		  @GLIB_CFLAGS@			\
 		  -DCLD_LIBDIR=\""$(libdir)"\"	\
 		  -DCLD_LOCAL_STATE_DIR="\"$(localstatedir)\""
@@ -8,7 +9,8 @@ sbin_PROGRAMS	= cld cldbadm
 
 cld_SOURCES	= cldb.h cld.h \
 		  ../lib/common.c ../lib/libtimer.c ../lib/pkt.c \
-		  cldb.c msg.c server.c session.c util.c
+		  cldb.c msg.c server.c session.c util.c \
+		  ../lib/cld_msg_rpc_xdr.c
 cld_LDADD	= @CRYPTO_LIBS@ @GLIB_LIBS@ @DB4_LIBS@
 
 cldbadm_SOURCES	= cldb.h cldbadm.c
server/msg.c +102 -195

604 lines not on this page · raw message

server/server.c +418 -283

371 lines not on this page · raw message

server/session.c +186 -223

409 lines not on this page · raw message

test/load-file-event.c +1 -1
diff -X /garz/tmp/dontdiff -urNp cld/test/load-file-event.c cld.rpcgen/test/load-file-event.c

Lines of this file are not shown. View the raw message.

test/Makefile.am +1 -0
diff -X /garz/tmp/dontdiff -urNp cld/test/Makefile.am cld.rpcgen/test/Makefile.am

Lines of this file are not shown. View the raw message.

tools/cldcli.c +3 -3
diff -X /garz/tmp/dontdiff -urNp cld/tools/cldcli.c cld.rpcgen/tools/cldcli.c

Lines of this file are not shown. View the raw message.

tools/Makefile.am +1 -0
diff -X /garz/tmp/dontdiff -urNp cld/tools/Makefile.am cld.rpcgen/tools/Makefile.am

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#12 lore raw
Quoted 2 lines · On Thu, 04 Feb 2010 19:59:45 -0500 Jeff Garzik <[email protected]> wrote:

Attached is the XDR working tree, following
[master 2a73620] libcldc: cosmetic changes, preparing for upcoming XDR merge

Looks ok, if it works. Some strange casts and formatting.

-- Pete

#13 lore raw
Quoted 7 lines · Pete Zaitcev
Quoted 2 lines · On Thu, 04 Feb 2010 19:59:45 -0500 Jeff Garzik<[email protected]> wrote:

Attached is the XDR working tree, following
[master 2a73620] libcldc: cosmetic changes, preparing for upcoming XDR merge

Looks ok, if it works. Some strange casts and formatting.

Which one... commit 2a73620, or the attached XDR working patch?

The XDR working tree definitely works. While creating and committing the split-up patches, I have been bouncing between $current and $xdr, making changes to both, and making sure both continued to pass 'make check'.

Jeff

#14 lore raw
Quoted 6 lines · On Fri, 05 Feb 2010 01:06:32 -0500 Jeff Garzik <[email protected]> wrote:
Quoted 4 lines
Quoted 2 lines

Attached is the XDR working tree, following
[master 2a73620] libcldc: cosmetic changes, preparing for upcoming XDR merge

Looks ok, if it works. Some strange casts and formatting.

Which one... commit 2a73620, or the attached XDR working patch?

I looked at the attached patch.

-- Pete

Applied
#15 lore raw
In reply to Colin McCabe
Quoted 8 lines · Colin McCabe

This patch moves CLD from using manual data serialization to using XDR (via rpcgen). Both the packet header and the message body are now serialized and deserialized using XDR. This makes it easy to have a variable-length packet header, as well as a variable-length message body.

This patch introduces a minor libcldc API change in struct cldc_call_opts.

applied

I made yet more changes, and fixed a few minor bugs.

It passes 'make check' and 'make distcheck' without warnings. We can pound out any rough edges via normal patches, from now on.

Thanks for your efforts, this definitely moves CLD forward in a positive direction.

Jeff

#16 lore raw

Great news!

And thanks for your help in splitting what admittedly was a monster patch into something more manageable. :)

Colin

Quoted 28 lines · Jeff Garzik
Quoted 9 lines · Colin McCabe

This patch moves CLD from using manual data serialization to using XDR (via
rpcgen). Both the packet header and the message body are now serialized and
deserialized using XDR. This makes it easy to have a variable-length packet
header, as well as a variable-length message body.

Quoted 3 lines

This patch introduces a minor libcldc API change in struct cldc_call_opts.

applied

I made yet more changes, and fixed a few minor bugs.

It passes 'make check' and 'make distcheck' without warnings.  We can pound out any rough edges via normal patches, from now on.

Thanks for your efforts, this definitely moves CLD forward in a positive direction.

       Jeff

#17 lore raw
In reply to Colin McCabe

Useful per-packet cld [the daemon] verbose output seems to have disappeared? Or did I miss a knob somewhere?

The only call I see to __cld_pkt_hdr_to_str() is in server/session.c, when retrying packets. That does not cover incoming packets at all, which would be a regression from the pre-XDR codebase.

Jeff

#18 lore raw
Quoted 2 lines · Jeff Garzik

Useful per-packet cld [the daemon] verbose output seems to have disappeared? Or did I miss a knob somewhere?

cldcli no longers dumps per-packet debug info at maximum verbosity, either. Our built-in debug facilities have definitely regressed.

Jeff

#19 lore raw
Quoted 7 lines · On Tue, 09 Feb 2010 04:38:21 -0500 Jeff Garzik <[email protected]> wrote:
Quoted 2 lines · Jeff Garzik

Useful per-packet cld [the daemon] verbose output seems to have disappeared? Or did I miss a knob somewhere?

cldcli no longers dumps per-packet debug info at maximum verbosity, either. Our built-in debug facilities have definitely regressed.

The cldcli may be ncld's fault, let me look. I left the assignment of ->verbose at least in one place. I did not touch anything at all on the daemon side though.

-- Pete

#20 lore raw
In reply to Jeff Garzik
Quoted 7 lines · On Tue, 09 Feb 2010 04:38:21 -0500 Jeff Garzik <[email protected]> wrote:
Quoted 2 lines · Jeff Garzik

Useful per-packet cld [the daemon] verbose output seems to have disappeared? Or did I miss a knob somewhere?

cldcli no longers dumps per-packet debug info at maximum verbosity, either. Our built-in debug facilities have definitely regressed.

I posted the patch for both server and client, which should fix it. Looks like we became confused about what the exact meaning for log.verbose is, since historically we had 2: one means "enable LOG_DEBUG" and the other "enable per-packet dumping" (which is really verbose in normal operation). So the patch splits the two, thus permitting cldcli to control verbosity precisely. And no more commented-out assignments.

-- Pete

#21 lore raw
Quoted 10 lines · Pete Zaitcev
Quoted 7 lines · On Tue, 09 Feb 2010 04:38:21 -0500 Jeff Garzik<[email protected]> wrote:
Quoted 2 lines · Jeff Garzik

Useful per-packet cld [the daemon] verbose output seems to have disappeared? Or did I miss a knob somewhere?

cldcli no longers dumps per-packet debug info at maximum verbosity, either. Our built-in debug facilities have definitely regressed.

Quoted 7 lines

I posted the patch for both server and client, which should fix it. Looks like we became confused about what the exact meaning for log.verbose is, since historically we had 2: one means "enable LOG_DEBUG" and the other "enable per-packet dumping" (which is really verbose in normal operation). So the patch splits the two, thus permitting cldcli to control verbosity precisely. And no more commented-out assignments.

Actually it should be as presented in "cld --help" and "cldcli --help":
an integer, whose increasing value indicates increasing verbosity.
Higher values enable really verbose output, such as per-packet output.

So, the programs themselves have it right -- debug/verbose is an integer not a bool. The internal libraries get that wrong sometimes, though.

Having separate knobs for 'debug' and 'verbose' will be more confusing than a single control, IMO.

Jeff

#22 lore raw
Quoted 5 lines · On Tue, 09 Feb 2010 18:21:02 -0500 Jeff Garzik <[email protected]> wrote:

So, the programs themselves have it right -- debug/verbose is an integer not a bool. The internal libraries get that wrong sometimes, though.

Having separate knobs for 'debug' and 'verbose' will be more confusing than a single control, IMO.

I dunno, I think bigger packages tend to drift towards bitmasks. But I don't have a strong opinion. I just wanted to restore the per-packet output that you wanted. If you think that an integer is better, that's fine. The newer code should is more regular and easier to mold in any desired way.

Actually, I think the whole idea of debug levels is flawed. We should work on adding a CLD protocol dissector to Wireshark instead, now that with Colin's help we've settled to a protocol.

-- Pete

#23 lore raw
Quoted 6 lines · Pete Zaitcev
Quoted 3 lines · On Tue, 09 Feb 2010 18:21:02 -0500 Jeff Garzik<[email protected]> wrote:

So, the programs themselves have it right -- debug/verbose is an integer not a bool. The internal libraries get that wrong sometimes, though.

Quoted 8 lines
Quoted 2 lines

Having separate knobs for 'debug' and 'verbose' will be more confusing than a single control, IMO.

I dunno, I think bigger packages tend to drift towards bitmasks. But I don't have a strong opinion. I just wanted to restore the per-packet output that you wanted. If you think that an integer is better, that's fine. The newer code should is more regular and easier to mold in any desired way.

Integer or bitmask, either one is fine with me. Anything but two separate variables, one for 'debug' and one for 'verbose'. Programmers tend to like bitmasks, and users tend to -not- like them if forced to perform binary math.

Quoted 3 lines

Actually, I think the whole idea of debug levels is flawed. We should work on adding a CLD protocol dissector to Wireshark instead, now that with Colin's help we've settled to a protocol.

Long term, I agree. Creating a wireshark patch is definitely a to-do item.

For now, while a wireshark patch would be welcome, we are still changing the network protocol. In particular, replication will _definitely_ change the protocol. I was waiting on the XDR patch before making any more protocol changes.

That means we would either need to have locally patches wireshark packages, or maintain an out-of-tree wireshark patch in rawhide for a while, until the protocol settles down.

Jeff

#24 lore raw
Quoted 17 lines · Jeff Garzik
Quoted 7 lines · Pete Zaitcev
Quoted 3 lines · On Tue, 09 Feb 2010 18:21:02 -0500 Jeff Garzik<[email protected]>  wrote:

So, the programs themselves have it right -- debug/verbose is an integer not a bool.  The internal libraries get that wrong sometimes, though.

Quoted 8 lines
Quoted 2 lines

Having separate knobs for 'debug' and 'verbose' will be more confusing than a single control, IMO.

I dunno, I think bigger packages tend to drift towards bitmasks. But I don't have a strong opinion. I just wanted to restore the per-packet output that you wanted. If you think that an integer is better, that's fine. The newer code should is more regular and easier to mold in any desired way.

Quoted 4 lines

Integer or bitmask, either one is fine with me.  Anything but two separate variables, one for 'debug' and one for 'verbose'.  Programmers tend to like bitmasks, and users tend to -not- like them if forced to perform binary math.

I like bitmasks personally. If something is breaking, and you think it's in the foo subsystem, you can tell users to turn on debugging for just the foo system.

Even better is the ability to set the logging level after the program has been started. Sometimes you just run into these scenarios where the process has been running for a week, and it suddenly flakes out.

I wrote a logging system once where the daemon listened on a unix domain socket. By sending messages to that socket, you could change the log level on the fly.

Of course, there's a lot of other ways of getting the same information, like using gdb to read variables, or wireshark. When I was working on the XDR patch, I just hacked in a bunch of calls to print the packet header in various places.

Colin